Collins Software
Software Developer
713-682-1556
ETerms ICMap Mav Cg2 Contact Links Videos

CollinsLanguage.js

Building your own language compiler...

  • Reduction Table
  • Precedence
  • Associative properties
  • Resolve reduction conflicts
  • Terminals and Non-Terminals
  • Program generation
  • Recursive and non-recursive reductions
reductionTable = '' +
	'/Precedence;' +
	'+- plus  left;' +
	'+- minus left;' +
	'/Reduction;' + 
	'mathAdd:	   E -> E plus E 	PRECEDENCE +-;' +
	'mathSub:	   E -> E minus E 	PRECEDENCE +-;' +
	'number:	   E -> number;' +
	'/Script;' +
	'function mathAdd(compiler,A,op,B) {return A + B}';
	'function mathSub(compiler,A,op,B) {return A - B}';	
	'function number(compiler,A) {return parseFloat(A)}';	
	
language = new language$('MyLanguage',reductionTable);
language.writeToFile('MyLanguage.js');
		
compiler = new compiler$('MyLanguage.js');
alert(compiler.eval('123.3 plus 34.3'));	
			

Copyright © 2012, Collins Software
 Privacy       Hobbies