Class mmir.env.grammar.AsyncGenerator
Defined in: asyncGenerator.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Module that provides a generator for parser-compiler WebWorker instances:
initializes the WebWorker instance and provides functions for communicating with
the WebWorker.
|
Class Detail
mmir.env.grammar.AsyncGenerator()
Module that provides a generator for parser-compiler WebWorker instances:
initializes the WebWorker instance and provides functions for communicating with
the WebWorker.
//initializes a WebWorker at MMIR's worker path, i.e. at constants.getWorkerPath() + "file.name": var asyncCompiler = asyncGen.createWorker("jisonCompiler.js"); //create job ID (must be unique for each job): var taskId = '1'; //register callback for the job ID: asyncCompiler.addCallback(taskId, function(evtData){ if(evtData.error){ //... do something } else { var hasError = evtData.hasError; var grammarParser = evtData.def; //... do something } }); //start a compile job on the worker: asyncCompiler.postMessage({ cmd: 'parse', id: taskId, config: options, //compile options (specific to compiler engine) text: grammarDefinition //parser definition (using the syntax of the specific compiler engine) });
- Requires:
- WebWorker