Permalink
Browse files

Include EOF token in compilation unit tree

  • Loading branch information...
mdr committed May 8, 2012
1 parent 519d9d1 commit d7d9971478da871d5fff5c9bb22c0c56613cdeb2
View
@@ -1,3 +1,5 @@
+0.1.3 (..)
+
0.1.2 (7/May/12)
* Revamp command-line tool with more intuitive behaviour
@@ -50,7 +50,11 @@ trait SpecificFormatter {
preference = BooleanPreference.cast(rawPreference)
} actualFormattingPreferences = actualFormattingPreferences.setPreference(preference, onOrOff)
- require(parseResult.tokens == tokens.init, "Parse tokens differ from expected. Actual = " + parseResult.tokens + ", expected = " + tokens.init + ", parseResult = " + parseResult) // dropped EOF
+ val parsedTokens = parseResult.tokens.filter(_.tokenType != EOF)
+ require(parsedTokens == tokens.init /* <-- drop EOF */, "Parse tokens differ from expected.\n Actual = \n" +
+ parsedTokens.mkString("\n") + "\n expected = \n" + tokens.init.mkString("\n") + "\n parseResult = \n" +
+ parseResult)
+
if (debug) { println("Parse result: " + parseResult) }
val elapsedTime = System.currentTimeMillis - startTime
// if (debug)
@@ -394,8 +394,8 @@ case class AccessQualifier(lbracket: Token, thisOrId: Token, rbracket: Token) ex
lazy val tokens = flatten(lbracket, thisOrId, rbracket)
}
-case class CompilationUnit(topStats: StatSeq) extends AstNode {
- lazy val tokens = flatten(topStats)
+case class CompilationUnit(topStats: StatSeq, eofToken: Token) extends AstNode {
+ lazy val tokens = flatten(topStats, eofToken)
}
case class AnonymousFunctionStart(parameters: List[ExprElement], arrow: Token) extends ExprElement {
@@ -65,8 +65,8 @@ class ScalaParser(tokens: Array[Token]) {
def scriptBody(): CompilationUnit = {
val stmts = templateStats()
- accept(EOF)
- CompilationUnit(stmts)
+ val eofToken = accept(EOF)
+ CompilationUnit(stmts, eofToken)
}
private def templateStats() = {
@@ -1798,8 +1798,8 @@ class ScalaParser(tokens: Array[Token]) {
}
}
val topStats_ = topstats()
- accept(EOF)
- CompilationUnit(topStats_)
+ val eofToken = accept(EOF)
+ CompilationUnit(topStats_, eofToken)
}
private def xmlStartTag(isPattern: Boolean): XmlStartTag = {

0 comments on commit d7d9971

Please sign in to comment.