jweinst1
7/6/2016 - 12:36 AM

matches tree languages

matches tree languages

/*
* Tree Language to match repetitive bounds---
* only clause matches
* rule: start[$] stop[%] except[\w] only[\w, w, f, d]
* rule: start[##] stop [$$] except [2]
*/

//counter to keep
var DepthCounter = (function(){
	function DepthCounter(symbols){
		for(var i=0;i<symbols.length;i++){
			this[symbols[i]] = 0;
		}
	}
	DepthCounter.prototype.increment = function(member){
		if(member in this){
			this[member] += 1;
		}
	};
	DepthCounter.prototype.decrement = function(member){
		if(member in this){
			this[member] -= 1;
		}
	};
	return DepthCounter;
})();