Compare commits

...

14 commits

Author SHA1 Message Date
Bruno BELANYI ba2022d3c8 Add builtins highlighting
All checks were successful
ci/woodpecker/push/check Pipeline was successful
2024-04-09 12:28:28 +01:00
Bruno BELANYI 3475d713d5 Add 'select' highlighting 2024-04-09 12:28:28 +01:00
Bruno BELANYI ddb4f693be Add test for 'select' as an identifier 2024-04-09 12:28:28 +01:00
Bruno BELANYI ab6d235540 Add map properties highlighting 2024-04-09 12:28:28 +01:00
Bruno BELANYI 42bef1d592 Add punctuations highlighting 2024-04-09 12:28:28 +01:00
Bruno BELANYI a9ec312792 Add modules highlighting
Still debating whether modules should be highlighted as namespaces or as
function calls.
2024-04-09 12:28:28 +01:00
Bruno BELANYI 3e4879a593 Add 'type' field to new-style module
I'd forgotten it...
2024-04-09 12:28:28 +01:00
Bruno BELANYI d4d88a6f01 Use nvim semantics in tests
To be more explicit: this makes it so the behaviour is "last-defined,
innermost capture wins".
2024-04-09 12:28:28 +01:00
Bruno BELANYI 7d6dce936a Account for '-' as an operator
For syntax purposes it's part of the number, but it looks better when
highlighted as an operator.
2024-04-09 12:28:28 +01:00
Bruno BELANYI 91e6f7841c Add operators highlighting 2024-04-09 12:28:28 +01:00
Bruno BELANYI 69e7f36f75 Add variables highlighting 2024-04-09 12:28:28 +01:00
Bruno BELANYI b9fd34c084 Add literals highlighting 2024-04-08 20:48:15 +01:00
Bruno BELANYI e2aa90e0f4 Add comments highlighting 2024-04-08 20:48:15 +01:00
Bruno BELANYI 384da2d065 Add test for multiple modules 2024-04-08 20:27:53 +01:00
18 changed files with 379 additions and 161 deletions

View file

@ -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

View file

@ -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;
};

View file

@ -51,7 +51,7 @@ module.exports = grammar({
),
_new_module: ($) => seq(
$.identifier,
field("type", $.identifier),
"(",
optional(commaSeparated(
alias(field("property", $._equal_property), $.property)

69
queries/highlights.scm Normal file
View file

@ -0,0 +1,69 @@
[
(line_comment)
(block_comment)
] @comment
; Operators {{{
(operator) @operator
(integer_literal ("-") @operator)
; }}}
; Punctuation {{{
[
","
":"
] @punctuation.delimiter
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
; }}}
; Literal {{{
(boolean_literal) @boolean
(integer_literal) @number
[
(raw_string_literal)
(interpreted_string_literal)
] @string
(escape_sequence) @string.escape
; }}}
; Declarations {{{
(identifier) @variable
(module
type: (identifier) @module)
(module
(property
field: (identifier) @variable.member))
; }}}
; Built-ins {{{
[
(unset)
"default"
] @variable.builtin
(selection_type) @function.builtin
; }}}
; Expressions {{{
(map_expression
(property
field: (identifier) @property))
(select_expression
"select" @keyword.conditional)
; }}}
; vim: sw=2 foldmethod=marker

8
src/grammar.json generated
View file

@ -195,8 +195,12 @@
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
"type": "FIELD",
"name": "type",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
},
{
"type": "STRING",

12
src/node-types.json generated
View file

@ -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
}
]
}
},
{

273
src/parser.c generated
View file

@ -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

View file

@ -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
================================================================================

View file

@ -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))))

View file

@ -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

View file

@ -0,0 +1,10 @@
/* This is comment */
/* <- comment
^ comment
^ comment
*/
// And another comment
/* <- comment
^ comment
^ comment
*/

View file

@ -0,0 +1,3 @@
foo = bar + "baz"
// <- variable
// ^ variable

View file

@ -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

21
test/highlight/modules.bp Normal file
View file

@ -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
)

View file

@ -0,0 +1,9 @@
foo = bar
// ^ operator
foo += 1
// ^ operator
foo = -1 + 2
// ^ operator
// ^ operator

View file

@ -0,0 +1,7 @@
foo {
field: {
// <- variable.member
key: 42,
// <- property
},
}

View file

@ -0,0 +1,15 @@
foo (
// <- punctuation.bracket
bar = [
//^ punctuation.bracket
{
// <- punctuation.bracket
key: "value",
// ^ punctuation.delimiter
// ^ punctuation.delimiter
},
// <- punctuation.bracket
]
// <- punctuation.bracket
)
// <- punctuation.bracket

15
test/highlight/select.bp Normal file
View file

@ -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
}