4 ms·
I have been a happy user of PEG grammars for a while: https://en.wikipedia.org/wiki/Parsing_expression_grammar https://en.wikipedia.org/wiki/Parsing_expression
by heinrichhartman 7y ago
I have been a happy user of PEG grammars for a while:
https://en.wikipedia.org/wiki/Parsing_expression_grammar https://en.wikipedia.org/wiki/Parsing_expression_grammar
In particular this lua implementation:
http://www.inf.puc-rio.br/~roberto/lpeg/re.html http://www.inf.puc-rio.br/~roberto/lpeg/re.html
It let's you write stuff like this:
list <- (name s)*
name <- [a-z][a-z]*
s <- %s*
Features:
- Looks like EBNF
- Regular expressions are a subset
- Fast parser.