Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #765 > unrolled thread

LRstar

Started bypatchell@cox.net
First post2012-10-13 20:11 -0700
Last post2012-10-13 20:11 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.compilers


Contents

  LRstar patchell@cox.net - 2012-10-13 20:11 -0700

#765 — LRstar

Frompatchell@cox.net
Date2012-10-13 20:11 -0700
SubjectLRstar
Message-ID<12-10-007@comp.compilers>
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
this production:

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.

-Jim

[toc] | [standalone]


Back to top | Article view | comp.compilers


csiph-web