diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2009-04-21 15:53:28 (GMT) |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2009-04-24 08:05:52 (GMT) |
commit | eccf8f33890682a4827134805fa27bb354235e7a (patch) | |
tree | 4cb7ff858ae6fb67d2924ef97b6ebbed8e9ca559 | |
parent | 4d01ac2c6fc8e6484cfcb489e6037b846e491ee2 (diff) | |
download | Qt-eccf8f33890682a4827134805fa27bb354235e7a.zip Qt-eccf8f33890682a4827134805fa27bb354235e7a.tar.gz Qt-eccf8f33890682a4827134805fa27bb354235e7a.tar.bz2 |
Source locations for the statement nodes
-rw-r--r-- | src/declarative/qml/parser/javascript.g | 180 | ||||
-rw-r--r-- | src/declarative/qml/parser/javascriptast_p.h | 73 | ||||
-rw-r--r-- | src/declarative/qml/parser/javascriptparser.cpp | 180 |
3 files changed, 371 insertions, 62 deletions
diff --git a/src/declarative/qml/parser/javascript.g b/src/declarative/qml/parser/javascript.g index 9d0baae..219610e 100644 --- a/src/declarative/qml/parser/javascript.g +++ b/src/declarative/qml/parser/javascript.g @@ -1906,7 +1906,10 @@ Statement: DebuggerStatement ; Block: T_LBRACE StatementListOpt T_RBRACE ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::Block> (driver->nodePool(), sym(2).StatementList); + AST::Block *node = makeAstNode<AST::Block> (driver->nodePool(), sym(2).StatementList); + node->lbraceToken = loc(1); + node->rbraceToken = loc(3); + sym(1).Node = node; } break; ./ @@ -1942,7 +1945,8 @@ VariableStatement: VariableDeclarationKind VariableDeclarationList T_AUTOMATIC_S VariableStatement: VariableDeclarationKind VariableDeclarationList T_SEMICOLON ; /. case $rule_number: { - AST::VariableStatement *node = makeAstNode<AST::VariableStatement> (driver->nodePool(), sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST)); + AST::VariableStatement *node = makeAstNode<AST::VariableStatement> (driver->nodePool(), + sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST)); node->declarationKindToken = loc(1); node->semicolonToken = loc(3); sym(1).Node = node; @@ -1973,7 +1977,10 @@ case $rule_number: { VariableDeclarationList: VariableDeclarationList T_COMMA VariableDeclaration ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclarationList, sym(3).VariableDeclaration); + AST::VariableDeclarationList *node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), + sym(1).VariableDeclarationList, sym(3).VariableDeclaration); + node->commaToken = loc(2); + sym(1).Node = node; } break; ./ @@ -2012,6 +2019,7 @@ case $rule_number: { Initialiser: T_EQ AssignmentExpression ; /. case $rule_number: { + // ### TODO: AST for initializer sym(1) = sym(2); } break; ./ @@ -2028,6 +2036,7 @@ InitialiserOpt: Initialiser ; InitialiserNotIn: T_EQ AssignmentExpressionNotIn ; /. case $rule_number: { + // ### TODO: AST for initializer sym(1) = sym(2); } break; ./ @@ -2044,7 +2053,9 @@ InitialiserNotInOpt: InitialiserNotIn ; EmptyStatement: T_SEMICOLON ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::EmptyStatement> (driver->nodePool()); + AST::EmptyStatement *node = makeAstNode<AST::EmptyStatement> (driver->nodePool()); + node->semicolonToken = loc(1); + sym(1).Node = node; } break; ./ @@ -2061,14 +2072,23 @@ case $rule_number: { IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement T_ELSE Statement ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement, sym(7).Statement); + AST::IfStatement *node = makeAstNode<AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement, sym(7).Statement); + node->ifToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + node->elseToken = loc(5); + sym(1).Node = node; } break; ./ IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); + AST::IfStatement *node = makeAstNode<AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); + node->ifToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; } break; ./ @@ -2077,42 +2097,81 @@ IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_AUTOMA IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_SEMICOLON ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::DoWhileStatement> (driver->nodePool(), sym(2).Statement, sym(5).Expression); + AST::DoWhileStatement *node = makeAstNode<AST::DoWhileStatement> (driver->nodePool(), sym(2).Statement, sym(5).Expression); + node->doToken = loc(1); + node->whileToken = loc(3); + node->lparenToken = loc(4); + node->rparenToken = loc(6); + node->semicolonToken = loc(7); + sym(1).Node = node; } break; ./ IterationStatement: T_WHILE T_LPAREN Expression T_RPAREN Statement ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::WhileStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); + AST::WhileStatement *node = makeAstNode<AST::WhileStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); + node->whileToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; } break; ./ IterationStatement: T_FOR T_LPAREN ExpressionNotInOpt T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::ForStatement> (driver->nodePool(), sym(3).Expression, sym(5).Expression, sym(7).Expression, sym(9).Statement); + AST::ForStatement *node = makeAstNode<AST::ForStatement> (driver->nodePool(), sym(3).Expression, + sym(5).Expression, sym(7).Expression, sym(9).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->firstSemicolonToken = loc(4); + node->secondSemicolonToken = loc(6); + node->rparenToken = loc(8); + sym(1).Node = node; } break; ./ IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationListNotIn T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::LocalForStatement> (driver->nodePool(), sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, sym(8).Expression, sym(10).Statement); + AST::LocalForStatement *node = makeAstNode<AST::LocalForStatement> (driver->nodePool(), + sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, + sym(8).Expression, sym(10).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->varToken = loc(3); + node->firstSemicolonToken = loc(5); + node->secondSemicolonToken = loc(7); + node->rparenToken = loc(9); + sym(1).Node = node; } break; ./ IterationStatement: T_FOR T_LPAREN LeftHandSideExpression T_IN Expression T_RPAREN Statement ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::ForEachStatement> (driver->nodePool(), sym(3).Expression, sym(5).Expression, sym(7).Statement); + AST:: ForEachStatement *node = makeAstNode<AST::ForEachStatement> (driver->nodePool(), sym(3).Expression, + sym(5).Expression, sym(7).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->inToken = loc(4); + node->rparenToken = loc(6); + sym(1).Node = node; } break; ./ IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationNotIn T_IN Expression T_RPAREN Statement ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::LocalForEachStatement> (driver->nodePool(), sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement); + AST::LocalForEachStatement *node = makeAstNode<AST::LocalForEachStatement> (driver->nodePool(), + sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->varToken = loc(3); + node->inToken = loc(5); + node->rparenToken = loc(7); + sym(1).Node = node; } break; ./ @@ -2120,7 +2179,10 @@ ContinueStatement: T_CONTINUE T_AUTOMATIC_SEMICOLON ; -- automatic semicolon ContinueStatement: T_CONTINUE T_SEMICOLON ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::ContinueStatement> (driver->nodePool()); + AST::ContinueStatement *node = makeAstNode<AST::ContinueStatement> (driver->nodePool()); + node->continueToken = loc(1); + node->semicolonToken = loc(2); + sym(1).Node = node; } break; ./ @@ -2128,7 +2190,11 @@ ContinueStatement: T_CONTINUE T_IDENTIFIER T_AUTOMATIC_SEMICOLON ; -- automatic ContinueStatement: T_CONTINUE T_IDENTIFIER T_SEMICOLON ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::ContinueStatement> (driver->nodePool(), sym(2).sval); + AST::ContinueStatement *node = makeAstNode<AST::ContinueStatement> (driver->nodePool(), sym(2).sval); + node->continueToken = loc(1); + node->identifierToken = loc(2); + node->semicolonToken = loc(3); + sym(1).Node = node; } break; ./ @@ -2136,7 +2202,10 @@ BreakStatement: T_BREAK T_AUTOMATIC_SEMICOLON ; -- automatic semicolon BreakStatement: T_BREAK T_SEMICOLON ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::BreakStatement> (driver->nodePool()); + AST::BreakStatement *node = makeAstNode<AST::BreakStatement> (driver->nodePool()); + node->breakToken = loc(1); + node->semicolonToken = loc(2); + sym(1).Node = node; } break; ./ @@ -2144,7 +2213,11 @@ BreakStatement: T_BREAK T_IDENTIFIER T_AUTOMATIC_SEMICOLON ; -- automatic semic BreakStatement: T_BREAK T_IDENTIFIER T_SEMICOLON ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::BreakStatement> (driver->nodePool(), sym(2).sval); + AST::BreakStatement *node = makeAstNode<AST::BreakStatement> (driver->nodePool(), sym(2).sval); + node->breakToken = loc(1); + node->identifierToken = loc(2); + node->semicolonToken = loc(3); + sym(1).Node = node; } break; ./ @@ -2152,35 +2225,52 @@ ReturnStatement: T_RETURN ExpressionOpt T_AUTOMATIC_SEMICOLON ; -- automatic se ReturnStatement: T_RETURN ExpressionOpt T_SEMICOLON ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::ReturnStatement> (driver->nodePool(), sym(2).Expression); + AST::ReturnStatement *node = makeAstNode<AST::ReturnStatement> (driver->nodePool(), sym(2).Expression); + node->returnToken = loc(1); + node->semicolonToken = loc(3); + sym(1).Node = node; } break; ./ WithStatement: T_WITH T_LPAREN Expression T_RPAREN Statement ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::WithStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); + AST::WithStatement *node = makeAstNode<AST::WithStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); + node->withToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; } break; ./ SwitchStatement: T_SWITCH T_LPAREN Expression T_RPAREN CaseBlock ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::SwitchStatement> (driver->nodePool(), sym(3).Expression, sym(5).CaseBlock); + AST::SwitchStatement *node = makeAstNode<AST::SwitchStatement> (driver->nodePool(), sym(3).Expression, sym(5).CaseBlock); + node->switchToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; } break; ./ CaseBlock: T_LBRACE CaseClausesOpt T_RBRACE ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses); + AST::CaseBlock *node = makeAstNode<AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses); + node->lbraceToken = loc(1); + node->rbraceToken = loc(3); + sym(1).Node = node; } break; ./ CaseBlock: T_LBRACE CaseClausesOpt DefaultClause CaseClausesOpt T_RBRACE ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses); + AST::CaseBlock *node = makeAstNode<AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses); + node->lbraceToken = loc(1); + node->rbraceToken = loc(5); + sym(1).Node = node; } break; ./ @@ -2215,21 +2305,30 @@ case $rule_number: { CaseClause: T_CASE Expression T_COLON StatementListOpt ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::CaseClause> (driver->nodePool(), sym(2).Expression, sym(4).StatementList); + AST::CaseClause *node = makeAstNode<AST::CaseClause> (driver->nodePool(), sym(2).Expression, sym(4).StatementList); + node->caseToken = loc(1); + node->colonToken = loc(3); + sym(1).Node = node; } break; ./ DefaultClause: T_DEFAULT T_COLON StatementListOpt ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::DefaultClause> (driver->nodePool(), sym(3).StatementList); + AST::DefaultClause *node = makeAstNode<AST::DefaultClause> (driver->nodePool(), sym(3).StatementList); + node->defaultToken = loc(1); + node->colonToken = loc(2); + sym(1).Node = node; } break; ./ LabelledStatement: T_IDENTIFIER T_COLON Statement ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::LabelledStatement> (driver->nodePool(), sym(1).sval, sym(3).Statement); + AST::LabelledStatement *node = makeAstNode<AST::LabelledStatement> (driver->nodePool(), sym(1).sval, sym(3).Statement); + node->identifierToken = loc(1); + node->colonToken = loc(2); + sym(1).Node = node; } break; ./ @@ -2237,42 +2336,58 @@ ThrowStatement: T_THROW Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicol ThrowStatement: T_THROW Expression T_SEMICOLON ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::ThrowStatement> (driver->nodePool(), sym(2).Expression); + AST::ThrowStatement *node = makeAstNode<AST::ThrowStatement> (driver->nodePool(), sym(2).Expression); + node->throwToken = loc(1); + node->semicolonToken = loc(3); + sym(1).Node = node; } break; ./ TryStatement: T_TRY Block Catch ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch); + AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch); + node->tryToken = loc(1); + sym(1).Node = node; } break; ./ TryStatement: T_TRY Block Finally ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Finally); + AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Finally); + node->tryToken = loc(1); + sym(1).Node = node; } break; ./ TryStatement: T_TRY Block Catch Finally ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch, sym(4).Finally); + AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch, sym(4).Finally); + node->tryToken = loc(1); + sym(1).Node = node; } break; ./ Catch: T_CATCH T_LPAREN T_IDENTIFIER T_RPAREN Block ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::Catch> (driver->nodePool(), sym(3).sval, sym(5).Statement); + AST::Catch *node = makeAstNode<AST::Catch> (driver->nodePool(), sym(3).sval, sym(5).Statement); + node->catchToken = loc(1); + node->lparenToken = loc(2); + node->identifierToken = loc(3); + node->rparenToken = loc(4); + sym(1).Node = node; } break; ./ Finally: T_FINALLY Block ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::Finally> (driver->nodePool(), sym(2).Statement); + AST::Finally *node = makeAstNode<AST::Finally> (driver->nodePool(), sym(2).Statement); + node->finallyToken = loc(1); + sym(1).Node = node; } break; ./ @@ -2280,7 +2395,10 @@ DebuggerStatement: T_DEBUGGER T_AUTOMATIC_SEMICOLON ; -- automatic semicolon DebuggerStatement: T_DEBUGGER T_SEMICOLON ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::DebuggerStatement> (driver->nodePool()); + AST::DebuggerStatement *node = makeAstNode<AST::DebuggerStatement> (driver->nodePool()); + node->debuggerToken = loc(1); + node->semicolonToken = loc(2); + sym(1).Node = node; } break; ./ diff --git a/src/declarative/qml/parser/javascriptast_p.h b/src/declarative/qml/parser/javascriptast_p.h index 93f700f..56b2ec6 100644 --- a/src/declarative/qml/parser/javascriptast_p.h +++ b/src/declarative/qml/parser/javascriptast_p.h @@ -1004,6 +1004,8 @@ public: // attributes StatementList *statements; + SourceLocation lbraceToken; + SourceLocation rbraceToken; }; class StatementList: public Node @@ -1114,6 +1116,7 @@ public: // attributes VariableDeclaration *declaration; VariableDeclarationList *next; + SourceLocation commaToken; }; class EmptyStatement: public Statement @@ -1125,6 +1128,9 @@ public: virtual ~EmptyStatement() {} virtual void accept0(Visitor *visitor); + +// attributes + SourceLocation semicolonToken; }; class ExpressionStatement: public Statement @@ -1161,6 +1167,10 @@ public: ExpressionNode *expression; Statement *ok; Statement *ko; + SourceLocation ifToken; + SourceLocation lparenToken; + SourceLocation rparenToken; + SourceLocation elseToken; }; class DoWhileStatement: public Statement @@ -1179,6 +1189,11 @@ public: // attributes Statement *statement; ExpressionNode *expression; + SourceLocation doToken; + SourceLocation whileToken; + SourceLocation lparenToken; + SourceLocation rparenToken; + SourceLocation semicolonToken; }; class WhileStatement: public Statement @@ -1197,6 +1212,9 @@ public: // attributes ExpressionNode *expression; Statement *statement; + SourceLocation whileToken; + SourceLocation lparenToken; + SourceLocation rparenToken; }; class ForStatement: public Statement @@ -1217,6 +1235,11 @@ public: ExpressionNode *condition; ExpressionNode *expression; Statement *statement; + SourceLocation forToken; + SourceLocation lparenToken; + SourceLocation firstSemicolonToken; + SourceLocation secondSemicolonToken; + SourceLocation rparenToken; }; class LocalForStatement: public Statement @@ -1237,6 +1260,12 @@ public: ExpressionNode *condition; ExpressionNode *expression; Statement *statement; + SourceLocation forToken; + SourceLocation lparenToken; + SourceLocation varToken; + SourceLocation firstSemicolonToken; + SourceLocation secondSemicolonToken; + SourceLocation rparenToken; }; class ForEachStatement: public Statement @@ -1256,6 +1285,10 @@ public: ExpressionNode *initialiser; ExpressionNode *expression; Statement *statement; + SourceLocation forToken; + SourceLocation lparenToken; + SourceLocation inToken; + SourceLocation rparenToken; }; class LocalForEachStatement: public Statement @@ -1275,6 +1308,11 @@ public: VariableDeclaration *declaration; ExpressionNode *expression; Statement *statement; + SourceLocation forToken; + SourceLocation lparenToken; + SourceLocation varToken; + SourceLocation inToken; + SourceLocation rparenToken; }; class ContinueStatement: public Statement @@ -1291,6 +1329,9 @@ public: // attributes JavaScriptNameIdImpl *label; + SourceLocation continueToken; + SourceLocation identifierToken; + SourceLocation semicolonToken; }; class BreakStatement: public Statement @@ -1307,6 +1348,9 @@ public: // attributes JavaScriptNameIdImpl *label; + SourceLocation breakToken; + SourceLocation identifierToken; + SourceLocation semicolonToken; }; class ReturnStatement: public Statement @@ -1323,6 +1367,8 @@ public: // attributes ExpressionNode *expression; + SourceLocation returnToken; + SourceLocation semicolonToken; }; class WithStatement: public Statement @@ -1341,6 +1387,9 @@ public: // attributes ExpressionNode *expression; Statement *statement; + SourceLocation withToken; + SourceLocation lparenToken; + SourceLocation rparenToken; }; class SwitchStatement: public Statement @@ -1359,6 +1408,9 @@ public: // attributes ExpressionNode *expression; CaseBlock *block; + SourceLocation switchToken; + SourceLocation lparenToken; + SourceLocation rparenToken; }; class CaseBlock: public Node @@ -1378,6 +1430,8 @@ public: CaseClauses *clauses; DefaultClause *defaultClause; CaseClauses *moreClauses; + SourceLocation lbraceToken; + SourceLocation rbraceToken; }; class CaseClauses: public Node @@ -1429,6 +1483,8 @@ public: // attributes ExpressionNode *expression; StatementList *statements; + SourceLocation caseToken; + SourceLocation colonToken; }; class DefaultClause: public Node @@ -1446,6 +1502,8 @@ public: // attributes StatementList *statements; + SourceLocation defaultToken; + SourceLocation colonToken; }; class LabelledStatement: public Statement @@ -1464,6 +1522,9 @@ public: // attributes JavaScriptNameIdImpl *label; Statement *statement; + SourceLocation identifierToken; + SourceLocation colonToken; + SourceLocation semicolonToken; }; class ThrowStatement: public Statement @@ -1480,6 +1541,8 @@ public: // attributes ExpressionNode *expression; + SourceLocation throwToken; + SourceLocation semicolonToken; }; class TryStatement: public Statement @@ -1507,6 +1570,7 @@ public: Statement *statement; Catch *catchExpression; Finally *finallyExpression; + SourceLocation tryToken; }; class Catch: public Node @@ -1525,6 +1589,10 @@ public: // attributes JavaScriptNameIdImpl *name; Statement *statement; + SourceLocation catchToken; + SourceLocation lparenToken; + SourceLocation identifierToken; + SourceLocation rparenToken; }; class Finally: public Node @@ -1542,6 +1610,7 @@ public: // attributes Statement *statement; + SourceLocation finallyToken; }; class FunctionExpression: public ExpressionNode @@ -1741,6 +1810,10 @@ public: virtual ~DebuggerStatement() {} virtual void accept0(Visitor *visitor); + +// attributes + SourceLocation debuggerToken; + SourceLocation semicolonToken; }; class UiProgram: public Node diff --git a/src/declarative/qml/parser/javascriptparser.cpp b/src/declarative/qml/parser/javascriptparser.cpp index b46edfc..8708516 100644 --- a/src/declarative/qml/parser/javascriptparser.cpp +++ b/src/declarative/qml/parser/javascriptparser.cpp @@ -1040,7 +1040,10 @@ case 199: { } break; case 216: { - sym(1).Node = makeAstNode<AST::Block> (driver->nodePool(), sym(2).StatementList); + AST::Block *node = makeAstNode<AST::Block> (driver->nodePool(), sym(2).StatementList); + node->lbraceToken = loc(1); + node->rbraceToken = loc(3); + sym(1).Node = node; } break; case 217: { @@ -1060,7 +1063,8 @@ case 220: { } break; case 222: { - AST::VariableStatement *node = makeAstNode<AST::VariableStatement> (driver->nodePool(), sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST)); + AST::VariableStatement *node = makeAstNode<AST::VariableStatement> (driver->nodePool(), + sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST)); node->declarationKindToken = loc(1); node->semicolonToken = loc(3); sym(1).Node = node; @@ -1079,7 +1083,10 @@ case 225: { } break; case 226: { - sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclarationList, sym(3).VariableDeclaration); + AST::VariableDeclarationList *node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), + sym(1).VariableDeclarationList, sym(3).VariableDeclaration); + node->commaToken = loc(2); + sym(1).Node = node; } break; case 227: { @@ -1103,6 +1110,7 @@ case 230: { } break; case 231: { + // ### TODO: AST for initializer sym(1) = sym(2); } break; @@ -1111,6 +1119,7 @@ case 232: { } break; case 234: { + // ### TODO: AST for initializer sym(1) = sym(2); } break; @@ -1119,7 +1128,9 @@ case 235: { } break; case 237: { - sym(1).Node = makeAstNode<AST::EmptyStatement> (driver->nodePool()); + AST::EmptyStatement *node = makeAstNode<AST::EmptyStatement> (driver->nodePool()); + node->semicolonToken = loc(1); + sym(1).Node = node; } break; case 239: { @@ -1129,71 +1140,150 @@ case 239: { } break; case 240: { - sym(1).Node = makeAstNode<AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement, sym(7).Statement); + AST::IfStatement *node = makeAstNode<AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement, sym(7).Statement); + node->ifToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + node->elseToken = loc(5); + sym(1).Node = node; } break; case 241: { - sym(1).Node = makeAstNode<AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); + AST::IfStatement *node = makeAstNode<AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); + node->ifToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; } break; case 243: { - sym(1).Node = makeAstNode<AST::DoWhileStatement> (driver->nodePool(), sym(2).Statement, sym(5).Expression); + AST::DoWhileStatement *node = makeAstNode<AST::DoWhileStatement> (driver->nodePool(), sym(2).Statement, sym(5).Expression); + node->doToken = loc(1); + node->whileToken = loc(3); + node->lparenToken = loc(4); + node->rparenToken = loc(6); + node->semicolonToken = loc(7); + sym(1).Node = node; } break; case 244: { - sym(1).Node = makeAstNode<AST::WhileStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); + AST::WhileStatement *node = makeAstNode<AST::WhileStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); + node->whileToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; } break; case 245: { - sym(1).Node = makeAstNode<AST::ForStatement> (driver->nodePool(), sym(3).Expression, sym(5).Expression, sym(7).Expression, sym(9).Statement); + AST::ForStatement *node = makeAstNode<AST::ForStatement> (driver->nodePool(), sym(3).Expression, + sym(5).Expression, sym(7).Expression, sym(9).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->firstSemicolonToken = loc(4); + node->secondSemicolonToken = loc(6); + node->rparenToken = loc(8); + sym(1).Node = node; } break; case 246: { - sym(1).Node = makeAstNode<AST::LocalForStatement> (driver->nodePool(), sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, sym(8).Expression, sym(10).Statement); + AST::LocalForStatement *node = makeAstNode<AST::LocalForStatement> (driver->nodePool(), + sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, + sym(8).Expression, sym(10).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->varToken = loc(3); + node->firstSemicolonToken = loc(5); + node->secondSemicolonToken = loc(7); + node->rparenToken = loc(9); + sym(1).Node = node; } break; case 247: { - sym(1).Node = makeAstNode<AST::ForEachStatement> (driver->nodePool(), sym(3).Expression, sym(5).Expression, sym(7).Statement); + AST:: ForEachStatement *node = makeAstNode<AST::ForEachStatement> (driver->nodePool(), sym(3).Expression, + sym(5).Expression, sym(7).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->inToken = loc(4); + node->rparenToken = loc(6); + sym(1).Node = node; } break; case 248: { - sym(1).Node = makeAstNode<AST::LocalForEachStatement> (driver->nodePool(), sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement); + AST::LocalForEachStatement *node = makeAstNode<AST::LocalForEachStatement> (driver->nodePool(), + sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->varToken = loc(3); + node->inToken = loc(5); + node->rparenToken = loc(7); + sym(1).Node = node; } break; case 250: { - sym(1).Node = makeAstNode<AST::ContinueStatement> (driver->nodePool()); + AST::ContinueStatement *node = makeAstNode<AST::ContinueStatement> (driver->nodePool()); + node->continueToken = loc(1); + node->semicolonToken = loc(2); + sym(1).Node = node; } break; case 252: { - sym(1).Node = makeAstNode<AST::ContinueStatement> (driver->nodePool(), sym(2).sval); + AST::ContinueStatement *node = makeAstNode<AST::ContinueStatement> (driver->nodePool(), sym(2).sval); + node->continueToken = loc(1); + node->identifierToken = loc(2); + node->semicolonToken = loc(3); + sym(1).Node = node; } break; case 254: { - sym(1).Node = makeAstNode<AST::BreakStatement> (driver->nodePool()); + AST::BreakStatement *node = makeAstNode<AST::BreakStatement> (driver->nodePool()); + node->breakToken = loc(1); + node->semicolonToken = loc(2); + sym(1).Node = node; } break; case 256: { - sym(1).Node = makeAstNode<AST::BreakStatement> (driver->nodePool(), sym(2).sval); + AST::BreakStatement *node = makeAstNode<AST::BreakStatement> (driver->nodePool(), sym(2).sval); + node->breakToken = loc(1); + node->identifierToken = loc(2); + node->semicolonToken = loc(3); + sym(1).Node = node; } break; case 258: { - sym(1).Node = makeAstNode<AST::ReturnStatement> (driver->nodePool(), sym(2).Expression); + AST::ReturnStatement *node = makeAstNode<AST::ReturnStatement> (driver->nodePool(), sym(2).Expression); + node->returnToken = loc(1); + node->semicolonToken = loc(3); + sym(1).Node = node; } break; case 259: { - sym(1).Node = makeAstNode<AST::WithStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); + AST::WithStatement *node = makeAstNode<AST::WithStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); + node->withToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; } break; case 260: { - sym(1).Node = makeAstNode<AST::SwitchStatement> (driver->nodePool(), sym(3).Expression, sym(5).CaseBlock); + AST::SwitchStatement *node = makeAstNode<AST::SwitchStatement> (driver->nodePool(), sym(3).Expression, sym(5).CaseBlock); + node->switchToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; } break; case 261: { - sym(1).Node = makeAstNode<AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses); + AST::CaseBlock *node = makeAstNode<AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses); + node->lbraceToken = loc(1); + node->rbraceToken = loc(3); + sym(1).Node = node; } break; case 262: { - sym(1).Node = makeAstNode<AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses); + AST::CaseBlock *node = makeAstNode<AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses); + node->lbraceToken = loc(1); + node->rbraceToken = loc(5); + sym(1).Node = node; } break; case 263: { @@ -1213,43 +1303,71 @@ case 266: { } break; case 267: { - sym(1).Node = makeAstNode<AST::CaseClause> (driver->nodePool(), sym(2).Expression, sym(4).StatementList); + AST::CaseClause *node = makeAstNode<AST::CaseClause> (driver->nodePool(), sym(2).Expression, sym(4).StatementList); + node->caseToken = loc(1); + node->colonToken = loc(3); + sym(1).Node = node; } break; case 268: { - sym(1).Node = makeAstNode<AST::DefaultClause> (driver->nodePool(), sym(3).StatementList); + AST::DefaultClause *node = makeAstNode<AST::DefaultClause> (driver->nodePool(), sym(3).StatementList); + node->defaultToken = loc(1); + node->colonToken = loc(2); + sym(1).Node = node; } break; case 269: { - sym(1).Node = makeAstNode<AST::LabelledStatement> (driver->nodePool(), sym(1).sval, sym(3).Statement); + AST::LabelledStatement *node = makeAstNode<AST::LabelledStatement> (driver->nodePool(), sym(1).sval, sym(3).Statement); + node->identifierToken = loc(1); + node->colonToken = loc(2); + sym(1).Node = node; } break; case 271: { - sym(1).Node = makeAstNode<AST::ThrowStatement> (driver->nodePool(), sym(2).Expression); + AST::ThrowStatement *node = makeAstNode<AST::ThrowStatement> (driver->nodePool(), sym(2).Expression); + node->throwToken = loc(1); + node->semicolonToken = loc(3); + sym(1).Node = node; } break; case 272: { - sym(1).Node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch); + AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch); + node->tryToken = loc(1); + sym(1).Node = node; } break; case 273: { - sym(1).Node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Finally); + AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Finally); + node->tryToken = loc(1); + sym(1).Node = node; } break; case 274: { - sym(1).Node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch, sym(4).Finally); + AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch, sym(4).Finally); + node->tryToken = loc(1); + sym(1).Node = node; } break; case 275: { - sym(1).Node = makeAstNode<AST::Catch> (driver->nodePool(), sym(3).sval, sym(5).Statement); + AST::Catch *node = makeAstNode<AST::Catch> (driver->nodePool(), sym(3).sval, sym(5).Statement); + node->catchToken = loc(1); + node->lparenToken = loc(2); + node->identifierToken = loc(3); + node->rparenToken = loc(4); + sym(1).Node = node; } break; case 276: { - sym(1).Node = makeAstNode<AST::Finally> (driver->nodePool(), sym(2).Statement); + AST::Finally *node = makeAstNode<AST::Finally> (driver->nodePool(), sym(2).Statement); + node->finallyToken = loc(1); + sym(1).Node = node; } break; case 278: { - sym(1).Node = makeAstNode<AST::DebuggerStatement> (driver->nodePool()); + AST::DebuggerStatement *node = makeAstNode<AST::DebuggerStatement> (driver->nodePool()); + node->debuggerToken = loc(1); + node->semicolonToken = loc(2); + sym(1).Node = node; } break; case 279: { |