tree-sitter/spec/fixtures/corpus/javascript/literals.txt
2015-12-18 13:46:24 -08:00

82 lines
1.9 KiB
Text

==========================================
primitives
==========================================
theFunction(/regex1/, /regex2/g);
theFunction(100.0, 200);
theFunction('', "", 'single-quoted-string', "double-quoted-string");
---
(program
(expression_statement (function_call (identifier) (arguments (regex) (regex))))
(expression_statement (function_call (identifier) (arguments (number) (number))))
(expression_statement (function_call (identifier) (arguments (string) (string) (string) (string)))))
==========================================
function expressions
==========================================
var x = {
theMethod: function(argA, argB) {
var x = argA;
}
};
---
(program
(var_declaration (var_assignment
(identifier)
(object (pair (identifier) (function_expression
(formal_parameters (identifier) (identifier))
(statement_block
(var_declaration (var_assignment (identifier) (identifier))))))))))
==========================================
comments
==========================================
// this is the beginning of the script.
// here we go.
var thing = {
// this is a property.
// its value is a function.
key: function(x /* this is a parameter */) {
// this is one statement
one();
// this is another statement
two();
}
};
---
(program
(comment)
(comment)
(var_declaration (var_assignment
(identifier)
(object
(comment)
(comment)
(pair (identifier) (function_expression
(formal_parameters (identifier)) (comment)
(statement_block
(comment)
(expression_statement (function_call (identifier) (arguments)))
(comment)
(expression_statement (function_call (identifier) (arguments))))))))))
==========================================
comments within expressions
==========================================
y // comment
* z;
---
(program (expression_statement
(math_op (identifier) (comment) (identifier))))