diff --git a/grammar.js b/grammar.js index 44b3d08..c4bf35c 100644 --- a/grammar.js +++ b/grammar.js @@ -89,7 +89,7 @@ module.exports = grammar({ seq( "mod", optional("?"), - field("modname", $.identifier), + field("mod_name", $.identifier), optional($.string), ), @@ -114,7 +114,10 @@ module.exports = grammar({ "set", "shell", ":=", - array($.string), + field( + "right", + array($.string), + ), $.eol, ), ), diff --git a/queries/highlights.scm b/queries/highlights.scm index 5806f82..f4deb3c 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -11,9 +11,9 @@ left: (identifier) @variable) (module - modname: (identifier) @namespace) + mod_name: (identifier) @namespace) -(setting "shell" @keyword) +; highlight known settings (filtering does not always work) (setting left: ((identifier) @keyword (#any-of? @keyword @@ -40,7 +40,7 @@ (function_call name: (identifier) @function) - +; highlight known attributes (filtering does not always work) (attribute attr_item: ((identifier) @attribute (#any-of? @attribute @@ -59,12 +59,10 @@ "windows-shell" ))) -(attribute - attr_item: (identifier) @variable) - (recipe_header recipe_name: (identifier) @function) +; recipe argument specification ; pattern includes variadic_parameter (parameter param: (identifier) @variable.parameter @@ -75,6 +73,7 @@ (dependency_expression recipe: (identifier) @function) +; handle escape sequences (string (_ (string_escape) @constant.character.escape)) (string) @string @@ -93,6 +92,7 @@ "set" ] @keyword +; exclude `=` since it is only an operator in parameters (matching covered there) ["@" "==" "!=" "+" ":=" "*" ":" "/" "?"] @operator ["(" ")" "[" "]" "{{" "}}" "{" "}"] @punctuation.bracket diff --git a/src/grammar.json b/src/grammar.json index 54d566b..781d527 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -193,7 +193,7 @@ }, { "type": "FIELD", - "name": "modname", + "name": "mod_name", "content": { "type": "SYMBOL", "name": "identifier" @@ -371,85 +371,89 @@ }, { "type": "FIELD", - "name": "array", + "name": "right", "content": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "[" - }, - { - "type": "FIELD", - "name": "contents", - "content": { - "type": "CHOICE", - "members": [ - { - "type": "SEQ", - "members": [ - { - "type": "SEQ", - "members": [ - { - "type": "FIELD", - "name": "array_item", - "content": { - "type": "SYMBOL", - "name": "string" - } - }, - { - "type": "REPEAT", - "content": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "," - }, - { - "type": "FIELD", - "name": "array_item", - "content": { - "type": "SYMBOL", - "name": "string" + "type": "FIELD", + "name": "array", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "[" + }, + { + "type": "FIELD", + "name": "contents", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "array_item", + "content": { + "type": "SYMBOL", + "name": "string" + } + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "FIELD", + "name": "array_item", + "content": { + "type": "SYMBOL", + "name": "string" + } } - } - ] + ] + } } - } - ] - }, - { - "type": "CHOICE", - "members": [ - { - "type": "FIELD", - "name": "array_item", - "content": { - "type": "SYMBOL", - "name": "string" + ] + }, + { + "type": "CHOICE", + "members": [ + { + "type": "FIELD", + "name": "array_item", + "content": { + "type": "SYMBOL", + "name": "string" + } + }, + { + "type": "BLANK" } - }, - { - "type": "BLANK" - } - ] - } - ] - }, - { - "type": "BLANK" - } - ] + ] + } + ] + }, + { + "type": "BLANK" + } + ] + } + }, + { + "type": "STRING", + "value": "]" } - }, - { - "type": "STRING", - "value": "]" - } - ] + ] + } } }, { diff --git a/src/node-types.json b/src/node-types.json index 799454e..c9079ff 100644 --- a/src/node-types.json +++ b/src/node-types.json @@ -415,7 +415,7 @@ "type": "module", "named": true, "fields": { - "modname": { + "mod_name": { "multiple": false, "required": true, "types": [ @@ -663,6 +663,14 @@ "type": ":=", "named": false }, + { + "type": "[", + "named": false + }, + { + "type": "]", + "named": false + }, { "type": "boolean", "named": true diff --git a/src/parser.c b/src/parser.c index cc84897..ed1cda0 100644 --- a/src/parser.c +++ b/src/parser.c @@ -766,7 +766,7 @@ enum { field_expression = 8, field_kleene = 9, field_left = 10, - field_modname = 11, + field_mod_name = 11, field_name = 12, field_param = 13, field_recipe = 14, @@ -786,7 +786,7 @@ static const char * const ts_field_names[] = { [field_expression] = "expression", [field_kleene] = "kleene", [field_left] = "left", - [field_modname] = "modname", + [field_mod_name] = "mod_name", [field_name] = "name", [field_param] = "param", [field_recipe] = "recipe", @@ -843,13 +843,13 @@ static const TSFieldMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = { static const TSFieldMapEntry ts_field_map_entries[] = { [0] = - {field_modname, 1}, + {field_mod_name, 1}, [1] = {field_recipe_name, 0}, [2] = {field_param, 0}, [3] = - {field_modname, 2}, + {field_mod_name, 2}, [4] = {field_left, 1}, [5] = @@ -896,8 +896,8 @@ static const TSFieldMapEntry ts_field_map_entries[] = { [30] = {field_contents, 1}, [31] = - {field_array, 3}, - {field_array, 4}, + {field_right, 3}, + {field_right, 4}, [33] = {field_array, 3}, {field_array, 4}, @@ -921,9 +921,9 @@ static const TSFieldMapEntry ts_field_map_entries[] = { [47] = {field_array_item, 1}, [48] = - {field_array, 3}, - {field_array, 5}, {field_array_item, 4}, + {field_right, 3}, + {field_right, 5}, [51] = {field_array_item, 0, .inherited = true}, {field_array_item, 1, .inherited = true}, @@ -942,16 +942,16 @@ static const TSFieldMapEntry ts_field_map_entries[] = { {field_braced_body, 0, .inherited = true}, {field_braced_body, 1, .inherited = true}, [63] = - {field_array, 3}, - {field_array, 6}, {field_array_item, 4}, {field_array_item, 5}, + {field_right, 3}, + {field_right, 6}, [67] = - {field_array, 3}, - {field_array, 6}, {field_array_item, 4}, {field_array_item, 5, .inherited = true}, {field_contents, 5}, + {field_right, 3}, + {field_right, 6}, [72] = {field_array, 3}, {field_array, 6}, @@ -972,12 +972,12 @@ static const TSFieldMapEntry ts_field_map_entries[] = { {field_braced_body, 3, .inherited = true}, {field_braced_body, 5, .inherited = true}, [88] = - {field_array, 3}, - {field_array, 7}, {field_array_item, 4}, {field_array_item, 5, .inherited = true}, {field_array_item, 6}, {field_contents, 5}, + {field_right, 3}, + {field_right, 7}, [94] = {field_array, 3}, {field_array, 7},