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
|
|
|
|
==================
|
|
|
|
|
2023-10-31 17:04:22 +00:00
|
|
|
if false "True" else "False"
|
2023-10-31 09:51:37 +00:00
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
(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
|
|
|
|
==================
|
|
|
|
|
2023-10-31 17:04:22 +00:00
|
|
|
if false
|
2023-10-31 09:51:37 +00:00
|
|
|
"no"
|
2023-10-31 17:04:22 +00:00
|
|
|
else if false
|
2023-10-31 09:51:37 +00:00
|
|
|
"no"
|
2023-10-31 17:04:22 +00:00
|
|
|
else if 1 + 1 == 9
|
2023-10-31 09:51:37 +00:00
|
|
|
"not the answer"
|
2023-10-31 17:04:22 +00:00
|
|
|
else
|
2023-10-31 09:51:37 +00:00
|
|
|
"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))))))))))
|