Hide more invisible characters nodes
This commit is contained in:
parent
d62626bcb4
commit
d23b5a89fa
|
@ -42,7 +42,6 @@ message([[first argument]] [[second argument]])
|
|||
(identifier)
|
||||
(arguments
|
||||
(argument (bracket_argument (bracket_content)))
|
||||
(seperation (space))
|
||||
(argument (bracket_argument (bracket_content)))
|
||||
)
|
||||
)
|
||||
|
@ -61,12 +60,9 @@ message(
|
|||
(source_file
|
||||
(normal_command
|
||||
(identifier)
|
||||
(seperation (space))
|
||||
(arguments
|
||||
(argument (bracket_argument (bracket_content)))
|
||||
(seperation (space))
|
||||
(argument (bracket_argument (bracket_content)))
|
||||
(seperation (line_ending (newline)))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -23,7 +23,6 @@ message( )
|
|||
(source_file
|
||||
(normal_command
|
||||
(identifier)
|
||||
(seperation (space))
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -40,9 +39,6 @@ message(
|
|||
(source_file
|
||||
(normal_command
|
||||
(identifier)
|
||||
(seperation
|
||||
(line_ending (newline))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ message("First argument" "Second argument")
|
|||
(identifier)
|
||||
(arguments
|
||||
(argument (quoted_argument (quoted_element)))
|
||||
(seperation (space))
|
||||
(argument (quoted_argument (quoted_element)))
|
||||
)
|
||||
)
|
||||
|
|
|
@ -28,7 +28,6 @@ message(STATUS Hello)
|
|||
(identifier)
|
||||
(arguments
|
||||
(argument (unquoted_argument))
|
||||
(seperation (space))
|
||||
(argument (unquoted_argument))
|
||||
)
|
||||
)
|
||||
|
@ -46,14 +45,12 @@ STATUS)
|
|||
(source_file
|
||||
(normal_command
|
||||
(identifier)
|
||||
(seperation (space))
|
||||
(arguments
|
||||
(argument (unquoted_argument))
|
||||
)
|
||||
)
|
||||
(normal_command
|
||||
(identifier)
|
||||
(seperation (line_ending (newline)))
|
||||
(arguments
|
||||
(argument (unquoted_argument))
|
||||
)
|
||||
|
@ -71,14 +68,12 @@ STATUS)
|
|||
(source_file
|
||||
(normal_command
|
||||
(identifier)
|
||||
(seperation (space))
|
||||
(arguments
|
||||
(argument (unquoted_argument))
|
||||
)
|
||||
)
|
||||
(normal_command
|
||||
(identifier)
|
||||
(seperation (line_ending (newline)))
|
||||
(arguments
|
||||
(argument (unquoted_argument))
|
||||
)
|
||||
|
|
18
grammar.js
18
grammar.js
|
@ -4,10 +4,10 @@ module.exports = grammar({
|
|||
rules: {
|
||||
source_file: ($) => repeat($._command_invocation),
|
||||
|
||||
line_ending: ($) => $.newline,
|
||||
seperation: ($) => choice($.space, $.line_ending),
|
||||
space: ($) => /[ \t]+/,
|
||||
newline: ($) => /\n+/,
|
||||
_line_ending: ($) => $._newline,
|
||||
_seperation: ($) => choice($._space, $._line_ending),
|
||||
_space: ($) => /[ \t]+/,
|
||||
_newline: ($) => /\n+/,
|
||||
...commands("foreach", "endforeach"),
|
||||
identifier: ($) => /[A-Za-z_][A-Za-z0-9_]*/,
|
||||
integer: ($) => /[+-]*\d+/,
|
||||
|
@ -32,19 +32,20 @@ module.exports = grammar({
|
|||
|
||||
quoted_argument: ($) => seq('"', optional($.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)),
|
||||
|
||||
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, ")"),
|
||||
endforeach_command: ($) =>
|
||||
seq($.endforeach, "(", repeat($.seperation), optional($.argument), ")"),
|
||||
seq($.endforeach, "(", repeat($._seperation), optional($.argument), ")"),
|
||||
foreach_loop: ($) =>
|
||||
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),
|
||||
},
|
||||
|
@ -63,4 +64,3 @@ function commandName(name) {
|
|||
function commands(...names) {
|
||||
return Object.assign({}, ...names.map(commandName));
|
||||
}
|
||||
|
||||
|
|
|
@ -8,36 +8,36 @@
|
|||
"name": "_command_invocation"
|
||||
}
|
||||
},
|
||||
"line_ending": {
|
||||
"_line_ending": {
|
||||
"type": "SYMBOL",
|
||||
"name": "newline"
|
||||
"name": "_newline"
|
||||
},
|
||||
"seperation": {
|
||||
"_seperation": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "space"
|
||||
"name": "_space"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "line_ending"
|
||||
"name": "_line_ending"
|
||||
}
|
||||
]
|
||||
},
|
||||
"space": {
|
||||
"_space": {
|
||||
"type": "PATTERN",
|
||||
"value": "[ \\t]+"
|
||||
},
|
||||
"newline": {
|
||||
"_newline": {
|
||||
"type": "PATTERN",
|
||||
"value": "\\n+"
|
||||
},
|
||||
"_foreach": {
|
||||
"foreach": {
|
||||
"type": "PATTERN",
|
||||
"value": "[fF][oO][rR][eE][aA][cC][hH]"
|
||||
},
|
||||
"_endforeach": {
|
||||
"endforeach": {
|
||||
"type": "PATTERN",
|
||||
"value": "[eE][nN][dD][fF][oO][rR][eE][aA][cC][hH]"
|
||||
},
|
||||
|
@ -319,7 +319,7 @@
|
|||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "newline"
|
||||
"name": "_newline"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -372,7 +372,7 @@
|
|||
"type": "REPEAT1",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "seperation"
|
||||
"name": "_seperation"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -395,7 +395,7 @@
|
|||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_foreach"
|
||||
"name": "foreach"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
|
@ -416,7 +416,7 @@
|
|||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_endforeach"
|
||||
"name": "endforeach"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
|
@ -426,7 +426,7 @@
|
|||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "seperation"
|
||||
"name": "_seperation"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -482,7 +482,7 @@
|
|||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "seperation"
|
||||
"name": "_seperation"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -33,10 +33,6 @@
|
|||
{
|
||||
"type": "argument",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "seperation",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -82,14 +78,14 @@
|
|||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "argument",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "seperation",
|
||||
"type": "endforeach",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
|
@ -120,12 +116,16 @@
|
|||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": false,
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "arguments",
|
||||
"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",
|
||||
"named": true,
|
||||
|
@ -187,10 +172,6 @@
|
|||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "seperation",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -237,10 +218,6 @@
|
|||
"type": "escape_sequence",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "newline",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "variable_ref",
|
||||
"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",
|
||||
"named": true,
|
||||
|
@ -395,18 +353,18 @@
|
|||
"type": "]",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "endforeach",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "foreach",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "newline",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "space",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "}",
|
||||
"named": false
|
||||
|
|
2767
src/parser.c
2767
src/parser.c
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue