meta-coffee
meta-coffee copied to clipboard
How to define environment for compiled files
I'm trying to use this in node. There is a lot of external stuff in generated files which as obviously undefined.
module, __filename, __dirname) { MultiplicativeInterpreter = subclass(OMeta, {
^
ReferenceError: OMeta is not defined
at Object.<anonymous> (o:\glob-rules\grammar.js:1:100)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
found in its own sources https://github.com/xixixao/meta-coffee/blob/master/src/metacoffee/bs-semactionparser.mc#L1-L3
In Node, you can do {runtime: {subclass, OMeta}} = require 'metacoffee'
. The reason for the weird API was that I was using the compiler in both the browser and in Node. I didn't want to inline the runtime, which is pretty big. This still needs fixing.
Could you add this line to the examples in Readme.md? It could help people trying out your lib.
@KamilSzot Done. I welcome anyone to take a stab at better fixing this.