Files
tree-sitter-jhcl/test/corpus/templates.txt

770 lines
25 KiB
Plaintext
Raw Normal View History

================================================================================
simple quoted template expression
================================================================================
foo = "${ var.bar }"
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(quoted_template
(quoted_template_start)
(template_interpolation
(template_interpolation_start)
(expression
(variable_expr
(identifier))
(get_attr
(identifier)))
(template_interpolation_end))
(quoted_template_end)))))))
================================================================================
2021-06-27 15:54:15 +02:00
empty template interpolation
================================================================================
foo = "${}"
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(quoted_template
(quoted_template_start)
(template_interpolation
(template_interpolation_start)
(template_interpolation_end))
(quoted_template_end)))))))
2021-09-17 20:53:40 +02:00
================================================================================
template for expression in quoted template
================================================================================
foo = "%{ for a in b } prefix-${a} %{ endfor }"
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(quoted_template
(quoted_template_start)
(template_directive
(template_for
(template_for_start
(template_directive_start)
(identifier)
(expression
(variable_expr
(identifier)))
(template_directive_end))
(template_literal)
(template_interpolation
(template_interpolation_start)
(expression
(variable_expr
(identifier)))
(template_interpolation_end))
(template_for_end
(template_directive_start)
(template_directive_end))))
(quoted_template_end)))))))
================================================================================
escaped template for directive
================================================================================
foo = "%{ for a in b } %%{ endfor } %{ endfor }"
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(quoted_template
(quoted_template_start)
(template_directive
(template_for
(template_for_start
(template_directive_start)
(identifier)
(expression
(variable_expr
(identifier)))
(template_directive_end))
(template_literal)
(template_for_end
(template_directive_start)
(template_directive_end))))
(quoted_template_end)))))))
================================================================================
escaped template for directive 2
================================================================================
foo = "%%{ for a in b } %%{ endfor }"
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(literal_value
(string_lit
(quoted_template_start)
(template_literal)
(quoted_template_end)))))))
================================================================================
template for directive with weird whitespace
================================================================================
foo = "%{ for a in b } %{ endfor }"
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(quoted_template
(quoted_template_start)
(template_directive
(template_for
(template_for_start
(template_directive_start)
(identifier)
(expression
(variable_expr
(identifier)))
(template_directive_end))
(template_for_end
(template_directive_start)
(template_directive_end))))
(quoted_template_end)))))))
================================================================================
template for expression in heredoc template
================================================================================
foo = <<EOF
%{ for a in b ~}
prefix-${a}
%{~ endfor }
EOF
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(heredoc_template
(heredoc_start)
(heredoc_identifier)
(template_directive
(template_for
(template_for_start
(template_directive_start)
(identifier)
(expression
(variable_expr
(identifier)))
(strip_marker)
(template_directive_end))
(template_literal)
(template_interpolation
(template_interpolation_start)
(expression
(variable_expr
(identifier)))
(template_interpolation_end))
(template_for_end
(template_directive_start)
(strip_marker)
(template_directive_end))))
(heredoc_identifier)))))))
2021-06-27 15:54:15 +02:00
================================================================================
empty heredoc template
================================================================================
foo = <<END
END
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(heredoc_template
(heredoc_start)
(heredoc_identifier)
(heredoc_identifier)))))))
================================================================================
heredoc with fake ending
================================================================================
foo = <<END
END not!
END
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(heredoc_template
(heredoc_start)
(heredoc_identifier)
(template_literal)
(heredoc_identifier)))))))
================================================================================
quoted template expression with escaped strings and fake strip marker
================================================================================
foo = "${ " ~ " }"
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(quoted_template
(quoted_template_start)
(template_interpolation
(template_interpolation_start)
(expression
(literal_value
(string_lit
(quoted_template_start)
(template_literal)
(quoted_template_end))))
(template_interpolation_end))
(quoted_template_end)))))))
================================================================================
quoted template with nested quoted template
================================================================================
foo = "p-${ foo("v-${a.b}") }"
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(quoted_template
(quoted_template_start)
(template_literal)
(template_interpolation
(template_interpolation_start)
(expression
(function_call
(identifier)
(function_arguments
(expression
(template_expr
(quoted_template
(quoted_template_start)
(template_literal)
(template_interpolation
(template_interpolation_start)
(expression
(variable_expr
(identifier))
(get_attr
(identifier)))
(template_interpolation_end))
(quoted_template_end)))))))
(template_interpolation_end))
(quoted_template_end)))))))
================================================================================
quoted template interpolation with strip markers
================================================================================
foo = "hello ${~ "world" ~} hello"
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(quoted_template
(quoted_template_start)
(template_literal)
(template_interpolation
(template_interpolation_start)
(strip_marker)
(expression
(literal_value
(string_lit
(quoted_template_start)
(template_literal)
(quoted_template_end))))
(strip_marker)
(template_interpolation_end))
(template_literal)
(quoted_template_end)))))))
================================================================================
quoted template object expression in template
================================================================================
foo = "${ {a=b}[a] }"
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(quoted_template
(quoted_template_start)
(template_interpolation
(template_interpolation_start)
(expression
(collection_value
(object
(object_start)
(object_elem
2021-06-18 07:20:55 +02:00
(expression
(variable_expr
(identifier)))
(expression
(variable_expr
(identifier))))
(object_end)))
(index
(new_index
(expression
(variable_expr
(identifier))))))
(template_interpolation_end))
(quoted_template_end)))))))
================================================================================
escaped template interpolation start
================================================================================
foo = "hello $${ world"
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(literal_value
(string_lit
(quoted_template_start)
(template_literal)
(quoted_template_end)))))))
================================================================================
tricky heredoc
================================================================================
foo = <<END
contains fake endings
END (ineligible) END
END
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(heredoc_template
(heredoc_start)
(heredoc_identifier)
(template_literal)
(heredoc_identifier)))))))
================================================================================
heredoc with identifier that does not fit into the serialization buffer (should not crash)
================================================================================
foo = <<XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(heredoc_template
(heredoc_start)
(heredoc_identifier)
(heredoc_identifier)))))))
2021-09-19 13:25:57 +02:00
================================================================================
template if directive in quoted template
================================================================================
2022-12-02 19:47:43 +01:00
foo = "%{if cond} foo %{else} bar %{endif}"
2021-09-19 13:25:57 +02:00
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(quoted_template
(quoted_template_start)
(template_directive
(template_if
2022-12-02 19:47:43 +01:00
(template_if_intro
(template_directive_start)
(expression
(variable_expr
(identifier)))
(template_directive_end))
(template_literal)
(template_else_intro
(template_directive_start)
(template_directive_end))
(template_literal)
(template_if_end
(template_directive_start)
(template_directive_end))))
(quoted_template_end)))))))
================================================================================
template nested for directives with interlaced chunks
================================================================================
foo = "%{for a in b} x %{for c in a} ${c} %{endfor} %{endfor}"
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(quoted_template
(quoted_template_start)
(template_directive
(template_for
(template_for_start
(template_directive_start)
(identifier)
(expression
(variable_expr
(identifier)))
(template_directive_end))
(template_literal)
(template_directive
(template_for
(template_for_start
(template_directive_start)
(identifier)
(expression
(variable_expr
(identifier)))
(template_directive_end))
(template_interpolation
(template_interpolation_start)
(expression
(variable_expr
(identifier)))
(template_interpolation_end))
(template_for_end
(template_directive_start)
(template_directive_end))))
(template_for_end
(template_directive_start)
(template_directive_end))))
(quoted_template_end)))))))
================================================================================
template nested if directives with interlaced chunks
================================================================================
foo = "%{if a} %{if b} y %{else} x %{endif} %{endif}"
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(quoted_template
(quoted_template_start)
(template_directive
(template_if
(template_if_intro
(template_directive_start)
(expression
(variable_expr
(identifier)))
(template_directive_end))
(template_directive
(template_if
(template_if_intro
(template_directive_start)
(expression
(variable_expr
(identifier)))
(template_directive_end))
(template_literal)
(template_else_intro
(template_directive_start)
(template_directive_end))
(template_literal)
(template_if_end
(template_directive_start)
(template_directive_end))))
(template_if_end
(template_directive_start)
(template_directive_end))))
(quoted_template_end)))))))
================================================================================
template empty if else statement
================================================================================
foo = "%{if a} %{else} %{endif}"
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(quoted_template
(quoted_template_start)
(template_directive
(template_if
(template_if_intro
(template_directive_start)
(expression
(variable_expr
(identifier)))
(template_directive_end))
(template_else_intro
(template_directive_start)
(template_directive_end))
2021-09-19 13:25:57 +02:00
(template_if_end
(template_directive_start)
(template_directive_end))))
(quoted_template_end)))))))
2022-12-02 19:47:43 +01:00
================================================================================
template empty for statement
================================================================================
foo = "%{for a in b} %{endfor}"
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(quoted_template
(quoted_template_start)
(template_directive
(template_for
(template_for_start
(template_directive_start)
(identifier)
(expression
(variable_expr
(identifier)))
(template_directive_end))
(template_for_end
(template_directive_start)
(template_directive_end))))
(quoted_template_end)))))))
================================================================================
template parenthesis in heredoc for directive with nested if 1
================================================================================
tpl6 = <<-EOF
%{ for a in f(b) ~}
( %{~if a~} "true" %{~else~} "false" %{~endif~} )
%{ endfor ~}
EOF
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(heredoc_template
(heredoc_start)
(heredoc_identifier)
(template_directive
(template_for
(template_for_start
(template_directive_start)
(identifier)
(expression
(function_call
(identifier)
(function_arguments
(expression
(variable_expr
(identifier))))))
(strip_marker)
(template_directive_end))
(template_literal)
(template_directive
(template_if
(template_if_intro
(template_directive_start)
(strip_marker)
(expression
(variable_expr
(identifier)))
(strip_marker)
(template_directive_end))
(template_literal)
(template_else_intro
(template_directive_start)
(strip_marker)
(strip_marker)
(template_directive_end))
(template_literal)
(template_if_end
(template_directive_start)
(strip_marker)
(strip_marker)
(template_directive_end))))
(template_literal)
(template_for_end
(template_directive_start)
(strip_marker)
(template_directive_end))))
(heredoc_identifier)))))))
================================================================================
template parenthesis in heredoc for directive with nested if 2
================================================================================
tpl6 = <<-EOF
%{ for a in f(b) ~}
("foo")
%{~if a~} "true" %{~else~} "false" %{~endif~}
%{ endfor ~}
EOF
--------------------------------------------------------------------------------
(config_file
(body
(attribute
(identifier)
(expression
(template_expr
(heredoc_template
(heredoc_start)
(heredoc_identifier)
(template_directive
(template_for
(template_for_start
(template_directive_start)
(identifier)
(expression
(function_call
(identifier)
(function_arguments
(expression
(variable_expr
(identifier))))))
(strip_marker)
(template_directive_end))
(template_literal)
(template_directive
(template_if
(template_if_intro
(template_directive_start)
(strip_marker)
(expression
(variable_expr
(identifier)))
(strip_marker)
(template_directive_end))
(template_literal)
(template_else_intro
(template_directive_start)
(strip_marker)
(strip_marker)
(template_directive_end))
(template_literal)
(template_if_end
(template_directive_start)
(strip_marker)
(strip_marker)
(template_directive_end))))
(template_for_end
(template_directive_start)
(strip_marker)
(template_directive_end))))
(heredoc_identifier)))))))