146 lines
3.7 KiB
Plaintext
146 lines
3.7 KiB
Plaintext
================================================================================
|
|
Simple Statements
|
|
================================================================================
|
|
|
|
1
|
|
"one";
|
|
x
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(root
|
|
(statement
|
|
(statement_kind
|
|
(expression
|
|
(value
|
|
(integer)))))
|
|
(statement
|
|
(statement_kind
|
|
(expression
|
|
(value
|
|
(string)))))
|
|
(statement
|
|
(statement_kind
|
|
(expression
|
|
(identifier)))))
|
|
|
|
================================================================================
|
|
Simple Assignment
|
|
================================================================================
|
|
|
|
x = 1;
|
|
y = "one"
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(root
|
|
(statement
|
|
(statement_kind
|
|
(assignment
|
|
(identifier)
|
|
(assignment_operator)
|
|
(statement
|
|
(statement_kind
|
|
(expression
|
|
(value
|
|
(integer))))))))
|
|
(statement
|
|
(statement_kind
|
|
(assignment
|
|
(identifier)
|
|
(assignment_operator)
|
|
(statement
|
|
(statement_kind
|
|
(expression
|
|
(value
|
|
(string)))))))))
|
|
|
|
================================================================================
|
|
Complex Assignment
|
|
================================================================================
|
|
|
|
x = if 1 + 1 == 2 {
|
|
'yo'
|
|
} else {
|
|
'no'
|
|
}
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(root
|
|
(statement
|
|
(statement_kind
|
|
(assignment
|
|
(identifier)
|
|
(assignment_operator)
|
|
(statement
|
|
(statement_kind
|
|
(if_else
|
|
(if
|
|
(expression
|
|
(logic
|
|
(expression
|
|
(math
|
|
(expression
|
|
(value
|
|
(integer)))
|
|
(math_operator)
|
|
(expression
|
|
(value
|
|
(integer)))))
|
|
(logic_operator)
|
|
(expression
|
|
(value
|
|
(integer)))))
|
|
(block
|
|
(statement
|
|
(statement_kind
|
|
(expression
|
|
(value
|
|
(string)))))))
|
|
(else
|
|
(block
|
|
(statement
|
|
(statement_kind
|
|
(expression
|
|
(value
|
|
(string))))))))))))))
|
|
|
|
================================================================================
|
|
Expression Precedence
|
|
================================================================================
|
|
|
|
x = 3 == 1 + 2 + 2
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(root
|
|
(statement
|
|
(statement_kind
|
|
(assignment
|
|
(identifier)
|
|
(assignment_operator)
|
|
(statement
|
|
(statement_kind
|
|
(expression
|
|
(math
|
|
(expression
|
|
(math
|
|
(expression
|
|
(logic
|
|
(expression
|
|
(value
|
|
(integer)))
|
|
(logic_operator)
|
|
(expression
|
|
(value
|
|
(integer)))))
|
|
(math_operator)
|
|
(expression
|
|
(value
|
|
(integer)))))
|
|
(math_operator)
|
|
(expression
|
|
(value
|
|
(integer)))))))))))
|