|LRstar email@example.com (2012-10-13)|
|Date:||Sat, 13 Oct 2012 20:11:44 -0700 (PDT)|
|Posted-Date:||14 Oct 2012 17:34:37 EDT|
I finally got around to using LRstar (by Paul Mann). I am doing some
retro-computing. A for the fun of it project is to re-create the Rockwell
Aim65 PL/65 compiler. The syntax seemed almost impossible to write a grammar
for that did not have conflicts.One of the hardest ones to resolve was for
assignment ->MemRef '=' expr
->MemRef '+' expr
->MemRef '-' expr
The production with the '+' in it would be similar to += in C. And if I
changed the '+' to += and the '-' to '-=', that would of course fix the
problem, but it would not be compatible with PL/65 syntax.
I used LRstar to first analyze the grammar with the (nd=2 switch which let it
use lalr(k) parsing. This of course worked. But I also dug through the
conflicts report and was easily able to figure out how to fix the grammar to
make it 'lalr(1)' with no conflicts. One of the LRstar operators, '/->' which
is the same as the '->' will tell LRstar which rules you want it to use when a
conflict occurs. So I easily got the grammar going. This is the first parser
generator I have used that gave me a conflict report I could understand. So,
despite the fact I thought I needed LALR(k), I ended up only needing LALR(1).
Now, I just have to figure out how to make LRstar work with my AST class that
I made, or just figure out the AST generation that is built into LRstar.
Return to the
Search the comp.compilers archives again.