Re: typedef name question

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

 



"Michael Gong" <mwgong@xxxxxxxxxxxxxx> writes:

> To clarify myself a bit, is my following understanding correct ?
> 
> For this case:
>     int main() {
>         int foo;
>         foo abc;
>     }
> The Gcc's grammar does parse it, ie. an "identifier" can follow
> another "identifier".
> Then in the semantic analysis, gcc checks to make sure the first
> identifier "foo" must represent a type. In this case, it is not. So an
> error is reported.

I think you may be applying compiler theory to a real world compiler.

A better way to describe what happens would be to say that the lexer
looks up each identifier in the symbol table to see whether it is a
type before the parser proper ever sees it.

A truer way to describe what happens would be to observe that gcc uses
a recursive descent parser, not a grammar.

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux