Skip to content

Commit c3f8652

Browse files
committed
Ensure we can use Lionweb nodes as parser traces (wip)
1 parent 5453e81 commit c3f8652

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

src/interop/strumenta-playground.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ export class ParserNode extends TraceNode {
8686

8787
parent?: ParserNode;
8888

89-
constructor(eo: ECore.EObject, parent: ParserNode | undefined, protected trace: ParserTrace) {
90-
super(eo);
89+
constructor(inner: NodeAdapter, parent: ParserNode | undefined, protected trace: ParserTrace) {
90+
super(inner);
9191
this.parent = parent;
9292
}
9393

tests/interop/lionweb.test.ts

+31
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {
1111
} from "../../src/interop/lionweb";
1212
import {map, pipe, reduce} from "iter-ops";
1313
import {STARLASU_LANGUAGE} from "../../src/interop/lionweb-starlasu-language";
14+
import {ParserNode, ParserTrace} from "../../src/interop/strumenta-playground";
15+
import {PARSER_TRACE_ECLASS} from "../../src/interop/parser-package";
1416

1517
abstract class File extends Node {
1618
@Property()
@@ -87,6 +89,35 @@ describe('Lionweb integration', function() {
8789
expect(file.name).to.equal("delegate.egl");
8890
expect(file.contents.substring(0, 10)).to.equal("Delegate F");
8991

92+
expect(printSequence(walk(root.node))).to.equal(
93+
"resources.zip, resources, delegate.egl, rosetta-code-count-examples-2.egl, " +
94+
"rosetta-code-count-examples-1.egl, sub1, sub2, foreach.egl, SQLDropTable.egl, for.egl, SQLBatch.egl, " +
95+
"SQLCreateTable.egl, SQLDropTable.egl, hello.egl, foreach.egl, Calc.egl, SQLBatch.egl, " +
96+
"multipleWhenCondition.egl, handler.egl, SQLCreateTable.egl, newExample.egl, SQLDropTable.egl, " +
97+
"nestedLoop.egl, for.egl");
98+
});
99+
100+
it("supports trace nodes",
101+
function () {
102+
const nodes = deserializeChunk(FS_MODEL, new TylasuInstantiationFacade(), [FS_LANGUAGE], []);
103+
expect(nodes).not.to.be.empty;
104+
expect(nodes.length).to.equal(1);
105+
const root = nodes[0];
106+
expect(root.node).to.be.instanceof(LionwebNode);
107+
let dir = new ParserNode(root.node as LionwebNode, undefined, new ParserTrace(PARSER_TRACE_ECLASS.create({}))); // TODO
108+
expect(dir.nodeDefinition.name).to.equal("Directory");
109+
expect(dir.getAttribute("name")).to.equal("resources.zip");
110+
expect(dir.getChildren("files").length).to.equal(1);
111+
dir = dir.getChildren("files")[0];
112+
expect(dir.nodeDefinition.name).to.equal("Directory");
113+
expect(dir.getAttribute("name")).to.equal("resources");
114+
expect(dir.getChildren("files").length).to.equal(15);
115+
const file = dir.getChildren("files")[0];
116+
expect(file.nodeDefinition.name).to.equal("TextFile");
117+
expect(file.getAttribute("name")).to.equal("delegate.egl");
118+
expect(file.getAttribute("contents").substring(0, 10)).to.equal("Delegate F");
119+
expect(file.getPathFromRoot()).to.equal([]);
120+
90121
expect(printSequence(walk(root.node))).to.equal(
91122
"resources.zip, resources, delegate.egl, rosetta-code-count-examples-2.egl, " +
92123
"rosetta-code-count-examples-1.egl, sub1, sub2, foreach.egl, SQLDropTable.egl, for.egl, SQLBatch.egl, " +

0 commit comments

Comments
 (0)