Arpeggio is recursive descent parser with backtracking and memoization (a.k.a. pacrat parser). Arpeggio grammars are based on PEG formalism.
Arpeggio's main use is a foundation for a tool-chain for DSL development but it can be used for all sort of general purpose parsing.
For more information on PEG and packrat parsers see this page.
For a higher level library for building DSLs take a look at textX. It builds on top of Arpeggio and makes language parser implementation a lot easier.
See Getting started in the
User Guide menu to get you going or read some of the
- Using Parsing Expression Grammar and packrat parsing - unambiguous grammars, unlimited lookahead, linear time.
- Works as grammar interpreter - no code is generated.
- Multiple syntaxes for grammar definition (Python, peg, cleanpeg, make your own)
- Case sensitive/insensitive parsing
- Whitespace handling control
- Keyword handling
- Support for comments
- Newline termination for Repetition (available only in Python syntax)
- Parse tree navigation
- Visitors for semantic analysis
- Extensive error reporting
- Good support for debugging and visualization
- Good test coverage
- Beautiful mkdocs documentation - you are reading it
Arpeggio works with Python 3.6+. Other versions might work but are not tested.
Open-source projects using Arpeggio¶
- textX - Meta-language for building Domain-Specific Languages in Python (and all projects using textX)
- whatami - Unobtrusive object self-identification for Python (parsers module)
- ithkuil - A Python package providing tools for analysing texts in the Ithkuil constructed language.
Why is it called arpeggio?¶
In music, arpeggio is playing the chord notes one by one in sequence. I came up with the name by thinking that parsing is very similar to arpeggios in music. You take tokens one by one from an input and make sense out of it – make a chord!
Well, if you don't buy this maybe it is time to tell you the truth. I searched the dictionary for the words that contain PEG acronym and the word arpeggio was at the top of the list ;)
If you use Arpeggio please cite this paper:
Dejanović I., Milosavljević G., Vaderna R.: Arpeggio: A flexible PEG parser for Python, Knowledge-Based Systems, 2016, 95, 71 - 74, doi:10.1016/j.knosys.2015.12.004