I am trying to get my thick head around the following problem:
class LineParser extends JavaTokenParsers {
def lines: Parser[Any] = rep(line)
def line: Parser[String] = """^.+$""".r
}
object LineParserTest extends LineParser {
def main(args: Array[String]) {
val reader = new FileReader(args(0))
println("input : "+ args(0))
println(parseAll(lines, reader))
}
}
Input file:
one
two
When I run the program, it gives me this error:
[1.1] failure: string matching regex `^.+$' expected but `o' found
one
^
Apparently, I did something stupid, but couldn't figure out why. Please advise.
The above is a simplified version of the real goal: to parse a cisco-like configuration file which include commands and sub-commands and build an AST. There are several commands that I don't care and would like to ignore them using the pattern """^.+$""" above.