-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix: Fix improper state generation in setShiftAction
Previously, setShiftAction could modify an already populated state instead of regenerating its successor. This is problematic because 0. the modified state was then not marked for regeneration, so it could be left in an inconsisten state 1. the modified state could also be a successor of another state and the modification could hypothetically be incorrect for that state
- Loading branch information
Showing
5 changed files
with
64 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { LetDeclaration, parser } from "./grammar-6.js"; | ||
import { ParseError } from "../parser/parser.js"; | ||
|
||
describe('Parser', () => { | ||
it('does not parse ""', () => { | ||
const result = parser.parse(''); | ||
|
||
expect(result).toBeInstanceOf(ParseError); | ||
}); | ||
|
||
it('does not parse "l"', () => { | ||
const result = parser.parse('l'); | ||
|
||
expect(result).toBeInstanceOf(ParseError); | ||
}); | ||
|
||
it('parses "l{}"', () => { | ||
const result = parser.parse('l{}'); | ||
|
||
expect(result).toBeInstanceOf(LetDeclaration); | ||
expect(result as LetDeclaration).toHaveProperty('body', []); | ||
}); | ||
|
||
it('parses "l{l{}}"', () => { | ||
const result = parser.parse('l{l{}}'); | ||
|
||
expect(result).toBeInstanceOf(LetDeclaration); | ||
expect(result as LetDeclaration).toHaveProperty('body', [ | ||
expect.any(LetDeclaration), | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Caten, Maybe, MatchArr, SyntaxTreeNode } from "#pattern"; | ||
import { LogLevel } from "../parser/table/generate-table.js"; | ||
import { Parser } from "../parser/parser.js"; | ||
|
||
|
||
export class LetDeclaration extends SyntaxTreeNode { | ||
body!: LetDeclaration[]; | ||
|
||
static pattern: Caten = new Caten( | ||
'l', | ||
'{', | ||
new Maybe( | ||
new MatchArr('body', LetDeclaration), | ||
), | ||
'}', | ||
); | ||
} | ||
|
||
export const parser = new Parser(LetDeclaration, { | ||
logLevel: LogLevel.verbose, | ||
}); | ||
|
||
parser.parse('l{l{}}'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters