Skip to content

Commit

Permalink
fix: tokenize $ as id than punctuator (#58)
Browse files Browse the repository at this point in the history
tokenizing $ as punctuator is breaking existing workflow engine
  • Loading branch information
koladilip authored Jun 6, 2024
1 parent 900504b commit 89a4dc7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class JsonTemplateLexer {
const token = this.lookahead();
if (token.type === TokenType.PUNCT) {
const { value } = token;
return value === '.' || value === '..' || value === '^' || value === '$' || value === '@';
return value === '.' || value === '..' || value === '^' || value === '@';
}

return false;
Expand Down Expand Up @@ -359,7 +359,7 @@ export class JsonTemplateLexer {
}

private static isIdStart(ch: string) {
return ch === '_' || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z');
return ch === '_' || ch === '$' || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z');
}

private static isIdPart(ch: string) {
Expand Down Expand Up @@ -607,7 +607,7 @@ export class JsonTemplateLexer {
const start = this.idx;
const ch1 = this.codeChars[this.idx];

if (',;:{}()[]^+-*/%!><|=@~$#?\n'.includes(ch1)) {
if (',;:{}()[]^+-*/%!><|=@~#?\n'.includes(ch1)) {
return {
type: TokenType.PUNCT,
value: ch1,
Expand Down
4 changes: 2 additions & 2 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,10 @@ export class JsonTemplateParser {
if (root) {
return root;
}
if (this.lexer.matchID()) {
const nextToken = this.lexer.lookahead();
if (nextToken.type === TokenType.ID && nextToken.value !== '$') {
return this.lexer.value();
}
const nextToken = this.lexer.lookahead();
const tokenReturnValues = {
'^': DATA_PARAM_KEY,
$: pathType.inferredPathType === PathType.JSON ? DATA_PARAM_KEY : BINDINGS_PARAM_KEY,
Expand Down

0 comments on commit 89a4dc7

Please sign in to comment.