Skip to content

Commit

Permalink
feat: implement IParser interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Bikossor committed Jul 12, 2022
1 parent 7451473 commit fc4125b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/parser/JavaScript-rudus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
whitespace,
between,
} from "rudus";
import { IParser } from "../Interfaces";

const betweenDoubleQuotes = between(string('"'));
const optionalWhitespace = optional(whitespace());
Expand Down Expand Up @@ -41,10 +42,8 @@ const variableParser = sequenceOf([
variableValue.map(state => `<span style="color:blue">${state.result}</span>`),
]);

const parserResult = variableParser.run("const isCool = null");

if (parserResult.isError) {
console.log(parserResult.errorMessage);
} else {
console.log(parserResult.result);
export class JavaScriptRudusParser implements IParser {
parse(input: string) {
return variableParser.run(input);
}
}

0 comments on commit fc4125b

Please sign in to comment.