[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
for loops in C style
From: |
Ilyes Gouta |
Subject: |
for loops in C style |
Date: |
Thu, 28 Feb 2008 15:16:40 +0100 |
Hi!
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.
Let's assume that we have a rule like this:
unary:
const
| id
;
expr:
unary
| expr + expr
| expr - expr
| expr * expr
| expr / expr
;
assignment:
id '=' expr ';'
;
for_stmt:
for (assignment; expr; assignment) block
;
My problem is that I'd like to support loops with empty assignment and
expr parts (i.e, always true loops and the likes) such as:
int a, b, c;
for (;;) {
c = a + b;
}
but I couldn't find a way to identify an empty assignment (or
expression) and to define the action associated (to push/construct a
new node within my AST). How one would modify the grammar to take into
account such a scenario?
Any ideas?
Best regards,
Ilyes Gouta.
- for loops in C style,
Ilyes Gouta <=
- Re: for loops in C style, Bob Rossi, 2008/02/28
- Re: for loops in C style, Hans Aberg, 2008/02/28
- Re: for loops in C style, Ilyes Gouta, 2008/02/29
- Re: for loops in C style, Ilyes Gouta, 2008/02/29
- Re: for loops in C style, Laurence Finston, 2008/02/29
- Re: for loops in C style, Ilyes Gouta, 2008/02/29
- Re: for loops in C style, Laurence Finston, 2008/02/29
- Re: for loops in C style, Ilyes Gouta, 2008/02/29
- Re: for loops in C style, lfinsto1, 2008/02/29
- Re: for loops in C style, Evan Lavelle, 2008/02/29