Make node for each var assignment in JS grammar
This commit is contained in:
parent
d3137c6ac6
commit
22ee68e1a9
6 changed files with 21960 additions and 29206 deletions
10
spec/fixtures/grammars/javascript.cc
vendored
10
spec/fixtures/grammars/javascript.cc
vendored
|
|
@ -89,11 +89,13 @@ extern const Grammar javascript = Grammar({
|
|||
{ "break_statement", terminated(keyword("break")) },
|
||||
{ "var_declaration", terminated(seq({
|
||||
keyword("var"),
|
||||
comma_sep(err(seq({
|
||||
comma_sep1(err(choice({
|
||||
sym("identifier"),
|
||||
optional(seq({
|
||||
str("="),
|
||||
sym("expression") })) }))) })) },
|
||||
sym("var_assignment") }))) })) },
|
||||
{ "var_assignment", seq({
|
||||
sym("identifier"),
|
||||
str("="),
|
||||
sym("expression") }) },
|
||||
{ "expression_statement", terminated(err(sym("expression"))) },
|
||||
{ "return_statement", terminated(seq({
|
||||
keyword("return"),
|
||||
|
|
|
|||
51115
spec/fixtures/parsers/javascript.c
vendored
51115
spec/fixtures/parsers/javascript.c
vendored
File diff suppressed because it is too large
Load diff
|
|
@ -7,9 +7,9 @@ secondFunction(x);
|
|||
---
|
||||
(program
|
||||
(var_declaration
|
||||
(identifier) (object)
|
||||
(var_assignment (identifier) (object))
|
||||
(identifier)
|
||||
(identifier) (number))
|
||||
(var_assignment (identifier) (number)))
|
||||
(expression_statement (function_call (identifier) (identifier)))
|
||||
(expression_statement (function_call (identifier) (identifier))))
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ for (var i = 1; someCondition(i); i = next()) {
|
|||
}
|
||||
---
|
||||
(for_statement
|
||||
(var_declaration (identifier) (number))
|
||||
(var_declaration (var_assignment (identifier) (number)))
|
||||
(expression_statement (function_call (identifier) (identifier)))
|
||||
(assignment (identifier) (function_call (identifier)))
|
||||
(statement_block (expression_statement (function_call (identifier)))))
|
||||
|
|
|
|||
|
|
@ -31,11 +31,12 @@ var x = {
|
|||
}
|
||||
};
|
||||
---
|
||||
(var_declaration
|
||||
(var_declaration (var_assignment
|
||||
(identifier)
|
||||
(object (identifier) (function_expression
|
||||
(formal_parameters (identifier) (identifier))
|
||||
(statement_block (var_declaration (identifier) (identifier))))))
|
||||
(statement_block
|
||||
(var_declaration (var_assignment (identifier) (identifier))))))))
|
||||
|
||||
==========================================
|
||||
parses comments
|
||||
|
|
@ -55,14 +56,16 @@ var thing = {
|
|||
---
|
||||
(comment)
|
||||
(comment)
|
||||
(var_declaration (identifier) (object
|
||||
(comment)
|
||||
(comment)
|
||||
(identifier) (function_expression
|
||||
(formal_parameters (identifier) (comment))
|
||||
(statement_block
|
||||
(comment)
|
||||
(expression_statement (function_call (identifier)))))))
|
||||
(var_declaration (var_assignment
|
||||
(identifier)
|
||||
(object
|
||||
(comment)
|
||||
(comment)
|
||||
(identifier) (function_expression
|
||||
(formal_parameters (identifier) (comment))
|
||||
(statement_block
|
||||
(comment)
|
||||
(expression_statement (function_call (identifier))))))))
|
||||
|
||||
==========================================
|
||||
parses comments within expressions
|
||||
|
|
|
|||
|
|
@ -12,13 +12,13 @@ parses constructor calls
|
|||
==========================================
|
||||
var x = new Node(5, new Node(3, null));
|
||||
---
|
||||
(var_declaration
|
||||
(var_declaration (var_assignment
|
||||
(identifier)
|
||||
(constructor_call (function_call (identifier)
|
||||
(number)
|
||||
(constructor_call (function_call (identifier)
|
||||
(number)
|
||||
(null))))))
|
||||
(null)))))))
|
||||
|
||||
==========================================
|
||||
parses property access with dot notation
|
||||
|
|
|
|||
|
|
@ -279,8 +279,8 @@ describe("Parser", [&]() {
|
|||
set_text("var x = y;");
|
||||
|
||||
AssertThat(ts_node_string(root), Equals(
|
||||
"(DOCUMENT (var_declaration "
|
||||
"(identifier) (identifier)))"));
|
||||
"(DOCUMENT (var_declaration (var_assignment "
|
||||
"(identifier) (identifier))))"));
|
||||
|
||||
insert_text(strlen("var x = y"), " *");
|
||||
|
||||
|
|
@ -290,8 +290,8 @@ describe("Parser", [&]() {
|
|||
insert_text(strlen("var x = y *"), " z");
|
||||
|
||||
AssertThat(ts_node_string(root), Equals(
|
||||
"(DOCUMENT (var_declaration "
|
||||
"(identifier) (math_op (identifier) (identifier))))"));
|
||||
"(DOCUMENT (var_declaration (var_assignment "
|
||||
"(identifier) (math_op (identifier) (identifier)))))"));
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue