Skip to content

Commit

Permalink
Syntax: Add support for comma separated multiple pragma values
Browse files Browse the repository at this point in the history
Can be found in five upstream Qt test files.

See yuja/tree-sitter-qmljs@e663294
  • Loading branch information
ratijas committed Nov 14, 2023
1 parent 6c4f3f3 commit 5c422c2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
16 changes: 10 additions & 6 deletions Support/QML.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,25 @@ contexts:
scope: keyword.control.pragma.qml
push:
- pragma-meta
- maybe-pragma-value
- maybe-pragma-rhs
- pragma-name

pragma-meta:
- meta_include_prototype: false
- meta_scope: meta.pragma.qml
- include: immediately-pop

maybe-pragma-value:
maybe-pragma-rhs:
- match: ':'
scope: punctuation.separator.mapping.key-value.qml
set:
- match: '{{identifier}}'
scope: storage.modifier.pragma.qml
- include: semicolon-or-eol-pop
set: pragma-value-list
- include: semicolon-or-eol-pop

pragma-value-list:
- match: '{{identifier}}'
scope: storage.modifier.pragma.qml
- match: ','
scope: punctuation.separator.comma.qml
- include: semicolon-or-eol-pop

pragma-name:
Expand Down
12 changes: 11 additions & 1 deletion Support/tests/syntax_test_QML.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,22 @@ pragma Strict
// ^^^^^^^^^^ meta.pragma.qml
// ^^^^^^ storage.modifier.pragma

pragma ComponentBehavior: Bound
pragma ComponentBehavior: Bound;
// <- meta.pragma keyword.control.pragma
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.pragma.qml
// ^^^^^^^^^^^^^^^^^ storage.modifier.pragma
// ^ punctuation.separator.mapping.key-value
// ^^^^^ storage.modifier.pragma
// ^ punctuation.terminator.statement.qml

pragma ValueTypeBehavior: Copy, Addressable
// <- meta.pragma keyword.control.pragma
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.pragma.qml
// ^^^^^^^^^^^^^^^^^ storage.modifier.pragma
// ^ punctuation.separator.mapping.key-value
// ^^^^ storage.modifier.pragma
// ^ punctuation.separator.comma
// ^^^^^^^^^^^ storage.modifier.pragma

/* no version */
import QtQml
Expand Down

0 comments on commit 5c422c2

Please sign in to comment.