help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LALR : How it work during parsing time with empty rule ? what to do


From: Hans Aberg
Subject: Re: LALR : How it work during parsing time with empty rule ? what to do to the stack?
Date: Tue, 13 Sep 2005 00:45:16 +0200

On 12 Sep 2005, at 23:31, Baldurien (club internet) wrote:

I've  made  a  little  parser in PHP based on bison output file, and I
experiment a little problem :

When I have to reduce, saying by rule X : Y '+' X I know I have to pop
3  times, but what happens when the rule is simply X : /* empty */ ? I
can't pop at all, so what should I do?

Just don't pop. If s is the state on top of the state stack, the total effect is that the state goto(s, X) is pushed onto it. If you have a stack for non-terminals and terminals, which the Bison generated parser doesn't, then X will be pushed onto that. The rule action is executed.

  Hans Aberg






reply via email to

[Prev in Thread] Current Thread [Next in Thread]