(code)
| 19892 | return this |
| 19893 | } |
| 19894 | _requireInVmNodeJsRootParser(code) { |
| 19895 | const vm = require("vm") |
| 19896 | const path = require("path") |
| 19897 | // todo: cleanup up |
| 19898 | try { |
| 19899 | Object.keys(GlobalNamespaceAdditions).forEach(key => { |
| 19900 | global[key] = require("./" + GlobalNamespaceAdditions[key]) |
| 19901 | }) |
| 19902 | global.require = require |
| 19903 | global.__dirname = this._dirName |
| 19904 | global.module = {} |
| 19905 | return vm.runInThisContext(code) |
| 19906 | } catch (err) { |
| 19907 | // todo: figure out best error pattern here for debugging |
| 19908 | console.log(`Error in compiled parsers code for language "${this.parsersName}"`) |
| 19909 | // console.log(new Particle(code).toStringWithLineNumbers()) |
| 19910 | console.log(err) |
| 19911 | throw err |
| 19912 | } |
| 19913 | } |
| 19914 | examplesToTestBlocks(rootParser = this.compileAndReturnRootParser(), expectedErrorMessage = "") { |
| 19915 | const testBlocks = {} |
| 19916 | this.validConcreteAndAbstractParserDefinitions.forEach(def => |
no test coverage detected