diff options
Diffstat (limited to 'src/declarative/qml/parser/javascript.g')
-rw-r--r-- | src/declarative/qml/parser/javascript.g | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/src/declarative/qml/parser/javascript.g b/src/declarative/qml/parser/javascript.g index 961041e..f9a2165 100644 --- a/src/declarative/qml/parser/javascript.g +++ b/src/declarative/qml/parser/javascript.g @@ -87,7 +87,7 @@ %nonassoc T_IDENTIFIER T_COLON %nonassoc REDUCE_HERE -%start Program +%start UiProgram /. /**************************************************************************** @@ -286,7 +286,7 @@ public: bool parse(JavaScriptEnginePrivate *driver); JavaScript::AST::UiProgram *ast() - { return sym(1).UiProgram; } + { return program; } QList<DiagnosticMessage> diagnosticMessages() const { return diagnostic_messages; } @@ -326,6 +326,8 @@ protected: int *state_stack; JavaScript::AST::SourceLocation *location_stack; + JavaScript::AST::UiProgram *program; + // error recovery enum { TOKEN_BUFFER_SIZE = 3 }; @@ -422,6 +424,7 @@ bool JavaScriptParser::parse(JavaScriptEnginePrivate *driver) first_token = last_token = 0; tos = -1; + program = 0; do { if (++tos == stack_size) @@ -466,11 +469,12 @@ bool JavaScriptParser::parse(JavaScriptEnginePrivate *driver) -- Declarative UI -------------------------------------------------------------------------------------------------------- -Program: UiImportListOpt UiObjectMemberList ; +UiProgram: UiImportListOpt UiObjectMemberList ; /. case $rule_number: { - sym(1).Node = makeAstNode<AST::UiProgram> (driver->nodePool(), sym(1).UiImportList, + program = makeAstNode<AST::UiProgram> (driver->nodePool(), sym(1).UiImportList, sym(2).UiObjectMemberList->finish()); + sym(1).UiProgram = program; } break; ./ @@ -602,7 +606,7 @@ case $rule_number: { sym(4).UiObjectMemberList->finish()); node->colonToken = loc(2); node->lbracketToken = loc(3); - node->rbraceToken = loc(5); + node->rbracketToken = loc(5); sym(1).Node = node; } break; ./ @@ -630,6 +634,18 @@ case $rule_number: { } break; ./ +UiObjectMember: T_PUBLIC T_DEFAULT T_IDENTIFIER T_IDENTIFIER ; +/. +case $rule_number: { + AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval); + node->isDefaultMember = true; + node->publicToken = loc(1); + node->attributeTypeToken = loc(3); + node->identifierToken = loc(4); + sym(1).Node = node; +} break; +./ + UiObjectMember: T_PUBLIC T_IDENTIFIER T_IDENTIFIER T_COLON Expression ; /. case $rule_number: { @@ -643,6 +659,20 @@ case $rule_number: { } break; ./ +UiObjectMember: T_PUBLIC T_DEFAULT T_IDENTIFIER T_IDENTIFIER T_COLON Expression ; +/. +case $rule_number: { + AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval, + sym(6).Expression); + node->isDefaultMember = true; + node->publicToken = loc(1); + node->attributeTypeToken = loc(3); + node->identifierToken = loc(4); + node->colonToken = loc(5); + sym(1).Node = node; +} break; +./ + UiObjectMember: FunctionDeclaration ; /. case $rule_number: { @@ -2617,6 +2647,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ; yytoken = *tk; yylval = 0; yylloc = token_buffer[0].loc; + yylloc.length = 0; first_token = &token_buffer[0]; last_token = &token_buffer[2]; @@ -2639,6 +2670,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ; yytoken = tk; yylval = 0; yylloc = token_buffer[0].loc; + yylloc.length = 0; action = errorState; goto _Lcheck_token; |