Start extracting keywords in foreach command
This commit is contained in:
parent
d23b5a89fa
commit
6ccd073db5
|
@ -11,7 +11,7 @@ endforeach()
|
||||||
(foreach_loop
|
(foreach_loop
|
||||||
(foreach_command
|
(foreach_command
|
||||||
(foreach)
|
(foreach)
|
||||||
(arguments (argument (unquoted_argument)))
|
(argument (unquoted_argument))
|
||||||
)
|
)
|
||||||
(endforeach_command (endforeach))
|
(endforeach_command (endforeach))
|
||||||
)
|
)
|
||||||
|
@ -30,7 +30,7 @@ endforeach(var)
|
||||||
(foreach_loop
|
(foreach_loop
|
||||||
(foreach_command
|
(foreach_command
|
||||||
(foreach)
|
(foreach)
|
||||||
(arguments (argument (unquoted_argument)))
|
(argument (unquoted_argument))
|
||||||
)
|
)
|
||||||
(endforeach_command
|
(endforeach_command
|
||||||
(endforeach)
|
(endforeach)
|
||||||
|
@ -51,7 +51,7 @@ ENDFOREACH()
|
||||||
(foreach_loop
|
(foreach_loop
|
||||||
(foreach_command
|
(foreach_command
|
||||||
(foreach)
|
(foreach)
|
||||||
(arguments (argument (unquoted_argument)))
|
(argument (unquoted_argument))
|
||||||
)
|
)
|
||||||
(endforeach_command (endforeach))
|
(endforeach_command (endforeach))
|
||||||
)
|
)
|
||||||
|
@ -70,7 +70,7 @@ endForEach()
|
||||||
(foreach_loop
|
(foreach_loop
|
||||||
(foreach_command
|
(foreach_command
|
||||||
(foreach)
|
(foreach)
|
||||||
(arguments (argument (unquoted_argument)))
|
(argument (unquoted_argument))
|
||||||
)
|
)
|
||||||
(endforeach_command (endforeach))
|
(endforeach_command (endforeach))
|
||||||
)
|
)
|
||||||
|
|
|
@ -36,10 +36,9 @@ module.exports = grammar({
|
||||||
|
|
||||||
unquoted_argument: ($) => repeat1(choice($.variable_ref, /[^ ()#\"\\]/, $.escape_sequence)),
|
unquoted_argument: ($) => repeat1(choice($.variable_ref, /[^ ()#\"\\]/, $.escape_sequence)),
|
||||||
|
|
||||||
arguments: ($) => seq($.argument, repeat($._seperated_arguments)),
|
arguments: ($) => args($, $.argument),
|
||||||
_seperated_arguments: ($) => prec.left(seq(repeat1($._seperation), optional($.argument))),
|
|
||||||
|
|
||||||
foreach_command: ($) => seq($.foreach, "(", $.arguments, ")"),
|
foreach_command: ($) => seq($.foreach, "(", args($, $.argument, "IN"), ")"),
|
||||||
endforeach_command: ($) =>
|
endforeach_command: ($) =>
|
||||||
seq($.endforeach, "(", repeat($._seperation), optional($.argument), ")"),
|
seq($.endforeach, "(", repeat($._seperation), optional($.argument), ")"),
|
||||||
foreach_loop: ($) =>
|
foreach_loop: ($) =>
|
||||||
|
@ -64,3 +63,7 @@ function commandName(name) {
|
||||||
function commands(...names) {
|
function commands(...names) {
|
||||||
return Object.assign({}, ...names.map(commandName));
|
return Object.assign({}, ...names.map(commandName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function args($, ...rules) {
|
||||||
|
return seq(choice(...rules), repeat(prec.left(seq(repeat1($._seperation), optional(choice(...rules))))));
|
||||||
|
}
|
||||||
|
|
|
@ -348,21 +348,19 @@
|
||||||
},
|
},
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "argument"
|
"name": "argument"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "REPEAT",
|
"type": "REPEAT",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "_seperated_arguments"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"_seperated_arguments": {
|
|
||||||
"type": "PREC_LEFT",
|
"type": "PREC_LEFT",
|
||||||
"value": 0,
|
"value": 0,
|
||||||
"content": {
|
"content": {
|
||||||
|
@ -375,12 +373,17 @@
|
||||||
"name": "_seperation"
|
"name": "_seperation"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "argument"
|
"name": "argument"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "BLANK"
|
"type": "BLANK"
|
||||||
|
@ -389,6 +392,9 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"foreach_command": {
|
"foreach_command": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
|
@ -401,9 +407,63 @@
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
"value": "("
|
"value": "("
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "arguments"
|
"name": "argument"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "IN"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "REPEAT",
|
||||||
|
"content": {
|
||||||
|
"type": "PREC_LEFT",
|
||||||
|
"value": 0,
|
||||||
|
"content": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "REPEAT1",
|
||||||
|
"content": {
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_seperation"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "argument"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "IN"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "BLANK"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
|
|
|
@ -120,7 +120,7 @@
|
||||||
"required": true,
|
"required": true,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "arguments",
|
"type": "argument",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -329,6 +329,10 @@
|
||||||
"type": "=",
|
"type": "=",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "IN",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "[",
|
"type": "[",
|
||||||
"named": false
|
"named": false
|
||||||
|
|
3844
src/parser.c
3844
src/parser.c
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue