Revert change to parse
This commit is contained in:
@@ -81,9 +81,6 @@ export function complete(
|
||||
extensionFunctions
|
||||
);
|
||||
const expr = p.parse();
|
||||
if (!expr) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const ev = new Evaluator(expr, context, functions);
|
||||
const result = ev.evaluate();
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
import {Expr} from "./ast";
|
||||
import * as data from "./data";
|
||||
import {ExpressionEvaluationError} from "./errors";
|
||||
import {Evaluator} from "./evaluator";
|
||||
import {Lexer} from "./lexer";
|
||||
import {Parser} from "./parser";
|
||||
|
||||
function assertDefined(x: Expr | undefined): asserts x is Expr {
|
||||
expect(x).toBeDefined();
|
||||
}
|
||||
|
||||
describe("evaluator", () => {
|
||||
const lexAndParse = (input: string) => {
|
||||
const lexer = new Lexer(input);
|
||||
@@ -17,7 +12,6 @@ describe("evaluator", () => {
|
||||
// Parse
|
||||
const parser = new Parser(result.tokens, ["foo"], []);
|
||||
const expr = parser.parse();
|
||||
assertDefined(expr);
|
||||
return expr;
|
||||
};
|
||||
|
||||
|
||||
@@ -43,13 +43,16 @@ export class Parser {
|
||||
};
|
||||
}
|
||||
|
||||
public parse(): Expr | undefined {
|
||||
public parse(): Expr {
|
||||
// eslint-disable-next-line prefer-const
|
||||
let result!: Expr;
|
||||
|
||||
// No tokens
|
||||
if (this.atEnd()) {
|
||||
return;
|
||||
return result;
|
||||
}
|
||||
|
||||
const result = this.expression();
|
||||
result = this.expression();
|
||||
|
||||
if (!this.atEnd()) {
|
||||
throw this.buildError(ErrorType.ErrorUnexpectedSymbol, this.peek());
|
||||
|
||||
@@ -119,7 +119,7 @@ describe("x-lang tests", () => {
|
||||
// Parse
|
||||
const contextNames = testCase.contexts.pairs().map(x => x.key);
|
||||
const parser = new Parser(result.tokens, contextNames, []);
|
||||
let expr: Expr | undefined;
|
||||
let expr: Expr;
|
||||
try {
|
||||
expr = parser.parse();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user