2014-03-24 09:14:29 -07:00
|
|
|
==========================================
|
|
|
|
|
parses multiple statements
|
|
|
|
|
==========================================
|
2014-04-03 19:10:09 -07:00
|
|
|
var x = {}
|
2014-04-04 08:44:35 -07:00
|
|
|
firstFunction(x)
|
2014-03-26 22:56:58 -07:00
|
|
|
secondFunction(x);
|
2014-03-24 09:14:29 -07:00
|
|
|
---
|
|
|
|
|
(program
|
2014-03-28 12:59:47 -07:00
|
|
|
(var_declaration (assignment (identifier) (object)))
|
|
|
|
|
(expression_statement (function_call (identifier) (identifier)))
|
|
|
|
|
(expression_statement (function_call (identifier) (identifier))))
|
2014-03-24 09:14:29 -07:00
|
|
|
|
2014-03-26 08:23:13 -07:00
|
|
|
==========================================
|
2014-03-26 22:56:58 -07:00
|
|
|
parses function expressions and calls
|
2014-03-26 08:23:13 -07:00
|
|
|
==========================================
|
2014-03-26 22:43:08 -07:00
|
|
|
var x = {
|
|
|
|
|
theMethod: function(argA, argB) {
|
|
|
|
|
var x = argA;
|
|
|
|
|
}
|
2014-03-26 08:23:13 -07:00
|
|
|
};
|
|
|
|
|
|
2014-03-26 22:43:08 -07:00
|
|
|
x.theMethod(5, 6);
|
2014-03-26 08:23:13 -07:00
|
|
|
---
|
2014-03-28 13:51:32 -07:00
|
|
|
(program
|
2014-03-28 12:59:47 -07:00
|
|
|
(var_declaration (assignment
|
2014-03-26 08:23:13 -07:00
|
|
|
(identifier)
|
2014-03-26 22:43:08 -07:00
|
|
|
(object (identifier) (function_expression
|
|
|
|
|
(formal_parameters (identifier) (identifier))
|
2014-03-28 12:59:47 -07:00
|
|
|
(statement_block (var_declaration (assignment (identifier) (identifier))))))))
|
|
|
|
|
(expression_statement (function_call
|
2014-03-26 22:43:08 -07:00
|
|
|
(property_access (identifier) (identifier))
|
|
|
|
|
(number) (number))))
|
|
|
|
|
|
2014-04-05 15:55:20 -07:00
|
|
|
==========================================
|
|
|
|
|
parses property access with dot notation
|
|
|
|
|
==========================================
|
|
|
|
|
object.property = "the-value";
|
|
|
|
|
print(object.property);
|
2014-04-04 13:10:33 -07:00
|
|
|
---
|
|
|
|
|
(program
|
2014-04-05 15:55:20 -07:00
|
|
|
(expression_statement (assignment
|
|
|
|
|
(property_access (identifier) (identifier))
|
|
|
|
|
(string)))
|
|
|
|
|
(expression_statement (function_call
|
|
|
|
|
(identifier)
|
|
|
|
|
(property_access (identifier) (identifier)))))
|
2014-04-04 13:10:33 -07:00
|
|
|
|
2014-04-05 15:55:20 -07:00
|
|
|
===========================================
|
|
|
|
|
parses dynamic property access
|
|
|
|
|
==========================================
|
|
|
|
|
object[propertName()] = propertyValue();
|
|
|
|
|
print(object[propertyName()]);
|
|
|
|
|
---
|
|
|
|
|
(program
|
|
|
|
|
(expression_statement (assignment
|
|
|
|
|
(property_access (identifier) (function_call (identifier)))
|
|
|
|
|
(function_call (identifier))))
|
|
|
|
|
(expression_statement (function_call
|
|
|
|
|
(identifier)
|
|
|
|
|
(property_access (identifier) (function_call (identifier))))))
|
2014-04-04 13:10:33 -07:00
|
|
|
|
2014-04-24 13:22:23 -07:00
|
|
|
==========================================
|
|
|
|
|
parses comments
|
|
|
|
|
==========================================
|
|
|
|
|
// this is another comment
|
|
|
|
|
stuff(); // this is a comment
|
|
|
|
|
---
|
|
|
|
|
(program
|
|
|
|
|
(comment)
|
|
|
|
|
(expression_statement (function_call (identifier)))
|
|
|
|
|
(comment))
|