// Generated by Haxe 4.3.6 (function ($global) { "use strict"; var $estr = function() { return js_Boot.__string_rec(this,''); },$hxEnums = $hxEnums || {},$_; Math.__name__ = true; var Token = $hxEnums["Token"] = { __ename__:true,__constructs__:null ,Operation: ($_=function(op) { return {_hx_index:0,op:op,__enum__:"Token",toString:$estr}; },$_._hx_name="Operation",$_.__params__ = ["op"],$_) ,Number: ($_=function(num) { return {_hx_index:1,num:num,__enum__:"Token",toString:$estr}; },$_._hx_name="Number",$_.__params__ = ["num"],$_) }; Token.__constructs__ = [Token.Operation,Token.Number]; var Parser = function() { }; Parser.__name__ = true; Parser.main = function() { var button = window.document.querySelector(".runButton"); button.onclick = function(event) { Parser.runButton(); }; }; Parser.runButton = function() { var inputArea = window.document.querySelector(".source"); var res = Parser.run(Parser.parse(inputArea.value)); var outputDisplay = window.document.querySelector(".output"); outputDisplay.innerHTML = "Output:
" + res.join(", ") + ""; }; Parser.parse = function(input) { var array = []; var i = 0; var splits = input.split(" "); while(i < splits.length) { var split = splits[i]; if(split != " " && split != "\n" && split != "\r") { if(Std.parseInt(split) != null) { var num = Std.parseInt(split); array.push(Token.Number(num)); } else if(["+","-","*","/","@"].indexOf(split) != -1) { array.push(Token.Operation(split)); } } ++i; } return array; }; Parser.run = function(array) { var stack = []; var i = 0; while(i < array.length) { var e = array[i]; if($hxEnums[e.__enum__].__constructs__[e._hx_index]._hx_name == "Number") { stack.push(Type.enumParameters(array[i])[0]); } else { var e1 = array[i]; if($hxEnums[e1.__enum__].__constructs__[e1._hx_index]._hx_name == "Operation") { var op = Type.enumParameters(array[i])[0]; switch(op) { case "*": var right = stack.pop(); var left = stack.pop(); var res = left * right; stack.push(res); break; case "+": var right1 = stack.pop(); var left1 = stack.pop(); var res1 = left1 + right1; stack.push(res1); break; case "-": var right2 = stack.pop(); var left2 = stack.pop(); var res2 = left2 - right2; stack.push(res2); break; case "/": var right3 = stack.pop(); var left3 = stack.pop(); var res3 = left3 / right3; stack.push(Math.round(res3)); break; case "@": var right4 = stack.pop(); var left4 = stack.pop(); stack.push(right4); stack.push(left4); break; } } } ++i; } return stack; }; var Std = function() { }; Std.__name__ = true; Std.parseInt = function(x) { var v = parseInt(x); if(isNaN(v)) { return null; } return v; }; var Type = function() { }; Type.__name__ = true; Type.enumParameters = function(e) { var enm = $hxEnums[e.__enum__]; var params = enm.__constructs__[e._hx_index].__params__; if(params != null) { var _g = []; var _g1 = 0; while(_g1 < params.length) { var p = params[_g1]; ++_g1; _g.push(e[p]); } return _g; } else { return []; } }; var haxe_iterators_ArrayIterator = function(array) { this.current = 0; this.array = array; }; haxe_iterators_ArrayIterator.__name__ = true; haxe_iterators_ArrayIterator.prototype = { hasNext: function() { return this.current < this.array.length; } ,next: function() { return this.array[this.current++]; } }; var js_Boot = function() { }; js_Boot.__name__ = true; js_Boot.__string_rec = function(o,s) { if(o == null) { return "null"; } if(s.length >= 5) { return "<...>"; } var t = typeof(o); if(t == "function" && (o.__name__ || o.__ename__)) { t = "object"; } switch(t) { case "function": return "