Let foreach and endforeach accept arugments instead of variable
This commit is contained in:
parent
03ade79edb
commit
c0b417d056
|
@ -1,200 +0,0 @@
|
|||
========
|
||||
No items
|
||||
========
|
||||
|
||||
foreach(var)
|
||||
endforeach()
|
||||
|
||||
---
|
||||
(source_file
|
||||
(command_invocation
|
||||
(foreach_loop
|
||||
(foreach_iter
|
||||
loop_var: (variable)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
=================================
|
||||
No items with endforeach argument
|
||||
=================================
|
||||
|
||||
foreach(var)
|
||||
endforeach(var)
|
||||
|
||||
---
|
||||
(source_file
|
||||
(command_invocation
|
||||
(foreach_loop
|
||||
(foreach_iter
|
||||
loop_var: (variable)
|
||||
)
|
||||
(variable)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
========
|
||||
One item
|
||||
========
|
||||
|
||||
foreach(var item)
|
||||
endforeach()
|
||||
|
||||
---
|
||||
(source_file
|
||||
(command_invocation
|
||||
(foreach_loop
|
||||
(foreach_iter
|
||||
loop_var: (variable)
|
||||
(seperation (space))
|
||||
(arguments
|
||||
(argument (unquoted_argument))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
=========
|
||||
Two items
|
||||
=========
|
||||
|
||||
foreach(var item item)
|
||||
endforeach()
|
||||
|
||||
---
|
||||
(source_file
|
||||
(command_invocation
|
||||
(foreach_loop
|
||||
(foreach_iter
|
||||
loop_var: (variable)
|
||||
(seperation (space))
|
||||
(arguments
|
||||
(argument (unquoted_argument))
|
||||
(seperation (space))
|
||||
(argument (unquoted_argument))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
=====================
|
||||
Iter containing RANGE
|
||||
=====================
|
||||
|
||||
foreach(var RANGE1)
|
||||
endforeach()
|
||||
|
||||
---
|
||||
(source_file
|
||||
(command_invocation
|
||||
(foreach_loop
|
||||
(foreach_iter
|
||||
loop_var: (variable)
|
||||
(seperation (space))
|
||||
(arguments
|
||||
(argument (unquoted_argument))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
==========
|
||||
Range stop
|
||||
==========
|
||||
|
||||
foreach(var RANGE 10)
|
||||
endforeach()
|
||||
|
||||
---
|
||||
(source_file
|
||||
(command_invocation
|
||||
(foreach_loop
|
||||
(foreach_range
|
||||
(foreach_range_stop
|
||||
loop_var: (variable)
|
||||
(seperation (space))
|
||||
stop: (integer)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
================
|
||||
Range start stop
|
||||
================
|
||||
|
||||
foreach(var RANGE 0 10)
|
||||
endforeach()
|
||||
|
||||
---
|
||||
(source_file
|
||||
(command_invocation
|
||||
(foreach_loop
|
||||
(foreach_range
|
||||
(foreach_range_full
|
||||
loop_var: (variable)
|
||||
(seperation (space))
|
||||
start: (integer)
|
||||
stop: (integer)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
=========================
|
||||
Range lists with one list
|
||||
=========================
|
||||
|
||||
foreach(var IN LISTS A)
|
||||
endforeach()
|
||||
|
||||
---
|
||||
(source_file
|
||||
(command_invocation
|
||||
(foreach_loop
|
||||
(foreach_lists_items
|
||||
loop_var: (variable)
|
||||
(seperation (space))
|
||||
(seperation (space))
|
||||
(seperation (space))
|
||||
(arguments
|
||||
(argument (unquoted_argument))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
==========================
|
||||
Range lists with two lists
|
||||
==========================
|
||||
|
||||
foreach(var IN LISTS A B)
|
||||
endforeach()
|
||||
|
||||
---
|
||||
(source_file
|
||||
(command_invocation
|
||||
(foreach_loop
|
||||
(foreach_lists_items
|
||||
loop_var: (variable)
|
||||
(seperation (space))
|
||||
(seperation (space))
|
||||
(seperation (space))
|
||||
(arguments
|
||||
(argument (unquoted_argument))
|
||||
(seperation (space))
|
||||
(argument (unquoted_argument))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
|
@ -11,7 +11,7 @@ endforeach()
|
|||
(foreach_loop
|
||||
(foreach_command
|
||||
(foreach)
|
||||
(variable)
|
||||
(arguments (argument (unquoted_argument)))
|
||||
)
|
||||
(endforeach_command
|
||||
(endforeach)
|
||||
|
@ -32,11 +32,11 @@ endforeach(var)
|
|||
(foreach_loop
|
||||
(foreach_command
|
||||
(foreach)
|
||||
(variable)
|
||||
(arguments (argument (unquoted_argument)))
|
||||
)
|
||||
(endforeach_command
|
||||
(endforeach)
|
||||
(variable)
|
||||
(argument (unquoted_argument))
|
||||
)
|
||||
))
|
||||
|
||||
|
@ -53,7 +53,7 @@ ENDFOREACH()
|
|||
(foreach_loop
|
||||
(foreach_command
|
||||
(foreach)
|
||||
(variable)
|
||||
(arguments (argument (unquoted_argument)))
|
||||
)
|
||||
(endforeach_command
|
||||
(endforeach)
|
||||
|
@ -74,7 +74,7 @@ endForEach()
|
|||
(foreach_loop
|
||||
(foreach_command
|
||||
(foreach)
|
||||
(variable)
|
||||
(arguments (argument (unquoted_argument)))
|
||||
)
|
||||
(endforeach_command
|
||||
(endforeach)
|
||||
|
|
|
@ -39,9 +39,9 @@ module.exports = grammar({
|
|||
arguments: ($) => seq($.argument, repeat($._seperated_arguments)),
|
||||
_seperated_arguments: ($) => prec.left(seq(repeat1($.seperation), optional($.argument))),
|
||||
|
||||
foreach_command: ($) => seq($.foreach, "(", repeat($.seperation), $.variable, ")"),
|
||||
foreach_command: ($) => seq($.foreach, "(", $.arguments, ")"),
|
||||
endforeach_command: ($) =>
|
||||
seq($.endforeach, "(", repeat($.seperation), optional($.variable), ")"),
|
||||
seq($.endforeach, "(", repeat($.seperation), optional($.argument), ")"),
|
||||
foreach_loop: ($) =>
|
||||
seq($.foreach_command, repeat($._command_invocation), $.endforeach_command),
|
||||
normal_command: ($) => seq($.identifier, "(", repeat($.seperation), optional($.arguments), ")"),
|
||||
|
|
|
@ -401,16 +401,9 @@
|
|||
"type": "STRING",
|
||||
"value": "("
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "seperation"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "variable"
|
||||
"name": "arguments"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
|
@ -441,7 +434,7 @@
|
|||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "variable"
|
||||
"name": "argument"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
|
|
|
@ -84,6 +84,10 @@
|
|||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "argument",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "endforeach",
|
||||
"named": true
|
||||
|
@ -91,10 +95,6 @@
|
|||
{
|
||||
"type": "seperation",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "variable",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -127,17 +127,13 @@
|
|||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "arguments",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "foreach",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "seperation",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "variable",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
3711
src/parser.c
3711
src/parser.c
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue