parboiled for Scala
Content
- Introduction
- ... Motivation
- ... Features
- ... Simple Java Example
- ... Simple Scala Example
- ... RegEx vs. parboiled vs. Parser Generators
- ... Projects using parboiled
- Installation
- Concepts
- ... The Big Picture
- ... The Rule Tree
- ... The Value Stack
- ... The Parse Tree
- ... AST Construction
- ... Parse Error Handling
- parboiled for Java
- ... Rule Construction in Java
- ... Parser Action Expressions
- ... Working with the Value Stack
- ... Action Variables
- ... Parser Extension in Detail
- ... Style Guide
- ... Java Examples
- ...... ABC Grammar
- ...... Calculators
- ...... Time Parser
- ...... Java Parser
- ...... Markdown processor
- parboiled for Scala
- ... Rule Construction in Scala
- ... Parser Actions in Scala
- ... Parser Testing in Scala
- ... Scala Examples
- ...... Simple Calculator
- ...... JSON Parser
- Advanced Topics
- ... Handling Whitespace
- ... Parsing Performance Tuning
- ... Indentation Based Grammars
- ... The ProfilingParseRunner
- ... Grammar and Parser Debugging
- ... Thread Safety
- Building parboiled
- parboiled-core Javadoc API
- parboiled-java Javadoc API
- parboiled-scala Scaladoc API
- Change Log
- Patch Policy
Clone this wiki locally
Starting with release 0.9.8.0 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.