blob: 524be272d6ba0e04be505712fdde3c0dd72e7073 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
package test
import scala.reflect.io._
import dotty.tools.dotc.util._
import dotty.tools.dotc.core._
import dotty.tools.dotc.parsing._
import Tokens._, Parsers._
import dotty.tools.dotc.ast.untpd._
import org.junit.Test
import scala.collection.mutable.ListBuffer
class ParserTest extends DottyTest {
def parse(name: String): Tree = parse(new PlainFile(name))
var parsed = 0
val parsedTrees = new ListBuffer[Tree]
def reset() = {
parsed = 0
parsedTrees.clear()
}
def parse(file: PlainFile): Tree = {
//println("***** parsing " + file)
val source = new SourceFile(file)
val parser = new Parser(source)
val tree = parser.parse()
parsed += 1
parsedTrees += tree
tree
}
def parseDir(path: String): Unit = parseDir(Directory(path))
def parseDir(dir: Directory): Unit = {
for (f <- dir.files)
if (f.name.endsWith(".scala")) parse(new PlainFile(f))
for (d <- dir.dirs)
parseDir(d.path)
}
}
|