summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2007-07-09 09:43:09 +0000
committermichelou <michelou@epfl.ch>2007-07-09 09:43:09 +0000
commit819c89544ae936316b6142bbb236f9fd453c7e00 (patch)
tree6c7c7424687c7691eb59f3173d8b05b47eb0c5bb
parent03408a6c0261fe5e4ccfaf0d81bfa2d0a1188e33 (diff)
downloadscala-819c89544ae936316b6142bbb236f9fd453c7e00.tar.gz
scala-819c89544ae936316b6142bbb236f9fd453c7e00.tar.bz2
scala-819c89544ae936316b6142bbb236f9fd453c7e00.zip
updated svn:keywords, file headers, and scalado...
updated svn:keywords, file headers, and scaladoc comments
-rw-r--r--src/library/scala/util/parsing/combinator/lexical/Lexical.scala18
-rw-r--r--src/library/scala/util/parsing/combinator/lexical/Scanners.scala44
-rw-r--r--src/library/scala/util/parsing/combinator/lexical/StdLexical.scala33
-rw-r--r--src/library/scala/util/parsing/combinator/syntactical/BindingParsers.scala5
-rw-r--r--src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala5
-rw-r--r--src/library/scala/util/parsing/combinator/syntactical/TokenParsers.scala38
-rw-r--r--src/library/scala/util/parsing/combinator/testing/Tester.scala26
-rw-r--r--src/library/scala/util/parsing/json/JSON.scala21
-rw-r--r--src/library/scala/util/parsing/json/Lexer.scala115
-rw-r--r--src/library/scala/util/parsing/json/Parser.scala46
10 files changed, 218 insertions, 133 deletions
diff --git a/src/library/scala/util/parsing/combinator/lexical/Lexical.scala b/src/library/scala/util/parsing/combinator/lexical/Lexical.scala
index a2497bd6ad..e2759d1501 100644
--- a/src/library/scala/util/parsing/combinator/lexical/Lexical.scala
+++ b/src/library/scala/util/parsing/combinator/lexical/Lexical.scala
@@ -1,19 +1,27 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2006-2007, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
+// $Id$
+
+
package scala.util.parsing.combinator.lexical
import scala.util.parsing.syntax._
import scala.util.parsing.input.CharArrayReader.EofCh
-/** This component complements the `Scanners' component with common operations for lexical parsers.
- *<p>
- * {@see StdLexical} for a concrete implementation for a simple, Scala-like language.</p>
+/** <p>
+ * This component complements the <code>Scanners</code> component with
+ * common operations for lexical parsers.
+ * </p>
+ * <p>
+ * {@see StdLexical} for a concrete implementation for a simple, Scala-like
+ * language.
+ * </p>
*
* @author Martin Odersky, Adriaan Moors
*/
@@ -30,4 +38,4 @@ abstract class Lexical extends Scanners with Tokens {
/** A character-parser that matches a white-space character (and returns it)*/
def whitespaceChar = elem("space char", ch => ch <= ' ' && ch != EofCh)
-} \ No newline at end of file
+}
diff --git a/src/library/scala/util/parsing/combinator/lexical/Scanners.scala b/src/library/scala/util/parsing/combinator/lexical/Scanners.scala
index 81252ea414..53868021db 100644
--- a/src/library/scala/util/parsing/combinator/lexical/Scanners.scala
+++ b/src/library/scala/util/parsing/combinator/lexical/Scanners.scala
@@ -1,31 +1,37 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2006-2007, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
+// $Id$
+
+
package scala.util.parsing.combinator.lexical
import scala.util.parsing.syntax._
import scala.util.parsing.input._
-/** This component provides core functionality for lexical parsers.
- *<p>
- * See its subclasses {@see Lexical} and -- most interestingly {@see StdLexical},
- * for more functionality.</p>
+/** <p>
+ * This component provides core functionality for lexical parsers.
+ * </p>
+ * <p>
+ * See its subclasses {@see Lexical} and -- most interestingly {@see StdLexical},
+ * for more functionality.
+ * </p>
*
- * @requires token a parser that produces a token (from a stream of characters)
- * @requires whitespace a unit-parser for white-space
- * @provides Scanner essentially a parser that parses a stream of characters to produce `Token's,
- * which are typically passed to a syntactical parser (which operates on
- * `Token's, not on individual characters)
+ * @requires token a parser that produces a token (from a stream of characters)
+ * @requires whitespace a unit-parser for white-space
+ * @provides Scanner essentially a parser that parses a stream of characters to produce `Token's,
+ * which are typically passed to a syntactical parser (which operates on
+ * `Token's, not on individual characters)
*
- * @author Martin Odersky, Adriaan Moors
+ * @author Martin Odersky, Adriaan Moors
*/
trait Scanners extends Parsers with Tokens {
- type Elem = char
+ type Elem = Char
/** a parser that produces a token (from a stream of characters) */
def token: Parser[Token]
@@ -33,12 +39,16 @@ trait Scanners extends Parsers with Tokens {
/** a parser for white-space -- its result will be discarded */
def whitespace: Parser[Any]
- /** `Scanner' is essentially(*) a parser that produces `Token's from a stream of characters.
- * The tokens it produces are typically passed to parsers in `TokenParsers'.
- *
- * Note: (*) `Scanner' is really a `Reader' of `Token's
+ /** <p>
+ * <code>Scanner</code> is essentially(*) a parser that produces `Token's
+ * from a stream of characters. The tokens it produces are typically passed
+ * to parsers in <code>TokenParsers</code>.
+ * </p>
+ * <p>
+ * Note: (*) <code>Scanner</code> is really a `Reader' of `Token's
+ * </p>
*/
- class Scanner(in: Reader[char]) extends Reader[Token] {
+ class Scanner(in: Reader[Char]) extends Reader[Token] {
/** Convenience constructor (makes a character reader out of the given string) */
def this(in: String) = this(new CharArrayReader(in.toCharArray()))
private val Triple(tok, rest1, rest2) = whitespace(in) match {
diff --git a/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala b/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala
index ff3086a78f..b423b04fe4 100644
--- a/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala
+++ b/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala
@@ -1,27 +1,34 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2006-2007, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
+// $Id$
+
+
package scala.util.parsing.combinator.lexical
import scala.util.parsing.syntax._
import scala.util.parsing.input.CharArrayReader.EofCh
import collection.mutable.HashSet
-/** This component provides a standard lexical parser for a simple, Scala-like language.
- * It parses keywords and identifiers, numeric literals (integers), strings, and delimiters.
- *<p>
- * To distinguish between identifiers and keywords, it uses a set of reserved identifiers:
- * every string contained in `reserved' is returned as a keyword token. (Note that "=>" is hard-coded
- * as a keyword.)
- * Additionally, the kinds of delimiters can be specified by the `delimiters' set.</p>
- *<p>
- * Usually this component is used to break character-based input into bigger tokens, which are then
- * passed to a token-parser {@see TokenParsers}.</p>
+/** <p>
+ * This component provides a standard lexical parser for a simple, Scala-like language.
+ * It parses keywords and identifiers, numeric literals (integers), strings, and delimiters.
+ * </p>
+ * <p>
+ * To distinguish between identifiers and keywords, it uses a set of reserved identifiers:
+ * every string contained in `reserved' is returned as a keyword token.
+ * (Note that "=>" is hard-coded as a keyword.)
+ * Additionally, the kinds of delimiters can be specified by the `delimiters' set.
+ * </p>
+ * <p>
+ * Usually this component is used to break character-based input into bigger tokens,
+ * which are then passed to a token-parser {@see TokenParsers}.
+ * </p>
*
* @author Martin Odersky, Iulian Dragos, Adriaan Moors
*/
@@ -77,7 +84,7 @@ class StdLexical extends Lexical with StdTokens {
_delim
}
- private def lift[T](f: String => T)(xs: List[char]): T = f(xs.mkString("", "", ""))
+ private def lift[T](f: String => T)(xs: List[Char]): T = f(xs.mkString("", "", ""))
- private def lift2[T](f: String => T)(p: ~[char, List[char]]): T = lift(f)(p._1 :: p._2)
+ private def lift2[T](f: String => T)(p: ~[Char, List[Char]]): T = lift(f)(p._1 :: p._2)
}
diff --git a/src/library/scala/util/parsing/combinator/syntactical/BindingParsers.scala b/src/library/scala/util/parsing/combinator/syntactical/BindingParsers.scala
index 95befc5547..c86e7d9755 100644
--- a/src/library/scala/util/parsing/combinator/syntactical/BindingParsers.scala
+++ b/src/library/scala/util/parsing/combinator/syntactical/BindingParsers.scala
@@ -1,11 +1,14 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2006-2007, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
+// $Id$
+
+
package scala.util.parsing.combinator.syntactical
import scala.util.parsing.ast._
diff --git a/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala b/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala
index f34d881eb9..968c363f7a 100644
--- a/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala
+++ b/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala
@@ -1,11 +1,14 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2006-2007, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
+// $Id$
+
+
package scala.util.parsing.combinator.syntactical
import scala.util.parsing.syntax._
diff --git a/src/library/scala/util/parsing/combinator/syntactical/TokenParsers.scala b/src/library/scala/util/parsing/combinator/syntactical/TokenParsers.scala
index d0236015ce..013ac400c4 100644
--- a/src/library/scala/util/parsing/combinator/syntactical/TokenParsers.scala
+++ b/src/library/scala/util/parsing/combinator/syntactical/TokenParsers.scala
@@ -1,37 +1,51 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2006-2007, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
+// $Id$
+
+
package scala.util.parsing.combinator.syntactical
-/** This is the core component for token-based parsers.
- *
- * <p>@requires lexical a component providing the tokens consumed by the parsers in this component</p>
+/** <p>
+ * This is the core component for token-based parsers.
+ * </p>
+ * <p>
+ * @requires lexical a component providing the tokens consumed by the
+ * parsers in this component.
+ * </p>
*
- * @author Martin Odersky, Adriaan Moors
+ * @author Martin Odersky, Adriaan Moors
*/
trait TokenParsers extends Parsers {
/** Tokens is the abstract type of the `Token's consumed by the parsers in this component*/
type Tokens <: scala.util.parsing.syntax.Tokens
- /** lexical is the component responsible for consuming some basic kind of input (usually
- * character-based) and turning it into the tokens understood by these parsers.
+ /** lexical is the component responsible for consuming some basic kind of
+ * input (usually character-based) and turning it into the tokens
+ * understood by these parsers.
*/
val lexical: Tokens
/** The input-type for these parsers*/
type Elem = lexical.Token
- /** A parser generator delimiting whole phrases (i.e. programs).
- *<p>
- * phrase(p) succeeds if `p' succeeds and no input is left over after `p'.</p>
+ /** <p>
+ * A parser generator delimiting whole phrases (i.e. programs).
+ * </p>
+ * <p>
+ * <code>phrase(p)</code> succeeds if <code>p</code> succeeds and
+ * no input is left over after <code>p</code>.
+ * </p>
*
- * @param p the parser that must consume all input for the resulting parser to succeed
- * @return a parser that has the same result as `p', but that only succeeds if `p' consumed all the input
+ * @param p the parser that must consume all input for the resulting parser
+ * to succeed.
+ * @return a parser that has the same result as `p', but that only succeeds
+ * if <code>p</code> consumed all the input.
*/
def phrase[t](p: Parser[t]) = new Parser[t] {
def apply(in: Input) = p(in) match {
diff --git a/src/library/scala/util/parsing/combinator/testing/Tester.scala b/src/library/scala/util/parsing/combinator/testing/Tester.scala
index 573f4643cc..0f58057a47 100644
--- a/src/library/scala/util/parsing/combinator/testing/Tester.scala
+++ b/src/library/scala/util/parsing/combinator/testing/Tester.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2006-2007, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
@@ -11,11 +11,20 @@ package scala.util.parsing.combinator.testing
import scala.util.parsing.combinator.lexical.Lexical
import scala.util.parsing.combinator.syntactical.TokenParsers
-/** Facilitates testing a given parser on various input strings.
- *<p>
- * Example use:, val syntactic = new MyParsers
- * and val parser = syntactic.term (if MyParsers extends TokenParsers with a parser called
- * `term')</p>
+/** <p>
+ * Facilitates testing a given parser on various input strings.
+ * </p>
+ * <p>
+ * Example use:
+ * </p><pre>
+ * <b>val</b> syntactic = <b>new</b> MyParsers</pre>
+ * <p>
+ * and
+ * </p><pre>
+ * <b>val</b> parser = syntactic.term</pre>
+ * <p>
+ * (if MyParsers extends TokenParsers with a parser called `term')
+ * </p>
*
* @author Martin Odersky, Adriaan Moors
*/
@@ -25,8 +34,9 @@ abstract class Tester {
val parser: syntactic.Parser[Any]
- /** Scans a String (using a `syntactic.lexical.Scanner'), parses it using `phrase(parser)', and
- * prints the input and the parsed result to the console.
+ /** Scans a String (using a `syntactic.lexical.Scanner'), parses it
+ * using <code>phrase(parser)</code>, and prints the input and the
+ * parsed result to the console.
*/
def test(in: String) {
Console.println("\nin : "+in)
diff --git a/src/library/scala/util/parsing/json/JSON.scala b/src/library/scala/util/parsing/json/JSON.scala
index e0431f5724..458fc7eb87 100644
--- a/src/library/scala/util/parsing/json/JSON.scala
+++ b/src/library/scala/util/parsing/json/JSON.scala
@@ -1,11 +1,24 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2006-2007, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id$
+
+
package scala.util.parsing.json
import scala.collection.mutable.HashMap
-/** This object mainly shows how a JSON parser maybe instantiated
+/** This object mainly shows how a JSON parser may be instantiated.
*
+ * @author Derek Chen-Becker <java@chen-becker.org>
*/
object JSON extends Parser {
+
def parse(input: String) =
phrase(root)(new lexical.Scanner(input)) match {
case Success(result, _) => Some(result)
@@ -21,11 +34,11 @@ object JSON extends Parser {
input match {
case jo: List[(String,Any)] =>
/*println("Resolving object")*/
- val objMap = new HashMap[String,Any]()
+ val objMap = new HashMap[String, Any]()
jo.foreach {
- case (key,value) =>
- objMap.update(key,resolveType(value))
+ case (key, value) =>
+ objMap.update(key, resolveType(value))
}
objMap
diff --git a/src/library/scala/util/parsing/json/Lexer.scala b/src/library/scala/util/parsing/json/Lexer.scala
index 6a6b3684a2..83f60d971a 100644
--- a/src/library/scala/util/parsing/json/Lexer.scala
+++ b/src/library/scala/util/parsing/json/Lexer.scala
@@ -1,75 +1,84 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2006-2007, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id$
+
+
package scala.util.parsing.json
import scala.util.parsing.combinator._
import scala.util.parsing.combinator.syntactical._
import scala.util.parsing.combinator.lexical._
import scala.util.parsing.input.CharArrayReader.EofCh
-import scala.util.parsing.combinator.~
/**
* @author Derek Chen-Becker <java@chen-becker.org>
*/
-
class Lexer extends StdLexical with ImplicitConversions {
- override def token: Parser[Token] =
- ('\"' ~ rep(charSeq | letter) ~ '\"' ^^ lift(StringLit)
- | number ~ letter ^^ { case n ~ l => ErrorToken("Invalid number format : " + n + l) }
- | '-' ~ whitespace ~ number ~ letter ^^ {case ws ~ num ~ l => ErrorToken("Invalid number format : -" + num + l) }
- | '-' ~ whitespace ~ number ^^ {case ws ~ num => NumericLit("-" + num)}
- | number ^^ NumericLit
- | EofCh ^^ EOF
- | delim
- | '\"' ~ failure("Unterminated string")
- | rep(letter) ^^ checkKeyword
- | failure("Illegal character")
- )
+ override def token: Parser[Token] =
+ ('\"' ~ rep(charSeq | letter) ~ '\"' ^^ lift(StringLit)
+ | number ~ letter ^^ { case n ~ l => ErrorToken("Invalid number format : " + n + l) }
+ | '-' ~ whitespace ~ number ~ letter ^^ {case ws ~ num ~ l => ErrorToken("Invalid number format : -" + num + l) }
+ | '-' ~ whitespace ~ number ^^ {case ws ~ num => NumericLit("-" + num)}
+ | number ^^ NumericLit
+ | EofCh ^^ EOF
+ | delim
+ | '\"' ~ failure("Unterminated string")
+ | rep(letter) ^^ checkKeyword
+ | failure("Illegal character")
+ )
- def checkKeyword(xs : List[Any]) = {
- val strRep = xs.mkString("")
- if (reserved.contains(strRep)) Keyword(strRep) else ErrorToken("Not a keyword: " + strRep)
- }
+ def checkKeyword(xs : List[Any]) = {
+ val strRep = xs.mkString("")
+ if (reserved.contains(strRep)) Keyword(strRep) else ErrorToken("Not a keyword: " + strRep)
+ }
- override def whitespace = rep(whitespaceChar)
+ override def whitespace = rep(whitespaceChar)
- def number = intPart ~ opt(fracPart) ~ opt(expPart) ^^ { case i ~ f ~ e =>
- i + optString(".",f) + optString("",e)
- }
- def intPart = zero | intList
- def intList = nonzero ~ rep(digit) ^^ {case x ~ y => (x :: y) mkString ""}
- def fracPart = '.' ~ rep(digit) ^^ {x => x.mkString("")}
- def expPart = exponent ~ opt(sign) ~ rep1(digit) ^^ { case e ~ s ~ d =>
- e + optString("",s) + d.mkString("")
- }
+ def number = intPart ~ opt(fracPart) ~ opt(expPart) ^^ { case i ~ f ~ e =>
+ i + optString(".",f) + optString("",e)
+ }
+ def intPart = zero | intList
+ def intList = nonzero ~ rep(digit) ^^ {case x ~ y => (x :: y) mkString ""}
+ def fracPart = '.' ~ rep(digit) ^^ {x => x.mkString("")}
+ def expPart = exponent ~ opt(sign) ~ rep1(digit) ^^ { case e ~ s ~ d =>
+ e + optString("",s) + d.mkString("")
+ }
- def optString[A](pre: String, a: Option[A]) = a match {
- case Some(x) => pre + x.toString
- case None => ""
- }
+ def optString[A](pre: String, a: Option[A]) = a match {
+ case Some(x) => pre + x.toString
+ case None => ""
+ }
- def zero: Parser[String] = '0' ^^ toString
- def nonzero = elem("nonzero digit", d => d.isDigit && d != '0')
- def exponent = elem("exponent character", d => d == 'e' || d == 'E')
- def sign = elem("sign character", d => d == '-' || d == '+')
+ def zero: Parser[String] = '0' ^^ toString
+ def nonzero = elem("nonzero digit", d => d.isDigit && d != '0')
+ def exponent = elem("exponent character", d => d == 'e' || d == 'E')
+ def sign = elem("sign character", d => d == '-' || d == '+')
- def charSeq: Parser[String] =
- ('\\' ~ '\"' ^^ "\""
- |'\\' ~ '\\' ^^ "\\"
- |'\\' ~ '/' ^^ "/"
- |'\\' ~ 'b' ^^ "\b"
- |'\\' ~ 'f' ^^ "\f"
- |'\\' ~ 'n' ^^ "\n"
- |'\\' ~ 'r' ^^ "\r"
- |'\\' ~ 't' ^^ "\t"
- |'\\' ~ 'u' ~ unicodeBlock)
+ def charSeq: Parser[String] =
+ ('\\' ~ '\"' ^^ "\""
+ |'\\' ~ '\\' ^^ "\\"
+ |'\\' ~ '/' ^^ "/"
+ |'\\' ~ 'b' ^^ "\b"
+ |'\\' ~ 'f' ^^ "\f"
+ |'\\' ~ 'n' ^^ "\n"
+ |'\\' ~ 'r' ^^ "\r"
+ |'\\' ~ 't' ^^ "\t"
+ |'\\' ~ 'u' ~ unicodeBlock)
- val hexDigits = Set[Char]() ++ "0123456789abcdefABCDEF".toArray
- def hexDigit = elem("hex digit", hexDigits.contains(_))
+ val hexDigits = Set[Char]() ++ "0123456789abcdefABCDEF".toArray
+ def hexDigit = elem("hex digit", hexDigits.contains(_))
- def unicodeBlock = hexDigit ~ hexDigit ~ hexDigit ~ hexDigit ^^ {
- case a ~ b ~ c ~ d =>
- new String(Character.toChars(Integer.parseInt(List(a,b,c,d).mkString(""),16)))
- }
+ def unicodeBlock = hexDigit ~ hexDigit ~ hexDigit ~ hexDigit ^^ {
+ case a ~ b ~ c ~ d =>
+ new String(Character.toChars(Integer.parseInt(List(a,b,c,d).mkString(""),16)))
+ }
- private def lift[T](f: String => T)(xs: List[Any]): T = f(xs.mkString(""))
+ private def lift[T](f: String => T)(xs: List[Any]): T = f(xs.mkString(""))
}
diff --git a/src/library/scala/util/parsing/json/Parser.scala b/src/library/scala/util/parsing/json/Parser.scala
index 8c94e060eb..99d77036dc 100644
--- a/src/library/scala/util/parsing/json/Parser.scala
+++ b/src/library/scala/util/parsing/json/Parser.scala
@@ -1,31 +1,39 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2006-2007, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id$
+
+
package scala.util.parsing.json;
import scala.util.parsing.combinator._
import scala.util.parsing.combinator.syntactical._
import scala.util.parsing.combinator.lexical._
-import scala.util.parsing.input.CharArrayReader.EofCh
-import scala.util.parsing.combinator.~
/**
* @author Derek Chen-Becker <java@chen-becker.org>
*/
-
class Parser extends StdTokenParsers with ImplicitConversions {
- // Fill in abstract defs
- type Tokens = Lexer
- val lexical = new Tokens
-
- // Configure lexical parsing
- lexical.reserved ++= List("true", "false", "null")
- lexical.delimiters ++= List("{", "}", "[", "]", ":", ",")
-
- // Define the grammar
- def root = jsonObj | jsonArray
- def jsonObj = "{" ~ repsep(objEntry,",") ~ "}"
- def jsonArray = "[" ~ repsep(value, ",") ~ "]"
- def objEntry = stringVal ~ ":" ~ value ^^ { case x ~ y => (x,y) }
- def value: Parser[Any] = (jsonObj | jsonArray | number | "true" ^^ true | "false" ^^ false | "null" ^^ null | stringVal)
- def stringVal = accept("string", {case lexical.StringLit(n) => n})
- def number = accept("number", {case lexical.NumericLit(n) => n.toDouble})
+ // Fill in abstract defs
+ type Tokens = Lexer
+ val lexical = new Tokens
+
+ // Configure lexical parsing
+ lexical.reserved ++= List("true", "false", "null")
+ lexical.delimiters ++= List("{", "}", "[", "]", ":", ",")
+
+ // Define the grammar
+ def root = jsonObj | jsonArray
+ def jsonObj = "{" ~ repsep(objEntry,",") ~ "}"
+ def jsonArray = "[" ~ repsep(value, ",") ~ "]"
+ def objEntry = stringVal ~ ":" ~ value ^^ { case x ~ y => (x,y) }
+ def value: Parser[Any] = (jsonObj | jsonArray | number | "true" ^^ true | "false" ^^ false | "null" ^^ null | stringVal)
+ def stringVal = accept("string", {case lexical.StringLit(n) => n})
+ def number = accept("number", {case lexical.NumericLit(n) => n.toDouble})
}