Simplify handling of ubiquitous tokens during reduce
This commit is contained in:
parent
41c4e7cd8f
commit
7ba3953f7e
7 changed files with 14 additions and 31 deletions
|
|
@ -3,7 +3,7 @@ recovers from errors at the top level
|
|||
=====================================================
|
||||
x * * y
|
||||
---
|
||||
(expression (variable) (ERROR '*'))
|
||||
(ERROR '*')
|
||||
|
||||
=====================================================
|
||||
recovers from errors inside parenthesized expressions
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ var x = {
|
|||
(statement_block (var_declaration (identifier) (identifier)))))))
|
||||
|
||||
==========================================
|
||||
parses comments
|
||||
parses comments. TODO - leading comments
|
||||
==========================================
|
||||
// this is the beginning of the script.
|
||||
// here we go.
|
||||
|
|
@ -55,16 +55,14 @@ var thing = {
|
|||
};
|
||||
---
|
||||
(program
|
||||
(comment)
|
||||
(comment)
|
||||
(program (var_declaration (identifier) (object
|
||||
(var_declaration (identifier) (object
|
||||
(comment)
|
||||
(comment)
|
||||
(identifier) (function_expression
|
||||
(formal_parameters (identifier) (comment))
|
||||
(statement_block
|
||||
(comment)
|
||||
(expression_statement (function_call (identifier)))))))))
|
||||
(expression_statement (function_call (identifier))))))))
|
||||
|
||||
==========================================
|
||||
parses comments within expressions
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ recovers from top-level errors
|
|||
==========================================
|
||||
[}
|
||||
---
|
||||
(value (ERROR <EOF>) (ERROR '}'))
|
||||
(ERROR '}')
|
||||
|
||||
==========================================
|
||||
recovers from unexpected tokens
|
||||
|
|
|
|||
|
|
@ -66,12 +66,12 @@ describe("stacks", [&]() {
|
|||
|
||||
it("pops the given number of nodes off the stack", [&]() {
|
||||
AssertThat(stack.size, Equals<size_t>(4));
|
||||
ts_stack_reduce(&stack, sym2, 3, hidden_symbols, 0);
|
||||
ts_stack_reduce(&stack, sym2, 3, hidden_symbols);
|
||||
AssertThat(stack.size, Equals<size_t>(1));
|
||||
});
|
||||
|
||||
it("returns a node with the given symbol", [&]() {
|
||||
TSTree *node = ts_stack_reduce(&stack, sym2, 3, hidden_symbols, 0);
|
||||
TSTree *node = ts_stack_reduce(&stack, sym2, 3, hidden_symbols);
|
||||
AssertThat(node->symbol, Equals(sym2));
|
||||
});
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ describe("stacks", [&]() {
|
|||
stack.entries[3].node,
|
||||
};
|
||||
|
||||
TSTree *node = ts_stack_reduce(&stack, sym2, 3, hidden_symbols, 0);
|
||||
TSTree *node = ts_stack_reduce(&stack, sym2, 3, hidden_symbols);
|
||||
size_t child_count;
|
||||
TSTree **children = ts_tree_children(node, &child_count);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue