Re: Grammar question (Michael Bergman)
Thu, 22 Sep 1994 13:52:33 GMT

          From comp.compilers

Related articles
Grammar question (1994-09-20)
Re: Grammar question (1994-09-22)
Re: Grammar question (Chris Clark USG) (1994-09-26)
Re: Grammar question (Zerksis D. Umrigar) (1994-09-28)
grammar question (1996-03-14)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (Michael Bergman)
Keywords: parse, tools
Organization: Ellemtel Telecom Systems Labs, Stockholm, Sweden
References: 94-09-114
Date: Thu, 22 Sep 1994 13:52:33 GMT

Elan Feingold ( wrote:

>I am trying to use lex and yacc to parse the following sorts
>of "sentences":
>Where each of the parts in [] can be left out. The problem is that
>when I type "Verb Foo..." I don't know whether this should be returned
>as an IDENTIFIER or a FOO, without looking ahead to see if down the
>line to see if there is another "Foo." If I type something like

There you said it: looking ahed. Not much use in trying to parse this with
yacc. (Like John points out you could twist the lexer like h*** and try to
work something out from that)

Try PCCTS instead, if you can somehow make the grammar LL(k) it will
automatically do all the lookahed for you. I'm not saying it is doable
with PCCTS, but you should try it. First ask in if the ppl there think it's possible. Terence
Parr can probably look at it for 10 mins and then tell you if there's any
point persuing it.

>horrendous amount of lookahead glop into the lexer, frequently combined
>with hints from the parser, so that the lexer can feed the parser tokens
>it can handle. I managed to parse Fortran 77 in yacc that way. -John]

Ouch. Sounds like a REAL drag :-)

Michael Bergman Email:
EUA/XO Phone: +46 8 7275709
Ellemtel Telecom Systems Labs, Armborstv 14, S-125 25 Alvsjo, Sweden

Post a followup to this message

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