Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As it was correctly pointed out by @Gabe, you left some white-spaces unhandled:</p> <pre><code>scala&gt; object SchemeParsers extends RegexParsers { | | private def space = regex("[ \\n]*".r) | | // Scheme boolean #t and #f translate to Scala's true and false | private def bool : Parser[Boolean] = | ("#t" | "#f") ^^ {case "#t" =&gt; true; case "#f" =&gt; false} | | // A Scheme identifier allows alphanumeric chars, some symbols, and | // can't start with a digit | private def id : Parser[String] = | """[a-zA-Z=*+/&lt;&gt;!\?][a-zA-Z0-9=*+/&lt;&gt;!\?]*""".r | | // This interpreter only accepts numbers as integers | private def num : Parser[Int] = """-?\d+""".r ^^ {case s =&gt; s toInt} | | // A string can have any character except ", and is wrapped in " | private def str : Parser[String] = '"' ~&gt; """[^""]*""".r &lt;~ '"' &lt;~ space ^^ {case s =&gt; s} | | // A Scheme list is a series of expressions wrapped in () | private def list : Parser[List[Any]] = | '(' ~&gt; space ~&gt; rep(expr) &lt;~ ')' &lt;~ space ^^ {s: List[Any] =&gt; s} | | // A Scheme expression contains any of the other constructions | private def expr : Parser[Any] = id | str | num | bool | list ^^ {case s =&gt; s} | | def parseExpr(str: String) = parse(expr, str) | } defined module SchemeParsers scala&gt; SchemeParsers.parseExpr("""(("a" "b") ("a" "b"))""") res12: SchemeParsers.ParseResult[Any] = [1.22] parsed: List(List(a, b), List(a, b)) scala&gt; SchemeParsers.parseExpr("""("a" "b" "c")""") res13: SchemeParsers.ParseResult[Any] = [1.14] parsed: List(a, b, c) scala&gt; SchemeParsers.parseExpr("""((1) (1 2) (1 2 3))""") res14: SchemeParsers.ParseResult[Any] = [1.20] parsed: List(List(1), List(1, 2), List(1, 2, 3)) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload