Consider shift/reduce conflicts to be compilation errors unless they are resolved by a specified associativity.
172 lines
3.9 KiB
Text
172 lines
3.9 KiB
Text
==========================================
|
|
function calls
|
|
==========================================
|
|
|
|
x.theMethod(5, 6);
|
|
|
|
---
|
|
|
|
(expression_statement (function_call
|
|
(member_access (identifier) (identifier))
|
|
(arguments (number) (number))))
|
|
|
|
==========================================
|
|
constructor calls
|
|
==========================================
|
|
|
|
var x = new Node(5, new Node(3, null));
|
|
|
|
---
|
|
|
|
(var_declaration (var_assignment
|
|
(identifier)
|
|
(constructor_call (identifier) (arguments
|
|
(number)
|
|
(constructor_call (identifier) (arguments
|
|
(number)
|
|
(null)))))))
|
|
|
|
==========================================
|
|
property access with dot notation
|
|
==========================================
|
|
|
|
object.property = "the-value";
|
|
print(object.property);
|
|
|
|
---
|
|
|
|
(program
|
|
(expression_statement (assignment
|
|
(member_access (identifier) (identifier))
|
|
(string)))
|
|
(expression_statement (function_call
|
|
(identifier)
|
|
(member_access (identifier) (identifier)))))
|
|
|
|
==========================================
|
|
property access across lines
|
|
==========================================
|
|
|
|
object
|
|
.someProperty
|
|
.otherProperty
|
|
|
|
---
|
|
|
|
(expression_statement
|
|
(member_access
|
|
(member_access (identifier) (identifier))
|
|
(identifier)))
|
|
|
|
===========================================
|
|
dynamic property access
|
|
==========================================
|
|
|
|
object[propertName()] = propertyValue();
|
|
print(object[propertyName()]);
|
|
|
|
---
|
|
(program
|
|
(expression_statement (assignment
|
|
(subscript_access (identifier) (function_call (identifier)))
|
|
(function_call (identifier))))
|
|
(expression_statement (function_call
|
|
(identifier)
|
|
(subscript_access (identifier) (function_call (identifier))))))
|
|
|
|
==========================================
|
|
ternary expressions
|
|
==========================================
|
|
|
|
print(isDone() ? stuff : otherStuff);
|
|
|
|
---
|
|
|
|
(expression_statement
|
|
(function_call
|
|
(identifier)
|
|
(ternary (function_call (identifier)) (identifier) (identifier))))
|
|
|
|
==========================================
|
|
mathematical operators
|
|
==========================================
|
|
|
|
a++ + b * c - d / e--
|
|
|
|
---
|
|
(expression_statement
|
|
(math_op
|
|
(math_op
|
|
(math_op (identifier))
|
|
(math_op (identifier) (identifier)))
|
|
(math_op
|
|
(identifier)
|
|
(math_op (identifier)))))
|
|
|
|
==========================================
|
|
boolean operators
|
|
=========================================
|
|
|
|
!a || !(b && c)
|
|
|
|
---
|
|
|
|
(expression_statement
|
|
(bool_op
|
|
(bool_op (identifier))
|
|
(bool_op
|
|
(expression (bool_op (identifier) (identifier))))))
|
|
|
|
===========================================
|
|
type operators
|
|
===========================================
|
|
|
|
print((x instanceof Array) || (typeof x === "string"))
|
|
|
|
---
|
|
|
|
(expression_statement (function_call (identifier)
|
|
(bool_op
|
|
(expression (type_op (identifier) (identifier)))
|
|
(expression (rel_op (type_op (identifier)) (string))))))
|
|
|
|
============================================
|
|
the 'in' operator
|
|
===========================================
|
|
|
|
print(x in y)
|
|
|
|
---
|
|
(expression_statement (function_call
|
|
(identifier)
|
|
(type_op (identifier) (identifier))))
|
|
|
|
============================================
|
|
assignment operators
|
|
============================================
|
|
|
|
x += 1;
|
|
x -= 1;
|
|
x *= 2;
|
|
x /= 2;
|
|
|
|
---
|
|
|
|
(program
|
|
(expression_statement (math_assignment (identifier) (number)))
|
|
(expression_statement (math_assignment (identifier) (number)))
|
|
(expression_statement (math_assignment (identifier) (number)))
|
|
(expression_statement (math_assignment (identifier) (number))))
|
|
|
|
============================================
|
|
property access and operators
|
|
============================================
|
|
|
|
print(x.y.z && a.b.c)
|
|
|
|
---
|
|
|
|
(expression_statement (function_call (identifier)
|
|
(bool_op
|
|
(member_access (member_access (identifier) (identifier)) (identifier))
|
|
(member_access (member_access (identifier) (identifier)) (identifier)))))
|