2014-06-11 16:43:03 -07:00
|
|
|
==========================================
|
2014-10-19 12:36:43 -07:00
|
|
|
function calls
|
2014-06-11 16:43:03 -07:00
|
|
|
==========================================
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2014-06-11 16:43:03 -07:00
|
|
|
x.theMethod(5, 6);
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2014-06-11 16:43:03 -07:00
|
|
|
---
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2015-08-23 10:42:06 -07:00
|
|
|
(program (expression_statement
|
|
|
|
|
(function_call
|
2014-10-21 08:49:16 -07:00
|
|
|
(member_access (identifier) (identifier))
|
2015-08-23 10:42:06 -07:00
|
|
|
(arguments (number) (number)))))
|
2014-06-11 16:43:03 -07:00
|
|
|
|
|
|
|
|
==========================================
|
2014-10-19 12:36:43 -07:00
|
|
|
constructor calls
|
2014-06-11 16:43:03 -07:00
|
|
|
==========================================
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2014-06-11 16:43:03 -07:00
|
|
|
var x = new Node(5, new Node(3, null));
|
2015-09-02 13:05:31 -07:00
|
|
|
new Thing;
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2014-06-11 16:43:03 -07:00
|
|
|
---
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2015-09-02 13:05:31 -07:00
|
|
|
(program
|
|
|
|
|
(var_declaration (var_assignment
|
|
|
|
|
(identifier)
|
2014-10-21 08:49:16 -07:00
|
|
|
(constructor_call (identifier) (arguments
|
2015-08-23 10:42:06 -07:00
|
|
|
(number)
|
2015-09-02 13:05:31 -07:00
|
|
|
(constructor_call (identifier) (arguments
|
|
|
|
|
(number)
|
|
|
|
|
(null)))))))
|
|
|
|
|
(expression_statement (constructor_call (identifier))))
|
2014-06-11 16:43:03 -07:00
|
|
|
|
|
|
|
|
==========================================
|
2014-10-19 12:36:43 -07:00
|
|
|
property access with dot notation
|
2014-06-11 16:43:03 -07:00
|
|
|
==========================================
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2014-06-11 16:43:03 -07:00
|
|
|
object.property = "the-value";
|
2015-09-02 13:05:31 -07:00
|
|
|
object.property;
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2014-06-11 16:43:03 -07:00
|
|
|
---
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2014-06-11 16:43:03 -07:00
|
|
|
(program
|
2015-09-02 13:05:31 -07:00
|
|
|
(expression_statement
|
|
|
|
|
(assignment (member_access (identifier) (identifier)) (string)))
|
|
|
|
|
(expression_statement
|
|
|
|
|
(member_access (identifier) (identifier))))
|
2014-06-11 16:43:03 -07:00
|
|
|
|
2014-07-01 20:47:35 -07:00
|
|
|
==========================================
|
2014-10-19 12:36:43 -07:00
|
|
|
property access across lines
|
2014-07-01 20:47:35 -07:00
|
|
|
==========================================
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2014-07-01 20:47:35 -07:00
|
|
|
object
|
|
|
|
|
.someProperty
|
|
|
|
|
.otherProperty
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2014-07-01 20:47:35 -07:00
|
|
|
---
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2015-08-23 10:42:06 -07:00
|
|
|
(program (expression_statement
|
|
|
|
|
(member_access
|
|
|
|
|
(member_access (identifier) (identifier))
|
|
|
|
|
(identifier))))
|
2014-07-01 20:47:35 -07:00
|
|
|
|
2014-06-11 16:43:03 -07:00
|
|
|
===========================================
|
2014-10-19 12:36:43 -07:00
|
|
|
dynamic property access
|
2014-06-11 16:43:03 -07:00
|
|
|
==========================================
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2014-06-11 16:43:03 -07:00
|
|
|
object[propertName()] = propertyValue();
|
2015-09-02 13:05:31 -07:00
|
|
|
object[propertyName()];
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2014-06-11 16:43:03 -07:00
|
|
|
---
|
2015-08-23 10:42:06 -07:00
|
|
|
|
2014-06-11 16:43:03 -07:00
|
|
|
(program
|
2015-09-02 13:05:31 -07:00
|
|
|
(expression_statement
|
|
|
|
|
(assignment
|
|
|
|
|
(subscript_access (identifier) (function_call (identifier) (arguments)))
|
|
|
|
|
(function_call (identifier) (arguments))))
|
|
|
|
|
(expression_statement
|
|
|
|
|
(subscript_access (identifier) (function_call (identifier) (arguments)))))
|
2014-06-11 16:43:03 -07:00
|
|
|
|
2014-04-23 22:07:44 -07:00
|
|
|
==========================================
|
2014-10-19 12:36:43 -07:00
|
|
|
ternary expressions
|
2014-04-23 22:07:44 -07:00
|
|
|
==========================================
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2015-09-02 13:05:31 -07:00
|
|
|
isDone() ? stuff : otherStuff;
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2014-04-23 22:07:44 -07:00
|
|
|
---
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2015-08-23 10:42:06 -07:00
|
|
|
(program (expression_statement
|
2015-09-02 13:05:31 -07:00
|
|
|
(ternary (function_call (identifier) (arguments)) (identifier) (identifier))))
|
2014-04-23 22:25:48 -07:00
|
|
|
|
|
|
|
|
==========================================
|
2014-10-19 12:36:43 -07:00
|
|
|
mathematical operators
|
2014-04-23 22:25:48 -07:00
|
|
|
==========================================
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2014-10-21 08:49:16 -07:00
|
|
|
a++ + b * c - d / e--
|
2014-06-26 08:52:42 -07:00
|
|
|
|
2014-04-23 22:25:48 -07:00
|
|
|
---
|
2015-08-23 10:42:06 -07:00
|
|
|
|
|
|
|
|
(program (expression_statement
|
2015-03-16 23:12:08 -07:00
|
|
|
(math_op
|
2014-04-23 22:25:48 -07:00
|
|
|
(math_op
|
2015-03-16 23:12:08 -07:00
|
|
|
(math_op (identifier))
|
|
|
|
|
(math_op (identifier) (identifier)))
|
|
|
|
|
(math_op
|
|
|
|
|
(identifier)
|
2015-08-23 10:42:06 -07:00
|
|
|
(math_op (identifier))))))
|
2014-04-25 22:08:11 -07:00
|
|
|
|
|
|
|
|
==========================================
|
2014-10-19 12:36:43 -07:00
|
|
|
boolean operators
|
2014-04-25 22:08:11 -07:00
|
|
|
=========================================
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2014-04-25 22:08:11 -07:00
|
|
|
!a || !(b && c)
|
2014-06-26 08:52:42 -07:00
|
|
|
|
2014-04-25 22:08:11 -07:00
|
|
|
---
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2015-08-23 10:42:06 -07:00
|
|
|
(program (expression_statement
|
|
|
|
|
(bool_op
|
|
|
|
|
(bool_op (identifier))
|
2014-04-25 22:08:11 -07:00
|
|
|
(bool_op
|
2015-09-02 13:05:31 -07:00
|
|
|
(bool_op (identifier) (identifier))))))
|
2014-06-11 11:28:49 -07:00
|
|
|
|
|
|
|
|
===========================================
|
2014-10-19 12:36:43 -07:00
|
|
|
type operators
|
2014-06-11 11:28:49 -07:00
|
|
|
===========================================
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2015-09-02 13:05:31 -07:00
|
|
|
(x instanceof Array) || (typeof x === "string")
|
2014-06-26 08:52:42 -07:00
|
|
|
|
2014-06-11 11:28:49 -07:00
|
|
|
---
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2015-08-23 10:42:06 -07:00
|
|
|
(program (expression_statement
|
2015-09-02 13:05:31 -07:00
|
|
|
(bool_op
|
|
|
|
|
(type_op (identifier) (identifier))
|
|
|
|
|
(rel_op (type_op (identifier)) (string)))))
|
2014-06-11 11:28:49 -07:00
|
|
|
|
|
|
|
|
============================================
|
2014-10-19 12:36:43 -07:00
|
|
|
the 'in' operator
|
2014-06-11 11:28:49 -07:00
|
|
|
===========================================
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2014-06-11 11:28:49 -07:00
|
|
|
print(x in y)
|
2014-06-26 08:52:42 -07:00
|
|
|
|
2014-06-11 11:28:49 -07:00
|
|
|
---
|
2015-08-23 10:42:06 -07:00
|
|
|
|
|
|
|
|
(program (expression_statement
|
|
|
|
|
(function_call
|
2014-06-11 14:01:38 -07:00
|
|
|
(identifier)
|
2015-09-02 13:05:31 -07:00
|
|
|
(arguments (type_op (identifier) (identifier))))))
|
2014-06-11 14:01:38 -07:00
|
|
|
|
2014-07-07 13:35:55 -07:00
|
|
|
============================================
|
2014-10-19 12:36:43 -07:00
|
|
|
assignment operators
|
2014-07-07 13:35:55 -07:00
|
|
|
============================================
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2014-07-07 13:35:55 -07:00
|
|
|
x += 1;
|
|
|
|
|
x -= 1;
|
|
|
|
|
x *= 2;
|
|
|
|
|
x /= 2;
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2014-07-07 13:35:55 -07:00
|
|
|
---
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2014-07-07 13:35:55 -07:00
|
|
|
(program
|
2015-08-23 10:42:06 -07:00
|
|
|
(expression_statement (math_assignment (identifier) (number)))
|
|
|
|
|
(expression_statement (math_assignment (identifier) (number)))
|
|
|
|
|
(expression_statement (math_assignment (identifier) (number)))
|
|
|
|
|
(expression_statement (math_assignment (identifier) (number))))
|
2014-07-07 13:35:55 -07:00
|
|
|
|
2014-06-11 14:01:38 -07:00
|
|
|
============================================
|
2014-10-19 12:36:43 -07:00
|
|
|
property access and operators
|
2014-06-11 14:01:38 -07:00
|
|
|
============================================
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2014-06-11 14:01:38 -07:00
|
|
|
print(x.y.z && a.b.c)
|
2014-06-26 08:52:42 -07:00
|
|
|
|
2014-06-11 14:01:38 -07:00
|
|
|
---
|
2014-10-19 12:36:43 -07:00
|
|
|
|
2015-08-23 10:42:06 -07:00
|
|
|
(program (expression_statement
|
|
|
|
|
(function_call (identifier)
|
2015-09-02 13:05:31 -07:00
|
|
|
(arguments (bool_op
|
2015-08-23 10:42:06 -07:00
|
|
|
(member_access (member_access (identifier) (identifier)) (identifier))
|
2015-09-02 13:05:31 -07:00
|
|
|
(member_access (member_access (identifier) (identifier)) (identifier)))))))
|