Skip to content

Commit

Permalink
allow expr as index
Browse files Browse the repository at this point in the history
  • Loading branch information
rapiz1 committed Nov 3, 2021
1 parent d38686b commit 744e1c3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ Expr* Parser::index() {
Expr* e = primary();
if (match(1, LEFT_SQUARE)) {
advance();
auto i = primary();
auto i = expression();
e = new Index(e, i);
consume(RIGHT_SQUARE, "Expect `]` after indexing");
}
Expand Down
2 changes: 1 addition & 1 deletion parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Parser {
Expr* unary(); // (! | - | -- | ++)* POSTFIX
Expr* postfix(); // CALL (++ | --)*
Expr* call(); // INDEX ('(' ARGS? ')')*
Expr* index(); // PRIM ('[' NUMBER ']')?
Expr* index(); // PRIM ('[' EXPR ']')?
Expr* primary();

public:
Expand Down

0 comments on commit 744e1c3

Please sign in to comment.