Skip to content

@systay /gist:984483
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Failing test
package org.neo4j.lab.cypher
import commands.Query
import util.parsing.combinator.JavaTokenParsers
import org.junit.Assert._
import org.junit.Test
class ParserTest {
@Test def lowerCaseWorks() {
val parser = new TestParser
val option: Option[Let] = parser.parse("let a = \"hello world\"")
if (option.isEmpty)
fail();
}
@Test def upperCaseWorks() {
val parser = new TestParser
val option: Option[Let] = parser.parse("LET a = \"hello world\"")
if (option.isEmpty)
fail();
}
}
case class Let(variable:String, value:String)
class TestParser extends JavaTokenParsers {
def let: Parser[Let] = "let" ~> ident ~ "=" ~ stringLiteral ^^ {
case variable ~ "=" ~ value => Let(variable, value)
}
def parse(statement: String): Option[Let] =
parseAll(let, statement) match {
case Success(r, q) => Option(r)
case x => println(x); None
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.