3 ms·
Parsers in nearley.js [1] are written in a very readable EBNF-like DSL; then they get desugared down to a JS file that's a lot like your snippet. [1] https://g
by hardmath123 6y ago
Parsers in nearley.js [1] are written in a very readable EBNF-like DSL; then they get desugared down to a JS file that's a lot like your snippet.
[1] https://github.com/kach/nearley https://github.com/kach/nearley
- matheusmoreira 6y agoI love Earley's algorithm! I wonder why it's so rare. Nearley is the only implementation I know. Why? It handles every possible grammar and yet it is a relatively simple algorithm. Would make an excellent choice for a standard library parse(grammar, input) function. Is it because the papers are hard to understand? All those symbols make no sense to the uninitiated. I definitely struggled to gain an understanding of how it works.