Hide more invisible characters nodes

This commit is contained in:
Uy Ha 2021-06-14 21:33:30 +02:00
parent d62626bcb4
commit d23b5a89fa
8 changed files with 1396 additions and 1505 deletions

View file

@ -42,7 +42,6 @@ message([[first argument]] [[second argument]])
(identifier) (identifier)
(arguments (arguments
(argument (bracket_argument (bracket_content))) (argument (bracket_argument (bracket_content)))
(seperation (space))
(argument (bracket_argument (bracket_content))) (argument (bracket_argument (bracket_content)))
) )
) )
@ -61,12 +60,9 @@ message(
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(seperation (space))
(arguments (arguments
(argument (bracket_argument (bracket_content))) (argument (bracket_argument (bracket_content)))
(seperation (space))
(argument (bracket_argument (bracket_content))) (argument (bracket_argument (bracket_content)))
(seperation (line_ending (newline)))
) )
) )
) )

View file

@ -23,7 +23,6 @@ message( )
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(seperation (space))
) )
) )
@ -40,9 +39,6 @@ message(
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(seperation
(line_ending (newline))
)
) )
) )

View file

@ -42,7 +42,6 @@ message("First argument" "Second argument")
(identifier) (identifier)
(arguments (arguments
(argument (quoted_argument (quoted_element))) (argument (quoted_argument (quoted_element)))
(seperation (space))
(argument (quoted_argument (quoted_element))) (argument (quoted_argument (quoted_element)))
) )
) )

View file

@ -28,7 +28,6 @@ message(STATUS Hello)
(identifier) (identifier)
(arguments (arguments
(argument (unquoted_argument)) (argument (unquoted_argument))
(seperation (space))
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
) )
@ -46,14 +45,12 @@ STATUS)
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(seperation (space))
(arguments (arguments
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
) )
(normal_command (normal_command
(identifier) (identifier)
(seperation (line_ending (newline)))
(arguments (arguments
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
@ -71,14 +68,12 @@ STATUS)
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(seperation (space))
(arguments (arguments
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
) )
(normal_command (normal_command
(identifier) (identifier)
(seperation (line_ending (newline)))
(arguments (arguments
(argument (unquoted_argument)) (argument (unquoted_argument))
) )

View file

@ -4,10 +4,10 @@ module.exports = grammar({
rules: { rules: {
source_file: ($) => repeat($._command_invocation), source_file: ($) => repeat($._command_invocation),
line_ending: ($) => $.newline, _line_ending: ($) => $._newline,
seperation: ($) => choice($.space, $.line_ending), _seperation: ($) => choice($._space, $._line_ending),
space: ($) => /[ \t]+/, _space: ($) => /[ \t]+/,
newline: ($) => /\n+/, _newline: ($) => /\n+/,
...commands("foreach", "endforeach"), ...commands("foreach", "endforeach"),
identifier: ($) => /[A-Za-z_][A-Za-z0-9_]*/, identifier: ($) => /[A-Za-z_][A-Za-z0-9_]*/,
integer: ($) => /[+-]*\d+/, integer: ($) => /[+-]*\d+/,
@ -32,19 +32,20 @@ module.exports = grammar({
quoted_argument: ($) => seq('"', optional($.quoted_element), '"'), quoted_argument: ($) => seq('"', optional($.quoted_element), '"'),
quoted_element: ($) => quoted_element: ($) =>
repeat1(choice($.variable_ref, /[^\\"]/, $.escape_sequence, seq("\\", $.newline))), repeat1(choice($.variable_ref, /[^\\"]/, $.escape_sequence, seq("\\", $._newline))),
unquoted_argument: ($) => repeat1(choice($.variable_ref, /[^ ()#\"\\]/, $.escape_sequence)), unquoted_argument: ($) => repeat1(choice($.variable_ref, /[^ ()#\"\\]/, $.escape_sequence)),
arguments: ($) => seq($.argument, repeat($._seperated_arguments)), arguments: ($) => seq($.argument, repeat($._seperated_arguments)),
_seperated_arguments: ($) => prec.left(seq(repeat1($.seperation), optional($.argument))), _seperated_arguments: ($) => prec.left(seq(repeat1($._seperation), optional($.argument))),
foreach_command: ($) => seq($.foreach, "(", $.arguments, ")"), foreach_command: ($) => seq($.foreach, "(", $.arguments, ")"),
endforeach_command: ($) => endforeach_command: ($) =>
seq($.endforeach, "(", repeat($.seperation), optional($.argument), ")"), seq($.endforeach, "(", repeat($._seperation), optional($.argument), ")"),
foreach_loop: ($) => foreach_loop: ($) =>
seq($.foreach_command, repeat($._command_invocation), $.endforeach_command), seq($.foreach_command, repeat($._command_invocation), $.endforeach_command),
normal_command: ($) => seq($.identifier, "(", repeat($.seperation), optional($.arguments), ")"), normal_command: ($) =>
seq($.identifier, "(", repeat($._seperation), optional($.arguments), ")"),
_command_invocation: ($) => choice($.normal_command, $.foreach_loop), _command_invocation: ($) => choice($.normal_command, $.foreach_loop),
}, },
@ -63,4 +64,3 @@ function commandName(name) {
function commands(...names) { function commands(...names) {
return Object.assign({}, ...names.map(commandName)); return Object.assign({}, ...names.map(commandName));
} }

View file

@ -8,36 +8,36 @@
"name": "_command_invocation" "name": "_command_invocation"
} }
}, },
"line_ending": { "_line_ending": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "newline" "name": "_newline"
}, },
"seperation": { "_seperation": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "space" "name": "_space"
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "line_ending" "name": "_line_ending"
} }
] ]
}, },
"space": { "_space": {
"type": "PATTERN", "type": "PATTERN",
"value": "[ \\t]+" "value": "[ \\t]+"
}, },
"newline": { "_newline": {
"type": "PATTERN", "type": "PATTERN",
"value": "\\n+" "value": "\\n+"
}, },
"_foreach": { "foreach": {
"type": "PATTERN", "type": "PATTERN",
"value": "[fF][oO][rR][eE][aA][cC][hH]" "value": "[fF][oO][rR][eE][aA][cC][hH]"
}, },
"_endforeach": { "endforeach": {
"type": "PATTERN", "type": "PATTERN",
"value": "[eE][nN][dD][fF][oO][rR][eE][aA][cC][hH]" "value": "[eE][nN][dD][fF][oO][rR][eE][aA][cC][hH]"
}, },
@ -319,7 +319,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "newline" "name": "_newline"
} }
] ]
} }
@ -372,7 +372,7 @@
"type": "REPEAT1", "type": "REPEAT1",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "seperation" "name": "_seperation"
} }
}, },
{ {
@ -395,7 +395,7 @@
"members": [ "members": [
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_foreach" "name": "foreach"
}, },
{ {
"type": "STRING", "type": "STRING",
@ -416,7 +416,7 @@
"members": [ "members": [
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_endforeach" "name": "endforeach"
}, },
{ {
"type": "STRING", "type": "STRING",
@ -426,7 +426,7 @@
"type": "REPEAT", "type": "REPEAT",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "seperation" "name": "_seperation"
} }
}, },
{ {
@ -482,7 +482,7 @@
"type": "REPEAT", "type": "REPEAT",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "seperation" "name": "_seperation"
} }
}, },
{ {

View file

@ -33,10 +33,6 @@
{ {
"type": "argument", "type": "argument",
"named": true "named": true
},
{
"type": "seperation",
"named": true
} }
] ]
} }
@ -82,14 +78,14 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "argument", "type": "argument",
"named": true "named": true
}, },
{ {
"type": "seperation", "type": "endforeach",
"named": true "named": true
} }
] ]
@ -120,12 +116,16 @@
"named": true, "named": true,
"fields": {}, "fields": {},
"children": { "children": {
"multiple": false, "multiple": true,
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "arguments", "type": "arguments",
"named": true "named": true
},
{
"type": "foreach",
"named": true
} }
] ]
} }
@ -157,21 +157,6 @@
] ]
} }
}, },
{
"type": "line_ending",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "newline",
"named": true
}
]
}
},
{ {
"type": "normal_command", "type": "normal_command",
"named": true, "named": true,
@ -187,10 +172,6 @@
{ {
"type": "identifier", "type": "identifier",
"named": true "named": true
},
{
"type": "seperation",
"named": true
} }
] ]
} }
@ -237,10 +218,6 @@
"type": "escape_sequence", "type": "escape_sequence",
"named": true "named": true
}, },
{
"type": "newline",
"named": true
},
{ {
"type": "variable_ref", "type": "variable_ref",
"named": true "named": true
@ -248,25 +225,6 @@
] ]
} }
}, },
{
"type": "seperation",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "line_ending",
"named": true
},
{
"type": "space",
"named": true
}
]
}
},
{ {
"type": "source_file", "type": "source_file",
"named": true, "named": true,
@ -395,18 +353,18 @@
"type": "]", "type": "]",
"named": false "named": false
}, },
{
"type": "endforeach",
"named": true
},
{
"type": "foreach",
"named": true
},
{ {
"type": "identifier", "type": "identifier",
"named": true "named": true
}, },
{
"type": "newline",
"named": true
},
{
"type": "space",
"named": true
},
{ {
"type": "}", "type": "}",
"named": false "named": false

File diff suppressed because it is too large Load diff