4 ms·
> If OP wants sexprs, they can get quick-and-dirty sexprs by: You know what it takes to implement a parser for s expressions? E := atom | '(' *E ')' With ato
by rewmie 3y ago
> If OP wants sexprs, they can get quick-and-dirty sexprs by:
You know what it takes to implement a parser for s expressions?
E := atom | '(' *E ')'
With atom expanding to all data types you wish to support.
Let's presume using a parser generator is an insurmountable task for someone developing a parser. In a hand-rolled packrat parser, this whole grammar is implemented with a couple of functions.
Is writing two functions too much work for someone wanting to write their own parser?
Your ad-hoc trick is much more work than actually implementing a proper, maintainable parser.
- carapace 3y agoFWIW, I've done it both ways. The ad-hoc trick is cromulent.