Related articles |
---|
Beginner help with LALR(1) closure kentr@rollinssoft.com (Kent Rollins) (1996-11-12) |
Re: Beginner help with LALR(1) closure dlester@cs.man.ac.uk (1996-11-14) |
Re: Beginner help with LALR(1) closure grout@sp55.csrd.uiuc.edu (1996-11-14) |
Re: Beginner help with LALR(1) closure compres@world.std.com (1996-11-14) |
Re: Beginner help with LALR(1) closure farzu@cs.tamu.edu (Francisco Arzu) (1996-11-14) |
Re: Beginner help with LALR(1) closure adrian@dcs.rhbnc.ac.uk (1996-11-19) |
Re: Beginner help with LALR(1) closure salomon@silver.cs.umanitoba.ca (1996-11-19) |
Re: Beginner help with LALR(1) closure gianni@engr.sgi.com (Gianni Mariani) (1996-12-03) |
Re: Beginner help with LALR(1) closure icedancer@ibm.net (1996-12-07) |
Re: Beginner help with LALR(1) closure salomon@silver.cs.umanitoba.ca (1996-12-15) |
From: | compres@world.std.com (Compiler Resources) |
Newsgroups: | comp.compilers |
Date: | 14 Nov 1996 21:56:54 -0500 |
Organization: | The World Public Access UNIX, Brookline, MA |
References: | 96-11-080 |
Keywords: | LALR |
> I'm using 'Compiler Design in C' [Holub]. I'm currently working
> on performing LALR(1) closure on LALR(1) states. I've got 2
> questions:
>
> 1. I've downloaded a few YACC-able grammars and I've noticed that
> they all have left-recusive grammars like (A) below. When I
> run this thru my generator, these cause infinite recursion.
When performing a [LA]LR closure on a state, the state is a set of
items. When you recursively add an item to the state, you may be
adding an item that is already in the state, simply check for that
situation before making the recursive call (or immediately upon entry
to the recursive call) and don't recurse when the item is already in
the set (the state).
BTW, that solves your problem with question 2 also.
Hope this helps,
-Chris
*****************************************************************************
Chris Clark Internet : compres@world.std.com
Compiler Resources, Inc. CompuServe : 74252,1375
85 Main Street, Suite 310 voice : (508) 435-5016
Hopkinton, MA 01748 USA fax : (508) 435-4847 (24 hours)
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.