142 lines
3.8 KiB
Plaintext
142 lines
3.8 KiB
Plaintext
================================================================================
|
|
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))))
|
|
|
|
================================================================================
|
|
While
|
|
================================================================================
|
|
|
|
while 12 do 27
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(source_file
|
|
(while_expression
|
|
condition: (integer_literal)
|
|
body: (integer_literal)))
|
|
|
|
================================================================================
|
|
For
|
|
================================================================================
|
|
|
|
for i := 12 to nil do "42"
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(source_file
|
|
(for_expression
|
|
index: (identifier)
|
|
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))
|
|
|
|
================================================================================
|
|
Break
|
|
================================================================================
|
|
|
|
break
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(source_file
|
|
(break_expression))
|
|
|
|
================================================================================
|
|
Break in loops
|
|
================================================================================
|
|
|
|
for i := break to break do while break do break
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(source_file
|
|
(for_expression
|
|
(identifier)
|
|
(break_expression)
|
|
(break_expression)
|
|
(while_expression
|
|
(break_expression)
|
|
(break_expression))))
|