Hi, TCC stackholders,
I am tracing TCC's source codes, and find something I don't understand.
What I don't understand is about the grammar.
>From the C89 or C99 standard:
======================================================================
assignment_expression
: lvalue assignment_operator *assignment_expression*
| conditional_expression
;
======================================================================
However, in TCC,
======================================================================
static void gexpr(void)
{
while (1) {*
expr_eq();*
if (tok != ',')
break;
vpop();
next();
}
}
======================================================================
and expr_eq( ) seems to parse C conditional expression (ie, xxx ? xxx :
xxx).
It seems that it doesn't parse codes like "a = b = c = d = 4;".
And in the C standard,
======================================================================
multiplicative_expression
: (*cast_expression*) ('*' *cast_expression* | '/'* cast_expression *| '%' *
cast_expression*)*
;
======================================================================
However, in TCC, the function to parse "multiplicative_expression" is
expr_prod( ):
======================================================================
static void expr_prod(void)
{
int t;
*
uneq();*
while (tok == '*' || tok == '/' || tok == '%') {
t = tok;
next();*
uneq();*
gen_op(t);
}
}
======================================================================
and *uneq( ) *seems to parse the so-call "assignment_expression.", not the
standard-defined "cast_expression"
Why TCC uses such a grammar? it seems not compatible with the C standard.
Wei.
_______________________________________________
Tinycc-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/tinycc-devel