3 ms·
Is there any particular reason these days to favour a parser generator over a straight-up backtracking parser combinator library like attoparsec these days? Se
by moomin 11y ago
Is there any particular reason these days to favour a parser generator over a straight-up backtracking parser combinator library like attoparsec these days?
Seems like the whole reason for LALR(1) parsers was performance, and parsing is no longer as significant an amount of time compared to the old days, while helpful feedback, which any parser generator approach tends to be bad at, is at a premium.
- cynicalkane 11y agoIf your grammar is very simple and performance is important, but not important enough to hand-write a parser. This is common when, for example, ingesting data.
- jimrandomh 11y agoParsing speed is no longer important inside of compilers, but it still matters inside of text editors and IDEs. In those contexts, you have to choose between the extra complexity of managing parser generation, or the extra complexity of avoiding too many reparses.
- wtetzner 11y agoUnfortunately, you can't really use a parser generator for editors and IDEs, unless they're structured editors. If they're not structured editors, then the parser has to be able to gracefully handle broken parses.
- ltratt 11y agoIncremental parsing is designed for just this use case. The last major work in the area that I know of is Tim Wagner's PhD thesis http://www.cs.berkeley.edu/Research/Projects/harmonia/papers/twagner-thesis.pdf http://www.cs.berkeley.edu/Research/Projects/harmonia/papers...
- troutwine 11y ago> Parsing speed is no longer important inside of compilers, but it still matters inside of text editors and IDEs. Maybe! I agree with the second half there but I think the first half is not totally spot on. For _small_ projects modern machines will parse through faster than you can perceive but as source code grows a pokey parser will out. Becomes increasingly frustrating as the parser sub-system is tied up with early analysis, making it difficult to modify without getting deeply involved in the rest of the compilation steps.
- deleted 11y ago[deleted]
- ufo 11y agoThe point of LALR, as opposed to LR is performance but one of the advantages of bottom-up combinators over backtracking combinators is that ambiguities in the syntax can be detected at compile time.