feat: put arguments in argument_list node

This commit is contained in:
Uy Ha 2023-06-28 14:33:56 +00:00
parent 47564fb004
commit fe9b5e0229
17 changed files with 15571 additions and 19150 deletions

View file

@ -10,8 +10,10 @@ endfunction()
(function_def (function_def
(function_command (function_command
(function) (function)
(argument (argument_list
(unquoted_argument) (argument
(unquoted_argument)
)
) )
) )
(body) (body)
@ -33,17 +35,19 @@ endfunction()
(function_def (function_def
(function_command (function_command
(function) (function)
(argument (argument_list
(unquoted_argument) (argument
) (unquoted_argument)
(argument )
(unquoted_argument) (argument
) (unquoted_argument)
(argument )
(unquoted_argument) (argument
) (unquoted_argument)
(argument )
(unquoted_argument) (argument
(unquoted_argument)
)
) )
) )
(body) (body)
@ -65,8 +69,10 @@ endmacro()
(macro_def (macro_def
(macro_command (macro_command
(macro) (macro)
(argument (argument_list
(unquoted_argument) (argument
(unquoted_argument)
)
) )
) )
(body) (body)
@ -88,17 +94,19 @@ endmacro()
(macro_def (macro_def
(macro_command (macro_command
(macro) (macro)
(argument (argument_list
(unquoted_argument) (argument
) (unquoted_argument)
(argument )
(unquoted_argument) (argument
) (unquoted_argument)
(argument )
(unquoted_argument) (argument
) (unquoted_argument)
(argument )
(unquoted_argument) (argument
(unquoted_argument)
)
) )
) )
(body) (body)
@ -120,20 +128,22 @@ endblock()
(block_def (block_def
(block_command (block_command
(block) (block)
(argument (argument_list
(unquoted_argument) (argument
) (unquoted_argument)
(argument )
(unquoted_argument) (argument
) (unquoted_argument)
(argument )
(unquoted_argument) (argument
) (unquoted_argument)
(argument )
(unquoted_argument) (argument
) (unquoted_argument)
(argument )
(unquoted_argument) (argument
(unquoted_argument)
)
) )
) )
(body) (body)
@ -156,16 +166,20 @@ endfunction()
(function_def (function_def
(function_command (function_command
(function) (function)
(argument (argument_list
(unquoted_argument) (argument
(unquoted_argument)
)
) )
) )
(body (body
(function_def (function_def
(function_command (function_command
(function) (function)
(argument (argument_list
(unquoted_argument) (argument
(unquoted_argument)
)
) )
) )
(body) (body)

View file

@ -8,7 +8,9 @@ message([[]])
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (bracket_argument)) (argument_list
(argument (bracket_argument))
)
) )
) )
@ -22,7 +24,9 @@ message([[an argument]])
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (bracket_argument)) (argument_list
(argument (bracket_argument))
)
) )
) )
@ -36,8 +40,10 @@ message([[first argument]] [[second argument]])
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (bracket_argument)) (argument_list
(argument (bracket_argument)) (argument (bracket_argument))
(argument (bracket_argument))
)
) )
) )
@ -54,8 +60,10 @@ message(
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (bracket_argument)) (argument_list
(argument (bracket_argument)) (argument (bracket_argument))
(argument (bracket_argument))
)
) )
) )
@ -71,7 +79,9 @@ with line break
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (bracket_argument)) (argument_list
(argument (bracket_argument))
)
) )
) )
@ -87,7 +97,9 @@ with line break ]==]
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (bracket_argument)) (argument_list
(argument (bracket_argument))
)
) )
) )

View file

@ -19,10 +19,12 @@ message(STATUS #[[Some comment]] "comment is next" #[[Some comment]])
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (unquoted_argument)) (argument_list
(bracket_comment) (argument (unquoted_argument))
(argument (quoted_argument (quoted_element))) (bracket_comment)
(bracket_comment) (argument (quoted_argument (quoted_element)))
(bracket_comment)
)
) )
) )
@ -50,9 +52,11 @@ Second #Some other line comment
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (unquoted_argument)) (argument_list
(line_comment) (argument (unquoted_argument))
(argument (unquoted_argument)) (line_comment)
(line_comment) (argument (unquoted_argument))
(line_comment)
)
) )
) )

View file

@ -10,7 +10,9 @@ endif()
(if_condition (if_condition
(if_command (if_command
(if) (if)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument))
)
) )
(body) (body)
(endif_command (endif)) (endif_command (endif))
@ -30,12 +32,16 @@ endif()
(if_condition (if_condition
(if_command (if_command
(if) (if)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument))
)
) )
(body) (body)
(elseif_command (elseif_command
(elseif) (elseif)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument))
)
) )
(body) (body)
(endif_command (endif)) (endif_command (endif))
@ -56,12 +62,16 @@ endif()
(if_condition (if_condition
(if_command (if_command
(if) (if)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument))
)
) )
(body) (body)
(elseif_command (elseif_command
(elseif) (elseif)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument))
)
) )
(body) (body)
(else_command (else)) (else_command (else))
@ -81,23 +91,29 @@ endif()
--- ---
(source_file (source_file
(if_condition (if_condition
(if_command (if_command
(if) (if)
(argument (unquoted_argument)) (argument_list
) (argument (unquoted_argument))
(body )
(normal_command
(identifier)
(argument (unquoted_argument))
) )
(normal_command (body
(identifier) (normal_command
(argument (unquoted_argument)) (identifier)
(argument_list
(argument (unquoted_argument))
)
)
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
)
)
) )
(endif_command (endif))
) )
(endif_command (endif))
)
) )
============================================================== ==============================================================
@ -117,51 +133,69 @@ endif()
--- ---
(source_file (source_file
(if_condition (if_condition
(if_command (if_command
(if) (if)
(argument (unquoted_argument)) (argument_list
) (argument (unquoted_argument))
(body )
(normal_command )
(identifier) (body
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
)
)
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
)
)
)
(elseif_command
(elseif)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
(normal_command )
(identifier) (body
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
)
)
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
)
)
)
(else_command
(else)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(elseif_command
(elseif)
(argument (unquoted_argument))
)
(body
(normal_command
(identifier)
(argument (unquoted_argument))
) )
(normal_command (body
(identifier) (normal_command
(argument (unquoted_argument)) (identifier)
(argument_list
(argument (unquoted_argument))
)
)
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
)
)
) )
(endif_command (endif))
) )
(else_command
(else)
(argument (unquoted_argument))
)
(body
(normal_command
(identifier)
(argument (unquoted_argument))
)
(normal_command
(identifier)
(argument (unquoted_argument))
)
)
(endif_command (endif))
)
) )
@ -175,11 +209,13 @@ endif()
(if_condition (if_condition
(if_command (if_command
(if) (if)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument))
)
) )
(body) (body)
(endif_command (endif)) (endif_command (endif))
@ -194,37 +230,43 @@ else(NOT (A AND B) OR C)
endif(NOT (A AND B) OR C) endif(NOT (A AND B) OR C)
--- ---
(source_file (source_file
(if_condition (if_condition
(if_command (if_command
(if) (if)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument))
)
)
(body)
(else_command
(else)
(argument_list
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
)
)
(body)
(endif_command
(endif)
(argument_list
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
)
)
) )
(body)
(else_command
(else)
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
)
(body)
(endif_command
(endif)
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
)
)
) )
============================ ============================
@ -241,13 +283,17 @@ endif()
(if_condition (if_condition
(if_command (if_command
(if) (if)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument))
)
) )
(body (body
(if_condition (if_condition
(if_command (if_command
(if) (if)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument))
)
) )
(body) (body)
(endif_command (endif)) (endif_command (endif))

View file

@ -1,5 +1,5 @@
======================================== ========================================
Escape sequence of "\;" [Escape_sequence] Escape sequence of "\;" [escape_sequence]
========================================= =========================================
set(var "It is \; and \"") set(var "It is \; and \"")
@ -9,10 +9,17 @@ set(var "It is \; and \"")
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (argument_list
(unquoted_argument)) (argument
(argument (unquoted_argument))
(quoted_argument (argument
(quoted_element (quoted_argument
(escape_sequence) (quoted_element
(escape_sequence)))))) (escape_sequence)
(escape_sequence)
)
)
)
)
)
)

View file

@ -8,15 +8,17 @@ endforeach()
--- ---
(source_file (source_file
(foreach_loop (foreach_loop
(foreach_command (foreach_command
(foreach) (foreach)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument))
)
)
(body)
(endforeach_command (endforeach))
) )
(body) )
(endforeach_command (endforeach))
)
)
=============================================================== ===============================================================
Empty foreach loop with one argument endforeach [foreach] Empty foreach loop with one argument endforeach [foreach]
@ -28,17 +30,20 @@ endforeach(var)
--- ---
(source_file (source_file
(foreach_loop (foreach_loop
(foreach_command (foreach_command
(foreach) (foreach)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument))
)
)
(body)
(endforeach_command
(endforeach)
(argument (unquoted_argument))
)
) )
(body) )
(endforeach_command
(endforeach)
(argument (unquoted_argument))
)
))
================================= =================================
Uppercase foreach [foreach] Uppercase foreach [foreach]
@ -50,15 +55,17 @@ ENDFOREACH()
--- ---
(source_file (source_file
(foreach_loop (foreach_loop
(foreach_command (foreach_command
(foreach) (foreach)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument))
)
)
(body)
(endforeach_command (endforeach))
) )
(body) )
(endforeach_command (endforeach))
)
)
================================== ==================================
Mixed case foreach [foreach] Mixed case foreach [foreach]
@ -70,15 +77,17 @@ endForEach()
--- ---
(source_file (source_file
(foreach_loop (foreach_loop
(foreach_command (foreach_command
(foreach) (foreach)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument))
)
)
(body)
(endforeach_command (endforeach))
) )
(body) )
(endforeach_command (endforeach))
)
)
================================== ==================================
Empty IN [foreach] Empty IN [foreach]
@ -90,16 +99,18 @@ endforeach()
--- ---
(source_file (source_file
(foreach_loop (foreach_loop
(foreach_command (foreach_command
(foreach) (foreach)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument))
)
)
(body)
(endforeach_command (endforeach))
) )
(body) )
(endforeach_command (endforeach))
)
)
================================== ==================================
Empty RANGE [foreach] Empty RANGE [foreach]
@ -111,13 +122,15 @@ endforeach()
--- ---
(source_file (source_file
(foreach_loop (foreach_loop
(foreach_command (foreach_command
(foreach) (foreach)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument))
)
)
(body)
(endforeach_command (endforeach))
) )
(body) )
(endforeach_command (endforeach))
)
)

View file

@ -7,12 +7,14 @@ add_custom_target(OUTPUT somefile)
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) (argument (unquoted_argument))
) )
)
)
================================================ ================================================
add_custom_target with new line [function_calls] add_custom_target with new line [function_calls]
@ -24,9 +26,11 @@ add_custom_target(
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) (argument (unquoted_argument))
) )
)
)

View file

@ -8,9 +8,15 @@ message($<>)
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (argument_list
(unquoted_argument (argument
(gen_exp))))) (unquoted_argument
(gen_exp)
)
)
)
)
)
===================================== =====================================
Quoted generator expression [gen_exp] Quoted generator expression [gen_exp]
@ -22,10 +28,17 @@ message("$<>")
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (argument_list
(quoted_argument (argument
(quoted_argument
(quoted_element (quoted_element
(gen_exp)))))) (gen_exp)
)
)
)
)
)
)
===================== =====================
No argument [gen_exp] No argument [gen_exp]
@ -37,11 +50,19 @@ message($<ANGLE-R>)
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (argument_list
(unquoted_argument (argument
(unquoted_argument
(gen_exp (gen_exp
(argument (argument
(unquoted_argument))))))) (unquoted_argument)
)
)
)
)
)
)
)
============================================ ============================================
No argument with superfluous colon [gen_exp] No argument with superfluous colon [gen_exp]
@ -53,11 +74,19 @@ message($<ANGLE-R:>)
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (argument_list
(unquoted_argument (argument
(gen_exp (unquoted_argument
(argument (gen_exp
(unquoted_argument))))))) (argument
(unquoted_argument)
)
)
)
)
)
)
)
====================== ======================
One argument [gen_exp] One argument [gen_exp]
@ -69,13 +98,21 @@ message($<BOOL:-NOTFOUND>)
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (argument_list
(unquoted_argument (argument
(unquoted_argument
(gen_exp (gen_exp
(argument (argument
(unquoted_argument)) (unquoted_argument))
(argument (argument
(unquoted_argument))))))) (unquoted_argument)
)
)
)
)
)
)
)
======================= =======================
Two arguments [gen_exp] Two arguments [gen_exp]
@ -87,12 +124,20 @@ message($<AND:TRUE,FALSE>)
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (argument_list
(unquoted_argument (argument
(gen_exp (unquoted_argument
(argument (gen_exp
(argument
(unquoted_argument)) (unquoted_argument))
(argument (argument
(unquoted_argument)) (unquoted_argument))
(argument (argument
(unquoted_argument))))))) (unquoted_argument)
)
)
)
)
)
)
)

View file

@ -7,10 +7,10 @@ message()
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
) )
) )
================================= =================================
No argument with spaces [message] No argument with spaces [message]
@ -21,10 +21,11 @@ message( )
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
) (argument_list)
) )
)
=============================================== ===============================================
Message without argument with newline [message] Message without argument with newline [message]
@ -37,10 +38,11 @@ message(
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
) (argument_list)
) )
)
================================================== ==================================================
Message with STATUS and bracket argument [message] Message with STATUS and bracket argument [message]
@ -53,8 +55,10 @@ message(STATUS [=[Some argument ]==] ]=] )
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (unquoted_argument)) (argument_list
(argument (bracket_argument)) (argument (unquoted_argument))
(argument (bracket_argument))
)
) )
) )
@ -69,12 +73,14 @@ message(STATUS
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (unquoted_argument)) (argument_list
(argument (bracket_argument)) (argument (unquoted_argument))
) (argument (bracket_argument))
) )
)
)
====================================================== ======================================================
Message with STATUS and an unquoted argument [message] Message with STATUS and an unquoted argument [message]
@ -87,7 +93,9 @@ message(STATUS argument)
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument))
)
) )
) )

View file

@ -6,8 +6,10 @@ message(STATUS (TEST))
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument))
)
) )
) )
@ -19,8 +21,11 @@ message(STATUS (TEST)
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument)) (MISSING ")") (argument (unquoted_argument))
(argument (unquoted_argument))
)
(MISSING ")")
) )
) )
@ -32,8 +37,11 @@ message(STATUS ((TEST))
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument)) (MISSING ")") (argument (unquoted_argument))
(argument (unquoted_argument))
)
(MISSING ")")
) )
) )
@ -45,8 +53,10 @@ message(STATUS (TEST SECOND_TEST))
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument))
)
) )
) )

View file

@ -6,11 +6,13 @@ message("")
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (quoted_argument)) (argument_list
) (argument (quoted_argument))
) )
)
)
===================================== =====================================
One quoted argument [quoted_argument] One quoted argument [quoted_argument]
@ -20,11 +22,13 @@ message("An argument")
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (quoted_argument (quoted_element))) (argument_list
) (argument (quoted_argument (quoted_element)))
) )
)
)
====================================== ======================================
Two quoted arguments [quoted_argument] Two quoted arguments [quoted_argument]
@ -34,12 +38,14 @@ message("First argument" "Second argument")
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (quoted_argument (quoted_element))) (argument_list
(argument (quoted_argument (quoted_element))) (argument (quoted_argument (quoted_element)))
) (argument (quoted_argument (quoted_element)))
) )
)
)
=================================================== ===================================================
A quoted argument with line break [quoted_argument] A quoted argument with line break [quoted_argument]
@ -50,11 +56,13 @@ with line break")
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (quoted_argument (quoted_element))) (argument_list
) (argument (quoted_argument (quoted_element)))
) )
)
)
======================================== ========================================
One variable reference [quoted_argument] One variable reference [quoted_argument]
@ -64,17 +72,19 @@ message("${var}")
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (argument_list
(quoted_argument (argument
(quoted_element (quoted_argument
(variable_ref (normal_var (variable))) (quoted_element
(variable_ref (normal_var (variable)))
)
)
)
) )
)
) )
) )
)
========================================= =========================================
Two Variable references [quoted_argument] Two Variable references [quoted_argument]
@ -84,18 +94,20 @@ message("${var} ${var}")
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (argument_list
(quoted_argument (argument
(quoted_element (quoted_argument
(variable_ref (normal_var (variable))) (quoted_element
(variable_ref (normal_var (variable))) (variable_ref (normal_var (variable)))
(variable_ref (normal_var (variable)))
)
)
)
) )
)
) )
) )
)
====================================================================== ======================================================================
Variable reference inside another variable reference [quoted_argument] Variable reference inside another variable reference [quoted_argument]
@ -105,17 +117,19 @@ message("${var_${var}}")
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (argument_list
(quoted_argument (argument
(quoted_element (quoted_argument
(variable_ref (normal_var (variable (variable_ref (normal_var (variable)))))) (quoted_element
(variable_ref (normal_var (variable (variable_ref (normal_var (variable))))))
)
)
)
) )
)
) )
) )
)
====================================================================== ======================================================================
Lookalike bracket comment inside quoted argument [quoted_argument] Lookalike bracket comment inside quoted argument [quoted_argument]
@ -125,17 +139,19 @@ message("${var_${var}} #[[comment]]")
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (argument_list
(quoted_argument (argument
(quoted_element (quoted_argument
(variable_ref (normal_var (variable (variable_ref (normal_var (variable)))))) (quoted_element
(variable_ref (normal_var (variable (variable_ref (normal_var (variable))))))
)
)
)
) )
)
) )
) )
)
====================================================================== ======================================================================
Lookalike line comment inside quoted argument [quoted_argument] Lookalike line comment inside quoted argument [quoted_argument]
@ -145,17 +161,19 @@ message("${var_${var}} #comment")
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (argument_list
(quoted_argument (argument
(quoted_element (quoted_argument
(variable_ref (normal_var (variable (variable_ref (normal_var (variable)))))) (quoted_element
(variable_ref (normal_var (variable (variable_ref (normal_var (variable))))))
)
)
)
) )
)
) )
) )
)
=========================================================== ===========================================================
Lookalike variable inside quoted argument [quoted_argument] Lookalike variable inside quoted argument [quoted_argument]
@ -165,12 +183,14 @@ message("$var")
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (argument_list
(quoted_argument (argument
(quoted_element) (quoted_argument
) (quoted_element)
)
)
)
) )
) )
)

View file

@ -7,11 +7,13 @@ message(STATUS)
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (unquoted_argument)) (argument_list
) (argument (unquoted_argument))
) )
)
)
========================================================= =========================================================
Command invocation with two arguments [unquoted_argument] Command invocation with two arguments [unquoted_argument]
@ -22,12 +24,14 @@ message(STATUS Hello)
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) (argument (unquoted_argument))
) )
)
)
=============================================================== ===============================================================
Command invocations with leading seperation [unquoted_argument] Command invocations with leading seperation [unquoted_argument]
@ -39,15 +43,20 @@ STATUS)
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (unquoted_argument)) (argument_list
) (argument (unquoted_argument))
(normal_command )
(identifier) )
(argument (unquoted_argument)) (normal_command
) (identifier)
(argument_list
(argument (unquoted_argument))
)
)
) )
============================================================ ============================================================
Command invocations with escape sequence [unquoted_argument] Command invocations with escape sequence [unquoted_argument]
============================================================ ============================================================
@ -58,15 +67,19 @@ STATUS)
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (unquoted_argument)) (argument_list
) (argument (unquoted_argument))
(normal_command )
(identifier) )
(argument (unquoted_argument)) (normal_command
) (identifier)
) (argument_list
(argument (unquoted_argument))
)
)
)
======================================== ========================================
Variable referencing [unquoted_argument] Variable referencing [unquoted_argument]
@ -75,15 +88,17 @@ message(${var_ref})
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (argument_list
(unquoted_argument (argument
(variable_ref (normal_var (variable))) (unquoted_argument
) (variable_ref (normal_var (variable)))
)
)
)
) )
) )
)
==================================================================== ====================================================================
Variable referencing inside variable referencing [unquoted_argument] Variable referencing inside variable referencing [unquoted_argument]
@ -92,15 +107,17 @@ message(${var_${var_ref}})
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (argument_list
(unquoted_argument (argument
(variable_ref (normal_var (variable (variable_ref (normal_var (variable)))))) (unquoted_argument
) (variable_ref (normal_var (variable (variable_ref (normal_var (variable))))))
)
)
)
) )
) )
)
=============================================================== ===============================================================
Lookalike variable inside unquoted argument [unquoted_argument] Lookalike variable inside unquoted argument [unquoted_argument]
@ -110,10 +127,12 @@ message($var)
--- ---
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument (argument_list
(unquoted_argument) (argument
(unquoted_argument)
)
)
) )
)
) )

View file

@ -11,7 +11,9 @@ endwhile()
(while_loop (while_loop
(while_command (while_command
(while) (while)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument))
)
) )
(body) (body)
(endwhile_command (endwhile)) (endwhile_command (endwhile))
@ -31,7 +33,9 @@ endwhile(cond)
(while_loop (while_loop
(while_command (while_command
(while) (while)
(argument (unquoted_argument)) (argument_list
(argument (unquoted_argument))
)
) )
(body) (body)
(endwhile_command (endwhile_command

View file

@ -52,34 +52,35 @@ module.exports = grammar({
_unquoted_text: (_) => prec.left(repeat1(choice("$", /[^()#"\\']/))), _unquoted_text: (_) => prec.left(repeat1(choice("$", /[^()#"\\']/))),
body: ($) => prec.right(repeat1($._untrimmed_command_invocation)), body: ($) => prec.right(repeat1($._untrimmed_command_invocation)),
argument_list: ($) => repeat1($._untrimmed_argument),
if_command: ($) => command($.if, repeat($._untrimmed_argument)), if_command: ($) => command($.if, $.argument_list),
elseif_command: ($) => command($.elseif, repeat($._untrimmed_argument)), elseif_command: ($) => command($.elseif, $.argument_list),
else_command: ($) => command($.else, repeat($._untrimmed_argument)), else_command: ($) => command($.else, optional($.argument_list)),
endif_command: ($) => command($.endif, repeat($._untrimmed_argument)), endif_command: ($) => command($.endif, optional($.argument_list)),
if_condition: ($) => seq($.if_command, repeat(choice($.body, $.elseif_command, $.else_command)), $.endif_command), if_condition: ($) => seq($.if_command, repeat(choice($.body, $.elseif_command, $.else_command)), $.endif_command),
foreach_command: ($) => command($.foreach, repeat($._untrimmed_argument)), foreach_command: ($) => command($.foreach, $.argument_list),
endforeach_command: ($) => command($.endforeach, optional($.argument)), endforeach_command: ($) => command($.endforeach, optional($.argument)),
foreach_loop: ($) => seq($.foreach_command, $.body, $.endforeach_command), foreach_loop: ($) => seq($.foreach_command, $.body, $.endforeach_command),
while_command: ($) => command($.while, repeat($._untrimmed_argument)), while_command: ($) => command($.while, $.argument_list),
endwhile_command: ($) => command($.endwhile, optional(seq(/\s*/, $.argument, /\s*/))), endwhile_command: ($) => command($.endwhile, optional(seq(/\s*/, $.argument, /\s*/))),
while_loop: ($) => seq($.while_command, $.body, $.endwhile_command), while_loop: ($) => seq($.while_command, $.body, $.endwhile_command),
function_command: ($) => command($.function, repeat($._untrimmed_argument)), function_command: ($) => command($.function, $.argument_list),
endfunction_command: ($) => command($.endfunction, repeat($._untrimmed_argument)), endfunction_command: ($) => command($.endfunction, optional($.argument_list)),
function_def: ($) => seq($.function_command, $.body, $.endfunction_command), function_def: ($) => seq($.function_command, $.body, $.endfunction_command),
macro_command: ($) => command($.macro, repeat($._untrimmed_argument)), macro_command: ($) => command($.macro, $.argument_list),
endmacro_command: ($) => command($.endmacro, repeat($._untrimmed_argument)), endmacro_command: ($) => command($.endmacro, optional($.argument_list)),
macro_def: ($) => seq($.macro_command, $.body, $.endmacro_command), macro_def: ($) => seq($.macro_command, $.body, $.endmacro_command),
block_command: ($) => command($.block, repeat($._untrimmed_argument)), block_command: ($) => command($.block, $.argument_list),
endblock_command: ($) => command($.endblock, repeat($._untrimmed_argument)), endblock_command: ($) => command($.endblock, optional($.argument_list)),
block_def: ($) => seq($.block_command, $.body, $.endblock_command), block_def: ($) => seq($.block_command, $.body, $.endblock_command),
normal_command: ($) => command($.identifier, repeat($._untrimmed_argument)), normal_command: ($) => command($.identifier, optional($.argument_list)),
_command_invocation: ($) => _command_invocation: ($) =>
choice($.normal_command, $.if_condition, $.foreach_loop, $.while_loop, $.function_def, $.macro_def, $.block_def), choice($.normal_command, $.if_condition, $.foreach_loop, $.while_loop, $.function_def, $.macro_def, $.block_def),

View file

@ -444,6 +444,13 @@
} }
} }
}, },
"argument_list": {
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "_untrimmed_argument"
}
},
"if_command": { "if_command": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
@ -463,11 +470,8 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT", "type": "SYMBOL",
"content": { "name": "argument_list"
"type": "SYMBOL",
"name": "_untrimmed_argument"
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -494,11 +498,8 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT", "type": "SYMBOL",
"content": { "name": "argument_list"
"type": "SYMBOL",
"name": "_untrimmed_argument"
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -525,11 +526,16 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT", "type": "CHOICE",
"content": { "members": [
"type": "SYMBOL", {
"name": "_untrimmed_argument" "type": "SYMBOL",
} "name": "argument_list"
},
{
"type": "BLANK"
}
]
}, },
{ {
"type": "STRING", "type": "STRING",
@ -556,11 +562,16 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT", "type": "CHOICE",
"content": { "members": [
"type": "SYMBOL", {
"name": "_untrimmed_argument" "type": "SYMBOL",
} "name": "argument_list"
},
{
"type": "BLANK"
}
]
}, },
{ {
"type": "STRING", "type": "STRING",
@ -620,11 +631,8 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT", "type": "SYMBOL",
"content": { "name": "argument_list"
"type": "SYMBOL",
"name": "_untrimmed_argument"
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -704,11 +712,8 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT", "type": "SYMBOL",
"content": { "name": "argument_list"
"type": "SYMBOL",
"name": "_untrimmed_argument"
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -801,11 +806,8 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT", "type": "SYMBOL",
"content": { "name": "argument_list"
"type": "SYMBOL",
"name": "_untrimmed_argument"
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -832,11 +834,16 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT", "type": "CHOICE",
"content": { "members": [
"type": "SYMBOL", {
"name": "_untrimmed_argument" "type": "SYMBOL",
} "name": "argument_list"
},
{
"type": "BLANK"
}
]
}, },
{ {
"type": "STRING", "type": "STRING",
@ -880,11 +887,8 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT", "type": "SYMBOL",
"content": { "name": "argument_list"
"type": "SYMBOL",
"name": "_untrimmed_argument"
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -911,11 +915,16 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT", "type": "CHOICE",
"content": { "members": [
"type": "SYMBOL", {
"name": "_untrimmed_argument" "type": "SYMBOL",
} "name": "argument_list"
},
{
"type": "BLANK"
}
]
}, },
{ {
"type": "STRING", "type": "STRING",
@ -959,11 +968,8 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT", "type": "SYMBOL",
"content": { "name": "argument_list"
"type": "SYMBOL",
"name": "_untrimmed_argument"
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -990,11 +996,16 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT", "type": "CHOICE",
"content": { "members": [
"type": "SYMBOL", {
"name": "_untrimmed_argument" "type": "SYMBOL",
} "name": "argument_list"
},
{
"type": "BLANK"
}
]
}, },
{ {
"type": "STRING", "type": "STRING",
@ -1038,11 +1049,16 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT", "type": "CHOICE",
"content": { "members": [
"type": "SYMBOL", {
"name": "_untrimmed_argument" "type": "SYMBOL",
} "name": "argument_list"
},
{
"type": "BLANK"
}
]
}, },
{ {
"type": "STRING", "type": "STRING",

View file

@ -23,21 +23,17 @@
} }
}, },
{ {
"type": "block_command", "type": "argument_list",
"named": true, "named": true,
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": true, "required": false,
"types": [ "types": [
{ {
"type": "argument", "type": "argument",
"named": true "named": true
}, },
{
"type": "block",
"named": true
},
{ {
"type": "bracket_comment", "type": "bracket_comment",
"named": true "named": true
@ -49,6 +45,25 @@
] ]
} }
}, },
{
"type": "block_command",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "argument_list",
"named": true
},
{
"type": "block",
"named": true
}
]
}
},
{ {
"type": "block_def", "type": "block_def",
"named": true, "named": true,
@ -143,20 +158,12 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "argument", "type": "argument_list",
"named": true
},
{
"type": "bracket_comment",
"named": true "named": true
}, },
{ {
"type": "else", "type": "else",
"named": true "named": true
},
{
"type": "line_comment",
"named": true
} }
] ]
} }
@ -170,20 +177,12 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "argument", "type": "argument_list",
"named": true
},
{
"type": "bracket_comment",
"named": true "named": true
}, },
{ {
"type": "elseif", "type": "elseif",
"named": true "named": true
},
{
"type": "line_comment",
"named": true
} }
] ]
} }
@ -197,20 +196,12 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "argument", "type": "argument_list",
"named": true
},
{
"type": "bracket_comment",
"named": true "named": true
}, },
{ {
"type": "endblock", "type": "endblock",
"named": true "named": true
},
{
"type": "line_comment",
"named": true
} }
] ]
} }
@ -243,20 +234,12 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "argument", "type": "argument_list",
"named": true
},
{
"type": "bracket_comment",
"named": true "named": true
}, },
{ {
"type": "endfunction", "type": "endfunction",
"named": true "named": true
},
{
"type": "line_comment",
"named": true
} }
] ]
} }
@ -270,20 +253,12 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "argument", "type": "argument_list",
"named": true
},
{
"type": "bracket_comment",
"named": true "named": true
}, },
{ {
"type": "endif", "type": "endif",
"named": true "named": true
},
{
"type": "line_comment",
"named": true
} }
] ]
} }
@ -297,20 +272,12 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "argument", "type": "argument_list",
"named": true
},
{
"type": "bracket_comment",
"named": true "named": true
}, },
{ {
"type": "endmacro", "type": "endmacro",
"named": true "named": true
},
{
"type": "line_comment",
"named": true
} }
] ]
} }
@ -363,20 +330,12 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "argument", "type": "argument_list",
"named": true
},
{
"type": "bracket_comment",
"named": true "named": true
}, },
{ {
"type": "foreach", "type": "foreach",
"named": true "named": true
},
{
"type": "line_comment",
"named": true
} }
] ]
} }
@ -413,20 +372,12 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "argument", "type": "argument_list",
"named": true
},
{
"type": "bracket_comment",
"named": true "named": true
}, },
{ {
"type": "function", "type": "function",
"named": true "named": true
},
{
"type": "line_comment",
"named": true
} }
] ]
} }
@ -478,20 +429,12 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "argument", "type": "argument_list",
"named": true
},
{
"type": "bracket_comment",
"named": true "named": true
}, },
{ {
"type": "if", "type": "if",
"named": true "named": true
},
{
"type": "line_comment",
"named": true
} }
] ]
} }
@ -536,15 +479,7 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "argument", "type": "argument_list",
"named": true
},
{
"type": "bracket_comment",
"named": true
},
{
"type": "line_comment",
"named": true "named": true
}, },
{ {
@ -586,20 +521,12 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "argument", "type": "argument_list",
"named": true
},
{
"type": "bracket_comment",
"named": true "named": true
}, },
{ {
"type": "identifier", "type": "identifier",
"named": true "named": true
},
{
"type": "line_comment",
"named": true
} }
] ]
} }
@ -778,15 +705,7 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "argument", "type": "argument_list",
"named": true
},
{
"type": "bracket_comment",
"named": true
},
{
"type": "line_comment",
"named": true "named": true
}, },
{ {

33379
src/parser.c

File diff suppressed because it is too large Load diff