From 0cf0becb2e07789dc2a6900468d0c597168ca36e Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 2 Feb 2010 12:03:37 +0100 Subject: Added AST building for __attribute__ constructs. --- src/shared/cplusplus/Parser.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src/shared/cplusplus/Parser.cpp') diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index e97b8e134c..319d1f65f2 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -2970,16 +2970,31 @@ bool Parser::parseAttributeSpecifier(SpecifierListAST *&node) return true; } -bool Parser::parseAttributeList(AttributeListAST *&) // ### create the AST +bool Parser::parseAttributeList(AttributeListAST *&node) { DEBUG_THIS_RULE(); + AttributeListAST **iter = &node; while (LA() == T_CONST || LA() == T_IDENTIFIER) { - if (LA() == T_CONST) - consumeToken(); - else if (LA() == T_IDENTIFIER) { - ExpressionAST *expression = 0; - parseExpression(expression); + *iter = new (_pool) AttributeListAST; + + if (LA() == T_CONST) { + AttributeAST *attr = new (_pool) AttributeAST; + attr->identifier_token = consumeToken(); + + (*iter)->value = attr; + iter = &(*iter)->next; + } else if (LA() == T_IDENTIFIER) { + AttributeAST *attr = new (_pool) AttributeAST; + attr->identifier_token = consumeToken(); + if (LA() == T_LPAREN) { + attr->lparen_token = consumeToken(); + parseExpressionList(attr->expression_list); + match(T_RPAREN, &attr->rparen_token); + } + + (*iter)->value = attr; + iter = &(*iter)->next; } if (LA() != T_COMMA) -- cgit v1.2.1