Reputation: 37847
I am writing a GLR parser generator and would like some advice on resources relating to this algorithm both on the internet and of the dead-tree variety (books for those unfamiliar with the geek-speak).
I know Bison can generate GLR parsers, and given it's under the GPL I can examine its code, however it'd be nice to have a full description of the algorithm.
So, does anybody know of any good resources out there which I can make use of? Thanks.
Upvotes: 24
Views: 5257
Reputation: 95420
Adrian Johnstone publishes a lot of work on advanced versions of GLR algorithms. His publications website will likely be an interesting resource.
Upvotes: 6
Reputation: 11584
The best description I have ever seen, with pictures illustrating each step of the algorithm, is contained in this book:
For pseudocode, go to the source: Generalized LR Parsing by Tomita, page 70 or so. Farshi's paper contains a compact description.
It's one of the techniques I tried for qb.js (qbasic in javascript).
Upvotes: 5
Reputation: 47058
Some good stuff I've come across before online:
and for more detail:
And I know of a third open source GLR parser: DParser.
Upvotes: 17
Reputation: 60033
From what I'm aware, it functions the same as an LALR parser - except when it encounters an ambiguity.
When it does, it essentially divides into separate parses corresponding to the possible options at that point, and continues with them in tandem - when a parse fails (due to encountering an illegal element), it is simply dropped, because it must have been a wrong guess at an earlier ambiguity.
At the end, all but one parse should have died - and the surviving one is the "correct" parse of those ambiguous points.
Upvotes: 2