Manage lookahead symbol correctly after a reduction
This commit is contained in:
parent
e174b89133
commit
8a317f6918
3 changed files with 22 additions and 5 deletions
|
|
@ -15,12 +15,24 @@ describe("arithmetic", []() {
|
|||
|
||||
it("parses variables", [&]() {
|
||||
TSDocumentSetText(document, "x");
|
||||
AssertThat(string(TSDocumentToString(document)), Equals("(expression (term (factor (variable))))"));
|
||||
AssertThat(string(TSDocumentToString(document)), Equals(
|
||||
"(expression (term (factor (variable))))"));
|
||||
});
|
||||
|
||||
it("parses products of variables", [&]() {
|
||||
TSDocumentSetText(document, "x*y");
|
||||
AssertThat(string(TSDocumentToString(document)), Equals("(expression (term (factor (variable)) (3) (factor (variable))))"));
|
||||
AssertThat(string(TSDocumentToString(document)), Equals(
|
||||
"(expression (term (factor (variable)) (3) (factor (variable))))"));
|
||||
});
|
||||
|
||||
it("parses complex trees", [&]() {
|
||||
TSDocumentSetText(document, "x*y+z*a");
|
||||
AssertThat(string(TSDocumentToString(document)), Equals(
|
||||
"(expression (term (factor (variable)) (3) (factor (variable))) (4) (term (factor (variable)) (3) (factor (variable))))"));
|
||||
|
||||
TSDocumentSetText(document, "x*(y+z)");
|
||||
AssertThat(string(TSDocumentToString(document)), Equals(
|
||||
"(expression (term (factor (variable)) (3) (factor (1) (expression (term (factor (variable))) (4) (term (factor (variable)))) (2))))"));
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue