Skip to content

Commit

Permalink
🐛 Fix minor parsing bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
fTrestour committed Jan 31, 2024
1 parent 9375401 commit 4f97cd8
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/domain/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,24 +132,19 @@ function parseClassDeclaration<T extends Token>(
throw new Error("Expected left brace");
}

rest = rest.slice(1);
let functions = new Array<Function<T>>();
while (rest[0].type !== "RIGHT_BRACE") {
const { ast: newAst, rest: newRest } = parseFunction(rest);

if (newAst === null) {
throw new Error("Expected function declaration");
if (newAst !== null) {
functions.push(newAst);
}

functions.push(newAst);
rest = newRest;
}
rest = rest.slice(1);

if (rest[0].type !== "SEMICOLON") {
throw new Error("Expected semicolon");
}
rest = rest.slice(1);

return {
ast: new ClassDeclaration(classToken, name, inheritance, functions),
rest,
Expand Down Expand Up @@ -899,7 +894,7 @@ function parseArguments<T extends Token>(

let expression = parseExpression(rest);
if (expression.ast === null) {
throw new Error("Expected expression");
return { args, rest };
}
args.push(new Argument(tokens[0], expression.ast));
rest = expression.rest;
Expand Down

0 comments on commit 4f97cd8

Please sign in to comment.