diff options
author | buraq <buraq@epfl.ch> | 2004-12-16 14:05:45 +0000 |
---|---|---|
committer | buraq <buraq@epfl.ch> | 2004-12-16 14:05:45 +0000 |
commit | 8aa1f96c454999d01cf79f4fd9d7852c6e25653f (patch) | |
tree | 9540d9a84b0efc802137b398ca2fdef4b9d8b4b8 | |
parent | 95381cac9e75291c4440cfaa85f0da7f9cf163ab (diff) | |
download | scala-8aa1f96c454999d01cf79f4fd9d7852c6e25653f.tar.gz scala-8aa1f96c454999d01cf79f4fd9d7852c6e25653f.tar.bz2 scala-8aa1f96c454999d01cf79f4fd9d7852c6e25653f.zip |
minor fix Scanner, NodeBuffer
-rw-r--r-- | doc/reference/ReferencePart.tex | 2 | ||||
-rw-r--r-- | sources/scala/xml/NodeBuffer.scala | 43 | ||||
-rw-r--r-- | sources/scala/xml/NodeSeq.scala | 4 |
3 files changed, 25 insertions, 24 deletions
diff --git a/doc/reference/ReferencePart.tex b/doc/reference/ReferencePart.tex index 848a4ba846..260053ef98 100644 --- a/doc/reference/ReferencePart.tex +++ b/doc/reference/ReferencePart.tex @@ -36,7 +36,7 @@ to the ASCII fragment \Urange{0000}{007F}. In Scala mode, \textit{Unicode escapes} are replaced by the corresponding Unicode character with the given hexadecimal code. \begin{lstlisting} -UnicodeEscape ::= \\{\\\\}u{u} HexDigit HexDigit HexDigit HexDigit +UnicodeEscape ::= \{\\}u{u} HexDigit HexDigit HexDigit HexDigit HexDigit ::= '0' | $\ldots$ | `9' | `A' | $\ldots$ | `F' | `a' | $\ldots$ | `f' | \end{lstlisting} To construct tokens, characters are distinguished according to the following classes diff --git a/sources/scala/xml/NodeBuffer.scala b/sources/scala/xml/NodeBuffer.scala index fc2c415106..93d3e9387c 100644 --- a/sources/scala/xml/NodeBuffer.scala +++ b/sources/scala/xml/NodeBuffer.scala @@ -24,33 +24,30 @@ class NodeBuffer extends scala.collection.mutable.ArrayBuffer[Node] { * Append a single node to this buffer, returns reference on this * NodeBuffer for convenience. * - * @param n - */ - override def +(n: Node): NodeBuffer = { super.+(n); this } - - /** - * Append a sequence of nodes to this buffer, returns reference on + * Append an iterable object to this buffer, returns reference on * this NodeBuffer for convenience. * - * @param ns - */ - def +(ns: Iterable[Node]): NodeBuffer = { super.++(ns); this } - - - /** - * Append a sequence of nodes to this buffer, returns reference on - * this NodeBuffer for convenience. - * - * @param ns - */ - def +(ns: Iterator[Node]): NodeBuffer = { ns.foreach{x => super.+(x)}; this } - - /** * Append given string as a <code>scala.xml.Text</code> node to this * buffer, returns reference on this NodeBuffer for convenience. * - * @param t + * @param n */ - def +(t :String): NodeBuffer = { super.+(Text(t)); this } - + def +(o: Any): NodeBuffer = { + o.match { + case n:Node => super.+(n); + case ns:Iterable[AnyRef] => + val it = ns.elements; + while(it.hasNext) { + this.+(it.next) + } + case _ => super.+(Text(o.toString())); + } + this + } + /* + def +(o: AnyVal): NodeBuffer = { + super.+(Text(o.toString())); + this + } + */ } diff --git a/sources/scala/xml/NodeSeq.scala b/sources/scala/xml/NodeSeq.scala index f8982bc3d9..56a72b30d8 100644 --- a/sources/scala/xml/NodeSeq.scala +++ b/sources/scala/xml/NodeSeq.scala @@ -9,6 +9,10 @@ package scala.xml ; +object NodeSeq { + final val Empty = new NodeSeq { def theSeq = Nil; } +} + /** a wrapper around Seq[Node] that adds XPath and comprehension methods */ abstract class NodeSeq extends Seq[Node] { |