import {Grammar, Parser} from "nearley";
import {readFileSync} from "fs";
export default class Actioniser {
parsed: string[];
parser: Parser;
constructor(grammar: Grammar) {
this.parser = new Parser(grammar);
}
start(_initpath: string) {
this.parsed = readFileSync(_initpath, "utf8").split(/\r\n/g);
for(let chunk of this.parsed) {
this.parser.feed(chunk);
}
console.log(this.parser.results);
}
}
I tracked it down to the this.parse = new parser that fails and its confusion
just so you know in the file that initializes it im doing
function continuerun(_opts:any) {
let grammar = require(resolve(__dirname, '../../../lang/o/grammar.js'));
let actioniser = new Actioniser(Grammar.fromCompiled(grammar));
if (!existsSync(resolve(process.cwd(), "project.json"))) {
throw new Error("project.json file not found");
}
let project = require(resolve(process.cwd(), "project.json"));
actioniser.start(resolve(process.cwd(), "src", project.compiler.entry));
}
basically i have a class that looks like:
I tracked it down to the this.parse = new parser that fails and its confusion just so you know in the file that initializes it im doing
and this is the full log: https://hastebin.com/yoyudafowa.rb and this is the outputted grammar file https://hastebin.com/otohemapev.js