Skip to content

Commit

Permalink
fix: issue with the deserializer and tokenizer
Browse files Browse the repository at this point in the history
  • Loading branch information
xhayper committed Nov 10, 2023
1 parent ba1d45a commit c886d9f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
27 changes: 13 additions & 14 deletions src/internal/lexicalAnalysis/tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,6 @@ export class Tokenizer {
else if (this.eachDividerChars.has(c)) return this.compileToken(TokenType.EachDivider);
else if (this.separatorChars.has(c)) return undefined;

const [isLocationToken, locationLength] = this.tryScanLocationToken();
if (isLocationToken) {
this._current += locationLength - 1;
return this.compileToken(TokenType.Location);
}

const [isSlideDeclaration, slideLength] = this.isReadingSlideDeclaration();
if (isSlideDeclaration) {
this._current += slideLength - 1;
return this.compileToken(TokenType.Slide);
}

switch (c) {
case ",":
return this.compileToken(TokenType.TimeStep);
Expand Down Expand Up @@ -106,10 +94,21 @@ export class Tokenizer {

return undefined;
}
}

const [isLocationToken, locationLength] = this.tryScanLocationToken();
if (isLocationToken) {
this._current += locationLength - 1;
return this.compileToken(TokenType.Location);
}

default:
throw new UnsupportedSyntaxException(this._line, this._charIndex);
const [isSlideDeclaration, slideLength] = this.isReadingSlideDeclaration();
if (isSlideDeclaration) {
this._current += slideLength - 1;
return this.compileToken(TokenType.Slide);
}

throw new UnsupportedSyntaxException(this._line, this._charIndex);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/internal/syntacticAnalysis/deserializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class Deserializer {
let group = NoteGroup.Tap;

if (isSensor) {
group = NoteGroup[token.lexeme[0].charCodeAt(0) - "A".charCodeAt(0) + 1] as unknown as NoteGroup;
group = (token.lexeme[0].charCodeAt(0) - "A".charCodeAt(0) + 1) as NoteGroup;

if (group === NoteGroup.CSensor) {
return [true, new Location(0, group)];
Expand Down

0 comments on commit c886d9f

Please sign in to comment.