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,10 +10,12 @@ endfunction()
(function_def (function_def
(function_command (function_command
(function) (function)
(argument_list
(argument (argument
(unquoted_argument) (unquoted_argument)
) )
) )
)
(body) (body)
(endfunction_command (endfunction_command
(endfunction) (endfunction)
@ -33,6 +35,7 @@ endfunction()
(function_def (function_def
(function_command (function_command
(function) (function)
(argument_list
(argument (argument
(unquoted_argument) (unquoted_argument)
) )
@ -46,6 +49,7 @@ endfunction()
(unquoted_argument) (unquoted_argument)
) )
) )
)
(body) (body)
(endfunction_command (endfunction_command
(endfunction) (endfunction)
@ -65,10 +69,12 @@ endmacro()
(macro_def (macro_def
(macro_command (macro_command
(macro) (macro)
(argument_list
(argument (argument
(unquoted_argument) (unquoted_argument)
) )
) )
)
(body) (body)
(endmacro_command (endmacro_command
(endmacro) (endmacro)
@ -88,6 +94,7 @@ endmacro()
(macro_def (macro_def
(macro_command (macro_command
(macro) (macro)
(argument_list
(argument (argument
(unquoted_argument) (unquoted_argument)
) )
@ -101,6 +108,7 @@ endmacro()
(unquoted_argument) (unquoted_argument)
) )
) )
)
(body) (body)
(endmacro_command (endmacro_command
(endmacro) (endmacro)
@ -120,6 +128,7 @@ endblock()
(block_def (block_def
(block_command (block_command
(block) (block)
(argument_list
(argument (argument
(unquoted_argument) (unquoted_argument)
) )
@ -136,6 +145,7 @@ endblock()
(unquoted_argument) (unquoted_argument)
) )
) )
)
(body) (body)
(endblock_command (endblock_command
(endblock) (endblock)
@ -156,18 +166,22 @@ endfunction()
(function_def (function_def
(function_command (function_command
(function) (function)
(argument_list
(argument (argument
(unquoted_argument) (unquoted_argument)
) )
) )
)
(body (body
(function_def (function_def
(function_command (function_command
(function) (function)
(argument_list
(argument (argument
(unquoted_argument) (unquoted_argument)
) )
) )
)
(body) (body)
(endfunction_command (endfunction_command
(endfunction) (endfunction)

View file

@ -8,9 +8,11 @@ message([[]])
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (bracket_argument)) (argument (bracket_argument))
) )
) )
)
======================================= =======================================
One bracket argument [bracket_argument] One bracket argument [bracket_argument]
@ -22,9 +24,11 @@ message([[an argument]])
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (bracket_argument)) (argument (bracket_argument))
) )
) )
)
======================================== ========================================
Two bracket arguments [bracket_argument] Two bracket arguments [bracket_argument]
@ -36,10 +40,12 @@ message([[first argument]] [[second argument]])
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (bracket_argument)) (argument (bracket_argument))
(argument (bracket_argument)) (argument (bracket_argument))
) )
) )
)
======================================================== ========================================================
Two bracket with two equals arguments [bracket_argument] Two bracket with two equals arguments [bracket_argument]
@ -54,10 +60,12 @@ message(
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (bracket_argument)) (argument (bracket_argument))
(argument (bracket_argument)) (argument (bracket_argument))
) )
) )
)
=================================================== ===================================================
Bracket argument with line break [bracket_argument] Bracket argument with line break [bracket_argument]
@ -71,9 +79,11 @@ with line break
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (bracket_argument)) (argument (bracket_argument))
) )
) )
)
===================================================================================== =====================================================================================
Bracket argument with embedded brackets and equal signs line break [bracket_argument] Bracket argument with embedded brackets and equal signs line break [bracket_argument]
@ -87,7 +97,9 @@ with line break ]==]
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (bracket_argument)) (argument (bracket_argument))
) )
) )
)

View file

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

View file

@ -10,8 +10,10 @@ endif()
(if_condition (if_condition
(if_command (if_command
(if) (if)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(body) (body)
(endif_command (endif)) (endif_command (endif))
) )
@ -30,13 +32,17 @@ endif()
(if_condition (if_condition
(if_command (if_command
(if) (if)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(body) (body)
(elseif_command (elseif_command
(elseif) (elseif)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(body) (body)
(endif_command (endif)) (endif_command (endif))
) )
@ -56,13 +62,17 @@ endif()
(if_condition (if_condition
(if_command (if_command
(if) (if)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(body) (body)
(elseif_command (elseif_command
(elseif) (elseif)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(body) (body)
(else_command (else)) (else_command (else))
(body) (body)
@ -84,18 +94,24 @@ endif()
(if_condition (if_condition
(if_command (if_command
(if) (if)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(body (body
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
) )
)
(endif_command (endif)) (endif_command (endif))
) )
) )
@ -120,46 +136,64 @@ endif()
(if_condition (if_condition
(if_command (if_command
(if) (if)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(body (body
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
) )
)
(elseif_command (elseif_command
(elseif) (elseif)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(body (body
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
) )
)
(else_command (else_command
(else) (else)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(body (body
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
) )
)
(endif_command (endif)) (endif_command (endif))
) )
) )
@ -175,12 +209,14 @@ endif()
(if_condition (if_condition
(if_command (if_command
(if) (if)
(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))
) )
)
(body) (body)
(endif_command (endif)) (endif_command (endif))
) )
@ -197,6 +233,7 @@ endif(NOT (A AND B) OR C)
(if_condition (if_condition
(if_command (if_command
(if) (if)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
@ -204,9 +241,11 @@ endif(NOT (A AND B) OR C)
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(body) (body)
(else_command (else_command
(else) (else)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
@ -214,9 +253,11 @@ endif(NOT (A AND B) OR C)
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(body) (body)
(endif_command (endif_command
(endif) (endif)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
@ -225,6 +266,7 @@ endif(NOT (A AND B) OR C)
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
) )
)
) )
============================ ============================
@ -241,14 +283,18 @@ endif()
(if_condition (if_condition
(if_command (if_command
(if) (if)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(body (body
(if_condition (if_condition
(if_command (if_command
(if) (if)
(argument_list
(argument (unquoted_argument)) (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_list
(argument (argument
(unquoted_argument)) (unquoted_argument))
(argument (argument
(quoted_argument (quoted_argument
(quoted_element (quoted_element
(escape_sequence) (escape_sequence)
(escape_sequence)))))) (escape_sequence)
)
)
)
)
)
)

View file

@ -11,12 +11,14 @@ endforeach()
(foreach_loop (foreach_loop
(foreach_command (foreach_command
(foreach) (foreach)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(body) (body)
(endforeach_command (endforeach)) (endforeach_command (endforeach))
) )
) )
=============================================================== ===============================================================
Empty foreach loop with one argument endforeach [foreach] Empty foreach loop with one argument endforeach [foreach]
@ -31,14 +33,17 @@ endforeach(var)
(foreach_loop (foreach_loop
(foreach_command (foreach_command
(foreach) (foreach)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(body) (body)
(endforeach_command (endforeach_command
(endforeach) (endforeach)
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)) )
)
================================= =================================
Uppercase foreach [foreach] Uppercase foreach [foreach]
@ -53,12 +58,14 @@ ENDFOREACH()
(foreach_loop (foreach_loop
(foreach_command (foreach_command
(foreach) (foreach)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(body) (body)
(endforeach_command (endforeach)) (endforeach_command (endforeach))
) )
) )
================================== ==================================
Mixed case foreach [foreach] Mixed case foreach [foreach]
@ -73,12 +80,14 @@ endForEach()
(foreach_loop (foreach_loop
(foreach_command (foreach_command
(foreach) (foreach)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(body) (body)
(endforeach_command (endforeach)) (endforeach_command (endforeach))
) )
) )
================================== ==================================
Empty IN [foreach] Empty IN [foreach]
@ -93,13 +102,15 @@ endforeach()
(foreach_loop (foreach_loop
(foreach_command (foreach_command
(foreach) (foreach)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(body) (body)
(endforeach_command (endforeach)) (endforeach_command (endforeach))
) )
) )
================================== ==================================
Empty RANGE [foreach] Empty RANGE [foreach]
@ -114,10 +125,12 @@ endforeach()
(foreach_loop (foreach_loop
(foreach_command (foreach_command
(foreach) (foreach)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(body) (body)
(endforeach_command (endforeach)) (endforeach_command (endforeach))
) )
) )

View file

@ -9,10 +9,12 @@ add_custom_target(OUTPUT somefile)
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (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]
@ -26,7 +28,9 @@ add_custom_target(
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (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_list
(argument (argument
(unquoted_argument (unquoted_argument
(gen_exp))))) (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_list
(argument (argument
(quoted_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_list
(argument (argument
(unquoted_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_list
(argument (argument
(unquoted_argument (unquoted_argument
(gen_exp (gen_exp
(argument (argument
(unquoted_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_list
(argument (argument
(unquoted_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,6 +124,7 @@ message($<AND:TRUE,FALSE>)
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (argument
(unquoted_argument (unquoted_argument
(gen_exp (gen_exp
@ -95,4 +133,11 @@ message($<AND:TRUE,FALSE>)
(argument (argument
(unquoted_argument)) (unquoted_argument))
(argument (argument
(unquoted_argument))))))) (unquoted_argument)
)
)
)
)
)
)
)

View file

@ -10,7 +10,7 @@ message()
(normal_command (normal_command
(identifier) (identifier)
) )
) )
================================= =================================
No argument with spaces [message] No argument with spaces [message]
@ -23,8 +23,9 @@ 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]
@ -39,8 +40,9 @@ 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,10 +55,12 @@ message(STATUS [=[Some argument ]==] ]=] )
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (bracket_argument)) (argument (bracket_argument))
) )
) )
)
============================================================== ==============================================================
Message with STATUS and bracket argument and newline [message] Message with STATUS and bracket argument and newline [message]
@ -71,10 +75,12 @@ message(STATUS
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (bracket_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_list
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
) )
)

View file

@ -6,9 +6,11 @@ message(STATUS (TEST))
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (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_list
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (MISSING ")") (argument (unquoted_argument))
)
(MISSING ")")
) )
) )
@ -32,8 +37,11 @@ message(STATUS ((TEST))
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (MISSING ")") (argument (unquoted_argument))
)
(MISSING ")")
) )
) )
@ -45,8 +53,10 @@ message(STATUS (TEST SECOND_TEST))
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
) )

View file

@ -8,9 +8,11 @@ message("")
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (quoted_argument)) (argument (quoted_argument))
) )
) )
)
===================================== =====================================
One quoted argument [quoted_argument] One quoted argument [quoted_argument]
@ -22,9 +24,11 @@ message("An argument")
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (quoted_argument (quoted_element))) (argument (quoted_argument (quoted_element)))
) )
) )
)
====================================== ======================================
Two quoted arguments [quoted_argument] Two quoted arguments [quoted_argument]
@ -36,10 +40,12 @@ message("First argument" "Second argument")
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (quoted_argument (quoted_element))) (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]
@ -52,9 +58,11 @@ with line break")
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (quoted_argument (quoted_element))) (argument (quoted_argument (quoted_element)))
) )
) )
)
======================================== ========================================
One variable reference [quoted_argument] One variable reference [quoted_argument]
@ -66,6 +74,7 @@ message("${var}")
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (argument
(quoted_argument (quoted_argument
(quoted_element (quoted_element
@ -75,6 +84,7 @@ message("${var}")
) )
) )
) )
)
========================================= =========================================
Two Variable references [quoted_argument] Two Variable references [quoted_argument]
@ -86,6 +96,7 @@ message("${var} ${var}")
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (argument
(quoted_argument (quoted_argument
(quoted_element (quoted_element
@ -96,6 +107,7 @@ message("${var} ${var}")
) )
) )
) )
)
====================================================================== ======================================================================
Variable reference inside another variable reference [quoted_argument] Variable reference inside another variable reference [quoted_argument]
@ -107,6 +119,7 @@ message("${var_${var}}")
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (argument
(quoted_argument (quoted_argument
(quoted_element (quoted_element
@ -116,6 +129,7 @@ message("${var_${var}}")
) )
) )
) )
)
====================================================================== ======================================================================
Lookalike bracket comment inside quoted argument [quoted_argument] Lookalike bracket comment inside quoted argument [quoted_argument]
@ -127,6 +141,7 @@ message("${var_${var}} #[[comment]]")
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (argument
(quoted_argument (quoted_argument
(quoted_element (quoted_element
@ -136,6 +151,7 @@ message("${var_${var}} #[[comment]]")
) )
) )
) )
)
====================================================================== ======================================================================
Lookalike line comment inside quoted argument [quoted_argument] Lookalike line comment inside quoted argument [quoted_argument]
@ -147,6 +163,7 @@ message("${var_${var}} #comment")
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (argument
(quoted_argument (quoted_argument
(quoted_element (quoted_element
@ -156,6 +173,7 @@ message("${var_${var}} #comment")
) )
) )
) )
)
=========================================================== ===========================================================
Lookalike variable inside quoted argument [quoted_argument] Lookalike variable inside quoted argument [quoted_argument]
@ -167,6 +185,7 @@ message("$var")
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (argument
(quoted_argument (quoted_argument
(quoted_element) (quoted_element)
@ -174,3 +193,4 @@ message("$var")
) )
) )
) )
)

View file

@ -9,9 +9,11 @@ message(STATUS)
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
) )
)
========================================================= =========================================================
Command invocation with two arguments [unquoted_argument] Command invocation with two arguments [unquoted_argument]
@ -24,10 +26,12 @@ message(STATUS Hello)
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
) )
)
=============================================================== ===============================================================
Command invocations with leading seperation [unquoted_argument] Command invocations with leading seperation [unquoted_argument]
@ -41,13 +45,18 @@ STATUS)
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
) )
============================================================ ============================================================
Command invocations with escape sequence [unquoted_argument] Command invocations with escape sequence [unquoted_argument]
============================================================ ============================================================
@ -60,13 +69,17 @@ STATUS)
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
)
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (unquoted_argument)) (argument (unquoted_argument))
) )
) )
)
======================================== ========================================
Variable referencing [unquoted_argument] Variable referencing [unquoted_argument]
@ -77,6 +90,7 @@ message(${var_ref})
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (argument
(unquoted_argument (unquoted_argument
(variable_ref (normal_var (variable))) (variable_ref (normal_var (variable)))
@ -84,6 +98,7 @@ message(${var_ref})
) )
) )
) )
)
==================================================================== ====================================================================
Variable referencing inside variable referencing [unquoted_argument] Variable referencing inside variable referencing [unquoted_argument]
@ -94,6 +109,7 @@ message(${var_${var_ref}})
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (argument
(unquoted_argument (unquoted_argument
(variable_ref (normal_var (variable (variable_ref (normal_var (variable)))))) (variable_ref (normal_var (variable (variable_ref (normal_var (variable))))))
@ -101,6 +117,7 @@ message(${var_${var_ref}})
) )
) )
) )
)
=============================================================== ===============================================================
Lookalike variable inside unquoted argument [unquoted_argument] Lookalike variable inside unquoted argument [unquoted_argument]
@ -112,8 +129,10 @@ message($var)
(source_file (source_file
(normal_command (normal_command
(identifier) (identifier)
(argument_list
(argument (argument
(unquoted_argument) (unquoted_argument)
) )
) )
)
) )

View file

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

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",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_untrimmed_argument" "name": "argument_list"
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -494,11 +498,8 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_untrimmed_argument" "name": "argument_list"
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -525,11 +526,16 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT", "type": "CHOICE",
"content": { "members": [
{
"type": "SYMBOL", "type": "SYMBOL",
"name": "_untrimmed_argument" "name": "argument_list"
},
{
"type": "BLANK"
} }
]
}, },
{ {
"type": "STRING", "type": "STRING",
@ -556,11 +562,16 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT", "type": "CHOICE",
"content": { "members": [
{
"type": "SYMBOL", "type": "SYMBOL",
"name": "_untrimmed_argument" "name": "argument_list"
},
{
"type": "BLANK"
} }
]
}, },
{ {
"type": "STRING", "type": "STRING",
@ -620,11 +631,8 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_untrimmed_argument" "name": "argument_list"
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -704,11 +712,8 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_untrimmed_argument" "name": "argument_list"
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -801,11 +806,8 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_untrimmed_argument" "name": "argument_list"
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -832,11 +834,16 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT", "type": "CHOICE",
"content": { "members": [
{
"type": "SYMBOL", "type": "SYMBOL",
"name": "_untrimmed_argument" "name": "argument_list"
},
{
"type": "BLANK"
} }
]
}, },
{ {
"type": "STRING", "type": "STRING",
@ -880,11 +887,8 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_untrimmed_argument" "name": "argument_list"
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -911,11 +915,16 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT", "type": "CHOICE",
"content": { "members": [
{
"type": "SYMBOL", "type": "SYMBOL",
"name": "_untrimmed_argument" "name": "argument_list"
},
{
"type": "BLANK"
} }
]
}, },
{ {
"type": "STRING", "type": "STRING",
@ -959,11 +968,8 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_untrimmed_argument" "name": "argument_list"
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -990,11 +996,16 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT", "type": "CHOICE",
"content": { "members": [
{
"type": "SYMBOL", "type": "SYMBOL",
"name": "_untrimmed_argument" "name": "argument_list"
},
{
"type": "BLANK"
} }
]
}, },
{ {
"type": "STRING", "type": "STRING",
@ -1038,11 +1049,16 @@
"value": "(" "value": "("
}, },
{ {
"type": "REPEAT", "type": "CHOICE",
"content": { "members": [
{
"type": "SYMBOL", "type": "SYMBOL",
"name": "_untrimmed_argument" "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