[cfe-dev] Writing a tentative parser for C++0x attributes

Sean Hunt rideau3 at gmail.com
Fri Aug 14 03:00:47 PDT 2009


Argyrios Kyrtzidis wrote:
> Hi Sean,
> 
> Don't forget to do "Reply-all" so that cfe-dev is included.
> Also, for future patches look into getting them attached instead of
> embedded into the email, so that they are easier to use.

Ah, I wasn't familiar with that aspect of this list. Thanks! I thought
I'd attached the patch, though. Oh well.

> About the patch, since attributes appear before statements &
> declarations, I suggest parsing them at
> Parser::ParseStatementOrDeclaration() before going into the "stmt or
> decl" parsing part. That way you will parse them once
> and then pass the AttributeList* to the statement parsing methods,
> instead of parsing them at each one.
> 
> Then for the decl/stmt ambiguity part, you only need to check for
> attributes in Parser::TryParseDeclarator().

The problem with this approach is that parsing them in
ParseStatementOrDeclaration() requires me to pass the attributes to
ParseDeclaration(), and then move the attribute check out of
ParseDeclaration() into its other two callers, when that check clearly
belongs in that function (it's called by
Parser::ParseStatementOrDeclaration(),
Parser::ParseCompoundStatementBody(), and
Parser::ParseExternalDeclaration(), and the latter calls
Parser::ParseDeclarationOrFunctionDefinition(), which currently does the
attribute check and itself has 2 other callers).

Sean Hunt




More information about the cfe-dev mailing list