[cfe-dev] Cleaning up the representation of Decls in the AST

Argiris Kirtzidis akyrtzi at gmail.com
Fri Sep 12 07:42:02 PDT 2008


Zhongxing Xu wrote:
>
>
> 2008/9/12 Argiris Kirtzidis <akyrtzi at gmail.com <mailto:akyrtzi at gmail.com>>
>
>     Zhongxing Xu wrote:
>
>         I agree with Ted that we should separate syntax thing from
>         semantics thing in the AST.
>
>         struct s;
>         struct s a;
>         struct s { int d; } x;
>
>         These 'struct s' have different meanings: type declaration,
>         type specifier, type definition.
>         But syntactically they are all RecordDecl.
>
>
>     Strictly syntactically speaking, and by standard terminology,
>     here's what the above constructs are:
>
>     struct s;       ->   type-specifier ';'
>     struct s a;    ->   type-specifier 'a' ';'
>     struct s { int d; } x;    ->  type-specifier 'x' ';'
>
>     Isn't it more faithful to the syntax to consider "struct s { int
>     d; }" as part of the type-specifier for 'x' ?
>
>
> These reflected the parsing steps faithfully. But it is not necessary 
> to retain parsing information entirely in the AST.

The point is having the AST closely match the C/C++ syntax.

-Argiris



More information about the cfe-dev mailing list