[cfe-dev] Cleaning up the representation of Decls in the AST
Argiris Kirtzidis
akyrtzi at gmail.com
Fri Sep 12 04:01:40 PDT 2008
To sum up my point here, it is more syntactically accurate to consider
RecordDecl a part of type-specifier.
In the syntax it's the type-specifier of a syntactic construct that
tells us whether it's "struct s" or "struct s { int d; }".
If we are not getting this kind of information, the type-specifier is
not represented correctly in the AST.
-Argiris
Argiris Kirtzidis wrote:
> 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' ?
> Here's how a client may work when it receives "struct s { int d; } x;"
> and wants to pretty-print it:
>
> -I've got a DeclGroup of one VarDecl named 'x'.
> -Print its type. It's type (the type-specifier part of the syntax) is
> RecordTypeDef. Print the RecordDecl by getting it from the RecordTypeDef.
> -Print "x;"
>
> This seems more syntactically-oriented to me, why is it more confusing ?
>
> -Argiris
>
>
More information about the cfe-dev
mailing list