tree-sitter/spec/runtime/languages/javascript/literals.txt
Max Brunsfeld ed11ef557a Fix expansion of repeat rules into recursive rules
Previously, the way repeat rules were expanded, the auxiliary
rule always needed to be reduced, even if the repeating content
was empty. This caused problems in parse states where some items
contained the repeat rule and some did not. To make those cases
work, the repeat rule had to explicitly be marked as optional.
With this change, that is no longer necessary.
2014-09-07 09:39:14 -07:00

73 lines
1.9 KiB
Text

==========================================
parses regexes
==========================================
theFunction(/regex1/, /regex2/g);
---
(expression_statement (function_call (identifier)
(regex) (regex)))
==========================================
parses numbers
==========================================
theFunction(100.0, 200);
---
(expression_statement (function_call (identifier)
(number) (number)))
==========================================
parses strings
==========================================
theFunction('', "", 'single-quoted-string', "double-quoted-string");
---
(expression_statement (function_call (identifier)
(string) (string) (string) (string)))
==========================================
parses function expressions
==========================================
var x = {
theMethod: function(argA, argB) {
var x = argA;
}
};
---
(var_declaration
(identifier)
(object (identifier) (function_expression
(formal_parameters (identifier) (identifier))
(statement_block (var_declaration (identifier) (identifier))))))
==========================================
parses 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 a statement
doStuff();
}
};
---
(comment)
(comment)
(var_declaration (identifier) (object
(comment)
(comment)
(identifier) (function_expression
(formal_parameters (identifier) (comment))
(statement_block
(comment)
(expression_statement (function_call (identifier)))))))
==========================================
parses comments within expressions
==========================================
y // comment
* z;
---
(expression_statement (math_op (expression (identifier) (comment)) (identifier)))