Skip to content

Commit

Permalink
test: precedence for array indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
yazaldefilimone committed Feb 25, 2024
1 parent 76d854a commit 647d04e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/parser/precedence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export enum Precedence {
PRODUCT, // *
PREFIX, // -X or !X
CALL, // myFunction(X)
INDEX, // array[index]
}

type precedenceMapType = Partial<Record<TokenType, Precedence>>;
Expand All @@ -21,4 +22,5 @@ export const precedences: precedenceMapType = {
[TokenType.MINUS]: Precedence.SUM,
[TokenType.EQ]: Precedence.EQUALS,
[TokenType.NOT_EQ]: Precedence.EQUALS,
};
[TokenType.LBRACKET]: Precedence.INDEX,
} as const;

0 comments on commit 647d04e

Please sign in to comment.