diff options
author | Paul Phillips <paulp@improving.org> | 2009-12-17 20:36:00 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-12-17 20:36:00 +0000 |
commit | 05363648a6f97f3a2175200484bb46df9f9548d5 (patch) | |
tree | 63a01b670f3545b0a37c1ebb6126ab56f0c66268 /src/compiler | |
parent | a25195fc1f025c0c9515b10af20c9327b0733ffa (diff) | |
download | scala-05363648a6f97f3a2175200484bb46df9f9548d5.tar.gz scala-05363648a6f97f3a2175200484bb46df9f9548d5.tar.bz2 scala-05363648a6f97f3a2175200484bb46df9f9548d5.zip |
Began the process of consolidating all the code...
Began the process of consolidating all the code which is painfully
duplicated between MarkupParsers and MarkupParser. This motivated by the
reappearance of bug #2354 in the exact same form as the one I already
fixed. no review.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala index 67e1cd8304..bd46d2219d 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala @@ -50,10 +50,17 @@ trait MarkupParsers import global._ - class MarkupParser(parser: UnitParser, final val preserveWS: Boolean) { + class MarkupParser(parser: UnitParser, final val preserveWS: Boolean) extends scala.xml.parsing.MarkupParserCommon { import Tokens.{ EMPTY, LBRACE, RBRACE } + type PositionType = Position + val eof = false + + def xHandleError(that: Char, msg: String) = + if (ch == SU) throw TruncatedXML + else reportSyntaxError(msg) + var input : CharArrayReader = _ import parser.{ symbXMLBuilder => handle, o2p, r2p } @@ -73,15 +80,6 @@ trait MarkupParsers finally setter(saved) } - /** munch expected XML token, report syntax error for unexpected. - * - * @param that ... - */ - def xToken(that: Char): Unit = - if (ch == that) nextch - else if (ch == SU) throw TruncatedXML - else reportSyntaxError("'%s' expected instead of '%s'".format(that, ch)) - private var debugLastStartElement = new mutable.Stack[(Int, String)] private def debugLastPos = debugLastStartElement.top._1 private def debugLastElem = debugLastStartElement.top._2 @@ -421,18 +419,6 @@ trait MarkupParsers buf.toString.intern } - /** scan [S] '=' [S]*/ - def xEQ = { xSpaceOpt; xToken('='); xSpaceOpt } - - /** skip optional space S? */ - def xSpaceOpt = { while (isSpace(ch)) { nextch }} - - /** scan [3] S ::= (#x20 | #x9 | #xD | #xA)+ */ - def xSpace = - if (isSpace(ch)) { nextch; xSpaceOpt } - else if (ch == SU) throw TruncatedXML - else reportSyntaxError("whitespace expected") - /** '<?' ProcInstr ::= Name [S ({Char} - ({Char}'>?' {Char})]'?>' * * see [15] @@ -558,8 +544,9 @@ trait MarkupParsers */ def xScalaPatterns: List[Tree] = escapeToScala(parser.patterns(true), "pattern") + def reportSyntaxError(pos: Int, str: String) = parser.syntaxError(pos, str) def reportSyntaxError(str: String) = { - parser.syntaxError(curOffset, "in XML literal: " + str) + reportSyntaxError(curOffset, "in XML literal: " + str) nextch } |