Skip to content

Commit

Permalink
Allow [ and ] instead of ( and )
Browse files Browse the repository at this point in the history
  • Loading branch information
pmatos authored Jun 15, 2023
1 parent 361d7f5 commit e2bb4f5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Lex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,16 @@ Tok Lex::gettok(SourceStream &S) {
// We start by skipping whitespace which is not part of a token
S.skipWhitespace();

// FIXME: we are allowing both [ and ] for readability but we don't really
// count them to ensure they match so this is valid:
// (+ 2 1]
switch (S.peekChar()) {
case '(':
case '[':
S.skipPrefix(1);
return {Tok::TokType::LPAREN, S.getPosition()};
case ')':
case ']':
S.skipPrefix(1);
return {Tok::TokType::RPAREN, S.getPosition()};
}
Expand Down

0 comments on commit e2bb4f5

Please sign in to comment.