Gwtyyohizsqt50uslobx
SkillsCast

Boosting parboiled2 with SBT

8th December 2014 in London at Business Design Centre

There are 54 other SkillsCasts available from Scala eXchange 2014

Skillscast coming soon.

parboiled2 (parboiled2.org) is a Scala 2.10.3+ library enabling lightweight and easy-to-use, yet powerful, fast and elegant parsing of arbitrary input text. It implements a macro-based parser generator for Parsing Expression Grammars (PEGs), which runs at compile time and translates a grammar rule definition (written in an internal Scala DSL) into corresponding JVM bytecode.

parboiled2 is 10+ times faster than parboiled1 and Scala combinator parsers and almost as fast as specialized parsing library (according to Json parsers micro-benchmarkings)

A limitation that prevents parboiled2 to optimize generated parsers is implementation of Scala macros. Technically it is forbidden (hacks not counted) to look out of current macro function that prevents parboiled2 inner compiler to deeply optimize generated code. This limitation even makes some features impossible to implement in principal. For example, let's take a look at grammar:

def aRule = rule { “a” } def inputRule = rule { aRule ~ aRule }

parboiled2 can't optimize inputRule to rule { “aa” }.

A solution proposed in this talk is a SBT plugin sbt-parboiled2-boost. It builds intermediate parboiled2 PEG AST that is then deeply optimized.

Implementation details and solved limitations would be covered in the talk.

https://github.com/alexander-myltsev/sbt-parboiled2-boost

YOU MAY ALSO LIKE:

Thanks to our sponsors

Boosting parboiled2 with SBT

Alexander Myltsev

Programmer, researcher, and big data hacker passionately building scalable software products in the garage on his own and as an outsource consultant. Geek of Akka, spray.io, and a core developer of parboiled2.org PEG parsing library.