Skip to content

Commit

Permalink
Fixed indentStack (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
JJtan2002 authored May 9, 2024
1 parent d5f42ea commit c9f94dc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,13 @@ export class Tokenizer {
if (this.indentStack.length == 0) {
throw new TokenizerErrors.InconsistentIndentError(this.line, this.col, this.source, this.current);
}
const prev = this.indentStack.pop();
const prev = this.indentStack[this.indentStack.length - 1];
if (prev === undefined || prev === null) {
throw new TokenizerErrors.InconsistentIndentError(this.line, this.col, this.source, this.current);
}
const indents = Math.floor((prev - accLeadingWhiteSpace) / 4);
for (let i = 0; i < indents; ++i) {
this.indentStack.pop();
this.addToken(TokenType.DEDENT);
}
}
Expand Down

0 comments on commit c9f94dc

Please sign in to comment.