Skip to content

Commit

Permalink
Throw error on extra closing bracket
Browse files Browse the repository at this point in the history
  • Loading branch information
samestep committed Jan 3, 2024
1 parent 6f82b50 commit 8464ab8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/rose/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type ErrorData =
// token trees
| { kind: "Unmatched"; left: TokenId }
| { kind: "Mismatched"; left: TokenId; right: TokenId }
| { kind: "Extra"; right: TokenId }

// `use`
| { kind: "UseListMissing"; use: TokenId }
Expand Down Expand Up @@ -97,7 +98,9 @@ export const forest = (tokens: Token[]): Tree[] => {
return trees;
};

return recurse();
const trees = recurse();
if (i < tokens.length) throw new ParseError({ kind: "Extra", right: i });
return trees;
};

export const filter = (tokens: Token[], trees: Tree[]): Tree[] => {
Expand Down

0 comments on commit 8464ab8

Please sign in to comment.