Class Index | File Index

Classes


Class mmir.env.grammar.AsyncGenerator


Defined in: asyncGenerator.js.

Class Summary
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

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Feb 26 2016 21:44:43 GMT+0100 (Mitteleuropäische Zeit)