Load and read PGF in test-web: doesn't fail but abstract name is empty

This commit is contained in:
John J. Camilleri
2022-08-01 14:47:28 +02:00
parent 8df9767493
commit 0bac8f0dae
2 changed files with 14 additions and 0 deletions

View File

@@ -41,6 +41,7 @@ RUN emcc .libs/libgu.a .libs/libpgf.a -o pgf.js \
ccall,\
FS,\
getValue,\
AsciiToString,\
stringToUTF8,\
UTF8ToString,\
allocateUTF8\

View File

@@ -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))");