faust icon indicating copy to clipboard operation
faust copied to clipboard

@grame/libfaust: .compileNode() doesn't return details about syntax errors

Open dxinteractive opened this issue 3 years ago • 0 comments

While making my own version of Faust IDE, I'm finding it a little difficult to use Faust.createMonoFactory().compileNode() when given incorrect dsp, because the specific details about the syntax error don't seem to be available anywhere. All that I see is that console.error is called stating that a syntax error occurred, and the result of the promise returned from .compileNode() is null.

image

My code:

const dsp = `
import("stdfaust.lib");
process = os.sawtooth(1000.0), os.sawtooth(200.0.0);
`;

const compiler = Faust.createCompiler(Faust.createLibFaust(module));
const node = await Faust.createMonoFactory().compileNode(
  audioCtx,
  "Faust",
  compiler,
  dsp,
  "-ftz 2",
  false,
  128
);

Would it be worth considering this? a) surfacing the details of the syntax error through the API a) If compilation fails, it might be more idiomatic javascript and more useful for developer if the promise returned from .compileNode() rejects with an Error containing those error details. Simply receiving null gives no information about what went wrong.

Or is there a way I don't know about? I'm looking into compilation parameters that might affect this.

The Faust IDE for example shows a more specific error "unexpected float":

import("stdfaust.lib");
process = os.sawtooth(1000.0), os.sawtooth(200.0.0);

yields

image

dxinteractive avatar Jun 29 '22 13:06 dxinteractive