1

The docs for parboiled2 mention the following to get results:

https://github.com/sirthias/parboiled2#access-to-parser-results

val parser = new MyParser(input) 
val result = parser.rootRule.run()

However I get a compilation error when attemping what seems to that approach:

Here is the outline of the parser:

case class CsvParser(input: ParserInput, delimiter: String = ",") extends Parser {
    ..
   def file = zeroOrMore(line) ~ EOI
}

The code to attempt to run it

val in = new StringBasedParserInput(readFile(fname))
val p = new CsvParser(in)
println(p.toString)
p.file.run

But the "run" is not accepted:

 Error:(81, 12) too few argument lists for macro invocation
  p.file.run
       ^
4

1 回答 1

1

看起来像以下行中的问题:

case class CsvParser(input: ParserInput, delimiter: String = ",") 

并且可以通过明确声明parserInput为 val来修复它

case class CsvParser(val input: ParserInput, delimiter: String = ",") 
于 2016-08-19T01:57:39.343 回答