Skip to content

Commit

Permalink
feat: add optionalSemicolon to variableParser
Browse files Browse the repository at this point in the history
  • Loading branch information
Bikossor committed Jul 17, 2022
1 parent 4950c28 commit c5e200a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/parser/JavaScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ const optionalWhitespace = optional(whitespace()).map(state => [
state.result,
]);

const optionalSemicolon = regex(/;?/).map(state => [
NodeType.Separator,
state.result,
]);

const declarationKeyword = regex(/^var|let|const/);
const word = regex(/\w+/); // word
const equalSign = string("=");
Expand All @@ -42,6 +47,7 @@ const variableParser = sequenceOf([
equalSign.map(state => [NodeType.Operator, state.result]),
optionalWhitespace,
variableValue,
optionalSemicolon,
]);

export class JavaScriptParser implements IParser {
Expand Down

0 comments on commit c5e200a

Please sign in to comment.