diff options
Diffstat (limited to 'src/library/scala/xml/dtd/Scanner.scala')
-rw-r--r-- | src/library/scala/xml/dtd/Scanner.scala | 64 |
1 files changed, 30 insertions, 34 deletions
diff --git a/src/library/scala/xml/dtd/Scanner.scala b/src/library/scala/xml/dtd/Scanner.scala index 9b30ba5ab6..9ccc167fa5 100644 --- a/src/library/scala/xml/dtd/Scanner.scala +++ b/src/library/scala/xml/dtd/Scanner.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -9,7 +9,7 @@ // $Id$ -package scala.xml.dtd; +package scala.xml.dtd /** Scanner for regexps (content models in DTD element declarations) @@ -18,29 +18,28 @@ package scala.xml.dtd; class Scanner extends Tokens with parsing.TokenTests { // zzz constants zzz - final val ENDCH = '\u0000'; + final val ENDCH = '\u0000' // zzz fields zzz - var token:Int = END; - var value:String = _; - - private var it:Iterator[Char] = null; - private var c:Char = 'z'; + var token:Int = END + var value:String = _ + private var it: Iterator[Char] = null + private var c: Char = 'z' /** initializes the scanner on input s */ - final def initScanner( s:String ) = { + final def initScanner(s: String) { //Console.println("[scanner init on \""+s+"\"]"); - value = ""; - it = Iterator.fromString( s ); - token = 1+END; - next; - nextToken; + value = "" + it = Iterator.fromString(s) + token = 1+END + next + nextToken } /** scans the next token */ - final def nextToken:Unit = { - if( token != END ) token = readToken; + final def nextToken { + if (token != END) token = readToken; //Console.println("["+token2string( token )+"]"); } @@ -50,13 +49,14 @@ class Scanner extends Tokens with parsing.TokenTests { final def isIdentChar = ( ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')); - final def next = if( it.hasNext ) c = it.next else c = ENDCH; + final def next = if (it.hasNext) c = it.next else c = ENDCH - final def acc( d:char ):Unit = - if( c == d ) next; else error("expected '"+d+"' found '"+c+"' !"); + final def acc(d: Char) { + if (c == d) next else error("expected '"+d+"' found '"+c+"' !"); + } - final def accS( ds:Seq[Char] ):Unit = { - val jt = ds.elements; while( jt.hasNext ) { acc( jt.next ) } + final def accS(ds: Seq[Char]) { + val jt = ds.elements; while (jt.hasNext) { acc(jt.next) } } /* @@ -67,10 +67,8 @@ class Scanner extends Tokens with parsing.TokenTests { */ final def readToken: Int = - if(isSpace(c)) { - while( isSpace(c) ) { - c = it.next; - } + if (isSpace(c)) { + while (isSpace(c)) c = it.next S } else c match { case '(' => next; LPAREN @@ -81,18 +79,16 @@ class Scanner extends Tokens with parsing.TokenTests { case '?' => next; OPT case '|' => next; CHOICE case '#' => next; accS( "PCDATA" ); TOKEN_PCDATA - case ENDCH => END; + case ENDCH => END case _ => - if( isNameStart( c ) ) name; // NAME - else { - error("unexpected character:"+c); END - } + if (isNameStart(c)) name; // NAME + else { error("unexpected character:"+c); END } } final def name = { - val sb = new compat.StringBuilder(); - do { sb.append( c ); next } while ( isNameChar( c ) ) ; - value = sb.toString(); + val sb = new compat.StringBuilder() + do { sb.append(c); next } while (isNameChar(c)); + value = sb.toString() NAME } |