summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorBurak Emir <emir@epfl.ch>2005-12-01 11:24:05 +0000
committerBurak Emir <emir@epfl.ch>2005-12-01 11:24:05 +0000
commit0a8b8f9b903512e25caf16fef1f732d9478d9170 (patch)
tree56fe7f61abe67c1979aebbecb7e7c65e7314e70c /sources
parent57ec040fbc878d6086e5c63c3356cef7b38ede83 (diff)
downloadscala-0a8b8f9b903512e25caf16fef1f732d9478d9170.tar.gz
scala-0a8b8f9b903512e25caf16fef1f732d9478d9170.tar.bz2
scala-0a8b8f9b903512e25caf16fef1f732d9478d9170.zip
fixes
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/xml/parsing/MarkupParser.scala56
1 files changed, 33 insertions, 23 deletions
diff --git a/sources/scala/xml/parsing/MarkupParser.scala b/sources/scala/xml/parsing/MarkupParser.scala
index 18833c3efd..2556529d42 100644
--- a/sources/scala/xml/parsing/MarkupParser.scala
+++ b/sources/scala/xml/parsing/MarkupParser.scala
@@ -119,9 +119,9 @@ import scala.xml.dtd._ ;
}
if(m.length - n != 0) {
- Console.println("[length "+(m.length - n)+"]");
reportSyntaxError("VersionInfo EncodingDecl? SDDecl? or '?>' expected!");
}
+ //Console.println("[MarkupParser::prolog] finished parsing prolog!");
Tuple3(info_ver,info_enc,info_stdl)
}
@@ -132,28 +132,28 @@ import scala.xml.dtd._ ;
var info_enc: Option[String] = None;
var m = xmlProcInstr();
+ var n = 0;
- if (!m.isPrefixed && m.key == "version") {
- if (m.value == "1.0") {
- info_ver = Some("1.0");
- m = m.next;
- } else {
- reportSyntaxError("cannot deal with versions != 1.0");
- }
- } else
- reportSyntaxError("VersionInfo expected!");
+ m.getValue("version") match {
+ case null => ;
+ case "1.0" => info_ver = Some("1.0"); n = n + 1;
+ case _ => reportSyntaxError("cannot deal with versions != 1.0");
+ }
- if (m != Null && !m.isPrefixed && m.key == "encoding") {
- val enc = m.value;
- if (!isValidIANAEncoding(enc))
+ m.getValue("encoding") match {
+ case null => ;
+ case enc => if (!isValidIANAEncoding(enc))
reportSyntaxError("\"" + enc + "\" is not a valid encoding");
- info_enc = Some(enc);
- m = m.next
+ else {
+ info_enc = Some(enc);
+ n = n + 1;
+ }
}
- if (m != Null)
- reportSyntaxError("VersionInfo EncodingDecl? SDDecl? or '?>' expected!");
-
+ if(m.length - n != 0) {
+ reportSyntaxError("VersionInfo EncodingDecl? or '?>' expected!");
+ }
+ //Console.println("[MarkupParser::textDecl] finished parsing textdecl");
Tuple2(info_ver, info_enc);
}
@@ -179,11 +179,21 @@ import scala.xml.dtd._ ;
}
nextch; // is prolog ?
+ var children: NodeSeq = null;
if ('?' == ch) {
+ //Console.println("[MarkupParser::document] starts with xml declaration");
nextch;
info_prolog = prolog();
+ children = content(TopScope); // DTD handled as side effect
+
+ } else {
+ //Console.println("[MarkupParser::document] does not start with xml declaration");
+ val ts = new NodeBuffer();
+ content1(TopScope, ts); // DTD handled as side effect
+ ts &+ content(TopScope);
+ children = NodeSeq.fromSeq(ts);
}
- val children = content(TopScope); // DTD handled as side effect
+ //Console.println("[MarkupParser::document] children now: "+children.toList);
var elemCount = 0;
var theNode: Node = null;
for (val c <- children) c match {
@@ -514,7 +524,7 @@ import scala.xml.dtd._ ;
case _ => // EntityRef
val n = xName ;
xToken(';');
- xName match {
+ n match {
case "lt" => ts &+ '<';
case "gt" => ts &+ '>';
case "amp" => ts &+ '&';
@@ -691,8 +701,7 @@ import scala.xml.dtd._ ;
val n = cbuf.toString().intern();
cbuf.setLength(0);
n
- }
- else {
+ } else {
reportSyntaxError("name expected");
new String()
}
@@ -1110,7 +1119,8 @@ import scala.xml.dtd._ ;
* report a syntax error
*/
def reportSyntaxError(pos: int, str: String): Unit = {
- curInput.reportError(pos, str)
+ curInput.reportError(pos, str);
+ //error("MarkupParser::synerr"); // DEBUG
}
def reportSyntaxError(str: String): Unit = reportSyntaxError(pos, str);