Skip to content

Commit

Permalink
Fix conditional statements (#32)
Browse files Browse the repository at this point in the history
* Fix conditional statements

* Update tokenizer.ts
  • Loading branch information
JJtan2002 authored Apr 15, 2024
1 parent ef683df commit 80f18e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class Parser {
const startToken = this.peek();
const statements: Stmt[] = [];
while (!this.isAtEnd()) {
if (this.match(TokenType.NEWLINE)) {
if (this.match(TokenType.NEWLINE) || this.match(TokenType.DEDENT)) {
continue;
}
statements.push(this.stmt());
Expand Down
7 changes: 7 additions & 0 deletions src/tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,19 @@ export class Tokenizer {
while (this.isDigit(this.peek())) {
this.advance();
}

if (this.peek() !== '.' && this.peek() !== 'e') {
this.addToken(TokenType.BIGINT);
return;
}

if (this.peek() === '.') {
this.advance();
while (this.isDigit(this.peek())) {
this.advance();
}
}

if (this.peek() === 'e') {
this.advance();
if (this.peek() === '-') {
Expand Down

0 comments on commit 80f18e8

Please sign in to comment.