mirror of https://github.com/Wilfred/difftastic/
Unvendor tree-sitter-qmljs
parent
160e184933
commit
ef5cd765ef
@ -1 +0,0 @@
|
|||||||
../tree-sitter-qmljs/queries/highlights.scm
|
|
||||||
@ -1 +0,0 @@
|
|||||||
tree-sitter-qmljs/src
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
name: CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ dev ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ dev ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
fail-fast: true
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-node@v2
|
|
||||||
with:
|
|
||||||
node-version: '14'
|
|
||||||
- name: Install dependencies (gyp would fail)
|
|
||||||
run: npm install || true
|
|
||||||
- name: Generate parser sources
|
|
||||||
run: make generate
|
|
||||||
- name: Install dependencies (again to run gyp rebuild)
|
|
||||||
run: npm install
|
|
||||||
- name: Run tests
|
|
||||||
run: npm test
|
|
||||||
- name: Run cargo tests
|
|
||||||
run: cargo test
|
|
||||||
- name: Parse examples
|
|
||||||
run: make fetch-examples parse-examples
|
|
||||||
@ -1,38 +0,0 @@
|
|||||||
name: Package
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ master ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test-regenerate:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
fail-fast: true
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-node@v2
|
|
||||||
with:
|
|
||||||
node-version: '14'
|
|
||||||
- name: Install dependencies
|
|
||||||
run: npm install
|
|
||||||
- name: Regenerate parser sources
|
|
||||||
run: make generate
|
|
||||||
- name: Verify generated sources
|
|
||||||
run: git diff --exit-code
|
|
||||||
|
|
||||||
test-without-regenerate:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
fail-fast: true
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-node@v2
|
|
||||||
with:
|
|
||||||
node-version: '14'
|
|
||||||
- name: Install dependencies
|
|
||||||
run: npm install
|
|
||||||
- name: Run tests
|
|
||||||
run: npm test
|
|
||||||
- name: Run cargo tests
|
|
||||||
run: cargo test
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
#*#
|
|
||||||
*.orig
|
|
||||||
*~
|
|
||||||
.#*
|
|
||||||
\#*#
|
|
||||||
|
|
||||||
/Cargo.lock
|
|
||||||
/build/
|
|
||||||
/examples/qtdeclarative
|
|
||||||
/node_modules/
|
|
||||||
/package-lock.json
|
|
||||||
/target/
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "tree-sitter-qmljs"
|
|
||||||
description = "QML grammar for the tree-sitter parsing library"
|
|
||||||
version = "0.1.2"
|
|
||||||
keywords = ["incremental", "parsing", "qml"]
|
|
||||||
categories = ["parsing", "text-editors"]
|
|
||||||
repository = "https://github.com/yuja/tree-sitter-qmljs"
|
|
||||||
edition = "2021"
|
|
||||||
license = "MIT"
|
|
||||||
|
|
||||||
build = "bindings/rust/build.rs"
|
|
||||||
include = [
|
|
||||||
"bindings/rust/*",
|
|
||||||
"grammar.js",
|
|
||||||
"queries/*",
|
|
||||||
"src/*",
|
|
||||||
]
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
path = "bindings/rust/lib.rs"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
tree-sitter = "~0.20"
|
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
cc = "1.0"
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
Copyright (c) 2021 Yuya Nishihara
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
a copy of this software and associated documentation files (the
|
|
||||||
"Software"), to deal in the Software without restriction, including
|
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
||||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
@ -1,64 +0,0 @@
|
|||||||
JQ = jq
|
|
||||||
TREE_SITTER = node_modules/.bin/tree-sitter
|
|
||||||
|
|
||||||
.PHONY: help
|
|
||||||
help:
|
|
||||||
@echo 'Make targets:'
|
|
||||||
@echo ' generate - generate parser sources'
|
|
||||||
@echo ' clean - remove build directory and intermediate files'
|
|
||||||
@echo ' tests - run all tests'
|
|
||||||
@echo ' fetch-examples - fetch example repositories'
|
|
||||||
@echo ' parse-examples - parse example files'
|
|
||||||
|
|
||||||
.PHONY: generate
|
|
||||||
generate:
|
|
||||||
$(MAKE) queries/highlights-javascript.scm queries/highlights-typescript.scm
|
|
||||||
$(MAKE) src/typescript-scanner.h
|
|
||||||
$(TREE_SITTER) generate
|
|
||||||
|
|
||||||
# create symlinks out of sub packages so cargo can pick them up
|
|
||||||
queries/highlights-javascript.scm: node_modules/tree-sitter-javascript/queries/highlights.scm
|
|
||||||
ln -sf ../$< $@
|
|
||||||
queries/highlights-typescript.scm: node_modules/tree-sitter-typescript/queries/highlights.scm
|
|
||||||
ln -sf ../$< $@
|
|
||||||
|
|
||||||
src/typescript-scanner.h: \
|
|
||||||
node_modules/tree-sitter-typescript/common/scanner.h \
|
|
||||||
node_modules/tree-sitter-typescript/LICENSE \
|
|
||||||
package.json
|
|
||||||
( \
|
|
||||||
echo '/*'; \
|
|
||||||
echo 'Source:'; \
|
|
||||||
$(JQ) -r '.devDependencies["tree-sitter-typescript"]' package.json; \
|
|
||||||
echo; \
|
|
||||||
cat node_modules/tree-sitter-typescript/LICENSE; \
|
|
||||||
echo '*/'; \
|
|
||||||
echo; \
|
|
||||||
cat $<; \
|
|
||||||
) > $@
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
|
||||||
$(RM) -R build target
|
|
||||||
$(RM) \
|
|
||||||
queries/highlights-javascript.scm \
|
|
||||||
queries/highlights-typescript.scm \
|
|
||||||
src/grammar.json \
|
|
||||||
src/node-types.json \
|
|
||||||
src/parser.c \
|
|
||||||
src/tree_sitter/parser.h \
|
|
||||||
src/typescript-scanner.h
|
|
||||||
|
|
||||||
.PHONY: tests
|
|
||||||
tests:
|
|
||||||
$(TREE_SITTER) test $(TESTFLAGS)
|
|
||||||
|
|
||||||
.PHONY: fetch-examples
|
|
||||||
fetch-examples:
|
|
||||||
$(MAKE) -C examples all
|
|
||||||
|
|
||||||
.PHONY: parse-examples
|
|
||||||
parse-examples:
|
|
||||||
cat examples/known-failures.txt \
|
|
||||||
| sed 's|^|!examples/|' \
|
|
||||||
| xargs $(TREE_SITTER) parse -q 'examples/**/*.qml'
|
|
||||||
@ -1,59 +0,0 @@
|
|||||||
tree-sitter-qmljs
|
|
||||||
=================
|
|
||||||
|
|
||||||
[QML][] grammar for the [tree-sitter][] parsing library.
|
|
||||||
|
|
||||||
[QML]: https://doc.qt.io/qt-6/qmlapplications.html
|
|
||||||
[tree-sitter]: https://github.com/tree-sitter/tree-sitter
|
|
||||||
|
|
||||||
References
|
|
||||||
----------
|
|
||||||
|
|
||||||
* https://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/qml/parser/qqmljs.g
|
|
||||||
|
|
||||||
Pitfalls
|
|
||||||
--------
|
|
||||||
|
|
||||||
Since grouped binding notation is syntactically ambiguous, it is parsed as
|
|
||||||
an object definition.
|
|
||||||
|
|
||||||
```qml
|
|
||||||
// (ui_object_definition type_name: (identifier "Button") ...)
|
|
||||||
Button {
|
|
||||||
// (ui_object_definition type_name: (identifier "icon") ...)
|
|
||||||
icon { source: "foo.png"; color: "transparent" }
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Building
|
|
||||||
--------
|
|
||||||
|
|
||||||
Use the `master` branch, which contains all generated files.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ git checkout master
|
|
||||||
$ npm install
|
|
||||||
$ cargo build --release
|
|
||||||
```
|
|
||||||
|
|
||||||
Hacking
|
|
||||||
-------
|
|
||||||
|
|
||||||
Use the `dev` branch, but you'll first need to run `npm install` in the
|
|
||||||
`master` branch.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ git checkout master
|
|
||||||
$ npm install
|
|
||||||
$ git checkout dev
|
|
||||||
```
|
|
||||||
|
|
||||||
Generate code and run tests:
|
|
||||||
```
|
|
||||||
$ make generate tests
|
|
||||||
```
|
|
||||||
|
|
||||||
Make sure example QML files can be parsed:
|
|
||||||
```
|
|
||||||
$ make fetch-examples parse-examples
|
|
||||||
```
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"targets": [
|
|
||||||
{
|
|
||||||
"target_name": "tree_sitter_qmljs_binding",
|
|
||||||
"include_dirs": [
|
|
||||||
"<!(node -e \"require('nan')\")",
|
|
||||||
"src"
|
|
||||||
],
|
|
||||||
"sources": [
|
|
||||||
"bindings/node/binding.cc",
|
|
||||||
"src/parser.c",
|
|
||||||
"src/scanner.c",
|
|
||||||
],
|
|
||||||
"cflags_c": [
|
|
||||||
"-std=c99",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
#include "tree_sitter/parser.h"
|
|
||||||
#include <node.h>
|
|
||||||
#include "nan.h"
|
|
||||||
|
|
||||||
using namespace v8;
|
|
||||||
|
|
||||||
extern "C" TSLanguage * tree_sitter_qmljs();
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
NAN_METHOD(New) {}
|
|
||||||
|
|
||||||
void Init(Local<Object> exports, Local<Object> module) {
|
|
||||||
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
|
|
||||||
tpl->SetClassName(Nan::New("Language").ToLocalChecked());
|
|
||||||
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
|
||||||
|
|
||||||
Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked();
|
|
||||||
Local<Object> instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked();
|
|
||||||
Nan::SetInternalFieldPointer(instance, 0, tree_sitter_qmljs());
|
|
||||||
|
|
||||||
Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("qmljs").ToLocalChecked());
|
|
||||||
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
NODE_MODULE(tree_sitter_qmljs_binding, Init)
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
try {
|
|
||||||
module.exports = require("../../build/Release/tree_sitter_qmljs_binding");
|
|
||||||
} catch (error1) {
|
|
||||||
if (error1.code !== 'MODULE_NOT_FOUND') {
|
|
||||||
throw error1;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
module.exports = require("../../build/Debug/tree_sitter_qmljs_binding");
|
|
||||||
} catch (error2) {
|
|
||||||
if (error2.code !== 'MODULE_NOT_FOUND') {
|
|
||||||
throw error2;
|
|
||||||
}
|
|
||||||
throw error1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
module.exports.nodeTypeInfo = require("../../src/node-types.json");
|
|
||||||
} catch (_) {}
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
fn main() {
|
|
||||||
let src_dir = std::path::Path::new("src");
|
|
||||||
|
|
||||||
let mut c_config = cc::Build::new();
|
|
||||||
c_config.include(&src_dir);
|
|
||||||
c_config
|
|
||||||
.flag_if_supported("-Wno-unused-parameter")
|
|
||||||
.flag_if_supported("-Wno-unused-but-set-variable")
|
|
||||||
.flag_if_supported("-Wno-trigraphs");
|
|
||||||
|
|
||||||
let parser_path = src_dir.join("parser.c");
|
|
||||||
c_config.file(&parser_path);
|
|
||||||
println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap());
|
|
||||||
|
|
||||||
let scanner_path = src_dir.join("scanner.c");
|
|
||||||
c_config.file(&scanner_path);
|
|
||||||
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
|
|
||||||
println!(
|
|
||||||
"cargo:rerun-if-changed={}",
|
|
||||||
src_dir.join("typescript-scanner.h").to_str().unwrap()
|
|
||||||
);
|
|
||||||
|
|
||||||
c_config.compile("parser-scanner");
|
|
||||||
}
|
|
||||||
@ -1,56 +0,0 @@
|
|||||||
//! This crate provides QML language support for the [tree-sitter][] parsing library.
|
|
||||||
//!
|
|
||||||
//! Typically, you will use the [language][language func] function to add this language to a
|
|
||||||
//! tree-sitter [Parser][], and then use the parser to parse some code:
|
|
||||||
//!
|
|
||||||
//! ```
|
|
||||||
//! let code = "";
|
|
||||||
//! let mut parser = tree_sitter::Parser::new();
|
|
||||||
//! parser.set_language(tree_sitter_qmljs::language()).expect("Error loading QML grammar");
|
|
||||||
//! let tree = parser.parse(code, None).unwrap();
|
|
||||||
//! ```
|
|
||||||
//!
|
|
||||||
//! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
|
|
||||||
//! [language func]: fn.language.html
|
|
||||||
//! [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html
|
|
||||||
//! [tree-sitter]: https://tree-sitter.github.io/
|
|
||||||
|
|
||||||
use tree_sitter::Language;
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
fn tree_sitter_qmljs() -> Language;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the tree-sitter [Language][] for this grammar.
|
|
||||||
///
|
|
||||||
/// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
|
|
||||||
pub fn language() -> Language {
|
|
||||||
unsafe { tree_sitter_qmljs() }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The content of the [`node-types.json`][] file for this grammar.
|
|
||||||
///
|
|
||||||
/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
|
|
||||||
pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json");
|
|
||||||
|
|
||||||
// Uncomment these to include any queries that this grammar contains
|
|
||||||
|
|
||||||
pub const HIGHLIGHTS_QUERY: &'static str = concat!(
|
|
||||||
include_str!("../../queries/highlights.scm"),
|
|
||||||
include_str!("../../queries/highlights-typescript.scm"),
|
|
||||||
include_str!("../../queries/highlights-javascript.scm"),
|
|
||||||
);
|
|
||||||
// pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
|
|
||||||
pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
|
|
||||||
// pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm");
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
#[test]
|
|
||||||
fn test_can_load_grammar() {
|
|
||||||
let mut parser = tree_sitter::Parser::new();
|
|
||||||
parser
|
|
||||||
.set_language(super::language())
|
|
||||||
.expect("Error loading QML language");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
GIT = git
|
|
||||||
GIT_LOG_FLAGS = -p --reverse
|
|
||||||
QTDECLARATIVE_GIT_ID = 49ec094b7fb1eb6675fdc1db8348409cd3ff8184
|
|
||||||
|
|
||||||
.PHONY: all
|
|
||||||
all: qtdeclarative
|
|
||||||
|
|
||||||
.PHONY: qtdeclarative
|
|
||||||
qtdeclarative:
|
|
||||||
[ -d $@ ] || $(GIT) clone git://code.qt.io/qt/qtdeclarative.git $@
|
|
||||||
$(GIT) -C $@ fetch
|
|
||||||
$(GIT) -C $@ reset --hard $(QTDECLARATIVE_GIT_ID)
|
|
||||||
|
|
||||||
.PHONY: review-qtdeclarative
|
|
||||||
review-qtdeclarative:
|
|
||||||
$(GIT) -C qtdeclarative log $(GIT_LOG_FLAGS) \
|
|
||||||
$(QTDECLARATIVE_GIT_ID)..origin/dev \
|
|
||||||
src/qml/compiler/qqmlirbuilder.cpp \
|
|
||||||
src/qml/parser
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
qtdeclarative/src/quick/doc/snippets/qml/image-ext.qml
|
|
||||||
qtdeclarative/tests/auto/qml/debugger/qqmlpreview/data/broken.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qmlformat/data/settings/Example1.formatted_mac_cr.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qmllint/data/failure1.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qqmlecmascript/data/numberParsing_error.1.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qqmlecmascript/data/numberParsing_error.2.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qqmlecmascript/data/stringParsing_error.5.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qqmlecmascript/data/stringParsing_error.6.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qqmllanguage/data/empty.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qqmllanguage/data/fuzzed.2.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qqmllanguage/data/fuzzed.3.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qqmllanguage/data/hangOnWarning.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.1.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qqmllanguage/data/invalidQmlEnumValue.2.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qqmllanguage/data/invalidRoot.1.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qqmllanguage/data/missingObject.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qqmllanguage/data/property.2.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qqmllanguage/data/property.3.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qqmllanguage/data/questionDotEOF.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qqmllanguage/data/signal.2.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qqmllanguage/data/signal.3.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qqmllanguage/data/signal.5.qml
|
|
||||||
qtdeclarative/tests/auto/qml/qquickfolderlistmodel/data/dummy.qml
|
|
||||||
qtdeclarative/tests/auto/qmlls/utils/data/completions/missingRHS.parserfail.qml
|
|
||||||
qtdeclarative/tests/auto/qmlls/utils/data/completions/missingRHS.qml
|
|
||||||
qtdeclarative/tests/auto/qmlls/utils/data/emptyFile.qml
|
|
||||||
qtdeclarative/tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml
|
|
||||||
qtdeclarative/tests/auto/quickcontrols/controls/data/tst_scrollbar.qml
|
|
||||||
qtdeclarative/tests/manual/qmllsformatter/test.qml
|
|
||||||
@ -1,375 +0,0 @@
|
|||||||
// Implemented based on
|
|
||||||
// https://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/qml/
|
|
||||||
// compiler/qqmlirbuilder.cpp
|
|
||||||
// parser/{qqmljs.g,qqmljsast_p.h,qqmljslexer.cpp}
|
|
||||||
// 49ec094b7fb1eb6675fdc1db8348409cd3ff8184
|
|
||||||
|
|
||||||
module.exports = grammar(require('tree-sitter-typescript/typescript/grammar'), {
|
|
||||||
name: 'qmljs',
|
|
||||||
|
|
||||||
supertypes: ($, original) => original.concat([
|
|
||||||
$._ui_object_member,
|
|
||||||
$._ui_script_statement,
|
|
||||||
]),
|
|
||||||
|
|
||||||
inline: ($, original) => original.concat([
|
|
||||||
$._ui_root_member,
|
|
||||||
$._ui_object_member,
|
|
||||||
$._ui_property_type,
|
|
||||||
$._ui_binding_value,
|
|
||||||
$._ui_property_value,
|
|
||||||
$._ui_script_statement,
|
|
||||||
$._ui_qualified_id,
|
|
||||||
$._ui_identifier,
|
|
||||||
$._ui_simple_qualified_id,
|
|
||||||
$._ui_reserved_identifier,
|
|
||||||
]),
|
|
||||||
|
|
||||||
conflicts: ($, original) => original.concat([
|
|
||||||
[$.ui_property_modifier, $.ui_required], // required property name vs required property
|
|
||||||
[$.ui_nested_identifier, $.primary_expression], // Nested.Obj {} vs member.expr
|
|
||||||
]),
|
|
||||||
|
|
||||||
rules: {
|
|
||||||
// should be 'ui_program' per naming convention, but we need to override the
|
|
||||||
// start rule of the javascript/typescript grammar.
|
|
||||||
program: $ => seq(
|
|
||||||
optional($.hash_bang_line),
|
|
||||||
repeat(choice(
|
|
||||||
$.ui_pragma,
|
|
||||||
$.ui_import,
|
|
||||||
)),
|
|
||||||
field('root', $._ui_root_member),
|
|
||||||
),
|
|
||||||
|
|
||||||
ui_pragma: $ => seq(
|
|
||||||
'pragma',
|
|
||||||
field('name', $.identifier), // PragmaId
|
|
||||||
optional(seq(
|
|
||||||
':',
|
|
||||||
// TODO: or insert 'values': (ui_pragma_value_list ..)?
|
|
||||||
sep1(field('value', choice($.identifier, $.string)), ','),
|
|
||||||
)),
|
|
||||||
$._semicolon,
|
|
||||||
),
|
|
||||||
|
|
||||||
ui_import: $ => seq(
|
|
||||||
'import',
|
|
||||||
field('source', choice(
|
|
||||||
$.string,
|
|
||||||
$._ui_qualified_id,
|
|
||||||
)), // ImportId: MemberExpression
|
|
||||||
optional(field('version', $.ui_version_specifier)),
|
|
||||||
optional(seq(
|
|
||||||
'as',
|
|
||||||
field('alias', $.identifier), // QmlIdentifier
|
|
||||||
)),
|
|
||||||
$._semicolon,
|
|
||||||
),
|
|
||||||
|
|
||||||
ui_version_specifier: $ => {
|
|
||||||
const version_number = alias(/\d+/, $.number);
|
|
||||||
return choice(
|
|
||||||
field('major', version_number),
|
|
||||||
seq(
|
|
||||||
field('major', version_number),
|
|
||||||
'.',
|
|
||||||
field('minor', version_number),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
_ui_root_member: $ => choice(
|
|
||||||
$.ui_object_definition,
|
|
||||||
$.ui_annotated_object,
|
|
||||||
),
|
|
||||||
|
|
||||||
ui_object_definition: $ => seq(
|
|
||||||
field('type_name', $._ui_qualified_id),
|
|
||||||
field('initializer', $.ui_object_initializer),
|
|
||||||
),
|
|
||||||
|
|
||||||
ui_annotated_object: $ => seq(
|
|
||||||
repeat1(field('annotation', $.ui_annotation)),
|
|
||||||
field('definition', $.ui_object_definition),
|
|
||||||
),
|
|
||||||
|
|
||||||
ui_annotation: $ => seq(
|
|
||||||
'@',
|
|
||||||
field('type_name', $._ui_simple_qualified_id),
|
|
||||||
field('initializer', $.ui_object_initializer),
|
|
||||||
),
|
|
||||||
|
|
||||||
ui_object_initializer: $ => seq(
|
|
||||||
'{',
|
|
||||||
repeat(choice(
|
|
||||||
$._ui_object_member,
|
|
||||||
$.ui_annotated_object_member,
|
|
||||||
)),
|
|
||||||
'}',
|
|
||||||
),
|
|
||||||
|
|
||||||
ui_annotated_object_member: $ => seq(
|
|
||||||
repeat1(field('annotation', $.ui_annotation)),
|
|
||||||
field('definition', $._ui_object_member),
|
|
||||||
),
|
|
||||||
|
|
||||||
_ui_object_member: $ => choice(
|
|
||||||
$.ui_object_definition,
|
|
||||||
$.ui_object_definition_binding,
|
|
||||||
$.ui_binding,
|
|
||||||
$.ui_property,
|
|
||||||
$.ui_required,
|
|
||||||
$.ui_signal,
|
|
||||||
$.ui_inline_component,
|
|
||||||
$.generator_function_declaration,
|
|
||||||
$.function_declaration,
|
|
||||||
$.variable_declaration,
|
|
||||||
alias($._qml_enum_declaration, $.enum_declaration),
|
|
||||||
),
|
|
||||||
|
|
||||||
ui_object_definition_binding: $ => seq(
|
|
||||||
field('type_name', $._ui_qualified_id),
|
|
||||||
'on',
|
|
||||||
field('name', $._ui_qualified_id),
|
|
||||||
field('initializer', $.ui_object_initializer),
|
|
||||||
),
|
|
||||||
|
|
||||||
ui_binding: $ => seq(
|
|
||||||
field('name', $._ui_qualified_id),
|
|
||||||
':',
|
|
||||||
field('value', $._ui_binding_value),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Duplicated modifiers are rejected by qqmljs.g, but we don't check for that.
|
|
||||||
ui_property: $ => seq(
|
|
||||||
repeat($.ui_property_modifier),
|
|
||||||
'property',
|
|
||||||
field('type', choice(
|
|
||||||
$._ui_property_type,
|
|
||||||
$.ui_list_property_type,
|
|
||||||
)),
|
|
||||||
field('name', $._ui_identifier), // QmlIdentifier
|
|
||||||
choice(
|
|
||||||
seq(
|
|
||||||
':',
|
|
||||||
field('value', $._ui_property_value),
|
|
||||||
),
|
|
||||||
$._semicolon,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
_ui_property_type: $ => choice(
|
|
||||||
$._type_identifier,
|
|
||||||
$.nested_type_identifier,
|
|
||||||
),
|
|
||||||
|
|
||||||
// "T_IDENTIFIER T_LT UiPropertyType T_GT", but only "list" is allowed as
|
|
||||||
// a property type modifier.
|
|
||||||
ui_list_property_type: $ => seq(
|
|
||||||
alias('list', $.type_identifier),
|
|
||||||
'<',
|
|
||||||
$._ui_property_type,
|
|
||||||
'>',
|
|
||||||
),
|
|
||||||
|
|
||||||
ui_property_modifier: $ => choice(
|
|
||||||
'default',
|
|
||||||
'readonly',
|
|
||||||
'required',
|
|
||||||
),
|
|
||||||
|
|
||||||
_ui_binding_value: $ => choice(
|
|
||||||
$.ui_object_array,
|
|
||||||
$.ui_object_definition,
|
|
||||||
$._ui_script_statement,
|
|
||||||
),
|
|
||||||
|
|
||||||
// similar to $._ui_binding_value, but optional semicolon is also allowed
|
|
||||||
// for array/object.
|
|
||||||
_ui_property_value: $=> choice(
|
|
||||||
seq($.ui_object_array, $._semicolon), // UiObjectMemberWithArray
|
|
||||||
seq($.ui_object_definition, $._semicolon), // UiObjectMemberExpressionStatementLookahead
|
|
||||||
$._ui_script_statement,
|
|
||||||
),
|
|
||||||
|
|
||||||
ui_object_array: $ => seq(
|
|
||||||
'[',
|
|
||||||
sep1($.ui_object_definition, ','), // UiArrayMemberList
|
|
||||||
']',
|
|
||||||
),
|
|
||||||
|
|
||||||
_ui_script_statement: $ => choice(
|
|
||||||
$.statement_block,
|
|
||||||
$.empty_statement,
|
|
||||||
$.expression_statement,
|
|
||||||
$.if_statement,
|
|
||||||
$.with_statement,
|
|
||||||
$.switch_statement,
|
|
||||||
$.try_statement,
|
|
||||||
),
|
|
||||||
|
|
||||||
ui_required: $ => seq(
|
|
||||||
'required',
|
|
||||||
field('name', $._ui_identifier), // QmlIdentifier
|
|
||||||
$._semicolon,
|
|
||||||
),
|
|
||||||
|
|
||||||
ui_signal: $ => seq(
|
|
||||||
'signal',
|
|
||||||
field('name', $.identifier),
|
|
||||||
optional(field('parameters', $.ui_signal_parameters)),
|
|
||||||
$._semicolon,
|
|
||||||
),
|
|
||||||
|
|
||||||
ui_signal_parameters: $ => seq(
|
|
||||||
'(',
|
|
||||||
sep($.ui_signal_parameter, ','),
|
|
||||||
')',
|
|
||||||
),
|
|
||||||
|
|
||||||
ui_signal_parameter: $ => choice(
|
|
||||||
seq(
|
|
||||||
field('name', $.identifier), // QmlIdentifier
|
|
||||||
':',
|
|
||||||
field('type', $._ui_property_type),
|
|
||||||
),
|
|
||||||
seq(
|
|
||||||
field('type', $._ui_property_type),
|
|
||||||
field('name', $.identifier), // QmlIdentifier
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
ui_inline_component: $ => seq(
|
|
||||||
'component',
|
|
||||||
field('name', $.identifier),
|
|
||||||
':',
|
|
||||||
field('component', $.ui_object_definition),
|
|
||||||
),
|
|
||||||
|
|
||||||
// QML enum can be considered a restricted form of the TypeScript enum.
|
|
||||||
_qml_enum_declaration: $ => seq(
|
|
||||||
'enum',
|
|
||||||
field('name', $.identifier),
|
|
||||||
field('body', alias($._qml_enum_body, $.enum_body)),
|
|
||||||
),
|
|
||||||
|
|
||||||
_qml_enum_body: $ => seq(
|
|
||||||
'{',
|
|
||||||
sep1(choice(
|
|
||||||
field('name', $.identifier),
|
|
||||||
alias($._qml_enum_assignment, $.enum_assignment),
|
|
||||||
), ','),
|
|
||||||
'}',
|
|
||||||
),
|
|
||||||
|
|
||||||
_qml_enum_assignment: $ => seq(
|
|
||||||
field('name', $.identifier),
|
|
||||||
'=',
|
|
||||||
field('value', choice(
|
|
||||||
$.number,
|
|
||||||
alias($._qml_enum_negative_number, $.unary_expression),
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
|
|
||||||
_qml_enum_negative_number: $ => seq(
|
|
||||||
field('operator', '-'), // '+' is not allowed
|
|
||||||
field('argument', $.number),
|
|
||||||
),
|
|
||||||
|
|
||||||
// MemberExpression -> reparseAsQualifiedId()
|
|
||||||
_ui_qualified_id: $ => choice(
|
|
||||||
$._ui_identifier,
|
|
||||||
alias($.ui_nested_identifier, $.nested_identifier),
|
|
||||||
),
|
|
||||||
|
|
||||||
_ui_identifier: $ => choice(
|
|
||||||
$.identifier,
|
|
||||||
alias($._ui_reserved_identifier, $.identifier),
|
|
||||||
),
|
|
||||||
|
|
||||||
ui_nested_identifier: $ => seq(
|
|
||||||
$._ui_qualified_id,
|
|
||||||
'.',
|
|
||||||
$.identifier,
|
|
||||||
),
|
|
||||||
|
|
||||||
_ui_simple_qualified_id: $ => choice(
|
|
||||||
$.identifier,
|
|
||||||
alias($.ui_simple_nested_identifier, $.nested_identifier),
|
|
||||||
),
|
|
||||||
|
|
||||||
ui_simple_nested_identifier: $ => seq(
|
|
||||||
$._ui_simple_qualified_id,
|
|
||||||
'.',
|
|
||||||
$.identifier,
|
|
||||||
),
|
|
||||||
|
|
||||||
// teach JavaScript/TypeScript grammar about QML keywords.
|
|
||||||
_reserved_identifier: ($, original) => choice(
|
|
||||||
original,
|
|
||||||
'property',
|
|
||||||
'signal',
|
|
||||||
'readonly',
|
|
||||||
'on',
|
|
||||||
'required',
|
|
||||||
'component',
|
|
||||||
// not QML keywords, but qmljs.g accepts them as JS expressions:
|
|
||||||
'from',
|
|
||||||
'of',
|
|
||||||
),
|
|
||||||
|
|
||||||
_ui_reserved_identifier: $ => choice(
|
|
||||||
// JavaScript:
|
|
||||||
'get',
|
|
||||||
'set',
|
|
||||||
'async',
|
|
||||||
'static',
|
|
||||||
'export',
|
|
||||||
'let',
|
|
||||||
|
|
||||||
// TypeScript:
|
|
||||||
'declare',
|
|
||||||
'namespace',
|
|
||||||
'type',
|
|
||||||
'public',
|
|
||||||
'private',
|
|
||||||
'protected',
|
|
||||||
'override',
|
|
||||||
'readonly',
|
|
||||||
'module',
|
|
||||||
'any',
|
|
||||||
'number',
|
|
||||||
'boolean',
|
|
||||||
'string',
|
|
||||||
'symbol',
|
|
||||||
'export',
|
|
||||||
'object',
|
|
||||||
// 'new', ('new {}' would conflict at property value position)
|
|
||||||
'readonly',
|
|
||||||
|
|
||||||
// QML (see QmlIdentifier):
|
|
||||||
'property',
|
|
||||||
'signal',
|
|
||||||
'readonly',
|
|
||||||
'on',
|
|
||||||
'from',
|
|
||||||
'of',
|
|
||||||
'required',
|
|
||||||
'component',
|
|
||||||
),
|
|
||||||
|
|
||||||
// Patch up JavaScript string rules to support multi-line string literal.
|
|
||||||
// (See also the change b16c69a70be9 in tree-sitter-javascript.)
|
|
||||||
unescaped_double_string_fragment: _ => token.immediate(prec(1, /[^"\\]+/)),
|
|
||||||
unescaped_single_string_fragment: _ => token.immediate(prec(1, /[^'\\]+/)),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
function sep(rule, sep) {
|
|
||||||
return optional(sep1(rule, sep));
|
|
||||||
}
|
|
||||||
|
|
||||||
function sep1(rule, sep) {
|
|
||||||
return seq(rule, repeat(seq(sep, rule)));
|
|
||||||
}
|
|
||||||
@ -1,54 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "tree-sitter-qmljs",
|
|
||||||
"version": "0.1.2",
|
|
||||||
"description": "QML grammar for the tree-sitter parsing library",
|
|
||||||
"main": "bindings/node",
|
|
||||||
"scripts": {
|
|
||||||
"test": "tree-sitter test"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/yuja/tree-sitter-qmljs.git"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"parser",
|
|
||||||
"tree-sitter",
|
|
||||||
"qml"
|
|
||||||
],
|
|
||||||
"author": "Yuya Nishihara",
|
|
||||||
"license": "MIT",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/yuja/tree-sitter-qmljs/issues"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/yuja/tree-sitter-qmljs#readme",
|
|
||||||
"dependencies": {
|
|
||||||
"nan": "^2.15.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"tree-sitter-cli": "^0.20.1",
|
|
||||||
"tree-sitter-javascript": "0.20.3",
|
|
||||||
"tree-sitter-typescript": "0.20.5"
|
|
||||||
},
|
|
||||||
"tree-sitter": [
|
|
||||||
{
|
|
||||||
"scope": "source.qml",
|
|
||||||
"file-types": [
|
|
||||||
"qml"
|
|
||||||
],
|
|
||||||
"highlights": [
|
|
||||||
"queries/highlights.scm",
|
|
||||||
"node_modules/tree-sitter-typescript/queries/highlights.scm",
|
|
||||||
"node_modules/tree-sitter-javascript/queries/highlights.scm"
|
|
||||||
],
|
|
||||||
"locals": [
|
|
||||||
"queries/locals.scm",
|
|
||||||
"node_modules/tree-sitter-typescript/queries/locals.scm",
|
|
||||||
"node_modules/tree-sitter-javascript/queries/locals.scm"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"node_modules/tree-sitter-typescript/queries/tags.scm",
|
|
||||||
"node_modules/tree-sitter-javascript/queries/tags.scm"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
../node_modules/tree-sitter-javascript/queries/highlights.scm
|
|
||||||
@ -1 +0,0 @@
|
|||||||
../node_modules/tree-sitter-typescript/queries/highlights.scm
|
|
||||||
@ -1,60 +0,0 @@
|
|||||||
;;; Annotations
|
|
||||||
|
|
||||||
(ui_annotation
|
|
||||||
"@" @operator
|
|
||||||
type_name: [
|
|
||||||
(identifier) @attribute
|
|
||||||
(nested_identifier (identifier) @attribute)
|
|
||||||
])
|
|
||||||
|
|
||||||
;;; Properties
|
|
||||||
|
|
||||||
(ui_object_definition_binding
|
|
||||||
name: [
|
|
||||||
(identifier) @property
|
|
||||||
(nested_identifier (identifier) @property)
|
|
||||||
])
|
|
||||||
|
|
||||||
(ui_binding
|
|
||||||
name: [
|
|
||||||
(identifier) @property
|
|
||||||
(nested_identifier (identifier) @property)
|
|
||||||
])
|
|
||||||
|
|
||||||
;; locals query appears not working unless id: <ref> isn't a parameter.
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier) @property
|
|
||||||
(#eq? @property "id")
|
|
||||||
value: (expression_statement (identifier) @variable.parameter))
|
|
||||||
|
|
||||||
(ui_property
|
|
||||||
name: (identifier) @property)
|
|
||||||
|
|
||||||
(ui_required
|
|
||||||
name: (identifier) @property)
|
|
||||||
|
|
||||||
(ui_list_property_type
|
|
||||||
["<" ">"] @punctuation.bracket)
|
|
||||||
|
|
||||||
;;; Signals
|
|
||||||
|
|
||||||
(ui_signal
|
|
||||||
name: (identifier) @function.signal)
|
|
||||||
|
|
||||||
(ui_signal_parameter
|
|
||||||
(identifier) @variable.parameter)
|
|
||||||
|
|
||||||
;;; Keywords
|
|
||||||
|
|
||||||
[
|
|
||||||
"as"
|
|
||||||
"component"
|
|
||||||
"default"
|
|
||||||
"import"
|
|
||||||
"on"
|
|
||||||
"pragma"
|
|
||||||
"property"
|
|
||||||
"readonly"
|
|
||||||
"required"
|
|
||||||
"signal"
|
|
||||||
] @keyword
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
;;; Definitions
|
|
||||||
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier) @property
|
|
||||||
(#eq? @property "id")
|
|
||||||
value: (expression_statement (identifier) @local.definition))
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,11 +0,0 @@
|
|||||||
#include <tree_sitter/parser.h>
|
|
||||||
#include "typescript-scanner.h"
|
|
||||||
|
|
||||||
void *tree_sitter_qmljs_external_scanner_create() { return NULL; }
|
|
||||||
void tree_sitter_qmljs_external_scanner_destroy(void *p) {}
|
|
||||||
unsigned tree_sitter_qmljs_external_scanner_serialize(void *p, char *buffer) { return 0; }
|
|
||||||
void tree_sitter_qmljs_external_scanner_deserialize(void *p, const char *b, unsigned n) {}
|
|
||||||
|
|
||||||
bool tree_sitter_qmljs_external_scanner_scan(void *payload, TSLexer *lexer, const bool *valid_symbols) {
|
|
||||||
return external_scanner_scan(payload, lexer, valid_symbols);
|
|
||||||
}
|
|
||||||
@ -1,224 +0,0 @@
|
|||||||
#ifndef TREE_SITTER_PARSER_H_
|
|
||||||
#define TREE_SITTER_PARSER_H_
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#define ts_builtin_sym_error ((TSSymbol)-1)
|
|
||||||
#define ts_builtin_sym_end 0
|
|
||||||
#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
|
|
||||||
|
|
||||||
typedef uint16_t TSStateId;
|
|
||||||
|
|
||||||
#ifndef TREE_SITTER_API_H_
|
|
||||||
typedef uint16_t TSSymbol;
|
|
||||||
typedef uint16_t TSFieldId;
|
|
||||||
typedef struct TSLanguage TSLanguage;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
TSFieldId field_id;
|
|
||||||
uint8_t child_index;
|
|
||||||
bool inherited;
|
|
||||||
} TSFieldMapEntry;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint16_t index;
|
|
||||||
uint16_t length;
|
|
||||||
} TSFieldMapSlice;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
bool visible;
|
|
||||||
bool named;
|
|
||||||
bool supertype;
|
|
||||||
} TSSymbolMetadata;
|
|
||||||
|
|
||||||
typedef struct TSLexer TSLexer;
|
|
||||||
|
|
||||||
struct TSLexer {
|
|
||||||
int32_t lookahead;
|
|
||||||
TSSymbol result_symbol;
|
|
||||||
void (*advance)(TSLexer *, bool);
|
|
||||||
void (*mark_end)(TSLexer *);
|
|
||||||
uint32_t (*get_column)(TSLexer *);
|
|
||||||
bool (*is_at_included_range_start)(const TSLexer *);
|
|
||||||
bool (*eof)(const TSLexer *);
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
TSParseActionTypeShift,
|
|
||||||
TSParseActionTypeReduce,
|
|
||||||
TSParseActionTypeAccept,
|
|
||||||
TSParseActionTypeRecover,
|
|
||||||
} TSParseActionType;
|
|
||||||
|
|
||||||
typedef union {
|
|
||||||
struct {
|
|
||||||
uint8_t type;
|
|
||||||
TSStateId state;
|
|
||||||
bool extra;
|
|
||||||
bool repetition;
|
|
||||||
} shift;
|
|
||||||
struct {
|
|
||||||
uint8_t type;
|
|
||||||
uint8_t child_count;
|
|
||||||
TSSymbol symbol;
|
|
||||||
int16_t dynamic_precedence;
|
|
||||||
uint16_t production_id;
|
|
||||||
} reduce;
|
|
||||||
uint8_t type;
|
|
||||||
} TSParseAction;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint16_t lex_state;
|
|
||||||
uint16_t external_lex_state;
|
|
||||||
} TSLexMode;
|
|
||||||
|
|
||||||
typedef union {
|
|
||||||
TSParseAction action;
|
|
||||||
struct {
|
|
||||||
uint8_t count;
|
|
||||||
bool reusable;
|
|
||||||
} entry;
|
|
||||||
} TSParseActionEntry;
|
|
||||||
|
|
||||||
struct TSLanguage {
|
|
||||||
uint32_t version;
|
|
||||||
uint32_t symbol_count;
|
|
||||||
uint32_t alias_count;
|
|
||||||
uint32_t token_count;
|
|
||||||
uint32_t external_token_count;
|
|
||||||
uint32_t state_count;
|
|
||||||
uint32_t large_state_count;
|
|
||||||
uint32_t production_id_count;
|
|
||||||
uint32_t field_count;
|
|
||||||
uint16_t max_alias_sequence_length;
|
|
||||||
const uint16_t *parse_table;
|
|
||||||
const uint16_t *small_parse_table;
|
|
||||||
const uint32_t *small_parse_table_map;
|
|
||||||
const TSParseActionEntry *parse_actions;
|
|
||||||
const char * const *symbol_names;
|
|
||||||
const char * const *field_names;
|
|
||||||
const TSFieldMapSlice *field_map_slices;
|
|
||||||
const TSFieldMapEntry *field_map_entries;
|
|
||||||
const TSSymbolMetadata *symbol_metadata;
|
|
||||||
const TSSymbol *public_symbol_map;
|
|
||||||
const uint16_t *alias_map;
|
|
||||||
const TSSymbol *alias_sequences;
|
|
||||||
const TSLexMode *lex_modes;
|
|
||||||
bool (*lex_fn)(TSLexer *, TSStateId);
|
|
||||||
bool (*keyword_lex_fn)(TSLexer *, TSStateId);
|
|
||||||
TSSymbol keyword_capture_token;
|
|
||||||
struct {
|
|
||||||
const bool *states;
|
|
||||||
const TSSymbol *symbol_map;
|
|
||||||
void *(*create)(void);
|
|
||||||
void (*destroy)(void *);
|
|
||||||
bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist);
|
|
||||||
unsigned (*serialize)(void *, char *);
|
|
||||||
void (*deserialize)(void *, const char *, unsigned);
|
|
||||||
} external_scanner;
|
|
||||||
const TSStateId *primary_state_ids;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Lexer Macros
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define START_LEXER() \
|
|
||||||
bool result = false; \
|
|
||||||
bool skip = false; \
|
|
||||||
bool eof = false; \
|
|
||||||
int32_t lookahead; \
|
|
||||||
goto start; \
|
|
||||||
next_state: \
|
|
||||||
lexer->advance(lexer, skip); \
|
|
||||||
start: \
|
|
||||||
skip = false; \
|
|
||||||
lookahead = lexer->lookahead;
|
|
||||||
|
|
||||||
#define ADVANCE(state_value) \
|
|
||||||
{ \
|
|
||||||
state = state_value; \
|
|
||||||
goto next_state; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define SKIP(state_value) \
|
|
||||||
{ \
|
|
||||||
skip = true; \
|
|
||||||
state = state_value; \
|
|
||||||
goto next_state; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define ACCEPT_TOKEN(symbol_value) \
|
|
||||||
result = true; \
|
|
||||||
lexer->result_symbol = symbol_value; \
|
|
||||||
lexer->mark_end(lexer);
|
|
||||||
|
|
||||||
#define END_STATE() return result;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Parse Table Macros
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define SMALL_STATE(id) id - LARGE_STATE_COUNT
|
|
||||||
|
|
||||||
#define STATE(id) id
|
|
||||||
|
|
||||||
#define ACTIONS(id) id
|
|
||||||
|
|
||||||
#define SHIFT(state_value) \
|
|
||||||
{{ \
|
|
||||||
.shift = { \
|
|
||||||
.type = TSParseActionTypeShift, \
|
|
||||||
.state = state_value \
|
|
||||||
} \
|
|
||||||
}}
|
|
||||||
|
|
||||||
#define SHIFT_REPEAT(state_value) \
|
|
||||||
{{ \
|
|
||||||
.shift = { \
|
|
||||||
.type = TSParseActionTypeShift, \
|
|
||||||
.state = state_value, \
|
|
||||||
.repetition = true \
|
|
||||||
} \
|
|
||||||
}}
|
|
||||||
|
|
||||||
#define SHIFT_EXTRA() \
|
|
||||||
{{ \
|
|
||||||
.shift = { \
|
|
||||||
.type = TSParseActionTypeShift, \
|
|
||||||
.extra = true \
|
|
||||||
} \
|
|
||||||
}}
|
|
||||||
|
|
||||||
#define REDUCE(symbol_val, child_count_val, ...) \
|
|
||||||
{{ \
|
|
||||||
.reduce = { \
|
|
||||||
.type = TSParseActionTypeReduce, \
|
|
||||||
.symbol = symbol_val, \
|
|
||||||
.child_count = child_count_val, \
|
|
||||||
__VA_ARGS__ \
|
|
||||||
}, \
|
|
||||||
}}
|
|
||||||
|
|
||||||
#define RECOVER() \
|
|
||||||
{{ \
|
|
||||||
.type = TSParseActionTypeRecover \
|
|
||||||
}}
|
|
||||||
|
|
||||||
#define ACCEPT_INPUT() \
|
|
||||||
{{ \
|
|
||||||
.type = TSParseActionTypeAccept \
|
|
||||||
}}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // TREE_SITTER_PARSER_H_
|
|
||||||
@ -1,324 +0,0 @@
|
|||||||
/*
|
|
||||||
Source:
|
|
||||||
0.20.5
|
|
||||||
|
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2017 GitHub
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "tree_sitter/parser.h"
|
|
||||||
|
|
||||||
#include <wctype.h>
|
|
||||||
|
|
||||||
enum TokenType {
|
|
||||||
AUTOMATIC_SEMICOLON,
|
|
||||||
TEMPLATE_CHARS,
|
|
||||||
TERNARY_QMARK,
|
|
||||||
HTML_COMMENT,
|
|
||||||
LOGICAL_OR,
|
|
||||||
ESCAPE_SEQUENCE,
|
|
||||||
FUNCTION_SIGNATURE_AUTOMATIC_SEMICOLON,
|
|
||||||
ERROR_RECOVERY,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void advance(TSLexer *lexer) { lexer->advance(lexer, false); }
|
|
||||||
|
|
||||||
static void skip(TSLexer *lexer) { lexer->advance(lexer, true); }
|
|
||||||
|
|
||||||
static bool scan_template_chars(TSLexer *lexer) {
|
|
||||||
lexer->result_symbol = TEMPLATE_CHARS;
|
|
||||||
for (bool has_content = false;; has_content = true) {
|
|
||||||
lexer->mark_end(lexer);
|
|
||||||
switch (lexer->lookahead) {
|
|
||||||
case '`':
|
|
||||||
return has_content;
|
|
||||||
case '\0':
|
|
||||||
return false;
|
|
||||||
case '$':
|
|
||||||
advance(lexer);
|
|
||||||
if (lexer->lookahead == '{') {
|
|
||||||
return has_content;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '\\':
|
|
||||||
return has_content;
|
|
||||||
default:
|
|
||||||
advance(lexer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool scan_whitespace_and_comments(TSLexer *lexer, bool *scanned_comment) {
|
|
||||||
for (;;) {
|
|
||||||
while (iswspace(lexer->lookahead)) {
|
|
||||||
skip(lexer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lexer->lookahead == '/') {
|
|
||||||
skip(lexer);
|
|
||||||
|
|
||||||
if (lexer->lookahead == '/') {
|
|
||||||
skip(lexer);
|
|
||||||
while (lexer->lookahead != 0 && lexer->lookahead != '\n') {
|
|
||||||
skip(lexer);
|
|
||||||
}
|
|
||||||
*scanned_comment = true;
|
|
||||||
} else if (lexer->lookahead == '*') {
|
|
||||||
skip(lexer);
|
|
||||||
while (lexer->lookahead != 0) {
|
|
||||||
if (lexer->lookahead == '*') {
|
|
||||||
skip(lexer);
|
|
||||||
if (lexer->lookahead == '/') {
|
|
||||||
skip(lexer);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
skip(lexer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool scan_automatic_semicolon(TSLexer *lexer, const bool *valid_symbols, bool *scanned_comment) {
|
|
||||||
lexer->result_symbol = AUTOMATIC_SEMICOLON;
|
|
||||||
lexer->mark_end(lexer);
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
if (lexer->lookahead == 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (lexer->lookahead == '}') {
|
|
||||||
// Automatic semicolon insertion breaks detection of object patterns
|
|
||||||
// in a typed context:
|
|
||||||
// type F = ({a}: {a: number}) => number;
|
|
||||||
// Therefore, disable automatic semicolons when followed by typing
|
|
||||||
do {
|
|
||||||
skip(lexer);
|
|
||||||
} while (iswspace(lexer->lookahead));
|
|
||||||
if (lexer->lookahead == ':') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!iswspace(lexer->lookahead)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (lexer->lookahead == '\n') {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
skip(lexer);
|
|
||||||
}
|
|
||||||
|
|
||||||
skip(lexer);
|
|
||||||
|
|
||||||
if (!scan_whitespace_and_comments(lexer, scanned_comment)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (lexer->lookahead) {
|
|
||||||
case ',':
|
|
||||||
case '.':
|
|
||||||
case ';':
|
|
||||||
case '*':
|
|
||||||
case '%':
|
|
||||||
case '>':
|
|
||||||
case '<':
|
|
||||||
case '=':
|
|
||||||
case '?':
|
|
||||||
case '^':
|
|
||||||
case '|':
|
|
||||||
case '&':
|
|
||||||
case '/':
|
|
||||||
case ':':
|
|
||||||
return false;
|
|
||||||
|
|
||||||
case '{':
|
|
||||||
if (valid_symbols[FUNCTION_SIGNATURE_AUTOMATIC_SEMICOLON]) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Don't insert a semicolon before a '[' or '(', unless we're parsing
|
|
||||||
// a type. Detect whether we're parsing a type or an expression using
|
|
||||||
// the validity of a binary operator token.
|
|
||||||
case '(':
|
|
||||||
case '[':
|
|
||||||
if (valid_symbols[LOGICAL_OR]) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Insert a semicolon before `--` and `++`, but not before binary `+` or `-`.
|
|
||||||
case '+':
|
|
||||||
skip(lexer);
|
|
||||||
return lexer->lookahead == '+';
|
|
||||||
case '-':
|
|
||||||
skip(lexer);
|
|
||||||
return lexer->lookahead == '-';
|
|
||||||
|
|
||||||
// Don't insert a semicolon before `!=`, but do insert one before a unary `!`.
|
|
||||||
case '!':
|
|
||||||
skip(lexer);
|
|
||||||
return lexer->lookahead != '=';
|
|
||||||
|
|
||||||
// Don't insert a semicolon before `in` or `instanceof`, but do insert one
|
|
||||||
// before an identifier.
|
|
||||||
case 'i':
|
|
||||||
skip(lexer);
|
|
||||||
|
|
||||||
if (lexer->lookahead != 'n') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
skip(lexer);
|
|
||||||
|
|
||||||
if (!iswalpha(lexer->lookahead)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < 8; i++) {
|
|
||||||
if (lexer->lookahead != "stanceof"[i]) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
skip(lexer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!iswalpha(lexer->lookahead)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool scan_ternary_qmark(TSLexer *lexer) {
|
|
||||||
for (;;) {
|
|
||||||
if (!iswspace(lexer->lookahead)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
skip(lexer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lexer->lookahead == '?') {
|
|
||||||
advance(lexer);
|
|
||||||
|
|
||||||
/* Optional chaining. */
|
|
||||||
if (lexer->lookahead == '?' || lexer->lookahead == '.') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
lexer->mark_end(lexer);
|
|
||||||
lexer->result_symbol = TERNARY_QMARK;
|
|
||||||
|
|
||||||
/* TypeScript optional arguments contain the ?: sequence, possibly
|
|
||||||
with whitespace. */
|
|
||||||
for (;;) {
|
|
||||||
if (!iswspace(lexer->lookahead)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
advance(lexer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lexer->lookahead == ':' || lexer->lookahead == ')' || lexer->lookahead == ',') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lexer->lookahead == '.') {
|
|
||||||
advance(lexer);
|
|
||||||
if (iswdigit(lexer->lookahead)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool scan_closing_comment(TSLexer *lexer) {
|
|
||||||
while (iswspace(lexer->lookahead) || lexer->lookahead == 0x2028 || lexer->lookahead == 0x2029) {
|
|
||||||
skip(lexer);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *comment_start = "<!--";
|
|
||||||
const char *comment_end = "-->";
|
|
||||||
|
|
||||||
if (lexer->lookahead == '<') {
|
|
||||||
for (unsigned i = 0; i < 4; i++) {
|
|
||||||
if (lexer->lookahead != comment_start[i]) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
advance(lexer);
|
|
||||||
}
|
|
||||||
} else if (lexer->lookahead == '-') {
|
|
||||||
for (unsigned i = 0; i < 3; i++) {
|
|
||||||
if (lexer->lookahead != comment_end[i]) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
advance(lexer);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (lexer->lookahead != 0 && lexer->lookahead != '\n' && lexer->lookahead != 0x2028 &&
|
|
||||||
lexer->lookahead != 0x2029) {
|
|
||||||
advance(lexer);
|
|
||||||
}
|
|
||||||
|
|
||||||
lexer->result_symbol = HTML_COMMENT;
|
|
||||||
lexer->mark_end(lexer);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool external_scanner_scan(void *payload, TSLexer *lexer, const bool *valid_symbols) {
|
|
||||||
if (valid_symbols[TEMPLATE_CHARS]) {
|
|
||||||
if (valid_symbols[AUTOMATIC_SEMICOLON]) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return scan_template_chars(lexer);
|
|
||||||
}
|
|
||||||
if (valid_symbols[AUTOMATIC_SEMICOLON] || valid_symbols[FUNCTION_SIGNATURE_AUTOMATIC_SEMICOLON]) {
|
|
||||||
bool scanned_comment = false;
|
|
||||||
bool ret = scan_automatic_semicolon(lexer, valid_symbols, &scanned_comment);
|
|
||||||
if (!ret && !scanned_comment && valid_symbols[TERNARY_QMARK] && lexer->lookahead == '?') {
|
|
||||||
return scan_ternary_qmark(lexer);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
if (valid_symbols[TERNARY_QMARK]) {
|
|
||||||
return scan_ternary_qmark(lexer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (valid_symbols[HTML_COMMENT] && !valid_symbols[LOGICAL_OR] && !valid_symbols[ESCAPE_SEQUENCE]) {
|
|
||||||
return scan_closing_comment(lexer);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@ -1,217 +0,0 @@
|
|||||||
================================================================================
|
|
||||||
Compatibility semicolon
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
// qtdeclarative/tests/auto/qml/qqmlecmascript/data/compatibilitySemicolon.qml
|
|
||||||
QtObject {
|
|
||||||
function code() {
|
|
||||||
// Not correct according to ECMA 5.1, but JSC and V8 accept the following:
|
|
||||||
do {
|
|
||||||
;
|
|
||||||
} while (false) true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
(comment)
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(function_declaration
|
|
||||||
(identifier)
|
|
||||||
(formal_parameters)
|
|
||||||
(statement_block
|
|
||||||
(comment)
|
|
||||||
(do_statement
|
|
||||||
(statement_block
|
|
||||||
(empty_statement))
|
|
||||||
(parenthesized_expression
|
|
||||||
(false)))
|
|
||||||
(expression_statement
|
|
||||||
(true)))))))
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Semicolon after array/object binding in property declaration
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
// qtdeclarative/tests/auto/qml/qqmlecmascript/data/semicolonAfterProperty.qml
|
|
||||||
QtObject {
|
|
||||||
property var field: {"key": "value"};
|
|
||||||
property list<QtObject> mylist: [
|
|
||||||
QtObject {id: a},
|
|
||||||
QtObject {id: b}
|
|
||||||
];
|
|
||||||
property var object: QtObject {};
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
(comment)
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_property
|
|
||||||
(type_identifier)
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(object
|
|
||||||
(pair
|
|
||||||
(string
|
|
||||||
(string_fragment))
|
|
||||||
(string
|
|
||||||
(string_fragment))))))
|
|
||||||
(ui_property
|
|
||||||
(ui_list_property_type
|
|
||||||
(type_identifier)
|
|
||||||
(type_identifier))
|
|
||||||
(identifier)
|
|
||||||
(ui_object_array
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))))
|
|
||||||
(ui_property
|
|
||||||
(type_identifier)
|
|
||||||
(identifier)
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer))))))
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Semicolon after array/object binding is not allowed
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
QtObject {
|
|
||||||
object: QtObject {};
|
|
||||||
array: [QtObject {}];
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer)))
|
|
||||||
(ERROR)
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(ui_object_array
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer))))
|
|
||||||
(ERROR))))
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Multi-line string literal
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
// qtdeclarative/tests/auto/qml/qmllint/data/multilineString.qml
|
|
||||||
// qtdeclarative/tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings.qml
|
|
||||||
QtObject {
|
|
||||||
property string multipart: "Hello
|
|
||||||
world"
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
multipart = 'Hello
|
|
||||||
world' + '!';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
(comment)
|
|
||||||
(comment)
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_property
|
|
||||||
(type_identifier)
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
(nested_identifier
|
|
||||||
(identifier)
|
|
||||||
(identifier))
|
|
||||||
(statement_block
|
|
||||||
(expression_statement
|
|
||||||
(assignment_expression
|
|
||||||
(identifier)
|
|
||||||
(binary_expression
|
|
||||||
(string
|
|
||||||
(string_fragment))
|
|
||||||
(string
|
|
||||||
(string_fragment))))))))))
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Weird object pattern
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
// Found in
|
|
||||||
// qtdeclarative/tests/auto/quickcontrols/controls/data/tst_scrollbar.qml
|
|
||||||
//
|
|
||||||
// This appears not accepted by Chrome/Firefox, but QML parser doesn't report
|
|
||||||
// any error.
|
|
||||||
Control {
|
|
||||||
id: control
|
|
||||||
function func() {
|
|
||||||
var p0 = { x = control.leftPadding, y = control.height/2 };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
(comment)
|
|
||||||
(comment)
|
|
||||||
(comment)
|
|
||||||
(comment)
|
|
||||||
(comment)
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))
|
|
||||||
(function_declaration
|
|
||||||
(identifier)
|
|
||||||
(formal_parameters)
|
|
||||||
(statement_block
|
|
||||||
(variable_declaration
|
|
||||||
(variable_declarator
|
|
||||||
(identifier))
|
|
||||||
(ERROR
|
|
||||||
(object_pattern
|
|
||||||
(object_assignment_pattern
|
|
||||||
(shorthand_property_identifier_pattern)
|
|
||||||
(member_expression
|
|
||||||
(identifier)
|
|
||||||
(property_identifier)))
|
|
||||||
(object_assignment_pattern
|
|
||||||
(shorthand_property_identifier_pattern)
|
|
||||||
(binary_expression
|
|
||||||
(member_expression
|
|
||||||
(identifier)
|
|
||||||
(property_identifier))
|
|
||||||
(number)))))))))))
|
|
||||||
@ -1,764 +0,0 @@
|
|||||||
================================================================================
|
|
||||||
Pragma and imports
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
pragma Singleton
|
|
||||||
pragma ListPropertyAssignBehavior: Append
|
|
||||||
pragma Translator: "myTranslationContext"
|
|
||||||
pragma ValueTypeBehavior: Copy, Addressable
|
|
||||||
import QtQuick
|
|
||||||
import Qt.labs.platform as Platform
|
|
||||||
import QtQuick.Controls 2
|
|
||||||
import QtQuick3D 1.15
|
|
||||||
import "path"
|
|
||||||
import "script.js" as Script
|
|
||||||
|
|
||||||
Item {}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
(ui_pragma
|
|
||||||
name: (identifier))
|
|
||||||
(ui_pragma
|
|
||||||
name: (identifier)
|
|
||||||
value: (identifier))
|
|
||||||
(ui_pragma
|
|
||||||
name: (identifier)
|
|
||||||
value: (string
|
|
||||||
(string_fragment)))
|
|
||||||
(ui_pragma
|
|
||||||
name: (identifier)
|
|
||||||
value: (identifier)
|
|
||||||
value: (identifier))
|
|
||||||
(ui_import
|
|
||||||
source: (identifier))
|
|
||||||
(ui_import
|
|
||||||
source: (nested_identifier
|
|
||||||
(nested_identifier
|
|
||||||
(identifier)
|
|
||||||
(identifier))
|
|
||||||
(identifier))
|
|
||||||
alias: (identifier))
|
|
||||||
(ui_import
|
|
||||||
source: (nested_identifier
|
|
||||||
(identifier)
|
|
||||||
(identifier))
|
|
||||||
version: (ui_version_specifier
|
|
||||||
major: (number)))
|
|
||||||
(ui_import
|
|
||||||
source: (identifier)
|
|
||||||
version: (ui_version_specifier
|
|
||||||
major: (number)
|
|
||||||
minor: (number)))
|
|
||||||
(ui_import
|
|
||||||
source: (string
|
|
||||||
(string_fragment)))
|
|
||||||
(ui_import
|
|
||||||
source: (string
|
|
||||||
(string_fragment))
|
|
||||||
alias: (identifier))
|
|
||||||
root: (ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer)))
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Shebang
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
#!/usr/bin/env qml
|
|
||||||
import QtQml
|
|
||||||
|
|
||||||
OtObject {}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
(hash_bang_line)
|
|
||||||
(ui_import
|
|
||||||
(identifier))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer)))
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Nested objects
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
import QtQuick
|
|
||||||
import QtQuick.Controls as C
|
|
||||||
|
|
||||||
Item {
|
|
||||||
Rectangle {}
|
|
||||||
C.Button {}
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
(ui_import
|
|
||||||
source: (identifier))
|
|
||||||
(ui_import
|
|
||||||
source: (nested_identifier
|
|
||||||
(identifier)
|
|
||||||
(identifier))
|
|
||||||
alias: (identifier))
|
|
||||||
root: (ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer
|
|
||||||
(ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer))
|
|
||||||
(ui_object_definition
|
|
||||||
type_name: (nested_identifier
|
|
||||||
(identifier)
|
|
||||||
(identifier))
|
|
||||||
initializer: (ui_object_initializer)))))
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Object on bindings
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
MyItem {
|
|
||||||
Behavior on value {}
|
|
||||||
Qualified.Object on qualified.prop {}
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
root: (ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer
|
|
||||||
(ui_object_definition_binding
|
|
||||||
type_name: (identifier)
|
|
||||||
name: (identifier)
|
|
||||||
initializer: (ui_object_initializer))
|
|
||||||
(ui_object_definition_binding
|
|
||||||
type_name: (nested_identifier
|
|
||||||
(identifier)
|
|
||||||
(identifier))
|
|
||||||
name: (nested_identifier
|
|
||||||
(identifier)
|
|
||||||
(identifier))
|
|
||||||
initializer: (ui_object_initializer)))))
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Object/Array bindings
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
MyItem {
|
|
||||||
array0: [] // is actually a script binding
|
|
||||||
array1: [expr]
|
|
||||||
arrayN: [member.expr, expr]
|
|
||||||
objArray1: [Element {}]
|
|
||||||
objArrayN: [Qualified.Element {}, Element {}]
|
|
||||||
object: Object {}
|
|
||||||
qualifiedObject: Qualified.Object {}
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
root: (ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(array)
|
|
||||||
(comment)))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(array
|
|
||||||
(identifier))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(array
|
|
||||||
(member_expression
|
|
||||||
object: (identifier)
|
|
||||||
property: (property_identifier))
|
|
||||||
(identifier))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (ui_object_array
|
|
||||||
(ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (ui_object_array
|
|
||||||
(ui_object_definition
|
|
||||||
type_name: (nested_identifier
|
|
||||||
(identifier)
|
|
||||||
(identifier))
|
|
||||||
initializer: (ui_object_initializer))
|
|
||||||
(ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer)))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (ui_object_definition
|
|
||||||
type_name: (nested_identifier
|
|
||||||
(identifier)
|
|
||||||
(identifier))
|
|
||||||
initializer: (ui_object_initializer))))))
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Script bindings
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
MyItem {
|
|
||||||
id: root
|
|
||||||
emptySt: ;
|
|
||||||
withSt: with (Math) PI
|
|
||||||
ifSt: if(x) true; else false;
|
|
||||||
switchSt: switch (y) {
|
|
||||||
default: return undefined;
|
|
||||||
}
|
|
||||||
objectLit: {foo: false, bar: true}
|
|
||||||
memberExpr: member.expr
|
|
||||||
paren.expr: (true)
|
|
||||||
onBlock: {}
|
|
||||||
onFunction: function(a) {}
|
|
||||||
onArrow: (b) => {}
|
|
||||||
onTrySt: try { foo(); } catch (error) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
root: (ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(identifier)))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (empty_statement))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (with_statement
|
|
||||||
object: (parenthesized_expression
|
|
||||||
(identifier))
|
|
||||||
body: (expression_statement
|
|
||||||
(identifier))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (if_statement
|
|
||||||
condition: (parenthesized_expression
|
|
||||||
(identifier))
|
|
||||||
consequence: (expression_statement
|
|
||||||
(true))
|
|
||||||
alternative: (else_clause
|
|
||||||
(expression_statement
|
|
||||||
(false)))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (switch_statement
|
|
||||||
value: (parenthesized_expression
|
|
||||||
(identifier))
|
|
||||||
body: (switch_body
|
|
||||||
(switch_default
|
|
||||||
body: (return_statement
|
|
||||||
(undefined))))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(object
|
|
||||||
(pair
|
|
||||||
key: (property_identifier)
|
|
||||||
value: (false))
|
|
||||||
(pair
|
|
||||||
key: (property_identifier)
|
|
||||||
value: (true)))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(member_expression
|
|
||||||
object: (identifier)
|
|
||||||
property: (property_identifier))))
|
|
||||||
(ui_binding
|
|
||||||
name: (nested_identifier
|
|
||||||
(identifier)
|
|
||||||
(identifier))
|
|
||||||
value: (expression_statement
|
|
||||||
(parenthesized_expression
|
|
||||||
(true))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (statement_block))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(function_expression
|
|
||||||
parameters: (formal_parameters
|
|
||||||
(required_parameter
|
|
||||||
pattern: (identifier)))
|
|
||||||
body: (statement_block))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(arrow_function
|
|
||||||
parameters: (formal_parameters
|
|
||||||
(required_parameter
|
|
||||||
pattern: (identifier)))
|
|
||||||
body: (statement_block))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (try_statement
|
|
||||||
body: (statement_block
|
|
||||||
(expression_statement
|
|
||||||
(call_expression
|
|
||||||
function: (identifier)
|
|
||||||
arguments: (arguments))))
|
|
||||||
handler: (catch_clause
|
|
||||||
parameter: (identifier)
|
|
||||||
body: (statement_block)))))))
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Grouped binding notation
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
// This is grammatically ambiguous and parsed as an object definition.
|
|
||||||
// See IRBuilder::visit(QQmlJS::AST::UiObjectDefinition *node) for details.
|
|
||||||
Button {
|
|
||||||
icon { source: "foo.png"; color: "transparent" }
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
(comment)
|
|
||||||
(comment)
|
|
||||||
root: (ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer
|
|
||||||
(ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment)))))))))
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Property declarations
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
MyItem {
|
|
||||||
property var varProp
|
|
||||||
property var varPropWithScriptStatement: if (0) 1; else 2
|
|
||||||
readonly property var readonlyVarPropWithScriptStatement: (0 ? 1 : 2)
|
|
||||||
required property var requiredVarProp
|
|
||||||
required default property var requiredDefaultVarProp
|
|
||||||
default property var defaultVarProp
|
|
||||||
default property var defaultVarPropWithScriptStatement: 123
|
|
||||||
default required property var defaultRequiredVarProp
|
|
||||||
|
|
||||||
property QtObject objectPropWithDefinition: QtObject {}
|
|
||||||
readonly property QtObject readonlyObjectPropWithDefinition: QtObject {}
|
|
||||||
|
|
||||||
property list<Rectangle> listProp
|
|
||||||
property list<Rectangle> listPropWithArray: [Rectangle {}, Rectangle {}]
|
|
||||||
readonly property list<Rectangle> readonlyListProp
|
|
||||||
readonly property list<Rectangle> readonlyListPropWithArray: [Rectangle {}]
|
|
||||||
required property list<Rectangle> requiredProp
|
|
||||||
required default property list<Rectangle> requiredDefaultListProp
|
|
||||||
default property list<Rectangle> defaultListProp
|
|
||||||
default required property list<Rectangle> defaultRequiredListProp
|
|
||||||
|
|
||||||
property Qualified.Object qualifiedObjectProp: Qualified.Object {}
|
|
||||||
property list<Qualified.Object> qualifiedArrayProp: [Qualified.Object {}]
|
|
||||||
|
|
||||||
required width
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
root: (ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier)
|
|
||||||
value: (if_statement
|
|
||||||
condition: (parenthesized_expression
|
|
||||||
(number))
|
|
||||||
consequence: (expression_statement
|
|
||||||
(number))
|
|
||||||
alternative: (else_clause
|
|
||||||
(expression_statement
|
|
||||||
(number)))))
|
|
||||||
(ui_property
|
|
||||||
(ui_property_modifier)
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(parenthesized_expression
|
|
||||||
(ternary_expression
|
|
||||||
condition: (number)
|
|
||||||
consequence: (number)
|
|
||||||
alternative: (number)))))
|
|
||||||
(ui_property
|
|
||||||
(ui_property_modifier)
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
(ui_property_modifier)
|
|
||||||
(ui_property_modifier)
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
(ui_property_modifier)
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
(ui_property_modifier)
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(number)))
|
|
||||||
(ui_property
|
|
||||||
(ui_property_modifier)
|
|
||||||
(ui_property_modifier)
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier)
|
|
||||||
value: (ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer)))
|
|
||||||
(ui_property
|
|
||||||
(ui_property_modifier)
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier)
|
|
||||||
value: (ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer)))
|
|
||||||
(ui_property
|
|
||||||
type: (ui_list_property_type
|
|
||||||
(type_identifier)
|
|
||||||
(type_identifier))
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (ui_list_property_type
|
|
||||||
(type_identifier)
|
|
||||||
(type_identifier))
|
|
||||||
name: (identifier)
|
|
||||||
value: (ui_object_array
|
|
||||||
(ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer))
|
|
||||||
(ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer))))
|
|
||||||
(ui_property
|
|
||||||
(ui_property_modifier)
|
|
||||||
type: (ui_list_property_type
|
|
||||||
(type_identifier)
|
|
||||||
(type_identifier))
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
(ui_property_modifier)
|
|
||||||
type: (ui_list_property_type
|
|
||||||
(type_identifier)
|
|
||||||
(type_identifier))
|
|
||||||
name: (identifier)
|
|
||||||
value: (ui_object_array
|
|
||||||
(ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer))))
|
|
||||||
(ui_property
|
|
||||||
(ui_property_modifier)
|
|
||||||
type: (ui_list_property_type
|
|
||||||
(type_identifier)
|
|
||||||
(type_identifier))
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
(ui_property_modifier)
|
|
||||||
(ui_property_modifier)
|
|
||||||
type: (ui_list_property_type
|
|
||||||
(type_identifier)
|
|
||||||
(type_identifier))
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
(ui_property_modifier)
|
|
||||||
type: (ui_list_property_type
|
|
||||||
(type_identifier)
|
|
||||||
(type_identifier))
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
(ui_property_modifier)
|
|
||||||
(ui_property_modifier)
|
|
||||||
type: (ui_list_property_type
|
|
||||||
(type_identifier)
|
|
||||||
(type_identifier))
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (nested_type_identifier
|
|
||||||
module: (identifier)
|
|
||||||
name: (type_identifier))
|
|
||||||
name: (identifier)
|
|
||||||
value: (ui_object_definition
|
|
||||||
type_name: (nested_identifier
|
|
||||||
(identifier)
|
|
||||||
(identifier))
|
|
||||||
initializer: (ui_object_initializer)))
|
|
||||||
(ui_property
|
|
||||||
type: (ui_list_property_type
|
|
||||||
(type_identifier)
|
|
||||||
(nested_type_identifier
|
|
||||||
module: (identifier)
|
|
||||||
name: (type_identifier)))
|
|
||||||
name: (identifier)
|
|
||||||
value: (ui_object_array
|
|
||||||
(ui_object_definition
|
|
||||||
type_name: (nested_identifier
|
|
||||||
(identifier)
|
|
||||||
(identifier))
|
|
||||||
initializer: (ui_object_initializer))))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier)))))
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Signals
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
MyItem {
|
|
||||||
signal sigNoArg
|
|
||||||
signal sig0()
|
|
||||||
signal sig1(var name)
|
|
||||||
signal sig2(name0: var, int name1, string name2)
|
|
||||||
signal sig3(name0: qualified.type0, qualified.type1 name1, name2: Type2)
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
root: (ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer
|
|
||||||
(ui_signal
|
|
||||||
name: (identifier))
|
|
||||||
(ui_signal
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (ui_signal_parameters))
|
|
||||||
(ui_signal
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (ui_signal_parameters
|
|
||||||
(ui_signal_parameter
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))))
|
|
||||||
(ui_signal
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (ui_signal_parameters
|
|
||||||
(ui_signal_parameter
|
|
||||||
name: (identifier)
|
|
||||||
type: (type_identifier))
|
|
||||||
(ui_signal_parameter
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_signal_parameter
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))))
|
|
||||||
(ui_signal
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (ui_signal_parameters
|
|
||||||
(ui_signal_parameter
|
|
||||||
name: (identifier)
|
|
||||||
type: (nested_type_identifier
|
|
||||||
module: (identifier)
|
|
||||||
name: (type_identifier)))
|
|
||||||
(ui_signal_parameter
|
|
||||||
type: (nested_type_identifier
|
|
||||||
module: (identifier)
|
|
||||||
name: (type_identifier))
|
|
||||||
name: (identifier))
|
|
||||||
(ui_signal_parameter
|
|
||||||
name: (identifier)
|
|
||||||
type: (type_identifier)))))))
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Inline component
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
MyItem {
|
|
||||||
component RedRect : Rectangle { color: "red" }
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
root: (ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer
|
|
||||||
(ui_inline_component
|
|
||||||
name: (identifier)
|
|
||||||
component: (ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))))))))
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
JavaScript/TypeScript declarations
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
MyItem {
|
|
||||||
function fun() {
|
|
||||||
}
|
|
||||||
|
|
||||||
function typedFun(param: string) : Qualified.Object {
|
|
||||||
}
|
|
||||||
|
|
||||||
function* gen() {
|
|
||||||
yield 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This can't be mapped to IR, but the parser somehow accepts it.
|
|
||||||
var v
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
root: (ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters
|
|
||||||
(required_parameter
|
|
||||||
pattern: (identifier)
|
|
||||||
type: (type_annotation
|
|
||||||
(predefined_type))))
|
|
||||||
return_type: (type_annotation
|
|
||||||
(nested_type_identifier
|
|
||||||
module: (identifier)
|
|
||||||
name: (type_identifier)))
|
|
||||||
body: (statement_block))
|
|
||||||
(generator_function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block
|
|
||||||
(expression_statement
|
|
||||||
(yield_expression
|
|
||||||
(number)))))
|
|
||||||
(comment)
|
|
||||||
(variable_declaration
|
|
||||||
(variable_declarator
|
|
||||||
name: (identifier))))))
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Enum
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
MyItem {
|
|
||||||
enum Foo {
|
|
||||||
Foo0
|
|
||||||
}
|
|
||||||
|
|
||||||
enum Bar {
|
|
||||||
Neg = -1,
|
|
||||||
Bar0 = 0,
|
|
||||||
Bar1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
root: (ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer
|
|
||||||
(enum_declaration
|
|
||||||
name: (identifier)
|
|
||||||
body: (enum_body
|
|
||||||
name: (identifier)))
|
|
||||||
(enum_declaration
|
|
||||||
name: (identifier)
|
|
||||||
body: (enum_body
|
|
||||||
(enum_assignment
|
|
||||||
name: (identifier)
|
|
||||||
value: (unary_expression
|
|
||||||
argument: (number)))
|
|
||||||
(enum_assignment
|
|
||||||
name: (identifier)
|
|
||||||
value: (number))
|
|
||||||
name: (identifier))))))
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Annotations
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
import QtQml
|
|
||||||
|
|
||||||
@Foo {}
|
|
||||||
@Bar {}
|
|
||||||
@Baz.Nested.Name {}
|
|
||||||
QtObject {
|
|
||||||
@Foo {}
|
|
||||||
@Bar {}
|
|
||||||
OtObject {}
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
(ui_import
|
|
||||||
source: (identifier))
|
|
||||||
root: (ui_annotated_object
|
|
||||||
annotation: (ui_annotation
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer))
|
|
||||||
annotation: (ui_annotation
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer))
|
|
||||||
annotation: (ui_annotation
|
|
||||||
type_name: (nested_identifier
|
|
||||||
(nested_identifier
|
|
||||||
(identifier)
|
|
||||||
(identifier))
|
|
||||||
(identifier))
|
|
||||||
initializer: (ui_object_initializer))
|
|
||||||
definition: (ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer
|
|
||||||
(ui_annotated_object_member
|
|
||||||
annotation: (ui_annotation
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer))
|
|
||||||
annotation: (ui_annotation
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer))
|
|
||||||
definition: (ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer)))))))
|
|
||||||
@ -1,897 +0,0 @@
|
|||||||
================================================================================
|
|
||||||
Reserved words as identifiers
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
MyItem {
|
|
||||||
Component {
|
|
||||||
id: component
|
|
||||||
}
|
|
||||||
|
|
||||||
QtObject {
|
|
||||||
property var any
|
|
||||||
property var async
|
|
||||||
property var component
|
|
||||||
property var declare
|
|
||||||
property var from
|
|
||||||
property var get
|
|
||||||
property var module
|
|
||||||
property var namespace
|
|
||||||
property var never
|
|
||||||
property var number
|
|
||||||
property var object
|
|
||||||
property var of
|
|
||||||
property var on
|
|
||||||
property var override
|
|
||||||
property var property
|
|
||||||
property var readonly
|
|
||||||
property var required
|
|
||||||
property var set
|
|
||||||
property var signal
|
|
||||||
property var string
|
|
||||||
property var symbol
|
|
||||||
property var type
|
|
||||||
property var unknown
|
|
||||||
property var yield
|
|
||||||
}
|
|
||||||
|
|
||||||
QtObject {
|
|
||||||
required any
|
|
||||||
required async
|
|
||||||
required component
|
|
||||||
required declare
|
|
||||||
required from
|
|
||||||
required get
|
|
||||||
required module
|
|
||||||
required namespace
|
|
||||||
required never
|
|
||||||
required number
|
|
||||||
required object
|
|
||||||
required of
|
|
||||||
required on
|
|
||||||
required override
|
|
||||||
required property
|
|
||||||
required readonly
|
|
||||||
required required
|
|
||||||
required set
|
|
||||||
required signal
|
|
||||||
required string
|
|
||||||
required symbol
|
|
||||||
required type
|
|
||||||
required unknown
|
|
||||||
required yield
|
|
||||||
}
|
|
||||||
|
|
||||||
QtObject {
|
|
||||||
any: "foo"
|
|
||||||
async: "foo"
|
|
||||||
component: "foo"
|
|
||||||
declare: "foo"
|
|
||||||
from: "foo"
|
|
||||||
get: "foo"
|
|
||||||
module: "foo"
|
|
||||||
namespace: "foo"
|
|
||||||
never: "foo"
|
|
||||||
number: "foo"
|
|
||||||
object: "foo"
|
|
||||||
of: "foo"
|
|
||||||
on: "foo"
|
|
||||||
override: "foo"
|
|
||||||
property: "foo"
|
|
||||||
readonly: "foo"
|
|
||||||
required: "foo"
|
|
||||||
set: "foo"
|
|
||||||
signal: "foo"
|
|
||||||
string: "foo"
|
|
||||||
symbol: "foo"
|
|
||||||
type: "foo"
|
|
||||||
unknown: "foo"
|
|
||||||
yield: "foo"
|
|
||||||
}
|
|
||||||
|
|
||||||
QtObject {
|
|
||||||
signal any
|
|
||||||
signal async
|
|
||||||
signal declare
|
|
||||||
signal module
|
|
||||||
signal namespace
|
|
||||||
signal never
|
|
||||||
signal number
|
|
||||||
signal object
|
|
||||||
signal override
|
|
||||||
signal string
|
|
||||||
signal symbol
|
|
||||||
signal type
|
|
||||||
signal unknown
|
|
||||||
signal yield
|
|
||||||
}
|
|
||||||
|
|
||||||
QtObject {
|
|
||||||
function any() {}
|
|
||||||
function async() {}
|
|
||||||
function component() {}
|
|
||||||
function declare() {}
|
|
||||||
function from() {}
|
|
||||||
function get() {}
|
|
||||||
function module() {}
|
|
||||||
function namespace() {}
|
|
||||||
function never() {}
|
|
||||||
function number() {}
|
|
||||||
function object() {}
|
|
||||||
function of() {}
|
|
||||||
function on() {}
|
|
||||||
function override() {}
|
|
||||||
function property() {}
|
|
||||||
function readonly() {}
|
|
||||||
function required() {}
|
|
||||||
function set() {}
|
|
||||||
function signal() {}
|
|
||||||
function static() {}
|
|
||||||
function string() {}
|
|
||||||
function symbol() {}
|
|
||||||
function type() {}
|
|
||||||
function unknown() {}
|
|
||||||
function yield() {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
root: (ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer
|
|
||||||
(ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))
|
|
||||||
(ui_property
|
|
||||||
type: (type_identifier)
|
|
||||||
name: (identifier))))
|
|
||||||
(ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))
|
|
||||||
(ui_required
|
|
||||||
name: (identifier))))
|
|
||||||
(ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
name: (identifier)
|
|
||||||
value: (expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))))
|
|
||||||
(ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer
|
|
||||||
(ui_signal
|
|
||||||
name: (identifier))
|
|
||||||
(ui_signal
|
|
||||||
name: (identifier))
|
|
||||||
(ui_signal
|
|
||||||
name: (identifier))
|
|
||||||
(ui_signal
|
|
||||||
name: (identifier))
|
|
||||||
(ui_signal
|
|
||||||
name: (identifier))
|
|
||||||
(ui_signal
|
|
||||||
name: (identifier))
|
|
||||||
(ui_signal
|
|
||||||
name: (identifier))
|
|
||||||
(ui_signal
|
|
||||||
name: (identifier))
|
|
||||||
(ui_signal
|
|
||||||
name: (identifier))
|
|
||||||
(ui_signal
|
|
||||||
name: (identifier))
|
|
||||||
(ui_signal
|
|
||||||
name: (identifier))
|
|
||||||
(ui_signal
|
|
||||||
name: (identifier))
|
|
||||||
(ui_signal
|
|
||||||
name: (identifier))
|
|
||||||
(ui_signal
|
|
||||||
name: (identifier))))
|
|
||||||
(ui_object_definition
|
|
||||||
type_name: (identifier)
|
|
||||||
initializer: (ui_object_initializer
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block))
|
|
||||||
(function_declaration
|
|
||||||
name: (identifier)
|
|
||||||
parameters: (formal_parameters)
|
|
||||||
body: (statement_block)))))))
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Reserved words as expressions
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
MyItem {
|
|
||||||
QtObject { id: any }
|
|
||||||
// qml accepts this but doesn't look valid: QtObject { id: as }
|
|
||||||
QtObject { id: async }
|
|
||||||
QtObject { id: component }
|
|
||||||
QtObject { id: declare }
|
|
||||||
QtObject { id: false }
|
|
||||||
QtObject { id: from }
|
|
||||||
QtObject { id: get }
|
|
||||||
QtObject { id: module }
|
|
||||||
QtObject { id: namespace }
|
|
||||||
QtObject { id: never }
|
|
||||||
QtObject { id: null }
|
|
||||||
QtObject { id: number }
|
|
||||||
QtObject { id: object }
|
|
||||||
QtObject { id: of }
|
|
||||||
QtObject { id: on }
|
|
||||||
QtObject { id: override }
|
|
||||||
QtObject { id: property }
|
|
||||||
QtObject { id: readonly }
|
|
||||||
QtObject { id: required }
|
|
||||||
QtObject { id: set }
|
|
||||||
QtObject { id: signal }
|
|
||||||
QtObject { id: static }
|
|
||||||
QtObject { id: string }
|
|
||||||
QtObject { id: symbol }
|
|
||||||
QtObject { id: this }
|
|
||||||
QtObject { id: true }
|
|
||||||
QtObject { id: type }
|
|
||||||
QtObject { objectName: undefined }
|
|
||||||
QtObject { id: unknown }
|
|
||||||
QtObject { id: yield }
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(comment)
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(false)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(null)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(this)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(true)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(undefined)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(identifier)))))
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(yield_expression))))))))
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Non-ascii type names
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
// qtdeclarative/tests/auto/qml/qqmllanguage/data/i18nNameSpace.qml
|
|
||||||
OtObject {
|
|
||||||
Áâãäå {}
|
|
||||||
Áâãäå.Áâãäå {}
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
(comment)
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer))
|
|
||||||
(ui_object_definition
|
|
||||||
(nested_identifier
|
|
||||||
(identifier)
|
|
||||||
(identifier))
|
|
||||||
(ui_object_initializer)))))
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Escaped type names
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
OtObject {
|
|
||||||
\u0041lice {} // "A"lice
|
|
||||||
B\u006f {} // B"o"b
|
|
||||||
\u{00043}arol {} // "C"arol
|
|
||||||
\u004audy {} // "J"udy
|
|
||||||
\u005A {} // "Z"
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer))
|
|
||||||
(comment)
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer))
|
|
||||||
(comment)
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer))
|
|
||||||
(comment)
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer))
|
|
||||||
(comment)
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer))
|
|
||||||
(comment))))
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Escaped property names
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
OtObject {
|
|
||||||
\u0061lice: "alice"
|
|
||||||
b\u006Fb: "bob"
|
|
||||||
\u{00063}arol: "carol"
|
|
||||||
\u006Audy: "judy"
|
|
||||||
\u007a: "z"
|
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
(ui_object_definition
|
|
||||||
(identifier)
|
|
||||||
(ui_object_initializer
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment))))
|
|
||||||
(ui_binding
|
|
||||||
(identifier)
|
|
||||||
(expression_statement
|
|
||||||
(string
|
|
||||||
(string_fragment)))))))
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
import QtQuick
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
component MyItem : Item {}
|
|
||||||
// <- keyword
|
|
||||||
// ^ type ^ type
|
|
||||||
|
|
||||||
Component {
|
|
||||||
// <- type
|
|
||||||
id: component
|
|
||||||
// ^ variable.parameter
|
|
||||||
Item {}
|
|
||||||
}
|
|
||||||
|
|
||||||
function foo() {
|
|
||||||
let component = null;
|
|
||||||
// ^ variable
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
import QtQuick
|
|
||||||
|
|
||||||
Item {
|
|
||||||
signal foo(int name0, name1: MyType)
|
|
||||||
// <- keyword
|
|
||||||
// ^ function.signal
|
|
||||||
// ^ type
|
|
||||||
// ^ variable.parameter
|
|
||||||
// ^ variable.parameter
|
|
||||||
// ^ type
|
|
||||||
|
|
||||||
function bar(name: string) : MyType {
|
|
||||||
// <- keyword
|
|
||||||
// ^ function
|
|
||||||
// ^ variable.parameter
|
|
||||||
// ^ type.builtin
|
|
||||||
// ^ type
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,65 +0,0 @@
|
|||||||
import QtQuick
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: root
|
|
||||||
// <- property
|
|
||||||
// ^ variable.parameter
|
|
||||||
|
|
||||||
property MyItem myItem: MyItem {}
|
|
||||||
// <- keyword
|
|
||||||
// ^ type
|
|
||||||
// ^ property
|
|
||||||
// ^ type
|
|
||||||
|
|
||||||
readonly property int someNumber: 123
|
|
||||||
// <- keyword
|
|
||||||
// ^ keyword
|
|
||||||
// ^ type
|
|
||||||
// ^ property ^ number
|
|
||||||
|
|
||||||
required property var requiredData
|
|
||||||
// <- keyword
|
|
||||||
// ^ keyword
|
|
||||||
// ^ type
|
|
||||||
// ^ property
|
|
||||||
|
|
||||||
property list<MyItem> myItems: [MyItem {}]
|
|
||||||
// <- keyword
|
|
||||||
// ^ type ^ type
|
|
||||||
// ^ punctuation.bracket
|
|
||||||
// ^ punctuation.bracket
|
|
||||||
// ^ property
|
|
||||||
// ^ type
|
|
||||||
// ^ punctuation.bracket
|
|
||||||
// ^ punctuation.bracket
|
|
||||||
|
|
||||||
default property list<QtObject> defaultProp
|
|
||||||
// <- keyword
|
|
||||||
// ^ keyword
|
|
||||||
// ^ type
|
|
||||||
// ^ punctuation.bracket
|
|
||||||
// ^ punctuation.bracket
|
|
||||||
// ^ type ^ property
|
|
||||||
|
|
||||||
component MyItem : Item {
|
|
||||||
Behavior on x {
|
|
||||||
// <- type
|
|
||||||
// ^ keyword
|
|
||||||
// ^ property
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
component MyAnimation: NumberAnimation {
|
|
||||||
required property
|
|
||||||
// <- keyword
|
|
||||||
// ^ property
|
|
||||||
}
|
|
||||||
|
|
||||||
x: 123
|
|
||||||
// ^ number
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
anchors.fill: root
|
|
||||||
// ^ variable.parameter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue