summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBurak Emir <emir@epfl.ch>2006-10-09 16:53:09 +0000
committerBurak Emir <emir@epfl.ch>2006-10-09 16:53:09 +0000
commit5f951ae31656ce06fc631ff17bc6df9077e66693 (patch)
tree621b2fac3ea6a2fb0057081123624b6084eb5df5 /src
parentbff27eb916c2cbd9030b1fc91cd99115702de337 (diff)
downloadscala-5f951ae31656ce06fc631ff17bc6df9077e66693.tar.gz
scala-5f951ae31656ce06fc631ff17bc6df9077e66693.tar.bz2
scala-5f951ae31656ce06fc631ff17bc6df9077e66693.zip
cleanup + xml:group feature
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala5
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala64
-rw-r--r--src/compiler/scala/tools/nsc/symtab/StdNames.scala30
3 files changed, 40 insertions, 59 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala
index 4ce4b1758a..ac82c14187 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala
@@ -344,7 +344,10 @@ class MarkupParser(unit: CompilationUnit, s: Scanner, p: Parser, presWS: boolean
val ts = content
xEndTag(qname)
debugLastStartElement.pop
- handle.element(pos1, qname, attrMap, ts)
+ if(qname=="xml:group")
+ handle.group(pos1, ts)
+ else
+ handle.element(pos1, qname, attrMap, ts)
}
}
diff --git a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala
index 92eb0e9077..da8c487c72 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala
@@ -27,33 +27,34 @@ abstract class SymbolicXMLBuilder(make: TreeBuilder, p: Parsers # Parser, preser
var isPattern:Boolean = _
- import nme.{
- _Attribute ,
- _MetaData ,
- _NamespaceBinding ,
- _NodeBuffer ,
-
- _Null ,
-
- _PrefixedAttribute ,
- _UnprefixedAttribute ,
- _Elem ,
- _Seq ,
- _immutable ,
- _mutable ,
- _append ,
- _plus ,
- _collection ,
- _toList ,
- _xml ,
- _Comment ,
- _Node ,
- _ProcInstr ,
- _Text ,
- _EntityRef ,
- _md,
- _scope,
- _tmpscope}
+ def _Attribute = global.newTypeName("Attribute")
+ def _MetaData = global.newTypeName("MetaData")
+ def _NamespaceBinding = global.newTypeName("NamespaceBinding")
+ def _NodeBuffer = global.newTypeName("NodeBuffer")
+ def _Null = global.newTermName("Null")
+
+ def _PrefixedAttribute = global.newTypeName("PrefixedAttribute")
+ def _UnprefixedAttribute = global.newTypeName("UnprefixedAttribute")
+ def _Elem = global.newTypeName("Elem")
+ def _Group = global.newTypeName("Group")
+ def _Seq = global.newTypeName("Seq")
+ def _immutable = global.newTermName("immutable")
+ def _mutable = global.newTermName("mutable")
+ def _append = global.newTermName("append")
+ def _plus = global.newTermName("$amp$plus")
+ def _collection = global.newTermName("collection")
+ def _toList = global.newTermName("toList")
+ def _xml = global.newTermName("xml")
+ def _Comment = global.newTypeName("Comment")
+ def _Node = global.newTypeName("Node")
+ def _None = global.newTermName("None")
+ def _Some = global.newTypeName("Some")
+ def _ProcInstr = global.newTypeName("ProcInstr")
+ def _Text = global.newTypeName("Text")
+ def _EntityRef = global.newTypeName("EntityRef")
+ final def _md = global.newTermName("$md")
+ final def _scope = global.newTermName("$scope")
+ final def _tmpscope = global.newTermName("$tmpscope")
// convenience methods
private def LL[A](x:A*):List[List[A]] = List(List(x:_*))
@@ -61,7 +62,7 @@ abstract class SymbolicXMLBuilder(make: TreeBuilder, p: Parsers # Parser, preser
private def _scala(name: Name) =
Select(Select(Ident(nme.ROOTPKG), nme.scala_), name)
- private def _scala_Seq = _scala(_Seq)
+ private def _scala_Seq = _scala(_Seq)
private def _scala_xml(name: Name) = Select(_scala(_xml), name)
private def _scala_xml_MetaData = _scala_xml(_MetaData)
@@ -77,13 +78,16 @@ abstract class SymbolicXMLBuilder(make: TreeBuilder, p: Parsers # Parser, preser
private def _scala_xml_Text = _scala_xml(_Text)
private def _scala_xml_Elem = _scala_xml(_Elem)
private def _scala_xml_Attribute = _scala_xml(_Attribute)
+ private def _scala_xml_Group = _scala_xml(_Group)
+ /*
private def bufferToArray(buf: mutable.Buffer[Tree]): Array[Tree] = {
val arr = new Array[Tree](buf.length)
var i = 0
for (val x <- buf.elements) { arr(i) = x; i = i + 1; }
arr
}
+ */
// create scala xml tree
@@ -203,6 +207,10 @@ abstract class SymbolicXMLBuilder(make: TreeBuilder, p: Parsers # Parser, preser
if (i != -1) Some(name.substring(0, i)) else None
}
+ def group(pos: int, args: mutable.Buffer[Tree]): Tree = {
+ atPos(pos) { New( _scala_xml_Group, LL( makeXMLseq(pos, args))) }
+ }
+
/** makes an element */
def element(pos: int, qname: String, attrMap: mutable.Map[String,Tree], args: mutable.Buffer[Tree]): Tree = {
//Console.println("SymbolicXMLBuilder::element("+pos+","+qname+","+attrMap+","+args+")");
diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala
index 0de28cecdb..830a6b5150 100644
--- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala
+++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala
@@ -344,36 +344,6 @@ trait StdNames requires SymbolTable {
val RuntimeAnnotationATTR = newTermName("RuntimeVisibleAnnotations")
val ClassfileAnnotationATTR = newTermName("RuntimeInvisibleAnnotations")
val RuntimeParamAnnotationATTR = newTermName("RuntimeVisibleParameterAnnotations")
-
- // '_' is temporary
- val _Attribute = newTypeName("Attribute")
- val _MetaData = newTypeName("MetaData")
- val _NamespaceBinding = newTypeName("NamespaceBinding")
- val _NodeBuffer = newTypeName("NodeBuffer")
- val _Null = newTermName("Null")
-
- val _PrefixedAttribute = newTypeName("PrefixedAttribute")
- val _UnprefixedAttribute = newTypeName("UnprefixedAttribute")
- val _Elem = newTypeName("Elem")
- val _Seq = newTypeName("Seq")
- val _immutable = newTermName("immutable")
- val _mutable = newTermName("mutable")
- val _append = newTermName("append")
- val _plus = newTermName("$amp$plus")
- val _collection = newTermName("collection")
- val _toList = newTermName("toList")
- val _xml = newTermName("xml")
- val _Comment = newTypeName("Comment")
- val _Node = newTypeName("Node")
- val _None = newTermName("None")
- val _Some = newTypeName("Some")
- val _ProcInstr = newTypeName("ProcInstr")
- val _Text = newTypeName("Text")
- val _EntityRef = newTypeName("EntityRef")
- final val _md = newTermName("$md")
- final val _scope = newTermName("$scope")
- final val _tmpscope = newTermName("$tmpscope")
-
}
def encode(str: String): Name = newTermName(NameTransformer.encode(str))