61 lines
1.9 KiB
Text
61 lines
1.9 KiB
Text
==========================================
|
|
parses ternary expressions
|
|
==========================================
|
|
print(isDone() ? stuff : otherStuff);
|
|
---
|
|
(program (expression_statement
|
|
(function_call
|
|
(identifier)
|
|
(ternary (function_call (identifier)) (identifier) (identifier)))))
|
|
|
|
==========================================
|
|
parses mathematical operators
|
|
==========================================
|
|
-a + b * c - d / +e
|
|
---
|
|
(program (expression_statement
|
|
(math_op
|
|
(math_op (identifier))
|
|
(math_op
|
|
(math_op (identifier) (identifier))
|
|
(math_op (identifier) (math_op (identifier)))))))
|
|
|
|
==========================================
|
|
parses boolean operators
|
|
=========================================
|
|
!a || !(b && c)
|
|
---
|
|
(program (expression_statement
|
|
(bool_op
|
|
(bool_op (identifier))
|
|
(bool_op
|
|
(expression (bool_op (identifier) (identifier)))))))
|
|
|
|
===========================================
|
|
parses the type operators
|
|
===========================================
|
|
print((x instanceof Array) || (typeof x == "string"))
|
|
---
|
|
(program (expression_statement (function_call (identifier)
|
|
(bool_op
|
|
(expression (instanceof_expression (identifier) (identifier)))
|
|
(expression (typeof_expression (bool_op (identifier) (string))))))))
|
|
|
|
============================================
|
|
parses the 'in' operator
|
|
===========================================
|
|
print(x in y)
|
|
---
|
|
(program (expression_statement (function_call
|
|
(identifier)
|
|
(in_expression (identifier) (identifier)))))
|
|
|
|
============================================
|
|
parses property access and operators
|
|
============================================
|
|
print(x.y.z && a.b.c)
|
|
---
|
|
(program (expression_statement (function_call (identifier)
|
|
(bool_op
|
|
(property_access (property_access (identifier) (identifier)) (identifier))
|
|
(property_access (property_access (identifier) (identifier)) (identifier))))))
|