This commit is contained in:
2023-10-16 22:02:26 +02:00
commit ef984491f7
20 changed files with 3752 additions and 0 deletions

95
test/corpus/if.txt Normal file
View File

@@ -0,0 +1,95 @@
====================================================
if statement
====================================================
func main() {
if true {
false
};
}
----------------------------------------------------
(source_file
(function_definition
name: (identifier)
parameters: (parameters)
body: (block
(if_statement
condition: (boolean_literal)
body: (block
(boolean_literal))))))
====================================================
if else expression
====================================================
func main() {
return if true {
false
} else {
true
};
}
----------------------------------------------------
(source_file
(function_definition
name: (identifier)
parameters: (parameters)
body: (block
(return_statement
(if_expression
condition: (boolean_literal)
body: (block
(boolean_literal))
else: (block
(boolean_literal)))))))
====================================================
if else expression (no brackets in else)
====================================================
func main() {
return if true {
false
} else true;
}
----------------------------------------------------
(source_file
(function_definition
name: (identifier)
parameters: (parameters)
body: (block
(return_statement
(if_expression
condition: (boolean_literal)
body: (block
(boolean_literal))
else: (boolean_literal))))))
====================================================
[Error] if expression (missing else)
====================================================
func main() {
return if true {
false
};
}
----------------------------------------------------
(source_file
(function_definition
name: (identifier)
parameters: (parameters)
body: (block
(return_statement
(ERROR
(boolean_literal)
(block
(boolean_literal)))))))