Can this grammar be modified for lookahead of 1 ?

rahul@lsil.com (Rahul Bhargava x4596 )
Mon, 15 Aug 1994 18:52:05 GMT

          From comp.compilers

Related articles
Can this grammar be modified for lookahead of 1 ? rahul@lsil.com (1994-08-15)
Can this grammar be modified for lookahead of 1 ? ssimmons@convex.com (1994-08-18)
Re: Can this grammar be modified for lookahead of 1 ? salomon@silver.cs.umanitoba.ca (1994-08-18)
Re: Can this grammar be modified for lookahead 1 ? zenger@ira.uka.de (1994-08-19)
Re: Can this grammar be modified for lookahead of 1 ? David=Cook%Diag%Mfg=Hou@bangate.compaq.com (1994-08-19)
| List of all articles for this month |
Newsgroups: comp.compilers
From: rahul@lsil.com (Rahul Bhargava x4596 )
Keywords: yacc, parse, question
Organization: LSI Logic Corporation
Date: Mon, 15 Aug 1994 18:52:05 GMT

Hi,


I am trying to generate a parser using yacc for the following grammar:


  s -> l (1)
  l -> L i F i e (2)
  i -> A | ACA | CA | AC | C (3)
  e -> C (4)


This happens in a language where identifiers can contain special
characters including end of line character (semicolon in my case). Though
yacc only reports shift/reduce conflict on C in production (3) but it
can't reduce using (4) correctly becuase it applies (3) instead. As I see
it a lookahead = 2 is needed to correctly figure out which production to
apply.


Wondering if there is some way in which this grammar can be twisted to do
the correct thing ?
_________________________________________________________________________


      Rahul Bhargava
      Third Party Interface & CAD - dept. 7221 +-----+
      LSI Logic Corporation phone : (408) 433-4596 LSI|LOGIC|
      1501 McCarthy Blvd. FAX : (408) 433-4156 | |
      M/S E-192 email : rahul +-----+
      Milpitas, Ca. 95035 internet : rahul@lsil.com
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.