From aa94ff8d8d00a540fb2f770016362aef47208630 Mon Sep 17 00:00:00 2001 From: maestrow Date: Mon, 17 May 2021 22:36:42 +0300 Subject: [PATCH] cli_trace --- src/cli_trace.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/cli_trace.ts diff --git a/src/cli_trace.ts b/src/cli_trace.ts new file mode 100644 index 0000000..c480ef5 --- /dev/null +++ b/src/cli_trace.ts @@ -0,0 +1,23 @@ +import * as fs from "fs"; +import { Parser } from './parser' +import { Ast as AST } from './grammar-ast' +import { math1 } from './grammars/math1' +import { ometa1, proj } from './grammars/ometa1' +import { TraceDiscovery } from "./utils/trace-discover"; + + +const input = fs.readFileSync('src/grammars/ometa1.ometa', 'utf-8') + +//const p = new Parser(math1, [...'((1+2)-3*3)/4']) +//const r = p.match('expr') + +const p = new Parser(ometa1, input as unknown as any[], proj) +const r = p.match('ometa') + + +console.dir(r, {depth: null}) +const disco = new TraceDiscovery(ometa1, input, p.trace.data) +const trace = disco.convert() + +//console.dir(trace, {depth: null}) +fs.writeFileSync("./dist/trace.json", JSON.stringify(trace, null, 2))