javadba javadba - 1 year ago 89
Scala Question

Running a parser within parboiled2

The docs for parboiled2 mention the following to get results:

val parser = new MyParser(input)
val result =

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)

But the "run" is not accepted:

Error:(81, 12) too few argument lists for macro invocation


Answer Source

Looks like that the problem inside the following line:

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

and it can be fixed by explicitly declaring parserInput as a val

case class CsvParser(val input: ParserInput, delimiter: String = ",") 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download