Skip to content

Commit fc4125b

Browse files
committed
feat: implement IParser interface
#119
1 parent 7451473 commit fc4125b

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/parser/JavaScript-rudus.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
whitespace,
88
between,
99
} from "rudus";
10+
import { IParser } from "../Interfaces";
1011

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

44-
const parserResult = variableParser.run("const isCool = null");
45-
46-
if (parserResult.isError) {
47-
console.log(parserResult.errorMessage);
48-
} else {
49-
console.log(parserResult.result);
45+
export class JavaScriptRudusParser implements IParser {
46+
parse(input: string) {
47+
return variableParser.run(input);
48+
}
5049
}

0 commit comments

Comments
 (0)