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));
|
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 (var_declaration (var_assignment
|
|
|
|
|
(identifier)
|
|
|
|
|
(constructor_call (identifier) (arguments
|
|
|
|
|
(number)
|
2014-10-21 08:49:16 -07:00
|
|
|
(constructor_call (identifier) (arguments
|
2015-08-23 10:42:06 -07:00
|
|
|
(number)
|
|
|
|
|
(null))))))))
|
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";
|
|
|
|
|
print(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-08-23 10:42:06 -07:00
|
|
|
(expression_statement (assignment
|
|
|
|
|
(member_access (identifier) (identifier))
|
|
|
|
|
(string)))
|
|
|
|
|
(expression_statement (function_call
|
|
|
|
|
(identifier)
|
|
|
|
|
(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();
|
|
|
|
|
print(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-08-23 10:42:06 -07:00
|
|
|
(expression_statement (assignment
|
|
|
|
|
(subscript_access (identifier) (function_call (identifier)))
|
|
|
|
|
(function_call (identifier))))
|
|
|
|
|
(expression_statement (function_call
|
|
|
|
|
(identifier)
|
|
|
|
|
(subscript_access (identifier) (function_call (identifier))))))
|
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
|
|
|
|
2014-04-23 22:07:44 -07:00
|
|
|
print(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
|
|
|
|
|
(function_call
|
|
|
|
|
(identifier)
|
|
|
|
|
(ternary (function_call (identifier)) (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-08-23 10:42:06 -07:00
|
|
|
(expression (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
|
|
|
|
2014-10-21 08:49:16 -07:00
|
|
|
print((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
|
|
|
|
|
(function_call (identifier)
|
2014-06-11 11:28:49 -07:00
|
|
|
(bool_op
|
2015-08-23 10:42:06 -07:00
|
|
|
(expression (type_op (identifier) (identifier)))
|
|
|
|
|
(expression (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-08-23 10:42:06 -07:00
|
|
|
(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)
|
2014-06-11 14:01:38 -07:00
|
|
|
(bool_op
|
2015-08-23 10:42:06 -07:00
|
|
|
(member_access (member_access (identifier) (identifier)) (identifier))
|
|
|
|
|
(member_access (member_access (identifier) (identifier)) (identifier))))))
|