tree-sitter-tiger/test/corpus/control_flow.txt

144 lines
3.9 KiB
Plaintext
Raw Normal View History

2022-06-01 20:18:10 +02:00
================================================================================
If then else
================================================================================
if 12 then 27 else 42
--------------------------------------------------------------------------------
(source_file
(if_expression
condition: (integer_literal)
consequence: (integer_literal)
alternative: (integer_literal)))
================================================================================
If then
================================================================================
if 12 then 27
--------------------------------------------------------------------------------
(source_file
(if_expression
condition: (integer_literal)
consequence: (integer_literal)))
================================================================================
Dangling else
================================================================================
if 12 then if 27 then 42 else "nope"
--------------------------------------------------------------------------------
(source_file
(if_expression
condition: (integer_literal)
consequence: (if_expression
condition: (integer_literal)
consequence: (integer_literal)
alternative: (string_literal))))
2022-06-01 20:19:56 +02:00
================================================================================
While
================================================================================
while 12 do 27
--------------------------------------------------------------------------------
(source_file
(while_expression
condition: (integer_literal)
body: (integer_literal)))
2022-06-01 20:23:04 +02:00
================================================================================
For
================================================================================
for i := 12 to nil do "42"
--------------------------------------------------------------------------------
(source_file
(for_expression
index: (identifier)
2022-06-03 11:42:57 +02:00
(operator)
2022-06-01 20:23:04 +02:00
start: (integer_literal)
end: (nil_literal)
body: (string_literal)))
================================================================================
For no index
================================================================================
for 12 to nil do "42"
--------------------------------------------------------------------------------
(source_file
(ERROR
(identifier)
(identifier)
(nil_literal))
(string_literal))
================================================================================
For no end
================================================================================
for 12 do "42"
--------------------------------------------------------------------------------
(source_file
(ERROR
(identifier)
(identifier))
(string_literal))
================================================================================
For no body
================================================================================
for 12 to nil
--------------------------------------------------------------------------------
(source_file
(ERROR
(identifier)
(identifier))
(nil_literal))
2022-06-01 20:23:46 +02:00
================================================================================
Break
================================================================================
break
--------------------------------------------------------------------------------
(source_file
(break_expression))
================================================================================
Break in loops
================================================================================
for i := break to break do while break do break
--------------------------------------------------------------------------------
(source_file
(for_expression
(identifier)
2022-06-03 11:42:57 +02:00
(operator)
2022-06-01 20:23:46 +02:00
(break_expression)
(break_expression)
(while_expression
(break_expression)
(break_expression))))