meta-coffee icon indicating copy to clipboard operation
meta-coffee copied to clipboard

How to define environment for compiled files

Open Evgenus opened this issue 10 years ago • 4 comments

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

Evgenus avatar Sep 05 '14 14:09 Evgenus

found in its own sources https://github.com/xixixao/meta-coffee/blob/master/src/metacoffee/bs-semactionparser.mc#L1-L3

Evgenus avatar Sep 07 '14 01:09 Evgenus

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.

xixixao avatar Nov 04 '14 00:11 xixixao

Could you add this line to the examples in Readme.md? It could help people trying out your lib.

KamilSzot avatar Feb 22 '15 12:02 KamilSzot

@KamilSzot Done. I welcome anyone to take a stab at better fixing this.

xixixao avatar Feb 22 '15 21:02 xixixao