Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
An update that fixes a critical bug where duplicate "ghost" characters were put into the list of scanned tokens/characters when there were multiple candidate tokens (i.e. tokens that start with identical substrings).
  • Loading branch information
CalinZBaenen authored Dec 13, 2021
1 parent ff1b73a commit 78ec5f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions parse_string.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ const parse_string = function parse_string(str="", toks=null) {
i += v.length-1;
} else parsed_array.push(c);
}
if(v instanceof Array) for(const tok of v) {
if(v instanceof Array) for(let i2 = 0; i2 < v.length; i2++) {
const tok = v[i2];

const slc = str.slice(i, i+tok.length);
const tvs = slc === tok;
if(tvs) {
parsed_array.push( Symbol.for(tok) );
i += tok.length-1;
break;
} else parsed_array.push(c);
} else if(i2 >= v.length-1) parsed_array.push(c);
};
} else parsed_array.push(c);
}
Expand Down
6 changes: 4 additions & 2 deletions parse_string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ const parse_string = function parse_string(
i += v.length-1;
} else parsed_array.push(c);
}
if(v instanceof Array) for(const tok of v) {
if(v instanceof Array) for(let i2 = 0; i2 < v.length; i2++) {
const tok = v[i2];

const slc = str.slice(i, i+tok.length);
const tvs = slc === tok;
if(tvs) {
parsed_array.push( Symbol.for(tok) );
i += tok.length-1;
break;
} else parsed_array.push(c);
} else if(i2 >= v.length) parsed_array.push(c);
};
} else parsed_array.push(c);
}
Expand Down

0 comments on commit 78ec5f7

Please sign in to comment.