return false;
}
+bool ResolveExpression::visit(CompoundExpressionAST *ast)
+{
+ return true; // ###
+}
+
bool ResolveExpression::visit(NestedExpressionAST *ast)
{
accept(ast->expression);
virtual bool visit(TypeIdAST *ast);
virtual bool visit(UnaryExpressionAST *ast);
virtual bool visit(CompoundLiteralAST *ast);
+ virtual bool visit(CompoundExpressionAST *ast);
//names
virtual bool visit(QualifiedNameAST *ast);
return literal_token + 1;
}
+unsigned CompoundExpressionAST::firstToken() const
+{
+ return lparen_token;
+}
+
+unsigned CompoundExpressionAST::lastToken() const
+{
+ if (rparen_token)
+ return rparen_token + 1;
+ else if (compoundStatement)
+ return compoundStatement->lastToken();
+ else
+ return lparen_token + 1;
+}
unsigned CompoundLiteralAST::firstToken() const
{
if (lparen_token) return lparen_token + 1;
return synchronized_token + 1;
}
-
-
virtual CastExpressionAST *asCastExpression() { return 0; }
virtual CatchClauseAST *asCatchClause() { return 0; }
virtual ClassSpecifierAST *asClassSpecifier() { return 0; }
+ virtual CompoundExpressionAST *asCompoundExpression() { return 0; }
virtual CompoundLiteralAST *asCompoundLiteral() { return 0; }
virtual CompoundStatementAST *asCompoundStatement() { return 0; }
virtual ConditionAST *asCondition() { return 0; }
virtual bool match0(AST *, ASTMatcher *);
};
+class CPLUSPLUS_EXPORT CompoundExpressionAST: public ExpressionAST
+{
+public:
+ unsigned lparen_token;
+ CompoundStatementAST *compoundStatement;
+ unsigned rparen_token;
+
+public:
+ virtual CompoundExpressionAST *asCompoundExpression() { return this; }
+
+ virtual unsigned firstToken() const;
+ virtual unsigned lastToken() const;
+
+ virtual CompoundExpressionAST *clone(MemoryPool *pool) const;
+
+protected:
+ virtual void accept0(ASTVisitor *visitor);
+ virtual bool match0(AST *, ASTMatcher *);
+};
+
class CPLUSPLUS_EXPORT CompoundLiteralAST: public ExpressionAST
{
public:
return ast;
}
+CompoundExpressionAST *CompoundExpressionAST::clone(MemoryPool *pool) const
+{
+ CompoundExpressionAST *ast = new (pool) CompoundExpressionAST;
+ ast->lparen_token = lparen_token;
+ if (compoundStatement)
+ ast->compoundStatement = compoundStatement->clone(pool);
+ ast->rparen_token = rparen_token;
+ return ast;
+}
+
CompoundLiteralAST *CompoundLiteralAST::clone(MemoryPool *pool) const
{
CompoundLiteralAST *ast = new (pool) CompoundLiteralAST;
return false;
}
+bool CompoundExpressionAST::match0(AST *pattern, ASTMatcher *matcher)
+{
+ if (CompoundExpressionAST *_other = pattern->asCompoundExpression())
+ return matcher->match(this, _other);
+
+ return false;
+}
+
bool CompoundLiteralAST::match0(AST *pattern, ASTMatcher *matcher)
{
if (CompoundLiteralAST *_other = pattern->asCompoundLiteral())
return true;
}
+bool ASTMatcher::match(CompoundExpressionAST *node, CompoundExpressionAST *pattern)
+{
+ (void) node;
+ (void) pattern;
+
+ pattern->lparen_token = node->lparen_token;
+
+ if (! pattern->compoundStatement)
+ pattern->compoundStatement = node->compoundStatement;
+ else if (! AST::match(node->compoundStatement, pattern->compoundStatement, this))
+ return false;
+
+ pattern->rparen_token = node->rparen_token;
+
+ return true;
+}
+
bool ASTMatcher::match(CompoundLiteralAST *node, CompoundLiteralAST *pattern)
{
(void) node;
virtual bool match(CastExpressionAST *node, CastExpressionAST *pattern);
virtual bool match(CatchClauseAST *node, CatchClauseAST *pattern);
virtual bool match(ClassSpecifierAST *node, ClassSpecifierAST *pattern);
+ virtual bool match(CompoundExpressionAST *node, CompoundExpressionAST *pattern);
virtual bool match(CompoundLiteralAST *node, CompoundLiteralAST *pattern);
virtual bool match(CompoundStatementAST *node, CompoundStatementAST *pattern);
virtual bool match(ConditionAST *node, ConditionAST *pattern);
visitor->endVisit(this);
}
+void CompoundExpressionAST::accept0(ASTVisitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(compoundStatement, visitor);
+ }
+ visitor->endVisit(this);
+}
+
void CompoundLiteralAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
virtual bool visit(CastExpressionAST *) { return true; }
virtual bool visit(CatchClauseAST *) { return true; }
virtual bool visit(ClassSpecifierAST *) { return true; }
+ virtual bool visit(CompoundExpressionAST *) { return true; }
virtual bool visit(CompoundLiteralAST *) { return true; }
virtual bool visit(CompoundStatementAST *) { return true; }
virtual bool visit(ConditionAST *) { return true; }
virtual void endVisit(CastExpressionAST *) { }
virtual void endVisit(CatchClauseAST *) { }
virtual void endVisit(ClassSpecifierAST *) { }
+ virtual void endVisit(CompoundExpressionAST *) { }
virtual void endVisit(CompoundLiteralAST *) { }
virtual void endVisit(CompoundStatementAST *) { }
virtual void endVisit(ConditionAST *) { }
class CastExpressionAST;
class CatchClauseAST;
class ClassSpecifierAST;
+class CompoundExpressionAST;
class CompoundLiteralAST;
class CompoundStatementAST;
class ConditionAST;
return false;
}
+bool CheckExpression::visit(CompoundExpressionAST *ast)
+{
+ return true; // ###
+}
+
bool CheckExpression::visit(NestedExpressionAST *ast)
{
FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope);
virtual bool visit(UnaryExpressionAST *ast);
virtual bool visit(QtMethodAST *ast);
virtual bool visit(CompoundLiteralAST *ast);
+ virtual bool visit(CompoundExpressionAST *ast);
//names
virtual bool visit(QualifiedNameAST *ast);
return parseThisExpression(node);
case T_LPAREN:
- return parseNestedExpression(node);
+ if (LA(2) == T_LBRACE) {
+ // GNU extension: '(' '{' statement-list '}' ')'
+ CompoundExpressionAST *ast = new (_pool) CompoundExpressionAST;
+ ast->lparen_token = consumeToken();
+ StatementAST *statement = 0;
+ parseCompoundStatement(statement);
+ ast->compoundStatement = statement->asCompoundStatement();
+ match(T_RPAREN, &ast->rparen_token);
+ node = ast;
+ return true;
+ } else {
+ return parseNestedExpression(node);
+ }
case T_SIGNAL:
case T_SLOT:
DEBUG_THIS_RULE();
if (LA() == T_LPAREN) {
unsigned lparen_token = consumeToken();
-
- if (LA() == T_LBRACE) {
- NestedExpressionAST *ast = new (_pool) NestedExpressionAST;
- ast->lparen_token = lparen_token;
-
- // ### ast
- StatementAST *statement = 0;
- parseCompoundStatement(statement);
- match(T_RPAREN, &ast->rparen_token);
- node = ast;
- return true;
- }
-
bool previousTemplateArguments = switchTemplateArguments(false);
ExpressionAST *expression = 0;
{
DEBUG_THIS_RULE();
- if (peekAtObjCContextKeyword(kind)) {
- in_token = consumeToken();
- return true;
- } else {
+ if (!peekAtObjCContextKeyword(kind))
return false;
- }
+
+ in_token = consumeToken();
+ return true;
}