Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.compilers > #765
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.misty.com!news.iecc.com!.POSTED!nerds-end |
|---|---|
| From | patchell@cox.net |
| Newsgroups | comp.compilers |
| Subject | LRstar |
| Date | Sat, 13 Oct 2012 20:11:44 -0700 (PDT) |
| Organization | Compilers Central |
| Lines | 28 |
| Sender | johnl@iecc.com |
| Approved | comp.compilers@iecc.com |
| Message-ID | <12-10-007@comp.compilers> (permalink) |
| NNTP-Posting-Host | news.iecc.com |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | leila.iecc.com 1350250477 15766 64.57.183.58 (14 Oct 2012 21:34:37 GMT) |
| X-Complaints-To | abuse@iecc.com |
| NNTP-Posting-Date | Sun, 14 Oct 2012 21:34:37 +0000 (UTC) |
| Keywords | parse, tools |
| Posted-Date | 14 Oct 2012 17:34:37 EDT |
| X-submission-address | compilers@iecc.com |
| X-moderator-address | compilers-request@iecc.com |
| X-FAQ-and-archives | http://compilers.iecc.com |
| Xref | csiph.com comp.compilers:765 |
Show key headers only | View raw
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
Back to comp.compilers | Previous | Next | Find similar | Unroll thread
LRstar patchell@cox.net - 2012-10-13 20:11 -0700
csiph-web