1
0
dust/tree-sitter-dust/corpus/if_else.txt
2023-10-31 16:25:13 -04:00

259 lines
5.3 KiB
Plaintext

==================
Simple If
==================
if true { "True" }
---
(root
(block
(statement
(if_else
(if
(expression
(value
(boolean)))
(block
(statement
(expression
(value
(string))))))))))
==================
Complex If
==================
if 1 == 1 && 2 == 2 && 3 == 3 "True"
---
(root
(block
(statement
(if_else
(if
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(value
(integer)))))))))))))
(block
(statement
(expression
(value
(string))))))))))
==================
Nested If
==================
if true
if 42 == 12
'hiya'
else
'bye'
---
(root
(block
(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))))))))))))))
==================
If Else
==================
if false "True" else "False"
---
(root
(block
(statement
(if_else
(if
(expression
(value
(boolean)))
(block
(statement
(expression
(value
(string))))))
(else
(block
(statement
(expression
(value
(string))))))))))
==================
If Else If
==================
if 1 == 1 {
"math is fun"
} else if 4 == 9 {
"math is broken"
}
---
(root
(block
(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))))))))))
==================
If Else Else If Else
==================
if false
"no"
else if false
"no"
else if 1 + 1 == 9
"not the answer"
else
"42"
---
(root
(block
(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))))))))))