aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser
Commit message (Collapse)AuthorAgeFilesLines
* Fix const expressions containing destructuring patternsLars Knoll2018-06-211-1/+0
| | | | | | | | Don't throw a syntax error when encountering a destructuring pattern. Change-Id: I93250a2963d2d50ff61d725229e1b51be17689e9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix array destructuring nested in a rest elementLars Knoll2018-06-211-18/+18
| | | | | Change-Id: I3a8c15fe221bff04a3b9b21ed8c0b06c04770a3d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix more issues with destructuringLars Knoll2018-06-212-25/+23
| | | | | | | | | | Fix destructuring targets that are complex lhs expressions. There are still some failures remaining, but this fixes another larger chunk of test cases. Change-Id: Icf08f42d7c70d4e81be5d5d2e27ebe6249d25467 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix handling of elisions in destructuring expressionsLars Knoll2018-06-213-14/+13
| | | | | | | | We need to iterator over elisions at the end, as those could trigger side effects by calling iterator.next() Change-Id: Ieb5fa3562b6e60fdf179fa228510b2eeaaf9da30 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix more test failures for destructuring expressionsLars Knoll2018-06-211-3/+6
| | | | | | | | Fix parsing of var { x = function(){} } = ... Change-Id: I524e39c7a556c392a5359eafc445b59020ccadf2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Correctly set the name of anonymous functions in most casesLars Knoll2018-06-211-0/+6
| | | | | | | | If the anonymous function is bound to an identifier, set the name to the identifier. Change-Id: Idbb3170210e6f91cca3c9bd36b2b6ddcb3a50c7b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Allow a trailing comma in parameter listsLars Knoll2018-06-211-8/+19
| | | | | | | | This got changed in ES8, but let's already take this in now, as there are quite a few tests checking this behavior. Change-Id: I73f86b8fd8a681881bcc9cc3132bef1589d5194f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* The first branch in a ( ? : ) operator can always include the in keywordLars Knoll2018-05-281-1/+1
| | | | | | | Fix the grammar to be compliant with the spec in this case. Change-Id: I5740c9427db6f5c6c2551d4e23f1f14070e497fb Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* Fix multi line string literals using backquotesLars Knoll2018-05-261-1/+1
| | | | | | Task-number: QTBUG-67476 Change-Id: Ia8c6863ad35c8a92298e5dffd750d17628200573 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Unify AST for the different 'for' statementsLars Knoll2018-05-115-46/+5
| | | | | Change-Id: I70ca83b0ce933d64dad4984a236e48592e989742 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Improve for-in and for-of supportLars Knoll2018-05-112-14/+25
| | | | | | | | | | | | Create a Block scope per iteration as defined in the ES spec. So closures created inside the loop will remember the iteration variable at that loop iteration. Add support for destructuring of the left hand side expression or declaration. Change-Id: Id06ef94e2a4b93646827da4f6ce922eb436e5a31 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Unify ForeachStatement and LocalForeachStatement in the ASTLars Knoll2018-05-115-52/+18
| | | | | | | | This saves quite some duplicated code, but requires a bit of care when iterating over the AST. Change-Id: Ic530de4be8b36b4079c9d544b4b77982c3b8be60 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Support destructuring inside catch()Lars Knoll2018-05-113-6/+21
| | | | | Change-Id: Ib60b56ac6a7111446e01235564a4cf92ad8ad025 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add some basic support for for-of loopsLars Knoll2018-05-094-13/+35
| | | | | | | | | | | | | The support is basically at the same level as for for-in at the moment. Currently unimplemented: * Destructuring * Proper lexical scoping * calling iterator.throw()/return() when required Change-Id: If193ce0b054c4315fc16b7e174334a31b2730dcf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add Generator supportLars Knoll2018-05-031-7/+6
| | | | | | | | | | | | | Add support for ES6 generators. Those are currently always executed in the interpreter (we never JIT them), to simplify the initial implementation. Most functionality, except for 'yield *' expressions are supported. 'yield *' will have to wait until we support for(... of ...) Change-Id: I7c059d1e3b301cbcb79e3746b4bec346738fd426 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Cosmetic cleanupLars Knoll2018-05-031-5/+3
| | | | | Change-Id: Idbd34a8c87a52ec78d5680bfab0a75d1430bb0b0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix handling of yield expression in the parserLars Knoll2018-05-031-6/+18
| | | | | | | | | | | | yield is an expression and as such does not have to be followed by a semicolon, so don't require one. This triggered another bug, where we had a conflict between the empty StatementListOpt rule and all other rules that had an ExpressionStatementLookahead (which is also an empty rule). Change-Id: I37a94e534e5b4b6629155ddb4344d6daa2b864ec Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QmlJS: Do not use realloc for QStringRefOrgad Shaneh2018-05-031-3/+2
| | | | | | | | | | | | | | | | It has a non-default copy ctor. This is in fact a false positive, since the copy ctor just explicitly copies all the members... Detected by GCC8. qqmljsparser.cpp: In member function ‘void QmlJS::Parser::reallocateStack()’: qqmljsparser.cpp:68:104: warning: ‘void* realloc(void*, size_t)’ moving an object of non-trivially copyable type ‘class QStringRef’; use ‘new’ and ‘delete’ instead [-Wclass-memaccess] Change-Id: Ica88740006374d83f25e20a3af58de524b552ce9 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix some parse errorsLars Knoll2018-05-031-3/+3
| | | | | | | | The parser was throwing a syntax error on 'function* X() {}' because of a shift-reduce conflict that wasn't properly reported by qlalr. Change-Id: Ifa55a569178e347346d49acd08c702f692e327dd Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Make qqmljs.g accessible in Qt CreatorSimon Hausmann2018-05-021-0/+2
| | | | | | | | Adding the grammar back to OTHER_FILES after it was removed with commit 1ea05eb7755e9e39f79ab982afa5c652f755d3e2. Change-Id: Ic291ac70c6d3ba7b68f4167ff993cdfed2c3ef69 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Correctly set source location when converting BindingPatternsLars Knoll2018-05-022-1/+2
| | | | | Change-Id: I89973ef22fc0eeb67dd3f8219e7b4d6fa02ddaf0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fixup bug in the parser when generating ObjectLiteralsLars Knoll2018-05-021-2/+5
| | | | | Change-Id: I0b7979db7aa6c39ff08b7b6cc08dfa635e97846d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Correctly iterate over the base of a TaggedTemplateLars Knoll2018-05-021-0/+1
| | | | | Change-Id: I2ff1d238998e752c75e9136c1d392b407ea57fec Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix destructuring of arrow function parametersLars Knoll2018-05-023-31/+54
| | | | | Change-Id: I64b49ae77ecd81eafb320cda04a1a7bf4b2dc90c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Properly set names of most anonymous functionsLars Knoll2018-05-023-1/+54
| | | | | | | | In ES6, anonymous functions assigned to a variable/property with a known name, inherit the name of that variable/property. Change-Id: I79479b9358b24d610e3e696eb19fe0ec4aee15d1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Support destructuring assignmentsLars Knoll2018-04-274-25/+234
| | | | | | | | Not everything works yet, but basic destructuring assignments do. Change-Id: I5f74691fd6458092ecfde9d1a8a802f99fc57b9e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for destructuring variable declarationsLars Knoll2018-04-271-1/+0
| | | | | Change-Id: Ia7f894fb61cfa760e253963ab4815d98103cfd9b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Use a PatternElement for VariableDeclarationsLars Knoll2018-04-275-68/+40
| | | | | | | Required to get proper destructuring working. Change-Id: I99fc20a9f1bace1fe3981d88ce5466f9c8d98245 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Rework the AST for Literals and destructuring expressionsLars Knoll2018-04-275-567/+326
| | | | | | | | | | | | | | | | | Array/ObjectLiterals and destructuring expressions are syntactically very similar. In some cases (when using a destructuring expression as the lhs of an assigment), the parser needs to convert the literal into a destructuring expression. To support these, use the same data structures for both in the AST. Those Patterns can be converted with little additional work from a Literal to an AssignmentPattern and be used in all places where we need destructuring in addition to literals. Change-Id: I177599b46eab0f6e8cb2a40c3b3b11ed00a07d6a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Rename Array/ObjectLiteral to Array/ObjectPattern in the ASTLars Knoll2018-04-275-30/+30
| | | | | | | | | | | | To get a consistent representation in the AST, we need to unify the AST that is generated by theObjectLiterals, ObjectBindingPattern and ObjectAssignmentPattern rules in the grammar. Like this we can avoid having to reparse part of the source code, and instead replace this with consistency checks once we know which of the three grammars are supposed to apply. Change-Id: Ib90f521f9595db6bcad446e40de9b912bab3da7c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix a small bug in the grammarLars Knoll2018-04-271-3/+2
| | | | | Change-Id: Idf8ea5263fc4b013f4aafa40fef9bc622c1a5a91 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for 'class' to the ASTLars Knoll2018-04-275-14/+173
| | | | | Change-Id: I2a9e8fb847dfa45ca77ee43e14f39f2b2def5792 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Added support for generator functions and yield expressions to the ASTLars Knoll2018-04-276-10/+136
| | | | | | | | | Some smaller changes to the codegen are included as well to ensure that we catch all uses of generators and properly throw an unimplemented error on them for now. Change-Id: Ib915a0e862e128644ff00dfe989507783c912c66 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* smaller cleanupLars Knoll2018-04-272-8/+8
| | | | | | | | The VariableDeclaration constructor shouldn't specify the scope of the declared variable. Change-Id: I1368cec7c5cb8535e169c0fc20d3be4e69368b47 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for '...' in arguments lists to the ASTLars Knoll2018-04-272-2/+16
| | | | | | | No support in the codegen yet. Change-Id: I9998d7abae086660fc0457c65b6d9050933a428f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for ... in ArrayLiterals to the ASTLars Knoll2018-04-272-1/+21
| | | | | | | The codegen still throws a syntax error for now. Change-Id: I8134b27d6153f6d6df81a9bafc7ae9d573085b73 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Properly mark catch statement with destructuring as unimplementedLars Knoll2018-04-271-0/+2
| | | | | Change-Id: I82cb787f068dbcc1e5410432f462eceaa3273457 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Don't fail on pre increment operator after a newlineLars Knoll2018-04-271-2/+2
| | | | | | | | In some valid cases, the lexer would add an automatic semicolon before the ++/-- operators even if it shouldn't. Change-Id: I2935259fd98a4c7f3f929cc1cecea85f7dde8016 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement support for the ** and **= operatorsLars Knoll2018-04-263-2/+22
| | | | | Change-Id: I58a21e70fdd040175b52465d6ba52e7fceaf6398 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for 'super' and 'new.target' to the ASTLars Knoll2018-04-265-19/+69
| | | | | | | Codegen will still throw a Syntax error on it though. Change-Id: I292dd166ad8cb4a62f2bcfa9637bdc76cf95bb51 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement support for function declarations in object literalsLars Knoll2018-04-261-1/+14
| | | | | | | { foo(args) {} } now works correctly. Change-Id: Ibd271fe957a5259863af793ad74380473690f4ab Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add partial support for computed property namesLars Knoll2018-04-265-3/+47
| | | | | | | | Computed property names currently work in object literals and destructuring arguments. Change-Id: I9dc5bc61b45139ef1836072695ea2fe1ce4994ae Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for shorthand property names in object literalsLars Knoll2018-04-261-1/+12
| | | | | | | "var x = 20; var o = {x}" works now. Change-Id: I8dd64bea0bc6191590592c80883716810052773f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix length property of Function objectsLars Knoll2018-04-261-2/+18
| | | | | | | | | | | According to ES6, the length property is the number of required arguments, ie. the number of arguments until the first arg that has adefault parameter. Also fix a crash when parsing a parameterlist with a trailing comma. Change-Id: I4f6b2be4feae7b513388be66b43b160bb3cc77f1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* More correct iteration over the ASTLars Knoll2018-04-261-1/+7
| | | | | | | Correctly iterate over the content of FormalParameterLists. Change-Id: Ia1c9cb94d161fb0aa5b9dfa347a00499c907e77b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for arrow functionsLars Knoll2018-04-262-18/+133
| | | | | | | | | | | | | Arrow parameter lists are tricky and require some reparsing by the standard to avoid conflicts in the parser with expression statements. Add an IsArrowFunction flag to the CompiledData::Function. This information is required in the runtime, when creating Function objects, as it does influence their behaviour in subtle ways. Change-Id: I298801b091f98e30a9269d3c77d9ff94e519dabc Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Support static as a keyword in class definitionsLars Knoll2018-04-253-6/+34
| | | | | | | | | This requires some interaction between parser and lexer as static is only recognized as a keyword directly in the class declaration. Change-Id: Ib64157ae6ad542706a5eee8ff4ec7f9cb79a62c3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix tokenizer to generate arrow and exponentiation tokensLars Knoll2018-04-251-0/+6
| | | | | Change-Id: Ib228925db9285e61acebc79f881acfbc2de9ff16 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Bring JS grammar in line with ES7 specLars Knoll2018-04-257-2123/+2434
| | | | | | | | | | | | | | | | | | | | | | | This basically updates all grammar rules in the qqmljs.g file to be in line with the ES7 specification. Some special handling for the lookahead rules appearing in the spec was needed and is implemented through empty lookahead rules in the grammar, that might push an additional token into the token stream. Renamed some classes in the AST to be in line with the names used in ES7, and removed some other ones (SourceElements) that are no longer used. The ES7 grammar rules contain lots of variations of the base rules (with In/Return/Yield/Default suffixes). With the exception of the In and Default rules, these are implemented through state tracking in the parser and lexer. Change-Id: I4017d97cd050ed816c1dad11833e882cba30801a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Rename JSIdentifer to IdentifierReferenceLars Knoll2018-04-251-41/+44
| | | | | | | | To bring the naming in line with the naming used in the ES7 grammar specification. Change-Id: Ie996bba5fb7d08e0790a8e55d3de62961a7257a8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>