-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(lex,parse): Allow stop statements (#247)
fixes #192
- Loading branch information
1 parent
165b129
commit 3a6f30b
Showing
7 changed files
with
369 additions
and
1 deletion.
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
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,42 @@ | ||
const brs = require("brs"); | ||
const { Lexeme } = brs.lexer; | ||
const { Int32 } = brs.types; | ||
|
||
const { token, identifier, EOF } = require("../ParserTests"); | ||
|
||
describe("stop statement", () => { | ||
it("cannot be used as a local variable", () => { | ||
let { statements, errors } = brs.parser.Parser.parse([ | ||
token(Lexeme.Stop, "stop"), | ||
token(Lexeme.Equal, "="), | ||
token(Lexeme.True, "true"), | ||
EOF, | ||
]); | ||
|
||
//should be an error | ||
expect(errors).toHaveLength(1); | ||
expect(statements).toBeDefined(); | ||
expect(statements).not.toBeNull(); | ||
expect(statements).toMatchSnapshot(); | ||
}); | ||
|
||
it("is valid as a statement", () => { | ||
let { statements, errors } = brs.parser.Parser.parse([token(Lexeme.Stop, "stop"), EOF]); | ||
expect(errors[0]).toBeUndefined(); | ||
expect(statements).toMatchSnapshot(); | ||
}); | ||
|
||
it("can be used as an object property", () => { | ||
let { tokens } = brs.lexer.Lexer.scan(` | ||
sub Main() | ||
theObject = { | ||
stop: false | ||
} | ||
theObject.stop = true | ||
end sub | ||
`); | ||
let { statements, errors } = brs.parser.Parser.parse(tokens); | ||
expect(errors.length).toEqual(0); | ||
expect(statements).toMatchSnapshot(); | ||
}); | ||
}); |
Oops, something went wrong.