parol
parol
is a LL(k) parser generator for Rust written in Rust with the following features
Generated parsers
parol
can generate types that resemble the AST of your grammar automatically. Semantic actions are then called with these types. This greatly improves the development process and makes it less error-prone.Other properties of parol
are:
parol
's parser is generated by parol
itself.LL parsing technique is a top-down parsing strategy that always starts from the start symbol of your grammar. This symbol becomes the root node of the parse tree. Then it tries to derive the left-most symbol first. All such symbols are then processed in a pre-order traversal. During this process the parse tree is created from the root downwards.
Both, processing the input and producing the parse tree in 'natural' direction ensures that at every point during parsing you can see where you came from and what you want to derive next. parol
's parse stack contains 'End of Production' markers which reflect the 'call hierarchy' of productions.
This tremendously helps to put your language processing into operation. In contrast, anyone who has ever debugged a LR parser will remember the effect of 'coming out of nowhere'.
Although LL grammars are known to be a subset of LR grammars many use cases exist where LL grammars are sufficient. By supporting more than one lookahead token the abilities of traditional LR(1) grammars and LL(k) grammars become more and more indistinct.
parol
?parol
is simple. You can actually understand all parts of it without broader knowledge in parsing theory.
parol
is fast. The use of deterministic automata ensures a minimal overhead during parsing, no backtracking needed.
parol
is a true LL(k) parser. You won't find much working LL(k) parsers out there.
parol
generates beautiful code that is easy to read which fosters debugging.
parol
is young. Although this might be a problem some times, especially regarding the stability of the API, the best is yet to come.
parol
is actively developed. Thus new features are likely to be added as the need arises.
This project contains some introductory grammar examples from entry level up to a more complex C-like expression language and an acceptor for Oberon-0 grammar.
Some of the examples describe the principles of language processing by using semantic actions in the way parol
advocates it.
A Tutorial explains step by step how to use parol
by implementing a JSON parser.
parol
's input language processing is an additional and very practical example.
parol
has proved its ability in many examples and tests during its development. Early adopters can quite safely use it.
But parol
is not ready for production yet. Features are still in development and the crate's interface can change at any time. Many work is still to do and help is appreciated.
Parsers generated by parol
have to add a dependency to the parolruntime crate. It provides the scanner and parser implementations needed. The parolruntime crate is very lightweight.