OK, got it.
One has just to define fexpr as:
fexpr:
';' { action1(); }
| expr ';' { action2(); }
and to redefine for_stmt as:
for_stmt:
for (assignment expr assignment) block
;
to get the right behavior. :)
Thanks again, guys!
Best regards,
Ilyes Gouta.
On Fri, Feb 29, 2008 at 10:23 AM, Ilyes Gouta <[EMAIL PROTECTED]> wrote:
> Hi!
>
> Thanks for your help.
>
> If I setup a new fexpr (and a new fassignment) that would accept
> nothing or expression, i.e:
>
> fexpr:
> | expr;
>
> for_stmt:
> for (fassignment; fexpr; fassignment) block
>
> How can I define an action that would be triggered only for the empty
> expressions? (I have to differentiate between the two cases since they
> won't have a common action)
>
> The only meaningful way, I found on the net to handle this, is this one:
> http://www.cs.uaf.edu/2007/fall/cs631/Cyacc.y
>
> Basically what it's done is enumerating all the possibilities for the
> construction of the for loop. Is it the only way do things clearly and
> properly?
>
> Best regards,
> Ilyes Gouta.
>
>
>
> On Thu, Feb 28, 2008 at 9:59 PM, Hans Aberg <[EMAIL PROTECTED]> wrote:
> > On 28 Feb 2008, at 15:16, Ilyes Gouta wrote:
> >
> > > I'm writing a small grammar for a very simplified C language. My goal
> > > is to produce an AST once a script file is parsed by the flex/bison
> > > tools. I got almost everything working nicely, except for the C style
> > > for loops.
> > ...
> >
> > > How one would modify the grammar to take into
> > > account such a scenario?
> > >
> > > Any ideas?
> >
> > There is a Yaccable grammar of C++ - you might check that out
> > http://www.parashift.com/c++-faq-lite/compiler-
> > dependencies.html#faq-38.11
> >
> > Hans Aberg
> >
> >
> >
>
_______________________________________________
[email protected] http://lists.gnu.org/mailman/listinfo/help-bison