Skip to content

Commit 0a17de8

Browse files
committed
pass 'Compiler module should provide correct parsing for rule statements'
1 parent d03396d commit 0a17de8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Diff for: src/ast.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export namespace syxparser {
6161

6262
if (rule.type === 'boolean') {
6363
const boolEx = parseExpression(false, false, true) as Expression;
64-
if (!(statementIsA(boolEx, NodeType.String) && dictionary.RuleTypeRegexes.boolean.test(boolEx.value))) throw new CompilerError(boolEx.range, `Rule '${rule.name}' requires a boolean value, found '${boolEx.value}'.`, filePath);
64+
if (!(statementIsA(boolEx, NodeType.Identifier) && dictionary.RuleTypeRegexes.boolean.test(boolEx.value))) throw new CompilerError(boolEx.range, `Rule '${rule.name}' requires a boolean value, found '${boolEx.value}'.`, filePath);
6565

6666
if (at().type !== TokenType.Semicolon) throw new CompilerError(at().range, `Expected semicolon after rule statement, found '${at().value}'.`, filePath);
6767
tokens.shift();

Diff for: src/test/compiler.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ describe('Compiler module', () => {
215215

216216
const tokens = tokenizeSyx('rule \'function-value-return-enabled\': true;');
217217
const ast = syxparser.parseTokens(tokens, 'TEST_FILE');
218-
const stmt: RuleStatement = { range: { start: { line: 1, character: 1 }, end: { line: 1, character: 43 } }, modifiers: [], rule: {range:r(6,38),type:NodeType.String,value:'function-value-return-enabled',modifiers:[]}, value: 'true', type: NodeType.Rule };
218+
const stmt: RuleStatement = { range: { start: { line: 1, character: 1 }, end: { line: 1, character: 43 } }, modifiers: [], rule: {range:r(6,37),type:NodeType.String,value:'function-value-return-enabled',modifiers:[]}, value: 'true', type: NodeType.Rule };
219219

220220
astTypeExpectations(ast);
221221
expect(ast.body[0]).to.be.a('object').to.be.deep.equal(stmt);

0 commit comments

Comments
 (0)