4 ms·
I agree there are a few places like this, but they're usually solved when you want an LL parser for as much as possible of the language by either making them pa
by vidarh 3y ago
I agree there are a few places like this, but they're usually solved when you want an LL parser for as much as possible of the language by either making them part of the tokenization or by "escaping" a small subset of the grammar.
I wish that language designers (looking at you, Ruby - as much as I love using Ruby, the grammar is an abomination) would at least try to stick to LL as much as possible, and consciously, carefully and in a limited fashion "escape" into LR for as small subsets as possible.
Break rules if it actually helps developers, sure, but it'd be nice if people tried to make the weird bits as tiny as possible...
EDIT: Also, in practice this is often what we end up doing when we write recursive descent anyway, only in a less than formal way. It'd be nice if more tooling let us write grammars that default to LL w/checking, but let you insert clearly delineated exceptions.
- marcosdumay 3y agoOh, I do agree with that! A language should be LL as much as possible. And also depend on the parsed data as little as possible. Stuff like C's variable declaration must be avoided. But I don't think either of those rules can be made universal. Some language for expressing exceptions would be great.