<div dir="ltr"><br><br><div class="gmail_quote">2008/9/12 Argiris Kirtzidis <span dir="ltr"><<a href="mailto:akyrtzi@gmail.com">akyrtzi@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">Zhongxing Xu wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I agree with Ted that we should separate syntax thing from semantics thing in the AST.<br>
<br>
struct s;<br>
struct s a;<br>
struct s { int d; } x;<br>
<br>
These 'struct s' have different meanings: type declaration, type specifier, type definition.<br>
But syntactically they are all RecordDecl.<br>
</blockquote>
<br></div>
Strictly syntactically speaking, and by standard terminology, here's what the above constructs are:<br>
<br>
struct s;       ->   type-specifier ';'<br>
struct s a;    ->   type-specifier 'a' ';'<br>
struct s { int d; } x;    ->  type-specifier 'x' ';'<br>
<br>
Isn't it more faithful to the syntax to consider "struct s { int d; }" as part of the type-specifier for 'x' ?<br>
Here's how a client may work when it receives "struct s { int d; } x;" and wants to pretty-print it:<br>
<br>
-I've got a DeclGroup of one VarDecl named 'x'.<br>
-Print its type. It's type (the type-specifier part of the syntax) is RecordTypeDef. Print the RecordDecl by getting it from the RecordTypeDef.<br>
-Print "x;"<br>
<br>
This seems more syntactically-oriented to me, why is it more confusing ?<br><font color="#888888">
</font></blockquote><div><br>As types are uniqued, how do we differentiate 'struct s a;' from 'struct s { int d; } x;' in the AST?<br>Use RecordTypeDef and RecordType?<br><br>-Zhongxing<br></div></div></div>