aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser/qqmljskeywords_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Use SPDX license identifiersLucie GĂ©rard2022-06-111-38/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Long live QML inline componentsFabian Kosmale2020-01-231-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | [ChangeLog][QtQml] It is now possible to declare new QML components in a QML file via the component keyword. They can be used just as if they were declared in another file, with the only difference that the type name needs to be prefixed with the name of the containing type outside of the file were the inline component has been declared. Notably, inline components are not closures: In the following example, the output would be 42 // MyItem.qml Item { property int i: 33 component IC: Item { Component.onCompleted: console.log(i) } } // user.qml Item { property int i: 42 MyItem.IC {} } Fixes: QTBUG-79382 Change-Id: I6a5ffc43f093a76323f435cfee9bab217781b8f5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Introduce required properties to QMLFabian Kosmale2019-09-091-0/+12
| | | | | | | | | | | | | | | | | | | [ChangeLog][QtQml] "required" is now a (contextual) keyword in QML, and users can mark properties with it to specify that those properties must be set when the component gets instantiated. This can be done either declaratively via standard property bindings from QML, or imperatively by using the functions to set initial properties (QQmlCompoent::setInitalProperties and related functions in C++, Qt.createObject, Loader.setSource,... in QML/JS). Logic has been added to QQmlComponent::create and the various QQmlIncubator classes to verify that the required properties were set. If properties marked as required are not set, a warning will be printed at runtime, and the component will not be created. Change-Id: I8e38227fc8f173b053b689c1597dc7fd40e835e7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Eliminate QT_QML_BEGIN_NAMESPACE and QT_QML_END_NAMESPACEShawn Rutledge2019-03-221-2/+2
| | | | | | | These are equivalent to the usual namespace macros. Change-Id: I3891397511e29694fe508414e77eb8483b877e03 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix grammar for ES modulesLars Knoll2018-08-021-2/+2
| | | | | | | | | | | | * Always parse 'import' as a keyword, as it is now one in Qml and ES. * Always parse 'as' as keyword but allow it as identifier using the same trick as for the other keywords. This fixes basic import statements such as import "foo.mjs" as bar but still allows funny variations such as import "foo.mjs" as as. Change-Id: I76a600aab90c1b5c07d079bf11b0a78742d44c53 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add some basic support for for-of loopsLars Knoll2018-05-091-1/+4
| | | | | | | | | | | | | 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>
* Support static as a keyword in class definitionsLars Knoll2018-04-251-1/+1
| | | | | | | | | 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>
* Bring JS grammar in line with ES7 specLars Knoll2018-04-251-1/+10
| | | | | | | | | | | | | | | | | | | | | | | 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>
* Add yield as a keywordLars Knoll2018-04-251-54/+65
| | | | | | | | | | | | It's not a keyword outside of generator functions, so extend the qmlmode boolean on the lexer to become a more general parsemode that we can use to also turn the yield keyword on and of. The parser can then set the flag when it enters the body of a generator function. Change-Id: Ibf792d4c7c567d825c6706f7b4997362c87fc575 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for enum declarations in QMLMichael Brasser2017-07-131-1/+1
| | | | | | | | | | | | | | | | | Enums can be declared with the following syntax: enum MyEnum { Value1, Value2 } Grammar changes done by Simon Hausmann. [ChangeLog][QtQml] Enums can now be declared directly in QML. Task-number: QTBUG-14861 Change-Id: Ic6b6e032651d01ee2ecf9d5ce5734976cb3ad7ab Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* parser: Add "let" keyword (& T_LET)Robin Burchell2017-02-031-0/+7
| | | | | | | | | | | We also tie this up to the existing skeletal "const" support so that they are also checked for duplicate declarations. While we do that, change from using a boolean to an enum so we make the scope of a declaration a little more easily comprehensible. Change-Id: I6a6e08aed4e16a53690d6f6bafb55632807b6024 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Codegen: Disallow const declaration without an initializer expressionRobin Burchell2017-02-021-1/+1
| | | | | | | | | | | | | | | | | | | | | This seems to match up with the spec behavior. 13.3.1.1 (Static Semantics: Early Errors) says: It is a Syntax Error if Initializer is not present and IsConstantDeclaration of the LexicalDeclaration containing this production is true. In addition, we also allow "const" to be used in JS mode too. We don't yet fully support the semantics, but as it's there, why not let it work. [ChangeLog][QtQml] "const" variable declarations are now available in JS as well as QML mode. [ChangeLog][QtQml] "const" variable declarations now require an initializer, bringing them closer to the required spec behavior. Task-number: QTBUG-58493 Change-Id: Ife5d5979b3e7a5d7340bf04f43605f847ee25ee2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Updated license headersJani Heikkinen2016-01-191-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: Ic36f1a0a1436fe6ac6eeca8c2375a79857e9cb12 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Remove dead codeFrank Meerkoetter2015-12-191-1/+1
| | | | | | | Fixes coverity CID10615. Change-Id: I46861e4ddcc0347e9ba53da5b94acb813f67ab89 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-121-7/+7
| | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: I61120571787870c0ed17066afb31779b1e6e30e9 Reviewed-by: Iikka Eklund <iikka.eklund@theqtcompany.com>
* Update license headers and add new licensesJani Heikkinen2014-08-251-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I84a565e2e0caa3b76bf291a7d188a57a4b00e1b0 Reviewed-by: Jani Heikkinen <jani.heikkinen@digia.com>
* Add Singleton support for QMLAntti Piira2013-09-211-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces Singleton support for QML (Composite Singleton). For now, the Singleton support is only availabe for QML types in modules or (remote and local) directories with qmldir file. However, in the future this support may be expanded to arbitrary QML file imports without by leaving out the qmldir requirement. You define a QML type as a Singleton with the following two steps: 1. By adding a pragma Singleton to a type's QML file: pragma Singleton The pragma and import statements can be mixed and their order does not matter. Singleton is the only supported pragma for now. Others will generate errors. 2. By specifying a qmldir file for the directory of your imported type and prepending the type with "singleton" keyword as follows: singleton TestTypeSingleton TestTypeSingleton.qml Alternatively you may specify a qmldir file for a module and specify your type as a singleton as follows: singleton TestTypeSingleton 1.0 TestTypeSingleton.qml Composite Singletons may be included in a module and may be used with a local namespace qualifier when imported with: "import xxx as NameSpace" A singleton instance is created at first use and stored into the QmlEngine (one instance per engine) and eventually released by the engine's destructor. CompositeSingletonType has a dual nature and will return true to both isComposite() and isSingleton() calls. In most cases its enough to check for just isComposite() or isSingleton(). However, there is a isCompositeSingleton() available as well. I used "qlalr --no-debug --no-lines --qt qqmljs.g" to generate the qqmljsparser and qqmljsgrammar files from qqmljs.g. Unit tests are included. Change-Id: I91b303612c5e132143b325b9a8f982e9355bc90e Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
* Move the parser folder from src/qml/qml to src/qmlLars Knoll2013-08-081-0/+884
Change-Id: I5e5684f5b98b00f791ade99c4cb6bc2ed880ad6a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>