diff --git a/src/runtime/javascript/Dockerfile b/src/runtime/javascript/Dockerfile index 13d37dc23..62378d73d 100644 --- a/src/runtime/javascript/Dockerfile +++ b/src/runtime/javascript/Dockerfile @@ -41,6 +41,7 @@ RUN emcc .libs/libgu.a .libs/libpgf.a -o pgf.js \ ccall,\ FS,\ getValue,\ + AsciiToString,\ stringToUTF8,\ UTF8ToString,\ allocateUTF8\ diff --git a/src/runtime/javascript/test-web.js b/src/runtime/javascript/test-web.js index 83b72ca41..2e4d3e87f 100644 --- a/src/runtime/javascript/test-web.js +++ b/src/runtime/javascript/test-web.js @@ -1,6 +1,19 @@ Module.onRuntimeInitialized = () => { const JSPGF = mkAPI(Module); + fetch('Foods.pgf') + .then((response) => response.arrayBuffer()) + .then((data) => { + const pgfPathFS = '/tmp/Foods.pgf'; + Module.FS.writeFile(pgfPathFS, new DataView(data)); + + // Read PGF + const pgf = JSPGF.readPGF(pgfPathFS); + + // Print its name + console.log(JSPGF.abstractName(pgf)); + }) + // Parse expression const expr = JSPGF.readExpr("Pred (Another (x f))");