diff options
author | Martin Odersky <odersky@gmail.com> | 2008-07-10 15:40:38 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2008-07-10 15:40:38 +0000 |
commit | 79727b4ea3c4e672d2f9ce64a167de47e8006d15 (patch) | |
tree | 537afa2cc930109379f649713cbd7dbeff3cfbcc | |
parent | d3744118959edcbb8fb061d106078864f83fb7b2 (diff) | |
download | scala-79727b4ea3c4e672d2f9ce64a167de47e8006d15.tar.gz scala-79727b4ea3c4e672d2f9ce64a167de47e8006d15.tar.bz2 scala-79727b4ea3c4e672d2f9ce64a167de47e8006d15.zip |
cosmetic indentation changes.
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/NewScanners.scala | 125 |
1 files changed, 68 insertions, 57 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/NewScanners.scala b/src/compiler/scala/tools/nsc/ast/parser/NewScanners.scala index 53d7b15371..7c171e04de 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/NewScanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/NewScanners.scala @@ -105,16 +105,17 @@ trait NewScanners { do { fill(next) } while (next.code match { - case NEWLINE|NEWLINES|WHITESPACE|COMMENT => - assert((next.code != COMMENT) == (xmlOk)) - hasNewline = hasNewline || next.code == NEWLINE || next.code == NEWLINES - if (next.code == COMMENT) - doc = next.value.asInstanceOf[Option[String]].getOrElse("") - true - case _ => false - }) - hasNewline + case NEWLINE|NEWLINES|WHITESPACE|COMMENT => + assert((next.code != COMMENT) == (xmlOk)) + hasNewline = hasNewline || next.code == NEWLINE || next.code == NEWLINES + if (next.code == COMMENT) + doc = next.value.asInstanceOf[Option[String]].getOrElse("") + true + case _ => false + }) + hasNewline } + def flushDoc = { val ret = doc doc = "" @@ -182,7 +183,7 @@ trait NewScanners { assert(xmlOk) val headIsRBRACE = if (sepRegions.isEmpty) true else sepRegions.head == RBRACE val hasNewline = fillNext - if (headIsRBRACE && ((inLastOfStat(lastCode) && inFirstOfStat(next.code)) + if (headIsRBRACE && (inLastOfStat(lastCode) && inFirstOfStat(next.code) /* This need to be commented out, otherwise line continuation in the interpreter will not work XXX: not sure how the IDE reacts with this commented out. @@ -194,25 +195,32 @@ trait NewScanners { case _ => } } + def token = { assert(current.code != EMPTY) current.code } + def nextTokenCode = { if (next.code == EMPTY) fillNext next.code } + def name = current.value.get.asInstanceOf[Name] + def charVal = current.value.get.asInstanceOf[Char] + def intVal(negated : Boolean) : Long = { val base = current.value.asInstanceOf[Option[Int]].getOrElse(10) intVal(current.offset, current.code, current.nLit(this), negated, base) } def intVal : Long = intVal(false) + def floatVal(negated: Boolean): Double = { floatVal(current.offset, current.code, current.nLit(this), negated) } def floatVal : Double = floatVal(false) + def stringVal = current.value.get.asInstanceOf[String] } @@ -234,6 +242,7 @@ trait NewScanners { this.offset = offset; this.length = length; this.code = code; this.value = Some(value) } def nLit(implicit in : BaseScanner) = (in.in.textFor(in.unadjust(offset), in.unadjust(offset + length))) + } trait BaseScanner { @@ -831,56 +840,58 @@ trait NewScanners { } //Token representation ----------------------------------------------------- - /** Convert name to token */ - def name2token(name: global.Name): Int = - if (name.start <= maxKey) key(name.start) else IDENTIFIER + /** Convert name to token */ + def name2token(name: global.Name): Int = + if (name.start <= maxKey) key(name.start) else IDENTIFIER - def isKeyword(code : Int) = code match { - case code if code >= IF && code <= REQUIRES => true - case _ => false - } - /** Returns the string representation of given token. */ - def token2string(token: Int): String = token match { - case IDENTIFIER | BACKQUOTED_IDENT => "identifier" - case CHARLIT => "character literal" - case INTLIT => "integer literal" - case LONGLIT => "long literal" - case FLOATLIT => "float literal" - case DOUBLELIT => "double literal" - case STRINGLIT => "string literal" - case SYMBOLLIT => "symbol literal" - case LPAREN => "'('" - case RPAREN => "')'" - case LBRACE => "'{'" - case RBRACE => "'}'" - case LBRACKET => "'['" - case RBRACKET => "']'" - case EOF => "eof" - case ERROR => "something" - case SEMI => "';'" - case NEWLINE => "';'" - case NEWLINES => "';'" - case COMMA => "','" - case CASECLASS => - "case class" - case CASEOBJECT => - "case object" - case XMLSTART => - "$XMLSTART$<" - case COMMENT => "cmnt" - case WHITESPACE => "ws" - case IGNORE => "ig" - case _ => - try { - "'" + tokenName(token) + "'" - } catch { - case _: ArrayIndexOutOfBoundsException => - "'<" + token + ">'" - case _: NullPointerException => - "'<(" + token + ")>'" - } + def isKeyword(code : Int) = code match { + case code if code >= IF && code <= REQUIRES => true + case _ => false + } + + /** Returns the string representation of given token. */ + def token2string(token: Int): String = token match { + case IDENTIFIER | BACKQUOTED_IDENT => "identifier" + case CHARLIT => "character literal" + case INTLIT => "integer literal" + case LONGLIT => "long literal" + case FLOATLIT => "float literal" + case DOUBLELIT => "double literal" + case STRINGLIT => "string literal" + case SYMBOLLIT => "symbol literal" + case LPAREN => "'('" + case RPAREN => "')'" + case LBRACE => "'{'" + case RBRACE => "'}'" + case LBRACKET => "'['" + case RBRACKET => "']'" + case EOF => "eof" + case ERROR => "something" + case SEMI => "';'" + case NEWLINE => "';'" + case NEWLINES => "';'" + case COMMA => "','" + case CASECLASS => + "case class" + case CASEOBJECT => + "case object" + case XMLSTART => + "$XMLSTART$<" + case COMMENT => "cmnt" + case WHITESPACE => "ws" + case IGNORE => "ig" + case _ => + try { + "'" + tokenName(token) + "'" + } catch { + case _: ArrayIndexOutOfBoundsException => + "'<" + token + ">'" + case _: NullPointerException => + "'<(" + token + ")>'" + } } } + class UnitScanner(unit: CompilationUnit) extends ParserScanner { implicit val in = new DefaultInput(new NewCharArrayReader(unit.source.content, !settings.nouescape.value, error)) { |