jweinst1
4/8/2016 - 8:52 PM

splitting function for javascript assembly

splitting function for javascript assembly

//;op:arg1:arg2; --> Format for commands
/*
;!foo(f,d,a);+:3;-:3:4; --> function declaration

;+=:d:3:4:5; --> assign-equal opers

;$:foo:3:4:5;=>:f; --> return oper

*/



function spliter(string) {
	if(/;.+;/.test(string)) {
		var tokens = string.slice(1, string.length-1).split(";");
		for(var i=0;i<tokens.length;i++) {
			tokens[i] = tokens[i].split(":");
		}
		return tokens;
	}
	else {
		//returns false if string is invalid assembly language
		return false;
	}
}