1
0
dust/tree-sitter-dust/corpus/if_else.txt

256 lines
6.1 KiB
Plaintext
Raw Permalink Normal View History

2023-11-11 01:44:03 +00:00
================================================================================
2023-10-31 09:51:37 +00:00
Simple If
2023-11-11 01:44:03 +00:00
================================================================================
2023-10-31 09:51:37 +00:00
if true { "True" }
2023-11-11 01:44:03 +00:00
--------------------------------------------------------------------------------
2023-10-31 09:51:37 +00:00
(root
2023-11-11 01:44:03 +00:00
(statement
(if_else
(if
(expression
(value
(boolean)))
(block
(statement
(expression
(value
(string)))))))))
================================================================================
2023-10-31 09:51:37 +00:00
Complex If
2023-11-11 01:44:03 +00:00
================================================================================
2023-10-31 09:51:37 +00:00
2023-11-11 01:44:03 +00:00
if 1 == 1 && 2 == 2 && 3 == 3 { "True" }
2023-10-31 09:51:37 +00:00
2023-11-11 01:44:03 +00:00
--------------------------------------------------------------------------------
2023-10-31 09:51:37 +00:00
(root
2023-11-11 01:44:03 +00:00
(statement
(if_else
(if
(expression
(logic
(expression
(logic
(expression
(logic
(expression
(logic
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(value
(integer)))))
(logic_operator)
(expression
(value
(integer)))))
(logic_operator)
(expression
(value
(integer)))))
(logic_operator)
(expression
(value
(integer)))))
(logic_operator)
(expression
(value
(integer)))))
2023-11-11 01:44:03 +00:00
(block
(statement
(expression
(value
(string)))))))))
================================================================================
2023-10-31 09:51:37 +00:00
Nested If
2023-11-11 01:44:03 +00:00
================================================================================
2023-10-31 09:51:37 +00:00
2023-11-11 01:44:03 +00:00
if true {
if 42 == 12 {
2023-10-31 09:51:37 +00:00
'hiya'
2023-11-11 01:44:03 +00:00
} else {
2023-10-31 09:51:37 +00:00
'bye'
2023-11-11 01:44:03 +00:00
}
}
2023-10-31 09:51:37 +00:00
2023-11-11 01:44:03 +00:00
--------------------------------------------------------------------------------
2023-10-31 09:51:37 +00:00
(root
2023-11-11 01:44:03 +00:00
(statement
(if_else
(if
(expression
(value
(boolean)))
(block
(statement
(if_else
(if
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(value
(integer)))))
(block
(statement
(expression
(value
(string))))))
(else
(block
(statement
(expression
(value
(string)))))))))))))
================================================================================
2023-10-31 09:51:37 +00:00
If Else
2023-11-11 01:44:03 +00:00
================================================================================
2023-10-31 09:51:37 +00:00
2023-11-11 01:44:03 +00:00
if false { "True" } else { "False" }
2023-10-31 09:51:37 +00:00
2023-11-11 01:44:03 +00:00
--------------------------------------------------------------------------------
2023-10-31 09:51:37 +00:00
(root
2023-11-11 01:44:03 +00:00
(statement
(if_else
(if
(expression
(value
(boolean)))
(block
(statement
(expression
(value
(string))))))
(else
(block
(statement
(expression
(value
(string)))))))))
================================================================================
2023-10-31 09:51:37 +00:00
If Else If
2023-11-11 01:44:03 +00:00
================================================================================
2023-10-31 09:51:37 +00:00
if 1 == 1 {
"math is fun"
} else if 4 == 9 {
"math is broken"
}
2023-11-11 01:44:03 +00:00
--------------------------------------------------------------------------------
2023-10-31 09:51:37 +00:00
(root
2023-11-11 01:44:03 +00:00
(statement
(if_else
(if
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(value
(integer)))))
(block
(statement
(expression
(value
(string))))))
(else_if
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(value
(integer)))))
(block
(statement
(expression
(value
(string)))))))))
================================================================================
2023-10-31 09:51:37 +00:00
If Else Else If Else
2023-11-11 01:44:03 +00:00
================================================================================
2023-10-31 09:51:37 +00:00
2023-11-11 01:44:03 +00:00
if false {
2023-10-31 09:51:37 +00:00
"no"
2023-11-11 01:44:03 +00:00
} else if false {
2023-10-31 09:51:37 +00:00
"no"
2023-11-11 01:44:03 +00:00
} else if 1 + 1 == 9 {
2023-10-31 09:51:37 +00:00
"not the answer"
2023-11-11 01:44:03 +00:00
} else {
2023-10-31 09:51:37 +00:00
"42"
2023-11-11 01:44:03 +00:00
}
2023-10-31 09:51:37 +00:00
2023-11-11 01:44:03 +00:00
--------------------------------------------------------------------------------
2023-10-31 09:51:37 +00:00
(root
2023-11-11 01:44:03 +00:00
(statement
(if_else
(if
(expression
(value
(boolean)))
(block
(statement
(expression
(value
(string))))))
(else_if
(expression
(value
(boolean)))
(block
(statement
(expression
(value
(string))))))
(else_if
(expression
(logic
(expression
(math
(expression
(value
(integer)))
(math_operator)
(expression
(value
(integer)))))
(logic_operator)
(expression
(value
(integer)))))
(block
(statement
(expression
(value
(string))))))
(else
(block
(statement
(expression
(value
(string)))))))))