Skip to content

parboiled for Scala

Arcnor edited this page Nov 4, 2011 · 7 revisions
Clone this wiki locally

Starting with release parboiled comes in a variant called parboiled for Scala.
parboiled for Scala provides a concise internal Scala (2.8) DSL for parser rule building that enables the use of the parboiled parsing engine from Scala code without having to resort to the “clunky” (to the Scala devs eye) Java DSL and “heavy-lifting” parser extension.

parboiled for Scala uses the exact same parsing engine for rule execution as parboiled for Java. The only difference lies in rule construction, which is done by special Scala DSL constructs. parboiled for Scala offers the following advantages over its Java counterpart:

  • More concise rule building DSL (making use of Scalas higher expressiveness)
  • Increased type safety by hiding the parser value stack behind further abstractions (largely enabled by Scalas type inference)
  • Higher-level rule constructors (like nTimes and automatically list building oneOrMores/zeroOrMores)
  • Faster initial rule building (no expensive parser extension step)

In order to use parboiled for Scala you should follow the instructions on the Installation page and import org.parboiled.scala._, which properly brings all main types and implicit conversions in scope.