From 384da2d0653108fb96af9ca97506714324df95e2 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 8 Apr 2024 20:27:53 +0100 Subject: [PATCH 01/14] Add test for multiple modules --- test/corpus/modules.txt | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/corpus/modules.txt b/test/corpus/modules.txt index 73d87bc..1eb7e9a 100644 --- a/test/corpus/modules.txt +++ b/test/corpus/modules.txt @@ -107,6 +107,40 @@ foo { (identifier) (interpreted_string_literal))))))) +================================================================================ +Multiple modules +================================================================================ + +foo { + answer: 42, + value: "test", +} + +bar { + baz: "qux", + done: true, +} + +-------------------------------------------------------------------------------- + +(source_file + (module + (identifier) + (property + (identifier) + (integer_literal)) + (property + (identifier) + (interpreted_string_literal))) + (module + (identifier) + (property + (identifier) + (interpreted_string_literal)) + (property + (identifier) + (boolean_literal)))) + ================================================================================ Rogue comma ================================================================================ From e2aa90e0f451ef768e5a57db58f7dd53b0647b93 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 8 Apr 2024 20:38:24 +0100 Subject: [PATCH 02/14] Add comments highlighting --- queries/highlights.scm | 6 ++++++ test/highlight/comments.bp | 10 ++++++++++ 2 files changed, 16 insertions(+) create mode 100644 queries/highlights.scm create mode 100644 test/highlight/comments.bp diff --git a/queries/highlights.scm b/queries/highlights.scm new file mode 100644 index 0000000..f24958e --- /dev/null +++ b/queries/highlights.scm @@ -0,0 +1,6 @@ +[ + (line_comment) + (block_comment) +] @comment + +; vim: sw=2 foldmethod=marker diff --git a/test/highlight/comments.bp b/test/highlight/comments.bp new file mode 100644 index 0000000..6e93dc9 --- /dev/null +++ b/test/highlight/comments.bp @@ -0,0 +1,10 @@ +/* This is comment */ +/* <- comment + ^ comment + ^ comment + */ +// And another comment +/* <- comment + ^ comment + ^ comment + */ From b9fd34c084b49bab7a8e28265adc6d0d89191200 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 8 Apr 2024 20:47:55 +0100 Subject: [PATCH 03/14] Add literals highlighting --- queries/highlights.scm | 13 +++++++++++++ test/highlight/litterals.bp | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 test/highlight/litterals.bp diff --git a/queries/highlights.scm b/queries/highlights.scm index f24958e..027ea74 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -3,4 +3,17 @@ (block_comment) ] @comment +; Literal {{{ +(boolean_literal) @boolean + +(integer_literal) @number + +[ + (raw_string_literal) + (interpreted_string_literal) +] @string + +(escape_sequence) @string.escape +; }}} + ; vim: sw=2 foldmethod=marker diff --git a/test/highlight/litterals.bp b/test/highlight/litterals.bp new file mode 100644 index 0000000..3f8131f --- /dev/null +++ b/test/highlight/litterals.bp @@ -0,0 +1,19 @@ +foo = 0 +// ^ number + +foo = -42 +// ^ number + +foo = true +// ^ boolean + +foo = "foo\nbar" +// ^ string +// ^ string.escape +// ^ string.escape +// ^ string +// ^ string + +foo = `baz` +// ^ string +// ^ string From 69e7f36f75e523bb99745986d293bb4411027dbd Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 8 Apr 2024 20:51:39 +0100 Subject: [PATCH 04/14] Add variables highlighting --- queries/highlights.scm | 4 ++++ test/highlight/identifiers.bp | 3 +++ 2 files changed, 7 insertions(+) create mode 100644 test/highlight/identifiers.bp diff --git a/queries/highlights.scm b/queries/highlights.scm index 027ea74..32c157a 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -16,4 +16,8 @@ (escape_sequence) @string.escape ; }}} +; Declarations {{{ +(identifier) @variable +; }}} + ; vim: sw=2 foldmethod=marker diff --git a/test/highlight/identifiers.bp b/test/highlight/identifiers.bp new file mode 100644 index 0000000..d855b5f --- /dev/null +++ b/test/highlight/identifiers.bp @@ -0,0 +1,3 @@ +foo = bar + "baz" +// <- variable +// ^ variable From 91e6f7841cce61fc7eae5ed00945082c4ee17663 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 8 Apr 2024 20:54:35 +0100 Subject: [PATCH 05/14] Add operators highlighting --- queries/highlights.scm | 4 ++++ test/highlight/operators.bp | 8 ++++++++ 2 files changed, 12 insertions(+) create mode 100644 test/highlight/operators.bp diff --git a/queries/highlights.scm b/queries/highlights.scm index 32c157a..20424ec 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -3,6 +3,10 @@ (block_comment) ] @comment +; Operators {{{ +(operator) @operator +; }}} + ; Literal {{{ (boolean_literal) @boolean diff --git a/test/highlight/operators.bp b/test/highlight/operators.bp new file mode 100644 index 0000000..33d9581 --- /dev/null +++ b/test/highlight/operators.bp @@ -0,0 +1,8 @@ +foo = bar +// ^ operator + +foo += 1 +// ^ operator + +foo = -1 + 2 +// ^ operator From 7d6dce936a437800a4c37da53f75b84787d94879 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 8 Apr 2024 20:58:17 +0100 Subject: [PATCH 06/14] Account for '-' as an operator For syntax purposes it's part of the number, but it looks better when highlighted as an operator. --- queries/highlights.scm | 2 ++ test/highlight/litterals.bp | 2 +- test/highlight/operators.bp | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/queries/highlights.scm b/queries/highlights.scm index 20424ec..af38e25 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -5,6 +5,8 @@ ; Operators {{{ (operator) @operator + +(integer_literal ("-") @operator) ; }}} ; Literal {{{ diff --git a/test/highlight/litterals.bp b/test/highlight/litterals.bp index 3f8131f..dfbdc71 100644 --- a/test/highlight/litterals.bp +++ b/test/highlight/litterals.bp @@ -2,7 +2,7 @@ foo = 0 // ^ number foo = -42 -// ^ number +// ^ number foo = true // ^ boolean diff --git a/test/highlight/operators.bp b/test/highlight/operators.bp index 33d9581..cfb75ac 100644 --- a/test/highlight/operators.bp +++ b/test/highlight/operators.bp @@ -5,4 +5,5 @@ foo += 1 // ^ operator foo = -1 + 2 +// ^ operator // ^ operator From d4d88a6f0137ae51a634c5c09887f052056020a3 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 8 Apr 2024 21:15:20 +0100 Subject: [PATCH 07/14] Use nvim semantics in tests To be more explicit: this makes it so the behaviour is "last-defined, innermost capture wins". --- Makefile | 4 ++-- flake.nix | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index f12211c..e421948 100644 --- a/Makefile +++ b/Makefile @@ -4,11 +4,11 @@ all: .PHONE: test test: all - tree-sitter test + tree-sitter test --apply-all-captures .PHONE: update-tests update-tests: all - tree-sitter test -u + tree-sitter test -u --apply-all-captures playground: nix shell pkgs#emscripten --command tree-sitter build-wasm diff --git a/flake.nix b/flake.nix index 4c513fb..e7053c4 100644 --- a/flake.nix +++ b/flake.nix @@ -93,7 +93,7 @@ tree-sitter = { enable = true; name = "tree-sitter tests"; - entry = "${tree-sitter-env}/bin/tree-sitter test"; + entry = "${tree-sitter-env}/bin/tree-sitter test --apply-all-captures"; pass_filenames = false; }; From 3e4879a593799657dbca44dc32c6434b656ea2fc Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 8 Apr 2024 21:25:44 +0100 Subject: [PATCH 08/14] Add 'type' field to new-style module I'd forgotten it... --- grammar.js | 2 +- src/grammar.json | 8 +- src/node-types.json | 12 +- src/parser.c | 273 +++++++++++++++++++++----------------------- 4 files changed, 137 insertions(+), 158 deletions(-) diff --git a/grammar.js b/grammar.js index 40e7e24..86d0dd6 100644 --- a/grammar.js +++ b/grammar.js @@ -51,7 +51,7 @@ module.exports = grammar({ ), _new_module: ($) => seq( - $.identifier, + field("type", $.identifier), "(", optional(commaSeparated( alias(field("property", $._equal_property), $.property) diff --git a/src/grammar.json b/src/grammar.json index 02c7230..c9b0e32 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -195,8 +195,12 @@ "type": "SEQ", "members": [ { - "type": "SYMBOL", - "name": "identifier" + "type": "FIELD", + "name": "type", + "content": { + "type": "SYMBOL", + "name": "identifier" + } }, { "type": "STRING", diff --git a/src/node-types.json b/src/node-types.json index 37c3eff..0a7db28 100644 --- a/src/node-types.json +++ b/src/node-types.json @@ -344,7 +344,7 @@ }, "type": { "multiple": false, - "required": false, + "required": true, "types": [ { "type": "identifier", @@ -352,16 +352,6 @@ } ] } - }, - "children": { - "multiple": false, - "required": false, - "types": [ - { - "type": "identifier", - "named": true - } - ] } }, { diff --git a/src/parser.c b/src/parser.c index d9a2ff9..f7c2b6f 100644 --- a/src/parser.c +++ b/src/parser.c @@ -14,7 +14,7 @@ #define EXTERNAL_TOKEN_COUNT 0 #define FIELD_COUNT 12 #define MAX_ALIAS_SEQUENCE_LENGTH 6 -#define PRODUCTION_ID_COUNT 20 +#define PRODUCTION_ID_COUNT 17 enum ts_symbol_identifiers { anon_sym_SLASH_SLASH = 1, @@ -515,24 +515,21 @@ static const char * const ts_field_names[] = { static const TSFieldMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = { [1] = {.index = 0, .length = 2}, - [2] = {.index = 2, .length = 1}, - [3] = {.index = 3, .length = 3}, - [4] = {.index = 6, .length = 1}, - [5] = {.index = 7, .length = 4}, - [6] = {.index = 11, .length = 3}, - [7] = {.index = 14, .length = 3}, - [8] = {.index = 17, .length = 1}, - [9] = {.index = 3, .length = 3}, - [10] = {.index = 18, .length = 2}, - [11] = {.index = 20, .length = 5}, - [12] = {.index = 25, .length = 2}, - [13] = {.index = 27, .length = 4}, - [14] = {.index = 31, .length = 4}, - [15] = {.index = 35, .length = 2}, + [2] = {.index = 2, .length = 3}, + [3] = {.index = 5, .length = 1}, + [4] = {.index = 6, .length = 4}, + [5] = {.index = 10, .length = 3}, + [6] = {.index = 13, .length = 1}, + [7] = {.index = 2, .length = 3}, + [8] = {.index = 14, .length = 2}, + [9] = {.index = 16, .length = 5}, + [10] = {.index = 21, .length = 2}, + [11] = {.index = 23, .length = 4}, + [12] = {.index = 27, .length = 2}, + [13] = {.index = 29, .length = 2}, + [14] = {.index = 31, .length = 2}, + [15] = {.index = 33, .length = 4}, [16] = {.index = 37, .length = 2}, - [17] = {.index = 39, .length = 2}, - [18] = {.index = 41, .length = 4}, - [19] = {.index = 45, .length = 2}, }; static const TSFieldMapEntry ts_field_map_entries[] = { @@ -540,72 +537,61 @@ static const TSFieldMapEntry ts_field_map_entries[] = { {field_property, 0, .inherited = true}, {field_type, 0, .inherited = true}, [2] = - {field_property, 0, .inherited = true}, - [3] = {field_left, 0}, {field_operator, 1}, {field_right, 2}, + [5] = + {field_type, 0}, [6] = - {field_type, 0}, - [7] = {field_field, 2, .inherited = true}, {field_property, 2}, {field_type, 0}, {field_value, 2, .inherited = true}, - [11] = - {field_field, 2, .inherited = true}, - {field_property, 2}, - {field_value, 2, .inherited = true}, - [14] = + [10] = {field_field, 1, .inherited = true}, {field_property, 1}, {field_value, 1, .inherited = true}, - [17] = + [13] = {field_element, 1}, - [18] = + [14] = {field_field, 0}, {field_value, 2}, - [20] = + [16] = {field_field, 2, .inherited = true}, {field_property, 2}, {field_property, 3, .inherited = true}, {field_type, 0}, {field_value, 2, .inherited = true}, - [25] = + [21] = {field_property, 0, .inherited = true}, {field_property, 1, .inherited = true}, - [27] = - {field_field, 2, .inherited = true}, - {field_property, 2}, - {field_property, 3, .inherited = true}, - {field_value, 2, .inherited = true}, - [31] = + [23] = {field_field, 1, .inherited = true}, {field_property, 1}, {field_property, 2, .inherited = true}, {field_value, 1, .inherited = true}, - [35] = + [27] = {field_element, 1}, {field_element, 2, .inherited = true}, - [37] = + [29] = {field_element, 0, .inherited = true}, {field_element, 1, .inherited = true}, - [39] = + [31] = {field_condition, 2}, {field_type, 0}, - [41] = + [33] = {field_condition, 3}, {field_namespace, 2}, {field_type, 0}, {field_variable, 4}, - [45] = + [37] = {field_pattern, 0}, {field_value, 2}, }; static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = { [0] = {0}, - [3] = { + [2] = { [1] = anon_sym_PLUS_EQ, }, }; @@ -7276,7 +7262,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(235), 2, + ACTIONS(227), 2, ts_builtin_sym_end, sym_identifier, STATE(84), 2, @@ -7287,7 +7273,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(237), 2, + ACTIONS(235), 2, ts_builtin_sym_end, sym_identifier, STATE(85), 2, @@ -7298,7 +7284,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(239), 2, + ACTIONS(237), 2, ts_builtin_sym_end, sym_identifier, STATE(86), 2, @@ -7309,7 +7295,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(241), 2, + ACTIONS(239), 2, ts_builtin_sym_end, sym_identifier, STATE(87), 2, @@ -7332,7 +7318,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(243), 2, + ACTIONS(241), 2, ts_builtin_sym_end, sym_identifier, STATE(89), 2, @@ -7343,7 +7329,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(245), 1, + ACTIONS(243), 1, anon_sym_COMMA, STATE(90), 2, sym_line_comment, @@ -7353,7 +7339,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(247), 1, + ACTIONS(245), 1, anon_sym_COMMA, STATE(91), 2, sym_line_comment, @@ -7363,7 +7349,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(249), 1, + ACTIONS(247), 1, anon_sym_RPAREN, STATE(92), 2, sym_line_comment, @@ -7373,7 +7359,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(251), 1, + ACTIONS(249), 1, anon_sym_COMMA, STATE(93), 2, sym_line_comment, @@ -7383,7 +7369,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(253), 1, + ACTIONS(251), 1, aux_sym_integer_literal_token1, STATE(94), 2, sym_line_comment, @@ -7393,7 +7379,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(255), 1, + ACTIONS(253), 1, anon_sym_RPAREN, STATE(95), 2, sym_line_comment, @@ -7403,7 +7389,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(257), 1, + ACTIONS(255), 1, anon_sym_RPAREN, STATE(96), 2, sym_line_comment, @@ -7413,7 +7399,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(259), 1, + ACTIONS(257), 1, anon_sym_SLASH, STATE(97), 2, sym_line_comment, @@ -7423,7 +7409,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(261), 1, + ACTIONS(259), 1, anon_sym_COMMA, STATE(98), 2, sym_line_comment, @@ -7433,7 +7419,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(263), 1, + ACTIONS(261), 1, anon_sym_RBRACE, STATE(99), 2, sym_line_comment, @@ -7443,7 +7429,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(265), 1, + ACTIONS(263), 1, anon_sym_RPAREN, STATE(100), 2, sym_line_comment, @@ -7453,7 +7439,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(267), 1, + ACTIONS(265), 1, anon_sym_COLON, STATE(101), 2, sym_line_comment, @@ -7463,7 +7449,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(269), 1, + ACTIONS(267), 1, anon_sym_COLON, STATE(102), 2, sym_line_comment, @@ -7473,7 +7459,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(271), 1, + ACTIONS(269), 1, anon_sym_COMMA, STATE(103), 2, sym_line_comment, @@ -7483,7 +7469,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(273), 1, + ACTIONS(271), 1, anon_sym_COMMA, STATE(104), 2, sym_line_comment, @@ -7493,7 +7479,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(275), 1, + ACTIONS(273), 1, anon_sym_COLON, STATE(105), 2, sym_line_comment, @@ -7503,7 +7489,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(277), 1, + ACTIONS(275), 1, anon_sym_EQ, STATE(106), 2, sym_line_comment, @@ -7513,7 +7499,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(279), 1, + ACTIONS(277), 1, anon_sym_RPAREN, STATE(107), 2, sym_line_comment, @@ -7523,7 +7509,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(281), 1, + ACTIONS(279), 1, anon_sym_LPAREN, STATE(108), 2, sym_line_comment, @@ -7533,7 +7519,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(102), 1, anon_sym_SLASH_STAR, - ACTIONS(283), 1, + ACTIONS(281), 1, aux_sym_line_comment_token1, STATE(109), 2, sym_line_comment, @@ -7543,7 +7529,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(285), 1, + ACTIONS(283), 1, ts_builtin_sym_end, STATE(110), 2, sym_line_comment, @@ -7553,7 +7539,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(287), 1, + ACTIONS(285), 1, anon_sym_RBRACE, STATE(111), 2, sym_line_comment, @@ -7563,7 +7549,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(289), 1, + ACTIONS(287), 1, anon_sym_RPAREN, STATE(112), 2, sym_line_comment, @@ -7573,7 +7559,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(291), 1, + ACTIONS(289), 1, anon_sym_COMMA, STATE(113), 2, sym_line_comment, @@ -7583,7 +7569,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(102), 1, anon_sym_SLASH_STAR, - ACTIONS(293), 1, + ACTIONS(291), 1, aux_sym_block_comment_token1, STATE(114), 2, sym_line_comment, @@ -7593,7 +7579,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(295), 1, + ACTIONS(293), 1, anon_sym_LPAREN, STATE(115), 2, sym_line_comment, @@ -7613,7 +7599,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(297), 1, + ACTIONS(295), 1, anon_sym_LPAREN, STATE(117), 2, sym_line_comment, @@ -7623,7 +7609,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(299), 1, + ACTIONS(297), 1, anon_sym_COMMA, STATE(118), 2, sym_line_comment, @@ -7633,7 +7619,7 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(301), 1, + ACTIONS(299), 1, anon_sym_COMMA, STATE(119), 2, sym_line_comment, @@ -7643,16 +7629,16 @@ static const uint16_t ts_small_parse_table[] = { anon_sym_SLASH_SLASH, ACTIONS(5), 1, anon_sym_SLASH_STAR, - ACTIONS(303), 1, + ACTIONS(301), 1, anon_sym_RPAREN, STATE(120), 2, sym_line_comment, sym_block_comment, [2541] = 1, - ACTIONS(305), 1, + ACTIONS(303), 1, ts_builtin_sym_end, [2545] = 1, - ACTIONS(307), 1, + ACTIONS(305), 1, ts_builtin_sym_end, }; @@ -7814,19 +7800,19 @@ static const TSParseActionEntry ts_parse_actions[] = { [62] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__string_literal, 1), [64] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_integer_literal, 1), [66] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_boolean_literal, 1), - [68] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_map_expression, 5, .production_id = 14), - [70] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_list_expression, 4, .production_id = 8), + [68] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_map_expression, 5, .production_id = 11), + [70] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_list_expression, 4, .production_id = 6), [72] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_select_expression, 6), - [74] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_list_expression, 3, .production_id = 8), + [74] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_list_expression, 3, .production_id = 6), [76] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__expr, 1), - [78] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_list_expression, 4, .production_id = 15), - [80] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_binary_expression, 3, .production_id = 9), + [78] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_list_expression, 4, .production_id = 12), + [80] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_binary_expression, 3, .production_id = 7), [82] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_list_expression, 2), - [84] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_map_expression, 4, .production_id = 7), - [86] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_list_expression, 5, .production_id = 15), - [88] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_map_expression, 4, .production_id = 14), + [84] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_map_expression, 4, .production_id = 5), + [86] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_list_expression, 5, .production_id = 12), + [88] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_map_expression, 4, .production_id = 11), [90] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_map_expression, 2), - [92] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_map_expression, 3, .production_id = 7), + [92] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_map_expression, 3, .production_id = 5), [94] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_integer_literal, 2), [96] = {.entry = {.count = 1, .reusable = true}}, SHIFT(108), [98] = {.entry = {.count = 1, .reusable = true}}, SHIFT(117), @@ -7863,75 +7849,74 @@ static const TSParseActionEntry ts_parse_actions[] = { [162] = {.entry = {.count = 1, .reusable = true}}, SHIFT(32), [164] = {.entry = {.count = 1, .reusable = true}}, SHIFT(52), [166] = {.entry = {.count = 1, .reusable = true}}, SHIFT(34), - [168] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_list_expression_repeat1, 2, .production_id = 8), + [168] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_list_expression_repeat1, 2, .production_id = 6), [170] = {.entry = {.count = 1, .reusable = true}}, SHIFT(48), [172] = {.entry = {.count = 1, .reusable = true}}, SHIFT(83), - [174] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_assignment, 3, .production_id = 3), - [176] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_list_expression_repeat1, 2, .production_id = 16), SHIFT_REPEAT(10), - [179] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_list_expression_repeat1, 2, .production_id = 16), + [174] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_assignment, 3, .production_id = 2), + [176] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_list_expression_repeat1, 2, .production_id = 13), SHIFT_REPEAT(10), + [179] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_list_expression_repeat1, 2, .production_id = 13), [181] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4), [183] = {.entry = {.count = 1, .reusable = true}}, SHIFT(27), [185] = {.entry = {.count = 1, .reusable = true}}, SHIFT(33), - [187] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__colon_property, 3, .production_id = 10), + [187] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__colon_property, 3, .production_id = 8), [189] = {.entry = {.count = 1, .reusable = true}}, SHIFT(87), - [191] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym__old_module_repeat1, 2, .production_id = 12), SHIFT_REPEAT(88), - [194] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym__old_module_repeat1, 2, .production_id = 12), - [196] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__equal_property, 3, .production_id = 10), + [191] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym__old_module_repeat1, 2, .production_id = 10), SHIFT_REPEAT(88), + [194] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym__old_module_repeat1, 2, .production_id = 10), + [196] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__equal_property, 3, .production_id = 8), [198] = {.entry = {.count = 1, .reusable = true}}, SHIFT(89), - [200] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym__new_module_repeat1, 2, .production_id = 12), SHIFT_REPEAT(71), - [203] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym__new_module_repeat1, 2, .production_id = 12), + [200] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym__new_module_repeat1, 2, .production_id = 10), SHIFT_REPEAT(71), + [203] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym__new_module_repeat1, 2, .production_id = 10), [205] = {.entry = {.count = 1, .reusable = true}}, SHIFT(70), [207] = {.entry = {.count = 1, .reusable = true}}, SHIFT(22), - [209] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__new_module, 3), - [211] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym__new_module_repeat1, 2, .production_id = 7), - [213] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym__old_module_repeat1, 2, .production_id = 7), - [215] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__new_module, 5, .production_id = 13), + [209] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__new_module, 3, .production_id = 3), + [211] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym__new_module_repeat1, 2, .production_id = 5), + [213] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym__old_module_repeat1, 2, .production_id = 5), + [215] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__new_module, 5, .production_id = 9), [217] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__case_value, 1), - [219] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__old_module, 5, .production_id = 11), + [219] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__old_module, 5, .production_id = 9), [221] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 1), - [223] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__old_module, 5, .production_id = 5), + [223] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__old_module, 5, .production_id = 4), [225] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__definition, 1), [227] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_module, 1, .production_id = 1), [229] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13), - [231] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__new_module, 4, .production_id = 6), - [233] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__old_module, 4, .production_id = 5), - [235] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_module, 1, .production_id = 2), - [237] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__new_module, 5, .production_id = 6), - [239] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__old_module, 3, .production_id = 4), - [241] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__old_module, 6, .production_id = 11), - [243] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__new_module, 6, .production_id = 13), - [245] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_select_value, 4, .production_id = 17), - [247] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_soong_config_variable, 6, .production_id = 18), - [249] = {.entry = {.count = 1, .reusable = true}}, SHIFT(90), - [251] = {.entry = {.count = 1, .reusable = true}}, SHIFT(38), - [253] = {.entry = {.count = 1, .reusable = true}}, SHIFT(35), - [255] = {.entry = {.count = 1, .reusable = true}}, SHIFT(24), - [257] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_select_cases, 5), - [259] = {.entry = {.count = 1, .reusable = false}}, SHIFT(122), - [261] = {.entry = {.count = 1, .reusable = true}}, SHIFT(81), - [263] = {.entry = {.count = 1, .reusable = true}}, SHIFT(96), - [265] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_select_cases, 2), - [267] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3), - [269] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2), - [271] = {.entry = {.count = 1, .reusable = true}}, SHIFT(45), - [273] = {.entry = {.count = 1, .reusable = true}}, SHIFT(111), - [275] = {.entry = {.count = 1, .reusable = true}}, SHIFT(8), - [277] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7), - [279] = {.entry = {.count = 1, .reusable = true}}, SHIFT(91), - [281] = {.entry = {.count = 1, .reusable = true}}, SHIFT(37), - [283] = {.entry = {.count = 1, .reusable = false}}, SHIFT(121), - [285] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), - [287] = {.entry = {.count = 1, .reusable = true}}, SHIFT(120), - [289] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_select_cases, 3), - [291] = {.entry = {.count = 1, .reusable = true}}, SHIFT(99), - [293] = {.entry = {.count = 1, .reusable = false}}, SHIFT(97), - [295] = {.entry = {.count = 1, .reusable = true}}, SHIFT(36), - [297] = {.entry = {.count = 1, .reusable = true}}, SHIFT(40), - [299] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_default_case, 3, .production_id = 19), - [301] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_select_case, 3, .production_id = 19), - [303] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_select_cases, 4), - [305] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_line_comment, 2), - [307] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_block_comment, 3), + [231] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__new_module, 4, .production_id = 4), + [233] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__old_module, 4, .production_id = 4), + [235] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__new_module, 5, .production_id = 4), + [237] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__old_module, 3, .production_id = 3), + [239] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__old_module, 6, .production_id = 9), + [241] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__new_module, 6, .production_id = 9), + [243] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_select_value, 4, .production_id = 14), + [245] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_soong_config_variable, 6, .production_id = 15), + [247] = {.entry = {.count = 1, .reusable = true}}, SHIFT(90), + [249] = {.entry = {.count = 1, .reusable = true}}, SHIFT(38), + [251] = {.entry = {.count = 1, .reusable = true}}, SHIFT(35), + [253] = {.entry = {.count = 1, .reusable = true}}, SHIFT(24), + [255] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_select_cases, 5), + [257] = {.entry = {.count = 1, .reusable = false}}, SHIFT(122), + [259] = {.entry = {.count = 1, .reusable = true}}, SHIFT(81), + [261] = {.entry = {.count = 1, .reusable = true}}, SHIFT(96), + [263] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_select_cases, 2), + [265] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3), + [267] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2), + [269] = {.entry = {.count = 1, .reusable = true}}, SHIFT(45), + [271] = {.entry = {.count = 1, .reusable = true}}, SHIFT(111), + [273] = {.entry = {.count = 1, .reusable = true}}, SHIFT(8), + [275] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7), + [277] = {.entry = {.count = 1, .reusable = true}}, SHIFT(91), + [279] = {.entry = {.count = 1, .reusable = true}}, SHIFT(37), + [281] = {.entry = {.count = 1, .reusable = false}}, SHIFT(121), + [283] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), + [285] = {.entry = {.count = 1, .reusable = true}}, SHIFT(120), + [287] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_select_cases, 3), + [289] = {.entry = {.count = 1, .reusable = true}}, SHIFT(99), + [291] = {.entry = {.count = 1, .reusable = false}}, SHIFT(97), + [293] = {.entry = {.count = 1, .reusable = true}}, SHIFT(36), + [295] = {.entry = {.count = 1, .reusable = true}}, SHIFT(40), + [297] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_default_case, 3, .production_id = 16), + [299] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_select_case, 3, .production_id = 16), + [301] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_select_cases, 4), + [303] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_line_comment, 2), + [305] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_block_comment, 3), }; #ifdef __cplusplus From a9ec312792211a4c72899c1fbf807a2157e22a20 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 8 Apr 2024 21:28:18 +0100 Subject: [PATCH 09/14] Add modules highlighting Still debating whether modules should be highlighted as namespaces or as function calls. --- queries/highlights.scm | 7 +++++++ test/highlight/modules.bp | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 test/highlight/modules.bp diff --git a/queries/highlights.scm b/queries/highlights.scm index af38e25..9541314 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -24,6 +24,13 @@ ; Declarations {{{ (identifier) @variable + +(module + type: (identifier) @module) + +(module + (property + field: (identifier) @variable.member)) ; }}} ; vim: sw=2 foldmethod=marker diff --git a/test/highlight/modules.bp b/test/highlight/modules.bp new file mode 100644 index 0000000..248acdf --- /dev/null +++ b/test/highlight/modules.bp @@ -0,0 +1,21 @@ +foo {} +// <- module + +foo () +// <- module + +foo { +// <- module + field: 12, + // <- variable.member + another_field: 27, + // <- variable.member +} + +foo ( +// <- module + field = 42, + // <- variable.member + done = false, + // <- variable.member +) From 42bef1d59230e82a99a625cb934a85496b47231f Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 8 Apr 2024 21:31:38 +0100 Subject: [PATCH 10/14] Add punctuations highlighting --- queries/highlights.scm | 16 ++++++++++++++++ test/highlight/punctuation.bp | 15 +++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 test/highlight/punctuation.bp diff --git a/queries/highlights.scm b/queries/highlights.scm index 9541314..9eae8a0 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -9,6 +9,22 @@ (integer_literal ("-") @operator) ; }}} +; Punctuation {{{ +[ + "," + ":" +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket +; }}} + ; Literal {{{ (boolean_literal) @boolean diff --git a/test/highlight/punctuation.bp b/test/highlight/punctuation.bp new file mode 100644 index 0000000..bc00194 --- /dev/null +++ b/test/highlight/punctuation.bp @@ -0,0 +1,15 @@ +foo ( + // <- punctuation.bracket + bar = [ + //^ punctuation.bracket + { + // <- punctuation.bracket + key: "value", + // ^ punctuation.delimiter + // ^ punctuation.delimiter + }, + // <- punctuation.bracket + ] + // <- punctuation.bracket +) +// <- punctuation.bracket From ab6d23554080af075bea5969c3db76189fedc7b5 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 8 Apr 2024 21:35:55 +0100 Subject: [PATCH 11/14] Add map properties highlighting --- queries/highlights.scm | 6 ++++++ test/highlight/properties.bp | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 test/highlight/properties.bp diff --git a/queries/highlights.scm b/queries/highlights.scm index 9eae8a0..a28d844 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -49,4 +49,10 @@ field: (identifier) @variable.member)) ; }}} +; Expressions {{{ +(map_expression + (property + field: (identifier) @property)) +; }}} + ; vim: sw=2 foldmethod=marker diff --git a/test/highlight/properties.bp b/test/highlight/properties.bp new file mode 100644 index 0000000..6bc97ef --- /dev/null +++ b/test/highlight/properties.bp @@ -0,0 +1,7 @@ +foo { + field: { + // <- variable.member + key: 42, + // <- property + }, +} From ddb4f693be9893c9499ff12e25ddd37768037dcf Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 9 Apr 2024 12:22:30 +0100 Subject: [PATCH 12/14] Add test for 'select' as an identifier --- test/corpus/select.txt | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/corpus/select.txt b/test/corpus/select.txt index 92f1342..fb76530 100644 --- a/test/corpus/select.txt +++ b/test/corpus/select.txt @@ -192,3 +192,26 @@ foo = select(some_unknown_type("CONDITION"), { (interpreted_string_literal)) (interpreted_string_literal)) (ERROR)) + +================================================================================ +Select as an identifier +================================================================================ + +select = 42 + +foo { + select: false, +} + +-------------------------------------------------------------------------------- + +(source_file + (assignment + (identifier) + (operator) + (integer_literal)) + (module + (identifier) + (property + (identifier) + (boolean_literal)))) From 3475d713d5f2f26f58a388f46696a6abd34970d7 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 8 Apr 2024 22:13:23 +0100 Subject: [PATCH 13/14] Add 'select' highlighting --- queries/highlights.scm | 3 +++ test/highlight/select.bp | 15 +++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 test/highlight/select.bp diff --git a/queries/highlights.scm b/queries/highlights.scm index a28d844..b4cc660 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -53,6 +53,9 @@ (map_expression (property field: (identifier) @property)) + +(select_expression + "select" @keyword.conditional) ; }}} ; vim: sw=2 foldmethod=marker diff --git a/test/highlight/select.bp b/test/highlight/select.bp new file mode 100644 index 0000000..831608d --- /dev/null +++ b/test/highlight/select.bp @@ -0,0 +1,15 @@ +foo = select(soong_config_variable("my_namespace", "my_var"), { + // ^ keyword.conditional + "foo": unset, + default: "bar", +}) + +// It can still be used as a normal variable name +select = 42 +// <- variable + +// Or module property +foo { + select: 42, + // <- variable.member +} From ba2022d3c8a3e8a23db3f2c3778e7b9aa51798d6 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 8 Apr 2024 22:13:23 +0100 Subject: [PATCH 14/14] Add builtins highlighting --- queries/highlights.scm | 8 ++++++++ test/highlight/builtins.bp | 14 ++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 test/highlight/builtins.bp diff --git a/queries/highlights.scm b/queries/highlights.scm index b4cc660..7422e6f 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -49,6 +49,14 @@ field: (identifier) @variable.member)) ; }}} +; Built-ins {{{ +[ + (unset) + "default" +] @variable.builtin +(selection_type) @function.builtin +; }}} + ; Expressions {{{ (map_expression (property diff --git a/test/highlight/builtins.bp b/test/highlight/builtins.bp new file mode 100644 index 0000000..508a8ed --- /dev/null +++ b/test/highlight/builtins.bp @@ -0,0 +1,14 @@ +foo = select(soong_config_variable("my_namespace", "my_var"), { + // ^ function.builtin + "foo": unset, + // ^ variable.builtin + default: select(variant("VARIANT") {}), + // <- variable.builtin + // ^ function.builtin +}) + +/* Assigning to builtins is conveniently not allowed at runtime */ +unset = 12 +// <- variable.builtin +default = 27 +// <- variable.builtin