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

262 lines
5.3 KiB
Plaintext
Raw Normal View History

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