1 /* 2 JessieCode Parser and Compiler 3 4 Copyright 2011-2012 5 Michael Gerhäuser 6 Alfred Wassermann 7 8 Licensed under the LGPL v3 9 */ 10 11 /** 12 * @fileoverview JessieCode is a scripting language designed to provide a simple scripting language to build constructions 13 * with JSXGraph. It is similar to JavaScript, but prevents access to the DOM. Hence, it can be used in community driven 14 * Math portals which want to use JSXGraph to display interactive math graphics. 15 */ 16 17 /** 18 * A JessieCode object provides an interfacce to the parser and stores all variables and objects used within a JessieCode script. 19 * The optional argument <tt>code</tt> is interpreted after initializing. To evaluate more code after initializing a JessieCode instance 20 * please use {@link JXG.JessieCode#parse}. For code snippets like single expressions use {@link JXG.JessieCode#snippet}. 21 * @constructor 22 * @param {String} [code] Code to parse. 23 * @param {Boolean} [geonext=false] Geonext compatibility mode. 24 */ 25 JXG.JessieCode = function(code, geonext) { 26 var i; 27 28 // Control structures 29 30 /** 31 * Stores all variables, local and global. The current scope is determined by {@link JXG.JessieCode#scope}. 32 * @type Array 33 * @private 34 */ 35 this.sstack = [{}]; 36 37 /** 38 * Defines the current variable scope. 39 * @type Number 40 * @private 41 */ 42 this.scope = 0; 43 44 /** 45 * A stack used to store the parameter lists for function definitions and calls. 46 * @type Array 47 * @private 48 */ 49 this.pstack = [[]]; 50 51 /** 52 * A stack to store debug information (like line and column where it was defined) of a parameter 53 * @type Array 54 * @private 55 */ 56 this.dpstack = [[]]; 57 58 /** 59 * Determines the parameter stack scope. 60 * @type Number 61 * @private 62 */ 63 this.pscope = 0; 64 65 /** 66 * Used to store the property-value definition while parsing an object literal. 67 * @type Array 68 * @private 69 */ 70 this.propstack = [{}]; 71 72 /** 73 * The current scope of the object literal stack {@link JXG.JessieCode#propstack}. 74 * @type Number 75 * @private 76 */ 77 this.propscope = 0; 78 79 /** 80 * Whenever an element attribute is set via <tt>element.attribute = 'something';</tt>, the element is stored 81 * in here, so following attribute changes can be set without the element: <tt>.attribute = 'something else';</tt>. 82 * @type JXG.GeometryElement 83 * @private 84 */ 85 this.propobj = 0; 86 87 /** 88 * Store the left hand side of an assignment. If an element is constructed and no attributes are given, this is 89 * used as the element's name. 90 * @type Array 91 * @private 92 */ 93 this.lhs = []; 94 95 /** 96 * lhs flag, used by JXG.JessieCode#replaceNames 97 * @type Boolean 98 * @default false 99 */ 100 this.isLHS = false; 101 102 /** 103 * The id of an HTML node in which innerHTML all warnings are stored (if no <tt>console</tt> object is available). 104 * @type String 105 * @default 'jcwarn' 106 */ 107 this.warnLog = 'jcwarn'; 108 109 /** 110 * Built-in functions and constants 111 * @type Object 112 */ 113 this.builtIn = this.defineBuiltIn(); 114 115 /** 116 * The board which currently is used to create and look up elements. 117 * @type JXG.Board 118 */ 119 this.board = null; 120 121 /** 122 * Keep track of which element is created in which line. 123 * @type Object 124 */ 125 this.lineToElement = {}; 126 127 this.countLines = true; 128 this.parCurLine = 1; 129 this.parCurColumn = 0; 130 this.line = 1; 131 this.col = 1; 132 133 this.code = ''; 134 135 if (typeof code === 'string') { 136 this.parse(code); 137 } 138 }; 139 140 141 JXG.extend(JXG.JessieCode.prototype, /** @lends JXG.JessieCode.prototype */ { 142 /** 143 * Create a new parse tree node. 144 * @param {String} type Type of node, e.g. node_op, node_var, or node_const 145 * @param value The nodes value, e.g. a variables value or a functions body. 146 * @param {Array} children Arbitrary number of child nodes. 147 */ 148 node: function (type, value, children) { 149 return { 150 type: type, 151 value: value, 152 children: children 153 }; 154 }, 155 156 /** 157 * Create a new parse tree node. Basically the same as node(), but this builds 158 * the children part out of an arbitrary number of parameters, instead of one 159 * array parameter. 160 * @param {String} type Type of node, e.g. node_op, node_var, or node_const 161 * @param value The nodes value, e.g. a variables value or a functions body. 162 * @param children Arbitrary number of parameters; define the child nodes. 163 */ 164 createNode: function (type, value, children) { 165 var n = this.node(type, value, []), 166 i; 167 168 for(i = 2; i < arguments.length; i++) 169 n.children.push( arguments[i] ); 170 171 n.line = this.parCurLine; 172 n.col = this.parCurColumn; 173 174 return n; 175 }, 176 177 /** 178 * Looks up an {@link JXG.GeometryElement} by its id. 179 * @param {String} id 180 * @returns {JXG.GeometryElement} 181 */ 182 getElementById: function (id) { 183 return this.board.objects[id]; 184 }, 185 186 /** 187 * Returns a element creator function which takes two parameters: the parents array and the attributes object. 188 * @param {String} vname The element type, e.g. 'point', 'line', 'midpoint' 189 * @returns {function} 190 */ 191 creator: (function () { 192 // stores the already defined creators 193 var _ccache = {}, r; 194 195 r = function (vname) { 196 var f; 197 198 // _ccache is global, i.e. it is the same for ALL JessieCode instances. 199 // That's why we need the board id here 200 if (typeof _ccache[this.board.id + vname] === 'function') { 201 return _ccache[this.board.id + vname]; 202 } else { 203 f = (function (that) { 204 return function (parameters, attributes) { 205 var attr; 206 207 if (JXG.exists(attributes)) { 208 attr = attributes; 209 } else { 210 attr = {name: (that.lhs[that.scope] !== 0 ? that.lhs[that.scope] : '')}; 211 } 212 return that.board.create(vname, parameters, attr); 213 } 214 })(this); 215 216 f.creator = true; 217 _ccache[this.board.id + vname] = f; 218 219 return f; 220 } 221 222 }; 223 224 r.clearCache = function () { 225 _ccache = {}; 226 }; 227 228 return r; 229 })(), 230 231 /** 232 * Assigns a value to a variable in the current scope. 233 * @param {String} vname Variable name 234 * @param {%} value Anything 235 * @see JXG.JessieCode#sstack 236 * @see JXG.JessieCode#scope 237 */ 238 letvar: function (vname, value) { 239 if (this.builtIn[vname]) { 240 this._warn('"' + vname + '" is a predefined value.'); 241 } 242 243 this.sstack[this.scope][vname] = value; 244 }, 245 246 /** 247 * Checks if the given variable name can be found in {@link JXG.JessieCode#sstack}. 248 * @param {String} vname 249 * @returns {Number} The position in the local variable stack where the variable can be found. <tt>-1</tt> if it couldn't be found. 250 */ 251 isLocalVariable: function (vname) { 252 var s; 253 for (s = this.scope; s > -1; s--) { 254 if (JXG.exists(this.sstack[s][vname])) { 255 return s; 256 } 257 } 258 259 return -1; 260 }, 261 262 /** 263 * Checks if the given variable name is a valid creator method. 264 * @param {String} vname 265 * @returns {Boolean} 266 */ 267 isCreator: function (vname) { 268 // check for an element with this name 269 return !!JXG.JSXGraph.elements[vname]; 270 }, 271 272 /** 273 * Checks if the given variable identifier is a valid member of the JavaScript Math Object. 274 * @param {String} vname 275 * @returns {Boolean} 276 */ 277 isMathMethod: function (vname) { 278 return vname !== 'E' && !!Math[vname]; 279 }, 280 281 /** 282 * Returns true if the given identifier is a builtIn variable/function. 283 * @param {String} vname 284 * @returns {Boolean} 285 */ 286 isBuiltIn: function (vname) { 287 return !!this.builtIn[vname]; 288 }, 289 290 /** 291 * Looks up the value of the given variable. 292 * @param {String} vname Name of the variable 293 * @paran {Boolean} [local=false] Only look up the internal symbol table and don't look for 294 * the <tt>vname</tt> in Math or the element list. 295 */ 296 getvar: function (vname, local) { 297 var s, undef; 298 299 local = JXG.def(local, false); 300 301 s = this.isLocalVariable(vname); 302 if (s > -1) { 303 return this.sstack[s][vname]; 304 } 305 306 // check for an element with this name 307 if (this.isCreator(vname)) { 308 return this.creator(vname); 309 } 310 311 if (this.isMathMethod(vname)) { 312 return Math[vname]; 313 } 314 315 if (this.isBuiltIn(vname)) { 316 return this.builtIn[vname]; 317 } 318 319 if (!local) { 320 s = JXG.getRef(this.board, vname); 321 if (s !== vname) { 322 return s; 323 } 324 } 325 326 return undef; 327 }, 328 329 /** 330 * Looks up a variable identifier in various tables and generates JavaScript code that could be eval'd to get the value. 331 * @param {String} vname Identifier 332 * @param {Boolean} [local=false] Don't resolve ids and names of elements 333 */ 334 getvarJS: function (vname, local, withProps) { 335 var s; 336 337 local = JXG.def(local, false); 338 withProps = JXG.def(withProps, false); 339 340 if (JXG.indexOf(this.pstack[this.pscope], vname) > -1) { 341 return vname; 342 } 343 344 s = this.isLocalVariable(vname); 345 if (s > -1 && !withProps) { 346 return '$jc$.sstack[' + s + '][\'' + vname + '\']'; 347 } 348 349 // check for an element with this name 350 if (this.isCreator(vname)) { 351 return '(function () { var a = Array.prototype.slice.call(arguments, 0), props = ' + (withProps ? 'a.pop()' : '{}') + '; return $jc$.board.create.apply($jc$.board, [\'' + vname + '\'].concat([a, props])); })'; 352 } 353 354 if (withProps) { 355 this._error('Syntax error (attribute values are allowed with element creators only)'); 356 } 357 358 if (this.isMathMethod(vname)) { 359 return 'Math.' + vname; 360 } 361 362 if (this.isBuiltIn(vname)) { 363 // if src does not exist, it is a number. in that case, just return the value. 364 return this.builtIn[vname].src || this.builtIn[vname]; 365 } 366 367 if (!local) { 368 if (JXG.isId(this.board, vname)) { 369 return '$jc$.board.objects[\'' + vname + '\']'; 370 } else if (JXG.isName(this.board, vname)) { 371 return '$jc$.board.elementsByName[\'' + vname + '\']'; 372 } else if (JXG.isGroup(this.board, vname)) { 373 return '$jc$.board.groups[\'' + vname + '\']'; 374 } 375 //return 'JXG.getRef(JXG.JSXGraph.boards[$jc$.board.id], \'' + vname + '\')'; 376 } 377 378 return ''; 379 }, 380 381 /** 382 * Merge all atribute values given with an element creator into one object. 383 * @param {Object} ... An arbitrary number of objects 384 * @returns {Object} All given objects merged into one. If properties appear in more (case sensitive) than one 385 * object the last value is taken. 386 */ 387 mergeAttributes: function () { 388 var i, attr = {}; 389 390 for (i = 0; i < arguments.length; i++) { 391 attr = JXG.deepCopy(attr, arguments[i], true); 392 } 393 394 return attr; 395 }, 396 397 /** 398 * Sets the property <tt>what</tt> of {@link JXG.JessieCode#propobj} to <tt>value</tt> 399 * @param {String} what 400 * @param {%} value 401 */ 402 setProp: function (o, what, value) { 403 var par = {}, x, y; 404 405 if (o.elementClass === JXG.OBJECT_CLASS_POINT && (what === 'X' || what === 'Y')) { 406 // set coords 407 408 what = what.toLowerCase(); 409 410 // be advised, we've spotted three cases in your AO: 411 // o.isDraggable && typeof value === number: 412 // stay draggable, just set the new coords (e.g. via moveTo) 413 // o.isDraggable && typeof value === function: 414 // convert to !o.isDraggable, set the new coords via o.addConstraint() 415 // !o.isDraggable: 416 // stay !o.isDraggable, update the given coord by overwriting X/YEval 417 418 if (o.isDraggable && typeof value === 'number') { 419 x = what === 'x' ? value : o.X(); 420 y = what === 'y' ? value : o.Y(); 421 422 o.setPosition(JXG.COORDS_BY_USER, [x, y]); 423 } else if (o.isDraggable && (typeof value === 'function' || typeof value === 'string')) { 424 x = what === 'x' ? value : o.coords.usrCoords[1]; 425 y = what === 'y' ? value : o.coords.usrCoords[2]; 426 427 o.addConstraint([x, y]); 428 } else if (!o.isDraggable) { 429 x = what === 'x' ? value : o.XEval.origin; 430 y = what === 'y' ? value : o.YEval.origin; 431 432 o.addConstraint([x, y]); 433 } 434 435 this.board.update(); 436 } else if (o.type === JXG.OBJECT_TYPE_TEXT && (what === 'X' || what === 'Y')) { 437 if (typeof value === 'number') { 438 o[what] = function () { return value; }; 439 } else if (typeof value === 'function') { 440 o.isDraggable = false; 441 o[what] = value; 442 } else if (typeof value === 'string') { 443 o.isDraggable = false; 444 o[what] = JXG.createFunction(value, this.board, null, true); 445 o[what + 'jc'] = value; 446 } 447 448 o[what].origin = value; 449 450 this.board.update(); 451 } else if (o.type && o.elementClass && o.visProp) { 452 par[what] = value; 453 o.setProperty(par); 454 } else { 455 o[what] = value; 456 } 457 }, 458 459 /** 460 * Encode characters outside the ASCII table into HTML Entities, because JavaScript or JS/CC can't handle a RegEx 461 * applied to a string with unicode characters. 462 * @param {String} string 463 * @returns {String} 464 */ 465 utf8_encode : function (string) { 466 var utftext = [], n, c; 467 468 for (n = 0; n < string.length; n++) { 469 c = string.charCodeAt(n); 470 471 if (c < 128) { 472 utftext.push(String.fromCharCode(c)); 473 } else { 474 utftext.push('' + c.toString(16) + ';'); 475 } 476 477 } 478 479 return utftext.join(''); 480 }, 481 482 /** 483 * Parses JessieCode 484 * @param {String} code 485 * @param {Boolean} [geonext=false] Geonext compatibility mode. 486 */ 487 parse: function (code, geonext, dontstore) { 488 var error_cnt = 0, 489 error_off = [], 490 error_la = [], 491 that = this, 492 to, 493 replacegxt = ['Abs', 'ACos', 'ASin', 'ATan','Ceil','Cos','Exp','Factorial','Floor','Log','Max','Min','Random','Round','Sin','Sqrt','Tan','Trunc', 'If', 'Deg', 'Rad', 'Dist'], 494 regex, setTextBackup = JXG.Text.prototype.setText, 495 ccode = code.replace(/\r\n/g,'\n').split('\n'), i, j, cleaned = []; 496 497 if (!dontstore) { 498 this.code += code + '\n'; 499 } 500 501 JXG.Text.prototype.setText = JXG.Text.prototype.setTextJessieCode; 502 503 try { 504 if (!JXG.exists(geonext)) { 505 geonext = false; 506 } 507 508 for (i = 0; i < ccode.length; i++) { 509 if (!(JXG.trim(ccode[i])[0] === '/' && JXG.trim(ccode[i])[1] === '/')) { 510 if (geonext) { 511 for (j = 0; j < replacegxt.length; j++) { 512 regex = new RegExp(replacegxt[j] + "\\(", 'g'); 513 ccode[i] = ccode[i].replace(regex, replacegxt[j].toLowerCase() + '('); 514 } 515 } 516 517 cleaned.push(ccode[i]); 518 } else { 519 cleaned.push(''); 520 } 521 } 522 code = cleaned.join('\n'); 523 code = this.utf8_encode(code); 524 525 if ((error_cnt = this._parse(code, error_off, error_la)) > 0) { 526 for (i = 0; i < error_cnt; i++) { 527 this.line = error_off[i].line; 528 this._error("Parse error in line " + error_off[i].line + " near >" + code.substr( error_off[i].offset, 30 ) + "<, expecting \"" + error_la[i].join() + "\""); 529 } 530 } 531 } catch (e) { 532 // make sure the original text method is back in place 533 JXG.Text.prototype.setText = setTextBackup; 534 535 // rethrow 536 throw e; 537 } 538 539 JXG.Text.prototype.setText = setTextBackup; 540 }, 541 542 /** 543 * Parses a JessieCode snippet, e.g. "3+4", and wraps it into a function, if desired. 544 * @param {String} code A small snippet of JessieCode. Must not be an assignment. 545 * @param {Boolean} funwrap If true, the code is wrapped in a function. 546 * @param {String} varname Name of the parameter(s) 547 * @param {Boolean} [geonext=false] Geonext compatibility mode. 548 */ 549 snippet: function (code, funwrap, varname, geonext) { 550 var vname, c, tmp, result; 551 552 vname = 'jxg__tmp__intern_' + JXG.Util.genUUID().replace(/\-/g, ''); 553 554 if (!JXG.exists(funwrap)) { 555 funwrap = true; 556 } 557 558 if (!JXG.exists(varname)) { 559 varname = ''; 560 } 561 562 if (!JXG.exists(geonext)) { 563 geonext = false; 564 } 565 566 // just in case... 567 tmp = this.sstack[0][vname]; 568 569 this.countLines = false; 570 571 c = vname + ' = ' + (funwrap ? ' function (' + varname + ') { return ' : '') + code + (funwrap ? '; }' : '') + ';'; 572 this.parse(c, geonext, true); 573 574 result = this.sstack[0][vname]; 575 if (JXG.exists(tmp)) { 576 this.sstack[0][vname] = tmp; 577 } else { 578 delete this.sstack[0][vname]; 579 } 580 581 this.countLines = true; 582 583 return result; 584 }, 585 586 /** 587 * Traverses through the given subtree and changes all values of nodes with the replaced flag set by 588 * {@link JXG.JessieCode#replaceNames} to the name of the element (if not empty). 589 * @param {Object} node 590 */ 591 replaceIDs: function (node) { 592 var i, v; 593 594 if (node.replaced) { 595 // these children exist, if node.replaced is set. 596 v = this.board.objects[node.children[1].children[0].value]; 597 if (JXG.exists(v) && JXG.exists(v) && v.name !== '') { 598 node.type = 'node_var'; 599 node.value = v.name; 600 // maybe it's not necessary, but just to be sure that everything's cleaned up we better delete all 601 // children and the replaced flag 602 node.children.length = 0; 603 delete node.replaced; 604 } 605 } 606 607 if (node.children) { 608 // assignments are first evaluated on the right hand side 609 for (i = node.children.length ; i > 0; i--) { 610 if (JXG.exists(node.children[i-1])) { 611 node.children[i-1] = this.replaceIDs(node.children[i-1]); 612 } 613 614 } 615 } 616 617 return node; 618 }, 619 620 /** 621 * Traverses through the given subtree and changes all elements referenced by names through referencing them by ID. 622 * An identifier is only replaced if it is not found in all scopes above the current scope and if it 623 * has not been blacklisted within the codeblock determined by the given subtree. 624 * @param {Object} node 625 */ 626 replaceNames: function (node) { 627 var i, v; 628 629 v = node.value; 630 631 // we are interested only in nodes of type node_var and node_op > op_lhs. 632 // currently, we are not checking if the id is a local variable. in this case, we're stuck anyway. 633 634 if (node.type == 'node_op' && v == 'op_lhs' && node.children.length === 1) { 635 this.isLHS = true; 636 } else if (node.type == 'node_var') { 637 if (this.isLHS) { 638 this.letvar(v, true); 639 } else if (!JXG.exists(this.getvar(v, true)) && JXG.exists(this.board.elementsByName[v])) { 640 node = this.createReplacementNode(node); 641 } 642 } 643 644 if (node.children) { 645 // assignments are first evaluated on the right hand side 646 for (i = node.children.length ; i > 0; i--) { 647 if (JXG.exists(node.children[i-1])) { 648 node.children[i-1] = this.replaceNames(node.children[i-1]); 649 } 650 651 } 652 } 653 654 if (node.type == 'node_op' && node.value == 'op_lhs' && node.children.length === 1) { 655 this.isLHS = false; 656 } 657 658 return node; 659 }, 660 661 /** 662 * Replaces node_var nodes with node_op>op_execfun nodes, calling the internal $() function with the id of the 663 * element accessed by the node_var node. 664 * @param {Object} node 665 * @returns {Object} op_execfun node 666 */ 667 createReplacementNode: function (node) { 668 var v = node.value, 669 el = this.board.elementsByName[v]; 670 671 node = this.createNode('node_op', 'op_execfun', 672 this.createNode('node_var', '$'), 673 this.createNode('node_op', 'op_param', 674 this.createNode('node_str', el.id) 675 ) 676 ); 677 678 node.replaced = true; 679 680 return node; 681 }, 682 683 /** 684 * Search the parse tree below <tt>node</tt> for <em>stationary</em> dependencies, i.e. dependencies hard coded into 685 * the function. 686 * @param {Object} node 687 * @param {Object} result An object where the referenced elements will be stored. Access key is their id. 688 */ 689 collectDependencies: function (node, result) { 690 var i, v, e; 691 692 v = node.value; 693 694 if (node.type == 'node_var') { 695 e = this.getvar(v); 696 if (e && e.visProp && e.type && e.elementClass && e.id) { 697 result[e.id] = e; 698 } 699 } 700 701 // the $()-function-calls are special because their parameter is given as a string, not as a node_var. 702 if (node.type == 'node_op' && node.value == 'op_execfun' && node.children.length > 1 && node.children[0].value == '$' && node.children[1].children.length > 0) { 703 e = node.children[1].children[0].value; 704 result[e] = this.board.objects[e]; 705 } 706 707 if (node.children) { 708 for (i = node.children.length; i > 0; i--) { 709 if (JXG.exists(node.children[i-1])) { 710 this.collectDependencies(node.children[i-1], result); 711 } 712 713 } 714 } 715 }, 716 717 resolveProperty: function (e, v, compile) { 718 compile = JXG.def(compile, false); 719 720 // is it a geometry element or a board? 721 if (e /*&& e.type && e.elementClass*/ && e.methodMap) { 722 // yeah, it is. but what does the user want? 723 if (v === 'label') { 724 // he wants to access the label properties! 725 // adjust the base object... 726 e = e.label; 727 // and the property we are accessing 728 v = 'content'; 729 } else { 730 // ok, it's not the label he wants to change 731 // well, what then? 732 if (JXG.exists(e.subs) && JXG.exists(e.subs[v])) { 733 // a subelement it is, good sir. 734 e = e.subs; 735 } else if (JXG.exists(e.methodMap[v])) { 736 // the user wants to call a method 737 v = e.methodMap[v]; 738 } else { 739 // the user wants to change an attribute 740 e = e.visProp; 741 v = v.toLowerCase(); 742 } 743 } 744 } 745 746 if (!JXG.exists(e)) { 747 this._error(e + ' is not an object'); 748 } 749 750 if (!JXG.exists(e[v])) { 751 this._error('unknown property ' + v); 752 } 753 754 if (compile && typeof e[v] === 'function') { 755 return function () { return e[v].apply(e, arguments); }; 756 } 757 758 return e[v]; 759 }, 760 761 /** 762 * Executes a parse subtree. 763 * @param {Object} node 764 * @returns Something 765 * @private 766 */ 767 execute: function (node) { 768 var ret, v, i, e, parents = []; 769 770 ret = 0; 771 772 if (!node) 773 return ret; 774 775 this.line = node.line; 776 this.col = node.col; 777 778 switch (node.type) { 779 case 'node_op': 780 switch (node.value) { 781 case 'op_none': 782 if (node.children[0]) { 783 this.execute(node.children[0]); 784 } 785 if (node.children[1]) { 786 ret = this.execute(node.children[1]); 787 } 788 break; 789 case 'op_assign': 790 v = this.execute(node.children[0]); 791 this.lhs[this.scope] = v[1]; 792 793 if (v[0].type && v[0].elementClass && v[0].methodMap && v[1] === 'label') { 794 this._error('Left-hand side of assignment is read-only.'); 795 } 796 797 if (v[0] !== this.sstack[this.scope] || (JXG.isArray(v[0]) && typeof v[1] === 'number')) { 798 // it is either an array component being set or a property of an object. 799 this.setProp(v[0], v[1], this.execute(node.children[1])); 800 } else { 801 // this is just a local variable inside JessieCode 802 this.letvar(v[1], this.execute(node.children[1])); 803 } 804 805 this.lhs[this.scope] = 0; 806 break; 807 case 'op_noassign': 808 ret = this.execute(node.children[0]); 809 break; 810 case 'op_if': 811 if (this.execute(node.children[0])) { 812 ret = this.execute(node.children[1]); 813 } 814 break; 815 case 'op_if_else': 816 if (this.execute(node.children[0])) { 817 ret = this.execute(node.children[1]); 818 } else { 819 ret = this.execute(node.children[2]); 820 } 821 break; 822 case 'op_while': 823 while (this.execute(node.children[0])) { 824 this.execute(node.children[1]); 825 } 826 break; 827 case 'op_do': 828 do { 829 this.execute(node.children[0]); 830 } while (this.execute(node.children[1])); 831 break; 832 case 'op_for': 833 for (this.execute(node.children[0]); this.execute(node.children[1]); this.execute(node.children[2])) { 834 this.execute(node.children[3]); 835 } 836 break; 837 case 'op_param': 838 if (node.children[1]) { 839 this.execute(node.children[1]); 840 } 841 842 ret = node.children[0]; 843 this.pstack[this.pscope].push(ret); 844 if (this.dpstack[this.pscope]) { 845 this.dpstack[this.pscope].push({ 846 line: node.children[0].line, 847 col: node.children[0].col 848 }); 849 } 850 break; 851 case 'op_paramdef': 852 if (node.children[1]) { 853 this.execute(node.children[1]); 854 } 855 856 ret = node.children[0]; 857 this.pstack[this.pscope].push(ret); 858 break; 859 case 'op_proplst': 860 if (node.children[0]) { 861 this.execute(node.children[0]); 862 } 863 if (node.children[1]) { 864 this.execute(node.children[1]); 865 } 866 break; 867 case 'op_proplst_val': 868 this.propstack.push({}); 869 this.propscope++; 870 871 this.execute(node.children[0]); 872 ret = this.propstack[this.propscope]; 873 874 this.propstack.pop(); 875 this.propscope--; 876 break; 877 case 'op_prop': 878 // child 0: Identifier 879 // child 1: Value 880 this.propstack[this.propscope][node.children[0]] = this.execute(node.children[1]); 881 break; 882 case 'op_array': 883 var l; 884 885 this.pstack.push([]); 886 this.pscope++; 887 888 this.execute(node.children[0]); 889 890 ret = []; 891 l = this.pstack[this.pscope].length; 892 893 for (i = 0; i < l; i++) { 894 ret.push(this.execute(this.pstack[this.pscope][i])); 895 } 896 897 this.pstack.pop(); 898 this.pscope--; 899 900 break; 901 case 'op_extvalue': 902 var undef; 903 904 ret = this.execute(node.children[0]); 905 i = this.execute(node.children[1]); 906 907 if (typeof i === 'number' && Math.abs(Math.round(i) - i) < JXG.Math.eps) { 908 ret = ret[i]; 909 } else { 910 ret = undef; 911 } 912 break; 913 case 'op_return': 914 if (this.scope === 0) { 915 this._error('Unexpected return.'); 916 } else { 917 return this.execute(node.children[0]); 918 } 919 break; 920 case 'op_function': 921 this.pstack.push([]); 922 this.pscope++; 923 924 // parse the parameter list 925 // after this, the parameters are in pstack 926 this.execute(node.children[0]); 927 928 if (this.board.options.jc.compile) { 929 this.sstack.push({}); 930 this.scope++; 931 932 this.isLHS = false; 933 934 for (i = 0; i < this.pstack[this.pscope].length; i++) { 935 this.sstack[this.scope][this.pstack[this.pscope][i]] = this.pstack[this.pscope][i]; 936 } 937 938 this.replaceNames(node.children[1]); 939 940 ret = (function ($jc$) { 941 var p = $jc$.pstack[$jc$.pscope].join(', '), 942 str = 'var f = function (' + p + ') {\n$jc$.sstack.push([]);\n$jc$.scope++;\nvar r = (function () {\n' + $jc$.compile(node.children[1], true) + '})();\n$jc$.sstack.pop();\n$jc$.scope--;\nreturn r;\n}; f;'; 943 // the function code formatted: 944 /* 945 var f = function (_parameters_) { 946 // handle the stack 947 $jc$.sstack.push([]); 948 $jc$.scope++; 949 950 // this is required for stack handling: usually at some point in a function 951 // there's a return statement, that prevents the cleanup of the stack. 952 var r = (function () { 953 _compiledcode_; 954 })(); 955 956 // clean up the stack 957 $jc$.sstack.pop(); 958 $jc$.scope--; 959 960 // return the result 961 return r; 962 }; 963 f; // the return value of eval() 964 */ 965 966 try{ 967 return eval(str); 968 } catch (e) { 969 //$jc$._error('catch errors. super simple stuff.', e.toString()) 970 throw e; 971 return function () {}; 972 } 973 })(this); 974 975 // clean up scope 976 this.sstack.pop(); 977 this.scope--; 978 } else { 979 ret = (function (_pstack, that) { 980 return function () { 981 var r; 982 983 that.sstack.push({}); 984 that.scope++; 985 for (r = 0; r < _pstack.length; r++) { 986 that.sstack[that.scope][_pstack[r]] = arguments[r]; 987 } 988 989 r = that.execute(node.children[1]); 990 991 that.sstack.pop(); 992 that.scope--; 993 return r; 994 }; 995 })(this.pstack[this.pscope], this); 996 } 997 998 ret.node = node; 999 ret.toJS = ret.toString; 1000 ret.toString = (function (_that) { 1001 return function () { 1002 return _that.compile(_that.replaceIDs(JXG.deepCopy(node))); 1003 }; 1004 })(this); 1005 1006 ret.deps = {}; 1007 this.collectDependencies(node.children[1], ret.deps); 1008 1009 this.pstack.pop(); 1010 this.pscope--; 1011 break; 1012 case 'op_execfun': 1013 // node.children: 1014 // [0]: Name of the function 1015 // [1]: Parameter list as a parse subtree 1016 // [2]: Properties, only used in case of a create function 1017 var fun, attr, sc; 1018 1019 this.pstack.push([]); 1020 this.dpstack.push([]); 1021 this.pscope++; 1022 1023 // parse the parameter list 1024 // after this, the parameters are in pstack 1025 this.execute(node.children[1]); 1026 1027 // parse the properties only if given 1028 if (typeof node.children[2] !== 'undefined') { 1029 if (node.children[3]) { 1030 this.pstack.push([]); 1031 this.dpstack.push([]); 1032 this.pscope++; 1033 1034 this.execute(node.children[2]); 1035 attr = {}; 1036 for (i = 0; i < this.pstack[this.pscope].length; i++) { 1037 attr = JXG.deepCopy(attr, this.execute(this.pstack[this.pscope][i]), true); 1038 } 1039 1040 this.pscope--; 1041 this.pstack.pop(); 1042 this.dpstack.pop(); 1043 } else { 1044 attr = this.execute(node.children[2]); 1045 } 1046 } 1047 1048 // look up the variables name in the variable table 1049 fun = this.execute(node.children[0]); 1050 1051 // determine the scope the function wants to run in 1052 if (fun && fun.sc) { 1053 sc = fun.sc; 1054 } else { 1055 sc = this; 1056 } 1057 1058 if (!fun.creator && typeof node.children[2] !== 'undefined') { 1059 this._error('Unexpected value. Only element creators are allowed to have a value after the function call.'); 1060 } 1061 1062 // interpret ALL the parameters 1063 for(i = 0; i < this.pstack[this.pscope].length; i++) { 1064 parents[i] = this.execute(this.pstack[this.pscope][i]); 1065 } 1066 // check for the function in the variable table 1067 if (typeof fun === 'function' && !fun.creator) { 1068 ret = fun.apply(sc, parents); 1069 } else if (typeof fun === 'function' && !!fun.creator) { 1070 e = this.line; 1071 // creator methods are the only ones that take properties, hence this special case 1072 try { 1073 /*this._log(node.children[0].value + '@' + this.line + ':' + node.col); 1074 for (i = 0; i < this.pstack[this.pscope].length; i++) { 1075 this._log(parents[i] + '@' + this.dpstack[this.pscope][i].line + ':' + this.dpstack[this.pscope][i].col); 1076 }*/ 1077 ret = fun(parents, attr); 1078 ret.jcLineStart = e; 1079 ret.jcLineEnd = node.line; 1080 1081 for (i = e; i <= node.line; i++) { 1082 this.lineToElement[i] = ret; 1083 } 1084 1085 ret.debugParents = this.dpstack[this.pscope]; 1086 } catch (ex) { 1087 this._error(ex.toString(), e); 1088 } 1089 } else { 1090 this._error('Function \'' + fun + '\' is undefined.'); 1091 } 1092 1093 // clear parameter stack 1094 this.pstack.pop(); 1095 this.dpstack.pop(); 1096 this.pscope--; 1097 break; 1098 case 'op_property': 1099 e = this.execute(node.children[0]); 1100 v = node.children[1]; 1101 1102 ret = this.resolveProperty(e, v, false); 1103 1104 // set the scope, in case this is a method the user wants to call 1105 if (JXG.exists(ret)) { 1106 ret.sc = e; 1107 } 1108 1109 break; 1110 case 'op_lhs': 1111 v = node.children[0]; 1112 1113 // we have a subtree here (in case this is an array component) 1114 if (v.children && v.type && v.value) { 1115 v = this.execute(v); 1116 } 1117 1118 if (node.children.length === 1) { 1119 e = this.sstack[this.scope]; 1120 } else { 1121 e = this.execute(node.children[1]); 1122 1123 if (e.type && e.elementClass && v.toLowerCase && v.toLowerCase() !== 'x' && v.toLowerCase() !== 'y') { 1124 v = v.toLowerCase(); 1125 } 1126 } 1127 1128 ret = [e, v]; 1129 break; 1130 case 'op_use': 1131 // node.children: 1132 // [0]: A string providing the id of the div the board is in. 1133 var found = false; 1134 1135 // search all the boards for the one with the appropriate container div 1136 for(var b in JXG.JSXGraph.boards) { 1137 if(JXG.JSXGraph.boards[b].container === node.children[0].toString()) { 1138 this.use(JXG.JSXGraph.boards[b]); 1139 found = true; 1140 } 1141 } 1142 1143 if(!found) 1144 this._error('Board \'' + node.children[0].toString() + '\' not found!'); 1145 break; 1146 case 'op_delete': 1147 v = this.getvar(node.children[0]); 1148 1149 if (typeof v === 'object' && JXG.exists(v.type) && JXG.exists(v.elementClass)) { 1150 this.board.removeObject(v); 1151 } 1152 break; 1153 case 'op_equ': 1154 ret = this.execute(node.children[0]) == this.execute(node.children[1]); 1155 break; 1156 case 'op_neq': 1157 ret = this.execute(node.children[0]) != this.execute(node.children[1]); 1158 break; 1159 case 'op_approx': 1160 ret = Math.abs(this.execute(node.children[0]) - this.execute(node.children[1])) < JXG.Math.eps; 1161 break; 1162 case 'op_grt': 1163 ret = this.execute(node.children[0]) > this.execute(node.children[1]); 1164 break; 1165 case 'op_lot': 1166 ret = this.execute(node.children[0]) < this.execute(node.children[1]); 1167 break; 1168 case 'op_gre': 1169 ret = this.execute(node.children[0]) >= this.execute(node.children[1]); 1170 break; 1171 case 'op_loe': 1172 ret = this.execute(node.children[0]) <= this.execute(node.children[1]); 1173 break; 1174 case 'op_or': 1175 ret = this.execute(node.children[0]) || this.execute(node.children[1]); 1176 break; 1177 case 'op_and': 1178 ret = this.execute(node.children[0]) && this.execute(node.children[1]); 1179 break; 1180 case 'op_not': 1181 ret = !this.execute(node.children[0]); 1182 break; 1183 case 'op_add': 1184 ret = JXG.Math.Statistics.add(this.execute(node.children[0]), this.execute(node.children[1])); 1185 break; 1186 case 'op_sub': 1187 ret = JXG.Math.Statistics.subtract(this.execute(node.children[0]), this.execute(node.children[1])); 1188 break; 1189 case 'op_div': 1190 ret = JXG.Math.Statistics.div(this.execute(node.children[0]), this.execute(node.children[1])); 1191 break; 1192 case 'op_mod': 1193 // use mathematical modulo, JavaScript implements the symmetric modulo. 1194 ret = JXG.Math.Statistics.mod(this.execute(node.children[0]), this.execute(node.children[1]), true); 1195 break; 1196 case 'op_mul': 1197 ret = this.mul(this.execute(node.children[0]), this.execute(node.children[1])); 1198 break; 1199 case 'op_exp': 1200 ret = Math.pow(this.execute(node.children[0]), this.execute(node.children[1])); 1201 break; 1202 case 'op_neg': 1203 ret = this.execute(node.children[0]) * -1; 1204 break; 1205 } 1206 break; 1207 1208 case 'node_var': 1209 ret = this.getvar(node.value); 1210 break; 1211 1212 case 'node_const': 1213 ret = Number(node.value); 1214 break; 1215 1216 case 'node_const_bool': 1217 ret = node.value.toLowerCase() !== 'false'; 1218 break; 1219 1220 case 'node_str': 1221 ret = node.value; 1222 break; 1223 } 1224 1225 return ret; 1226 }, 1227 1228 /** 1229 * Compiles a parse tree back to JessieCode. 1230 * @param {Object} node 1231 * @param {Boolean} [js=false] Currently ignored. Compile either to JavaScript or back to JessieCode (required for the UI). 1232 * @returns Something 1233 * @private 1234 */ 1235 compile: function (node, js) { 1236 var ret, i, e, v; 1237 1238 ret = ''; 1239 1240 if (!JXG.exists(js)) { 1241 js = false 1242 } 1243 1244 if (!node) 1245 return ret; 1246 1247 switch (node.type) { 1248 case 'node_op': 1249 switch (node.value) { 1250 case 'op_none': 1251 if (node.children[0]) { 1252 ret = this.compile(node.children[0], js); 1253 } 1254 if (node.children[1]) { 1255 ret += this.compile(node.children[1], js); 1256 } 1257 break; 1258 case 'op_assign': 1259 e = this.compile(node.children[0], js); 1260 if (js) { 1261 if (JXG.isArray(e)) { 1262 ret = '$jc$.setProp(' + e[0] + ', \'' + e[1] + '\', ' + this.compile(node.children[1], js) + ');\n'; 1263 } else { 1264 if (this.isLocalVariable(e) !== this.scope) { 1265 this.sstack[this.scope][e] = true; 1266 } 1267 ret = '$jc$.sstack[' + this.scope + '][\'' + e + '\'] = ' + this.compile(node.children[1], js) + ';\n'; 1268 } 1269 } else { 1270 ret = e + ' = ' + this.compile(node.children[1], js) + ';\n'; 1271 } 1272 1273 break; 1274 case 'op_noassign': 1275 ret = this.compile(node.children[0], js) + ';\n'; 1276 break; 1277 case 'op_if': 1278 ret = ' if (' + this.compile(node.children[0], js) + ') ' + this.compile(node.children[1], js); 1279 break; 1280 case 'op_if_else': 1281 ret = ' if (' + this.compile(node.children[0], js) + ')' + this.compile(node.children[1], js); 1282 ret += ' else ' + this.compile(node.children[2], js); 1283 break; 1284 case 'op_while': 1285 ret = ' while (' + this.compile(node.children[0], js) + ') {\n' + this.compile(node.children[1], js) + '}\n'; 1286 break; 1287 case 'op_do': 1288 ret = ' do {\n' + this.compile(node.children[0], js) + '} while (' + this.compile(node.children[1], js) + ');\n'; 1289 break; 1290 case 'op_for': 1291 ret = ' for (' + this.compile(node.children[0], js) + '; ' + this.compile(node.children[1], js) + '; ' + this.compile(node.children[2], js) + ') {\n' + this.compile(node.children[3], js) + '\n}\n'; 1292 break; 1293 case 'op_param': 1294 if (node.children[1]) { 1295 ret = this.compile(node.children[1], js) + ', '; 1296 } 1297 1298 ret += this.compile(node.children[0], js); 1299 break; 1300 case 'op_paramdef': 1301 if (node.children[1]) { 1302 ret = this.compile(node.children[1], js) + ', '; 1303 } 1304 1305 ret += node.children[0]; 1306 break; 1307 case 'op_proplst': 1308 if (node.children[0]) { 1309 ret = this.compile(node.children[0], js) + ', '; 1310 } 1311 1312 ret += this.compile(node.children[1], js); 1313 break; 1314 case 'op_prop': 1315 // child 0: Identifier 1316 // child 1: Value 1317 ret = node.children[0] + ': ' + this.compile(node.children[1], js); 1318 break; 1319 case 'op_proplst_val': 1320 ret = /*(js ? '{' : '<<') +*/ this.compile(node.children[0], js) /*+ (js ? '}' : '>>')*/; 1321 break; 1322 case 'op_array': 1323 ret = '[' + this.compile(node.children[0], js) + ']'; 1324 break; 1325 case 'op_extvalue': 1326 ret = this.compile(node.children[0], js) + '[' + this.compile(node.children[1], js) + ']'; 1327 break; 1328 case 'op_return': 1329 ret = ' return ' + this.compile(node.children[0], js) + ';\n'; 1330 break; 1331 case 'op_function': 1332 ret = ' function (' + this.compile(node.children[0], js) + ') {\n' + this.compile(node.children[1], js) + '}'; 1333 break; 1334 case 'op_execfun': 1335 // parse the properties only if given 1336 if (node.children[2]) { 1337 e = this.compile(node.children[2], js); 1338 1339 if (js) { 1340 e = '$jc$.mergeAttributes(' + e + ')'; 1341 } 1342 } 1343 node.children[0].withProps = !!node.children[2]; 1344 ret = this.compile(node.children[0], js) + '(' + this.compile(node.children[1], js) + (node.children[2] && js ? ', ' + e : '') + ')' + (node.children[2] && !js ? e : ''); 1345 1346 // save us a function call when compiled to javascript 1347 if (js && node.children[0].value === '$') { 1348 ret = '$jc$.board.objects[' + this.compile(node.children[1], js) + ']'; 1349 } 1350 1351 break; 1352 case 'op_property': 1353 if (js && node.children[1] !== 'X' && node.children[1] !== 'Y') { 1354 ret = '$jc$.resolveProperty(' + this.compile(node.children[0], js) + ', \'' + node.children[1] + '\', true)'; 1355 } else { 1356 ret = this.compile(node.children[0], js) + '.' + node.children[1]; 1357 } 1358 break; 1359 case 'op_lhs': 1360 if (node.children.length === 1) { 1361 ret = node.children[0]; 1362 } else if (node.children[2] === 'dot') { 1363 if (js) { 1364 ret = [this.compile(node.children[1], js), node.children[0]]; 1365 } else { 1366 ret = this.compile(node.children[1], js) + '.' + node.children[0]; 1367 } 1368 } else if (node.children[2] === 'bracket') { 1369 if (js) { 1370 ret = [this.compile(node.children[1], js), this.compile(node.children[0], js)]; 1371 } else { 1372 ret = this.compile(node.children[1], js) + '[' + this.compile(node.children[0], js) + ']'; 1373 } 1374 } 1375 break; 1376 case 'op_use': 1377 if (js) { 1378 ret = '$jc$.use(JXG.JSXGraph.boards[\'' + node.children[0] + '\'])'; 1379 } else { 1380 ret = 'use ' + node.children[0] + ';'; 1381 } 1382 break; 1383 case 'op_delete': 1384 ret = 'delete ' + node.children[0]; 1385 break; 1386 case 'op_equ': 1387 ret = '(' + this.compile(node.children[0], js) + ' == ' + this.compile(node.children[1], js) + ')'; 1388 break; 1389 case 'op_neq': 1390 ret = '(' + this.compile(node.children[0], js) + ' != ' + this.compile(node.children[1], js) + ')'; 1391 break; 1392 case 'op_approx': 1393 ret = '(' + this.compile(node.children[0], js) + ' ~= ' + this.compile(node.children[1], js) + ')'; 1394 break; 1395 case 'op_grt': 1396 ret = '(' + this.compile(node.children[0], js) + ' > ' + this.compile(node.children[1], js) + ')'; 1397 break; 1398 case 'op_lot': 1399 ret = '(' + this.compile(node.children[0], js) + ' < ' + this.compile(node.children[1], js) + ')'; 1400 break; 1401 case 'op_gre': 1402 ret = '(' + this.compile(node.children[0], js) + ' >= ' + this.compile(node.children[1], js) + ')'; 1403 break; 1404 case 'op_loe': 1405 ret = '(' + this.compile(node.children[0], js) + ' <= ' + this.compile(node.children[1], js) + ')'; 1406 break; 1407 case 'op_or': 1408 ret = '(' + this.compile(node.children[0], js) + ' || ' + this.compile(node.children[1], js) + ')'; 1409 break; 1410 case 'op_and': 1411 ret = '(' + this.compile(node.children[0], js) + ' && ' + this.compile(node.children[1], js) + ')'; 1412 break; 1413 case 'op_not': 1414 ret = '!(' + this.compile(node.children[0], js) + ')'; 1415 break; 1416 case 'op_add': 1417 if (js) { 1418 ret = 'JXG.Math.Statistics.add(' + this.compile(node.children[0], js) + ', ' + this.compile(node.children[1], js) + ')'; 1419 } else { 1420 ret = '(' + this.compile(node.children[0], js) + ' + ' + this.compile(node.children[1], js) + ')'; 1421 } 1422 break; 1423 case 'op_sub': 1424 if (js) { 1425 ret = 'JXG.Math.Statistics.subtract(' + this.compile(node.children[0], js) + ', ' + this.compile(node.children[1], js) + ')'; 1426 } else { 1427 ret = '(' + this.compile(node.children[0], js) + ' - ' + this.compile(node.children[1], js) + ')'; 1428 } 1429 break; 1430 case 'op_div': 1431 if (js) { 1432 ret = 'JXG.Math.Statistics.div(' + this.compile(node.children[0], js) + ', ' + this.compile(node.children[1], js) + ')'; 1433 } else { 1434 ret = '(' + this.compile(node.children[0], js) + ' / ' + this.compile(node.children[1], js) + ')'; 1435 } 1436 break; 1437 case 'op_mod': 1438 if (js) { 1439 ret = 'JXG.Math.mod(' + this.compile(node.children[0], js) + ', ' + this.compile(node.children[1], js) + ', true)'; 1440 } else { 1441 ret = '(' + this.compile(node.children[0], js) + ' % ' + this.compile(node.children[1], js) + ')'; 1442 } 1443 break; 1444 case 'op_mul': 1445 if (js) { 1446 ret = '$jc$.mul(' + this.compile(node.children[0], js) + ', ' + this.compile(node.children[1], js) + ')'; 1447 } else { 1448 ret = '(' + this.compile(node.children[0], js) + ' * ' + this.compile(node.children[1], js) + ')'; 1449 } 1450 break; 1451 case 'op_exp': 1452 if (js) { 1453 ret = 'Math.pow(' + this.compile(node.children[0], js) + ', ' + this.compile(node.children[1], js) + ')'; 1454 } else { 1455 ret = '(' + this.compile(node.children[0], js) + '^' + this.compile(node.children[1], js) + ')'; 1456 } 1457 break; 1458 case 'op_neg': 1459 ret = '(-' + this.compile(node.children[0], js) + ')'; 1460 break; 1461 } 1462 break; 1463 1464 case 'node_var': 1465 if (js) { 1466 //ret = '$jc$.getvar(\'' + node.value + '\')'; 1467 ret = this.getvarJS(node.value, false, node.withProps); 1468 } else { 1469 ret = node.value; 1470 } 1471 break; 1472 1473 case 'node_const': 1474 ret = node.value; 1475 break; 1476 1477 case 'node_const_bool': 1478 ret = node.value; 1479 break; 1480 1481 case 'node_str': 1482 ret = '\'' + node.value.replace(/'/g, '\\\'') + '\''; 1483 break; 1484 } 1485 1486 if (node.needsBrackets) { 1487 ret = '{\n' + ret + '}\n'; 1488 } 1489 1490 return ret; 1491 }, 1492 1493 /** 1494 * This is used as the global X() function. 1495 * @param {JXG.Point|JXG.Text} e 1496 * @returns {Number} 1497 */ 1498 X: function (e) { 1499 return e.X(); 1500 }, 1501 1502 /** 1503 * This is used as the global Y() function. 1504 * @param {JXG.Point|JXG.Text} e 1505 * @returns {Number} 1506 */ 1507 Y: function (e) { 1508 return e.Y(); 1509 }, 1510 1511 /** 1512 * This is used as the global V() function. 1513 * @param {Glider|Slider} e 1514 * @returns {%} 1515 */ 1516 V: function (e) { 1517 return e.Value(); 1518 }, 1519 1520 /** 1521 * This is used as the global L() function. 1522 * @param {JXG.Line} e 1523 * @returns {Number} 1524 */ 1525 L: function (e) { 1526 return e.L(); 1527 }, 1528 1529 /** 1530 * This is used as the global dist() function. 1531 * @param {JXG.Point} p1 1532 * @param {JXG.Point} p2 1533 * @returns {Number} 1534 */ 1535 dist: function (p1, p2) { 1536 if (!JXG.exists(p1) || !JXG.exists(p1.Dist)) { 1537 this._error('Error: Can\'t calculate distance.'); 1538 } 1539 1540 return p1.Dist(p2); 1541 }, 1542 1543 /** 1544 * Multiplication of vectors and numbers 1545 * @param {Number|Array} a 1546 * @param {Number|Array} b 1547 * @returns {Number|Array} (Inner) product of the given input values. 1548 */ 1549 mul: function (a, b) { 1550 if (JXG.isArray(a) * JXG.isArray(b)) { 1551 return JXG.Math.innerProduct(a, b, Math.min(a.length, b.length)); 1552 } else { 1553 return JXG.Math.Statistics.multiply(a, b); 1554 } 1555 }, 1556 1557 1558 use: function (board) { 1559 this.board = board; 1560 this.builtIn['$board'] = board; 1561 this.builtIn['$board'].src = '$jc$.board'; 1562 }, 1563 1564 /** 1565 * Find the first symbol to the given value from the given scope upwards. 1566 * @param {%} v Value 1567 * @param {Number} [scope=-1] The scope, default is to start with current scope (-1). 1568 * @returns {Array} An array containing the symbol and the scope if a symbol could be found, 1569 * an empty array otherwise; 1570 */ 1571 findSymbol: function (v, scope) { 1572 var s, i; 1573 1574 scope = JXG.def(scope, -1); 1575 1576 if (scope === -1) { 1577 scope = this.scope; 1578 } 1579 1580 for (s = scope; s >= 0; s--) { 1581 for (i in this.sstack[s]) { 1582 if (this.sstack[s][i] === v) { 1583 return [i, s]; 1584 } 1585 } 1586 } 1587 1588 return []; 1589 }, 1590 1591 /** 1592 * Defines built in methods and constants. 1593 * @returns {Object} BuiltIn control object 1594 */ 1595 defineBuiltIn: function () { 1596 var that = this, 1597 builtIn = { 1598 PI: Math.PI, 1599 EULER: Math.E, 1600 X: that.X, 1601 Y: that.Y, 1602 V: that.V, 1603 L: that.L, 1604 dist: that.dist, 1605 rad: JXG.Math.Geometry.rad, 1606 deg: JXG.Math.Geometry.trueAngle, 1607 factorial: JXG.Math.factorial, 1608 trunc: JXG.trunc, 1609 '$': that.getElementById, 1610 '$board': that.board 1611 }; 1612 1613 // special scopes for factorial, deg, and rad 1614 builtIn.rad.sc = JXG.Math.Geometry; 1615 builtIn.deg.sc = JXG.Math.Geometry; 1616 builtIn.factorial.sc = JXG.Math; 1617 1618 // set the javascript equivalent for the builtIns 1619 // some of the anonymous functions should be replaced by global methods later on 1620 builtIn.PI.src = 'Math.PI'; 1621 builtIn.EULER.src = 'Math.E'; 1622 builtIn.X.src = '$jc$.X'; 1623 builtIn.Y.src = '$jc$.Y'; 1624 builtIn.V.src = '$jc$.V'; 1625 builtIn.L.src = '$jc$.L'; 1626 builtIn.dist.src = '$jc$.dist'; 1627 builtIn.rad.src = 'JXG.Math.Geometry.rad'; 1628 builtIn.deg.src = 'JXG.Math.Geometry.trueAngle'; 1629 builtIn.factorial.src = 'JXG.Math.factorial'; 1630 builtIn.trunc.src = 'JXG.trunc'; 1631 // usually unused, see node_op > op_execfun 1632 builtIn['$'].src = '(function (n) { return JXG.getRef($jc$.board, n); })'; 1633 if (builtIn['$board']) { 1634 builtIn['$board'].src = '$jc$.board'; 1635 } 1636 1637 return builtIn; 1638 }, 1639 1640 /** 1641 * Output a debugging message. Uses debug console, if available. Otherwise an HTML element with the 1642 * id "debug" and an innerHTML property is used. 1643 * @param {String} log 1644 * @private 1645 */ 1646 _debug: function (log) { 1647 if(typeof console !== "undefined") { 1648 console.log(log); 1649 } else if(document && document.getElementById('debug') !== null) { 1650 document.getElementById('debug').innerHTML += log + '<br />'; 1651 } 1652 }, 1653 1654 /** 1655 * Throws an exception with the given error message. 1656 * @param {String} msg Error message 1657 */ 1658 _error: function (msg) { 1659 var e = new Error('Error(' + this.line + '): ' + msg); 1660 e.line = this.line; 1661 throw e; 1662 }, 1663 1664 /** 1665 * Output a warning message using {@link JXG#debug} and precedes the message with "Warning: ". 1666 * @param {String} msg 1667 */ 1668 _warn: function (msg) { 1669 if(typeof console !== "undefined") { 1670 console.log('Warning(' + this.line + '): ' + msg); 1671 } else if(document && document.getElementById(this.warnLog) !== null) { 1672 document.getElementById(this.warnLog).innerHTML += 'Warning(' + this.line + '): ' + msg + '<br />'; 1673 } 1674 }, 1675 1676 _log: function (msg) { 1677 if (typeof window === 'undefined' && typeof self !== 'undefined' && self.postMessage) { 1678 self.postMessage({type: 'log', msg: 'Log: ' + msg.toString()}); 1679 } else { 1680 console.log('Log: ', arguments); 1681 } 1682 } 1683 1684 }); 1685 1686 /* 1687 Copyright 2008-2011 1688 Matthias Ehmann, 1689 Michael Gerhaeuser, 1690 Carsten Miller, 1691 Bianca Valentin, 1692 Alfred Wassermann, 1693 Peter Wilfahrt 1694 1695 This file is part of JSXGraph. 1696 1697 JSXGraph is free software: you can redistribute it and/or modify 1698 it under the terms of the GNU Lesser General Public License as published by 1699 the Free Software Foundation, either version 3 of the License, or 1700 (at your option) any later version. 1701 1702 JSXGraph is distributed in the hope that it will be useful, 1703 but WITHOUT ANY WARRANTY; without even the implied warranty of 1704 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1705 GNU Lesser General Public License for more details. 1706 1707 You should have received a copy of the GNU Lesser General Public License 1708 along with JSXGraph. If not, see <http://www.gnu.org/licenses/>. 1709 */ 1710 1711 1712 1713 /* 1714 Default template driver for JS/CC generated parsers running as 1715 browser-based JavaScript/ECMAScript applications. 1716 1717 WARNING: This parser template will only run together with JSXGraph on a website. 1718 1719 Features: 1720 - Parser trace messages 1721 - Integrated panic-mode error recovery 1722 1723 Written 2007, 2008 by Jan Max Meyer, J.M.K S.F. Software Technologies 1724 Modified 2011 by Michael Gerhaeuser, JSXGraph 1725 1726 This is in the public domain. 1727 */ 1728 1729 1730 JXG.extend(JXG.JessieCode.prototype, /** @lends JXG.JessieCode.prototype */ { 1731 /** 1732 * Internal lexer method. 1733 * @private 1734 */ 1735 _lex: function (PCB) { 1736 var state, 1737 match = -1, 1738 match_pos = 0, 1739 start = 0, 1740 pos, 1741 chr; 1742 1743 while (1) { 1744 state = 0; 1745 match = -1; 1746 match_pos = 0; 1747 start = 0; 1748 pos = PCB.offset + 1 + ( match_pos - start ); 1749 1750 do { 1751 1752 pos--; 1753 state = 0; 1754 match = -2; 1755 start = pos; 1756 1757 if( PCB.src.length <= start ) 1758 return 68; 1759 1760 do { 1761 chr = PCB.src.charCodeAt( pos ); 1762 1763 switch( state ) 1764 { 1765 case 0: 1766 if( ( chr >= 9 && chr <= 10 ) || chr == 13 || chr == 32 ) state = 1; 1767 else if( chr == 33 ) state = 2; 1768 else if( chr == 35 ) state = 3; 1769 else if( chr == 36 || ( chr >= 65 && chr <= 67 ) || ( chr >= 71 && chr <= 72 ) || ( chr >= 74 && chr <= 77 ) || ( chr >= 79 && chr <= 81 ) || chr == 83 || chr == 86 || ( chr >= 88 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 99 ) || ( chr >= 103 && chr <= 104 ) || ( chr >= 106 && chr <= 113 ) || chr == 115 || chr == 118 || ( chr >= 120 && chr <= 122 ) ) state = 4; 1770 else if( chr == 37 ) state = 5; 1771 else if( chr == 40 ) state = 6; 1772 else if( chr == 41 ) state = 7; 1773 else if( chr == 42 ) state = 8; 1774 else if( chr == 43 ) state = 9; 1775 else if( chr == 44 ) state = 10; 1776 else if( chr == 45 ) state = 11; 1777 else if( chr == 46 ) state = 12; 1778 else if( chr == 47 ) state = 13; 1779 else if( ( chr >= 48 && chr <= 57 ) ) state = 14; 1780 else if( chr == 58 ) state = 15; 1781 else if( chr == 59 ) state = 16; 1782 else if( chr == 60 ) state = 17; 1783 else if( chr == 61 ) state = 18; 1784 else if( chr == 62 ) state = 19; 1785 else if( chr == 91 ) state = 20; 1786 else if( chr == 93 ) state = 21; 1787 else if( chr == 94 ) state = 22; 1788 else if( chr == 123 ) state = 23; 1789 else if( chr == 124 ) state = 24; 1790 else if( chr == 125 ) state = 25; 1791 else if( chr == 38 ) state = 49; 1792 else if( chr == 68 || chr == 100 ) state = 50; 1793 else if( chr == 39 ) state = 52; 1794 else if( chr == 73 || chr == 105 ) state = 53; 1795 else if( chr == 126 ) state = 54; 1796 else if( chr == 70 || chr == 102 ) state = 66; 1797 else if( chr == 78 ) state = 67; 1798 else if( chr == 85 || chr == 117 ) state = 68; 1799 else if( chr == 69 || chr == 101 ) state = 76; 1800 else if( chr == 84 || chr == 116 ) state = 77; 1801 else if( chr == 87 || chr == 119 ) state = 83; 1802 else if( chr == 82 || chr == 114 ) state = 87; 1803 else state = -1; 1804 break; 1805 1806 case 1: 1807 state = -1; 1808 match = 2; 1809 match_pos = pos; 1810 break; 1811 1812 case 2: 1813 if( chr == 61 ) state = 26; 1814 else state = -1; 1815 match = 31; 1816 match_pos = pos; 1817 break; 1818 1819 case 3: 1820 state = -1; 1821 match = 41; 1822 match_pos = pos; 1823 break; 1824 1825 case 4: 1826 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 122 ) ) state = 4; 1827 else state = -1; 1828 match = 46; 1829 match_pos = pos; 1830 break; 1831 1832 case 5: 1833 state = -1; 1834 match = 35; 1835 match_pos = pos; 1836 break; 1837 1838 case 6: 1839 state = -1; 1840 match = 38; 1841 match_pos = pos; 1842 break; 1843 1844 case 7: 1845 state = -1; 1846 match = 39; 1847 match_pos = pos; 1848 break; 1849 1850 case 8: 1851 state = -1; 1852 match = 36; 1853 match_pos = pos; 1854 break; 1855 1856 case 9: 1857 state = -1; 1858 match = 32; 1859 match_pos = pos; 1860 break; 1861 1862 case 10: 1863 state = -1; 1864 match = 40; 1865 match_pos = pos; 1866 break; 1867 1868 case 11: 1869 state = -1; 1870 match = 33; 1871 match_pos = pos; 1872 break; 1873 1874 case 12: 1875 if( ( chr >= 48 && chr <= 57 ) ) state = 29; 1876 else state = -1; 1877 match = 44; 1878 match_pos = pos; 1879 break; 1880 1881 case 13: 1882 state = -1; 1883 match = 34; 1884 match_pos = pos; 1885 break; 1886 1887 case 14: 1888 if( ( chr >= 48 && chr <= 57 ) ) state = 14; 1889 else if( chr == 46 ) state = 29; 1890 else state = -1; 1891 match = 48; 1892 match_pos = pos; 1893 break; 1894 1895 case 15: 1896 state = -1; 1897 match = 42; 1898 match_pos = pos; 1899 break; 1900 1901 case 16: 1902 state = -1; 1903 match = 20; 1904 match_pos = pos; 1905 break; 1906 1907 case 17: 1908 if( chr == 60 ) state = 30; 1909 else if( chr == 61 ) state = 31; 1910 else state = -1; 1911 match = 28; 1912 match_pos = pos; 1913 break; 1914 1915 case 18: 1916 if( chr == 61 ) state = 32; 1917 else state = -1; 1918 match = 21; 1919 match_pos = pos; 1920 break; 1921 1922 case 19: 1923 if( chr == 61 ) state = 33; 1924 else if( chr == 62 ) state = 34; 1925 else state = -1; 1926 match = 27; 1927 match_pos = pos; 1928 break; 1929 1930 case 20: 1931 state = -1; 1932 match = 16; 1933 match_pos = pos; 1934 break; 1935 1936 case 21: 1937 state = -1; 1938 match = 17; 1939 match_pos = pos; 1940 break; 1941 1942 case 22: 1943 state = -1; 1944 match = 37; 1945 match_pos = pos; 1946 break; 1947 1948 case 23: 1949 state = -1; 1950 match = 18; 1951 match_pos = pos; 1952 break; 1953 1954 case 24: 1955 if( chr == 124 ) state = 37; 1956 else state = -1; 1957 match = 43; 1958 match_pos = pos; 1959 break; 1960 1961 case 25: 1962 state = -1; 1963 match = 19; 1964 match_pos = pos; 1965 break; 1966 1967 case 26: 1968 state = -1; 1969 match = 23; 1970 match_pos = pos; 1971 break; 1972 1973 case 27: 1974 state = -1; 1975 match = 30; 1976 match_pos = pos; 1977 break; 1978 1979 case 28: 1980 state = -1; 1981 match = 47; 1982 match_pos = pos; 1983 break; 1984 1985 case 29: 1986 if( ( chr >= 48 && chr <= 57 ) ) state = 29; 1987 else state = -1; 1988 match = 49; 1989 match_pos = pos; 1990 break; 1991 1992 case 30: 1993 state = -1; 1994 match = 14; 1995 match_pos = pos; 1996 break; 1997 1998 case 31: 1999 state = -1; 2000 match = 25; 2001 match_pos = pos; 2002 break; 2003 2004 case 32: 2005 state = -1; 2006 match = 22; 2007 match_pos = pos; 2008 break; 2009 2010 case 33: 2011 state = -1; 2012 match = 26; 2013 match_pos = pos; 2014 break; 2015 2016 case 34: 2017 state = -1; 2018 match = 15; 2019 match_pos = pos; 2020 break; 2021 2022 case 35: 2023 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 122 ) ) state = 4; 2024 else state = -1; 2025 match = 6; 2026 match_pos = pos; 2027 break; 2028 2029 case 36: 2030 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 122 ) ) state = 4; 2031 else state = -1; 2032 match = 3; 2033 match_pos = pos; 2034 break; 2035 2036 case 37: 2037 state = -1; 2038 match = 29; 2039 match_pos = pos; 2040 break; 2041 2042 case 38: 2043 state = -1; 2044 match = 24; 2045 match_pos = pos; 2046 break; 2047 2048 case 39: 2049 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 122 ) ) state = 4; 2050 else state = -1; 2051 match = 7; 2052 match_pos = pos; 2053 break; 2054 2055 case 40: 2056 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 122 ) ) state = 4; 2057 else state = -1; 2058 match = 45; 2059 match_pos = pos; 2060 break; 2061 2062 case 41: 2063 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 122 ) ) state = 4; 2064 else state = -1; 2065 match = 9; 2066 match_pos = pos; 2067 break; 2068 2069 case 42: 2070 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 122 ) ) state = 4; 2071 else state = -1; 2072 match = 4; 2073 match_pos = pos; 2074 break; 2075 2076 case 43: 2077 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 122 ) ) state = 4; 2078 else state = -1; 2079 match = 12; 2080 match_pos = pos; 2081 break; 2082 2083 case 44: 2084 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 122 ) ) state = 4; 2085 else state = -1; 2086 match = 13; 2087 match_pos = pos; 2088 break; 2089 2090 case 45: 2091 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 122 ) ) state = 4; 2092 else state = -1; 2093 match = 5; 2094 match_pos = pos; 2095 break; 2096 2097 case 46: 2098 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 122 ) ) state = 4; 2099 else state = -1; 2100 match = 11; 2101 match_pos = pos; 2102 break; 2103 2104 case 47: 2105 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 122 ) ) state = 4; 2106 else state = -1; 2107 match = 10; 2108 match_pos = pos; 2109 break; 2110 2111 case 48: 2112 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 122 ) ) state = 4; 2113 else state = -1; 2114 match = 8; 2115 match_pos = pos; 2116 break; 2117 2118 case 49: 2119 if( chr == 38 ) state = 27; 2120 else state = -1; 2121 break; 2122 2123 case 50: 2124 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 68 ) || ( chr >= 70 && chr <= 78 ) || ( chr >= 80 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 100 ) || ( chr >= 102 && chr <= 110 ) || ( chr >= 112 && chr <= 122 ) ) state = 4; 2125 else if( chr == 79 || chr == 111 ) state = 35; 2126 else if( chr == 69 || chr == 101 ) state = 84; 2127 else state = -1; 2128 match = 46; 2129 match_pos = pos; 2130 break; 2131 2132 case 51: 2133 if( chr == 39 ) state = 28; 2134 else if( ( chr >= 0 && chr <= 38 ) || ( chr >= 40 && chr <= 91 ) || ( chr >= 93 && chr <= 254 ) ) state = 52; 2135 else if( chr == 92 ) state = 56; 2136 else state = -1; 2137 match = 47; 2138 match_pos = pos; 2139 break; 2140 2141 case 52: 2142 if( chr == 39 ) state = 28; 2143 else if( ( chr >= 0 && chr <= 38 ) || ( chr >= 40 && chr <= 91 ) || ( chr >= 93 && chr <= 254 ) ) state = 52; 2144 else if( chr == 92 ) state = 56; 2145 else state = -1; 2146 break; 2147 2148 case 53: 2149 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 69 ) || ( chr >= 71 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 101 ) || ( chr >= 103 && chr <= 122 ) ) state = 4; 2150 else if( chr == 70 || chr == 102 ) state = 36; 2151 else state = -1; 2152 match = 46; 2153 match_pos = pos; 2154 break; 2155 2156 case 54: 2157 if( chr == 61 ) state = 38; 2158 else state = -1; 2159 break; 2160 2161 case 55: 2162 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 81 ) || ( chr >= 83 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 113 ) || ( chr >= 115 && chr <= 122 ) ) state = 4; 2163 else if( chr == 82 || chr == 114 ) state = 39; 2164 else state = -1; 2165 match = 46; 2166 match_pos = pos; 2167 break; 2168 2169 case 56: 2170 if( chr == 39 ) state = 51; 2171 else if( ( chr >= 0 && chr <= 38 ) || ( chr >= 40 && chr <= 91 ) || ( chr >= 93 && chr <= 254 ) ) state = 52; 2172 else if( chr == 92 ) state = 56; 2173 else state = -1; 2174 break; 2175 2176 case 57: 2177 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 77 ) || ( chr >= 79 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 122 ) ) state = 4; 2178 else if( chr == 78 ) state = 40; 2179 else state = -1; 2180 match = 46; 2181 match_pos = pos; 2182 break; 2183 2184 case 58: 2185 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 68 ) || ( chr >= 70 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 100 ) || ( chr >= 102 && chr <= 122 ) ) state = 4; 2186 else if( chr == 69 || chr == 101 ) state = 41; 2187 else state = -1; 2188 match = 46; 2189 match_pos = pos; 2190 break; 2191 2192 case 59: 2193 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 68 ) || ( chr >= 70 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 100 ) || ( chr >= 102 && chr <= 122 ) ) state = 4; 2194 else if( chr == 69 || chr == 101 ) state = 42; 2195 else state = -1; 2196 match = 46; 2197 match_pos = pos; 2198 break; 2199 2200 case 60: 2201 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 68 ) || ( chr >= 70 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 100 ) || ( chr >= 102 && chr <= 122 ) ) state = 4; 2202 else if( chr == 69 || chr == 101 ) state = 43; 2203 else state = -1; 2204 match = 46; 2205 match_pos = pos; 2206 break; 2207 2208 case 61: 2209 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 68 ) || ( chr >= 70 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 100 ) || ( chr >= 102 && chr <= 122 ) ) state = 4; 2210 else if( chr == 69 || chr == 101 ) state = 44; 2211 else state = -1; 2212 match = 46; 2213 match_pos = pos; 2214 break; 2215 2216 case 62: 2217 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 68 ) || ( chr >= 70 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 100 ) || ( chr >= 102 && chr <= 122 ) ) state = 4; 2218 else if( chr == 69 || chr == 101 ) state = 45; 2219 else state = -1; 2220 match = 46; 2221 match_pos = pos; 2222 break; 2223 2224 case 63: 2225 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 68 ) || ( chr >= 70 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 100 ) || ( chr >= 102 && chr <= 122 ) ) state = 4; 2226 else if( chr == 69 || chr == 101 ) state = 46; 2227 else state = -1; 2228 match = 46; 2229 match_pos = pos; 2230 break; 2231 2232 case 64: 2233 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 77 ) || ( chr >= 79 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 109 ) || ( chr >= 111 && chr <= 122 ) ) state = 4; 2234 else if( chr == 78 || chr == 110 ) state = 47; 2235 else state = -1; 2236 match = 46; 2237 match_pos = pos; 2238 break; 2239 2240 case 65: 2241 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 77 ) || ( chr >= 79 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 109 ) || ( chr >= 111 && chr <= 122 ) ) state = 4; 2242 else if( chr == 78 || chr == 110 ) state = 48; 2243 else state = -1; 2244 match = 46; 2245 match_pos = pos; 2246 break; 2247 2248 case 66: 2249 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 66 && chr <= 78 ) || ( chr >= 80 && chr <= 84 ) || ( chr >= 86 && chr <= 90 ) || chr == 95 || ( chr >= 98 && chr <= 110 ) || ( chr >= 112 && chr <= 116 ) || ( chr >= 118 && chr <= 122 ) ) state = 4; 2250 else if( chr == 79 || chr == 111 ) state = 55; 2251 else if( chr == 65 || chr == 97 ) state = 78; 2252 else if( chr == 85 || chr == 117 ) state = 89; 2253 else state = -1; 2254 match = 46; 2255 match_pos = pos; 2256 break; 2257 2258 case 67: 2259 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 90 ) || chr == 95 || ( chr >= 98 && chr <= 122 ) ) state = 4; 2260 else if( chr == 97 ) state = 57; 2261 else state = -1; 2262 match = 46; 2263 match_pos = pos; 2264 break; 2265 2266 case 68: 2267 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 82 ) || ( chr >= 84 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 114 ) || ( chr >= 116 && chr <= 122 ) ) state = 4; 2268 else if( chr == 83 || chr == 115 ) state = 58; 2269 else state = -1; 2270 match = 46; 2271 match_pos = pos; 2272 break; 2273 2274 case 69: 2275 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 82 ) || ( chr >= 84 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 114 ) || ( chr >= 116 && chr <= 122 ) ) state = 4; 2276 else if( chr == 83 || chr == 115 ) state = 59; 2277 else state = -1; 2278 match = 46; 2279 match_pos = pos; 2280 break; 2281 2282 case 70: 2283 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 84 ) || ( chr >= 86 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 116 ) || ( chr >= 118 && chr <= 122 ) ) state = 4; 2284 else if( chr == 85 || chr == 117 ) state = 60; 2285 else state = -1; 2286 match = 46; 2287 match_pos = pos; 2288 break; 2289 2290 case 71: 2291 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 82 ) || ( chr >= 84 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 114 ) || ( chr >= 116 && chr <= 122 ) ) state = 4; 2292 else if( chr == 83 || chr == 115 ) state = 61; 2293 else state = -1; 2294 match = 46; 2295 match_pos = pos; 2296 break; 2297 2298 case 72: 2299 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 75 ) || ( chr >= 77 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 107 ) || ( chr >= 109 && chr <= 122 ) ) state = 4; 2300 else if( chr == 76 || chr == 108 ) state = 62; 2301 else state = -1; 2302 match = 46; 2303 match_pos = pos; 2304 break; 2305 2306 case 73: 2307 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 83 ) || ( chr >= 85 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 115 ) || ( chr >= 117 && chr <= 122 ) ) state = 4; 2308 else if( chr == 84 || chr == 116 ) state = 63; 2309 else state = -1; 2310 match = 46; 2311 match_pos = pos; 2312 break; 2313 2314 case 74: 2315 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 81 ) || ( chr >= 83 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 113 ) || ( chr >= 115 && chr <= 122 ) ) state = 4; 2316 else if( chr == 82 || chr == 114 ) state = 64; 2317 else state = -1; 2318 match = 46; 2319 match_pos = pos; 2320 break; 2321 2322 case 75: 2323 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 78 ) || ( chr >= 80 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 110 ) || ( chr >= 112 && chr <= 122 ) ) state = 4; 2324 else if( chr == 79 || chr == 111 ) state = 65; 2325 else state = -1; 2326 match = 46; 2327 match_pos = pos; 2328 break; 2329 2330 case 76: 2331 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 75 ) || ( chr >= 77 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 107 ) || ( chr >= 109 && chr <= 122 ) ) state = 4; 2332 else if( chr == 76 || chr == 108 ) state = 69; 2333 else state = -1; 2334 match = 46; 2335 match_pos = pos; 2336 break; 2337 2338 case 77: 2339 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 81 ) || ( chr >= 83 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 113 ) || ( chr >= 115 && chr <= 122 ) ) state = 4; 2340 else if( chr == 82 || chr == 114 ) state = 70; 2341 else state = -1; 2342 match = 46; 2343 match_pos = pos; 2344 break; 2345 2346 case 78: 2347 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 75 ) || ( chr >= 77 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 107 ) || ( chr >= 109 && chr <= 122 ) ) state = 4; 2348 else if( chr == 76 || chr == 108 ) state = 71; 2349 else state = -1; 2350 match = 46; 2351 match_pos = pos; 2352 break; 2353 2354 case 79: 2355 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 72 ) || ( chr >= 74 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 104 ) || ( chr >= 106 && chr <= 122 ) ) state = 4; 2356 else if( chr == 73 || chr == 105 ) state = 72; 2357 else state = -1; 2358 match = 46; 2359 match_pos = pos; 2360 break; 2361 2362 case 80: 2363 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 68 ) || ( chr >= 70 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 100 ) || ( chr >= 102 && chr <= 122 ) ) state = 4; 2364 else if( chr == 69 || chr == 101 ) state = 73; 2365 else state = -1; 2366 match = 46; 2367 match_pos = pos; 2368 break; 2369 2370 case 81: 2371 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 84 ) || ( chr >= 86 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 116 ) || ( chr >= 118 && chr <= 122 ) ) state = 4; 2372 else if( chr == 85 || chr == 117 ) state = 74; 2373 else state = -1; 2374 match = 46; 2375 match_pos = pos; 2376 break; 2377 2378 case 82: 2379 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 72 ) || ( chr >= 74 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 104 ) || ( chr >= 106 && chr <= 122 ) ) state = 4; 2380 else if( chr == 73 || chr == 105 ) state = 75; 2381 else state = -1; 2382 match = 46; 2383 match_pos = pos; 2384 break; 2385 2386 case 83: 2387 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 71 ) || ( chr >= 73 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 103 ) || ( chr >= 105 && chr <= 122 ) ) state = 4; 2388 else if( chr == 72 || chr == 104 ) state = 79; 2389 else state = -1; 2390 match = 46; 2391 match_pos = pos; 2392 break; 2393 2394 case 84: 2395 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 75 ) || ( chr >= 77 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 107 ) || ( chr >= 109 && chr <= 122 ) ) state = 4; 2396 else if( chr == 76 || chr == 108 ) state = 80; 2397 else state = -1; 2398 match = 46; 2399 match_pos = pos; 2400 break; 2401 2402 case 85: 2403 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 83 ) || ( chr >= 85 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 115 ) || ( chr >= 117 && chr <= 122 ) ) state = 4; 2404 else if( chr == 84 || chr == 116 ) state = 81; 2405 else state = -1; 2406 match = 46; 2407 match_pos = pos; 2408 break; 2409 2410 case 86: 2411 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 83 ) || ( chr >= 85 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 115 ) || ( chr >= 117 && chr <= 122 ) ) state = 4; 2412 else if( chr == 84 || chr == 116 ) state = 82; 2413 else state = -1; 2414 match = 46; 2415 match_pos = pos; 2416 break; 2417 2418 case 87: 2419 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 68 ) || ( chr >= 70 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 100 ) || ( chr >= 102 && chr <= 122 ) ) state = 4; 2420 else if( chr == 69 || chr == 101 ) state = 85; 2421 else state = -1; 2422 match = 46; 2423 match_pos = pos; 2424 break; 2425 2426 case 88: 2427 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 66 ) || ( chr >= 68 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 98 ) || ( chr >= 100 && chr <= 122 ) ) state = 4; 2428 else if( chr == 67 || chr == 99 ) state = 86; 2429 else state = -1; 2430 match = 46; 2431 match_pos = pos; 2432 break; 2433 2434 case 89: 2435 if( ( chr >= 48 && chr <= 57 ) || ( chr >= 65 && chr <= 77 ) || ( chr >= 79 && chr <= 90 ) || chr == 95 || ( chr >= 97 && chr <= 109 ) || ( chr >= 111 && chr <= 122 ) ) state = 4; 2436 else if( chr == 78 || chr == 110 ) state = 88; 2437 else state = -1; 2438 match = 46; 2439 match_pos = pos; 2440 break; 2441 2442 } 2443 2444 2445 2446 //Line- and column-counter 2447 if( state > -1 ) { 2448 if( chr == 10 ) { 2449 PCB.line++; 2450 PCB.column = 0; 2451 if (this.countLines) { 2452 this.parCurLine = PCB.line; 2453 } 2454 } 2455 PCB.column++; 2456 if (this.countLines) { 2457 this.parCurColumn = PCB.column; 2458 } 2459 } 2460 2461 pos++; 2462 2463 } while( state > -1 ); 2464 2465 } while (2 > -1 && match == 2); 2466 2467 if (match > -1) { 2468 PCB.att = PCB.src.substr( start, match_pos - start ); 2469 PCB.offset = match_pos; 2470 2471 if( match == 47 ) 2472 { 2473 PCB.att = PCB.att.substr( 1, PCB.att.length - 2 ); 2474 PCB.att = PCB.att.replace( /\\\'/g, "\'" ); 2475 } 2476 2477 } else { 2478 PCB.att = new String(); 2479 match = -1; 2480 } 2481 2482 break; 2483 } 2484 return match; 2485 }, 2486 2487 /** 2488 * Internal parse tree generator. 2489 * @param {String} src source code 2490 * @param {Array} err_off The positions where the errors occured are stored here. 2491 * @param {Array} err_la What the parser expected will be stored here. 2492 * @private 2493 */ 2494 _parse: function (src, err_off, err_la) { 2495 var sstack = [], 2496 vstack = [], 2497 err_cnt = 0, 2498 act, 2499 rval, 2500 i, 2501 2502 PCB = { 2503 la: 0, 2504 act: 0, 2505 offset: 0, 2506 src: src, 2507 att: '', 2508 line: 1, 2509 column: 1, 2510 error_step: 0 2511 }; 2512 2513 /* Pop-Table */ 2514 var pop_tab = new Array( 2515 new Array( 0/* Program' */, 1 ), 2516 new Array( 50/* Program */, 2 ), 2517 new Array( 50/* Program */, 0 ), 2518 new Array( 52/* Stmt_List */, 2 ), 2519 new Array( 52/* Stmt_List */, 0 ), 2520 new Array( 53/* Param_List */, 3 ), 2521 new Array( 53/* Param_List */, 1 ), 2522 new Array( 53/* Param_List */, 0 ), 2523 new Array( 55/* Prop_List */, 3 ), 2524 new Array( 55/* Prop_List */, 1 ), 2525 new Array( 55/* Prop_List */, 0 ), 2526 new Array( 56/* Prop */, 3 ), 2527 new Array( 57/* Param_Def_List */, 3 ), 2528 new Array( 57/* Param_Def_List */, 1 ), 2529 new Array( 57/* Param_Def_List */, 0 ), 2530 new Array( 58/* Attr_List */, 3 ), 2531 new Array( 58/* Attr_List */, 1 ), 2532 new Array( 61/* Assign */, 3 ), 2533 new Array( 51/* Stmt */, 3 ), 2534 new Array( 51/* Stmt */, 5 ), 2535 new Array( 51/* Stmt */, 3 ), 2536 new Array( 51/* Stmt */, 5 ), 2537 new Array( 51/* Stmt */, 9 ), 2538 new Array( 51/* Stmt */, 3 ), 2539 new Array( 51/* Stmt */, 2 ), 2540 new Array( 51/* Stmt */, 2 ), 2541 new Array( 51/* Stmt */, 2 ), 2542 new Array( 51/* Stmt */, 2 ), 2543 new Array( 51/* Stmt */, 3 ), 2544 new Array( 51/* Stmt */, 1 ), 2545 new Array( 60/* Lhs */, 3 ), 2546 new Array( 60/* Lhs */, 4 ), 2547 new Array( 60/* Lhs */, 1 ), 2548 new Array( 54/* Expression */, 3 ), 2549 new Array( 54/* Expression */, 3 ), 2550 new Array( 54/* Expression */, 3 ), 2551 new Array( 54/* Expression */, 3 ), 2552 new Array( 54/* Expression */, 3 ), 2553 new Array( 54/* Expression */, 3 ), 2554 new Array( 54/* Expression */, 3 ), 2555 new Array( 54/* Expression */, 1 ), 2556 new Array( 63/* LogExp */, 3 ), 2557 new Array( 63/* LogExp */, 3 ), 2558 new Array( 63/* LogExp */, 2 ), 2559 new Array( 63/* LogExp */, 1 ), 2560 new Array( 62/* AddSubExp */, 3 ), 2561 new Array( 62/* AddSubExp */, 3 ), 2562 new Array( 62/* AddSubExp */, 1 ), 2563 new Array( 64/* MulDivExp */, 3 ), 2564 new Array( 64/* MulDivExp */, 3 ), 2565 new Array( 64/* MulDivExp */, 3 ), 2566 new Array( 64/* MulDivExp */, 1 ), 2567 new Array( 66/* ExpExp */, 3 ), 2568 new Array( 66/* ExpExp */, 1 ), 2569 new Array( 65/* NegExp */, 2 ), 2570 new Array( 65/* NegExp */, 2 ), 2571 new Array( 65/* NegExp */, 1 ), 2572 new Array( 59/* ExtValue */, 4 ), 2573 new Array( 59/* ExtValue */, 7 ), 2574 new Array( 59/* ExtValue */, 4 ), 2575 new Array( 59/* ExtValue */, 5 ), 2576 new Array( 59/* ExtValue */, 3 ), 2577 new Array( 59/* ExtValue */, 1 ), 2578 new Array( 67/* Value */, 1 ), 2579 new Array( 67/* Value */, 1 ), 2580 new Array( 67/* Value */, 1 ), 2581 new Array( 67/* Value */, 3 ), 2582 new Array( 67/* Value */, 1 ), 2583 new Array( 67/* Value */, 7 ), 2584 new Array( 67/* Value */, 3 ), 2585 new Array( 67/* Value */, 3 ), 2586 new Array( 67/* Value */, 1 ), 2587 new Array( 67/* Value */, 1 ), 2588 new Array( 67/* Value */, 1 ) 2589 ); 2590 2591 /* Action-Table */ 2592 var act_tab = new Array( 2593 /* State 0 */ new Array( ), 2594 /* State 1 */ new Array( 3/* "IF" */,3 , 5/* "WHILE" */,4 , 6/* "DO" */,5 , 7/* "FOR" */,6 , 9/* "USE" */,7 , 11/* "DELETE" */,8 , 10/* "RETURN" */,9 , 18/* "{" */,12 , 20/* ";" */,13 , 46/* "Identifier" */,17 , 31/* "!" */,18 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 , 33/* "-" */,33 , 32/* "+" */,34 ), 2595 /* State 2 */ new Array( ), 2596 /* State 3 */ new Array( 31/* "!" */,18 , 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2597 /* State 4 */ new Array( 31/* "!" */,18 , 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2598 /* State 5 */ new Array( 3/* "IF" */,3 , 5/* "WHILE" */,4 , 6/* "DO" */,5 , 7/* "FOR" */,6 , 9/* "USE" */,7 , 11/* "DELETE" */,8 , 10/* "RETURN" */,9 , 18/* "{" */,12 , 20/* ";" */,13 , 46/* "Identifier" */,17 , 31/* "!" */,18 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 , 33/* "-" */,33 , 32/* "+" */,34 ), 2599 /* State 6 */ new Array( 38/* "(" */,41 ), 2600 /* State 7 */ new Array( 46/* "Identifier" */,42 ), 2601 /* State 8 */ new Array( 46/* "Identifier" */,43 ), 2602 /* State 9 */ new Array( 3/* "IF" */,3 , 5/* "WHILE" */,4 , 6/* "DO" */,5 , 7/* "FOR" */,6 , 9/* "USE" */,7 , 11/* "DELETE" */,8 , 10/* "RETURN" */,9 , 18/* "{" */,12 , 20/* ";" */,13 , 46/* "Identifier" */,17 , 31/* "!" */,18 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 , 33/* "-" */,33 , 32/* "+" */,34 ), 2603 /* State 10 */ new Array( 20/* ";" */,45 ), 2604 /* State 11 */ new Array( 24/* "~=" */,46 , 23/* "!=" */,47 , 26/* ">=" */,48 , 25/* "<=" */,49 , 27/* ">" */,50 , 28/* "<" */,51 , 22/* "==" */,52 , 20/* ";" */,53 ), 2605 /* State 12 */ new Array( ), 2606 /* State 13 */ new Array( ), 2607 /* State 14 */ new Array( 21/* "=" */,55 ), 2608 /* State 15 */ new Array( 30/* "&&" */,56 , 29/* "||" */,57 ), 2609 /* State 16 */ new Array( 44/* "." */,58 , 38/* "(" */,59 , 16/* "[" */,60 , 37/* "^" */,61 ), 2610 /* State 17 */ new Array( 21/* "=" */,-32 ), 2611 /* State 18 */ new Array( 31/* "!" */,18 , 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2612 /* State 19 */ new Array( 32/* "+" */,63 , 33/* "-" */,64 ), 2613 /* State 20 */ new Array( ), 2614 /* State 21 */ new Array( 35/* "%" */,65 , 34/* "/" */,66 , 36/* "*" */,67 ), 2615 /* State 22 */ new Array( ), 2616 /* State 23 */ new Array( ), 2617 /* State 24 */ new Array( 31/* "!" */,18 , 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2618 /* State 25 */ new Array( ), 2619 /* State 26 */ new Array( 38/* "(" */,69 ), 2620 /* State 27 */ new Array( 46/* "Identifier" */,72 ), 2621 /* State 28 */ new Array( 31/* "!" */,18 , 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2622 /* State 29 */ new Array( ), 2623 /* State 30 */ new Array( ), 2624 /* State 31 */ new Array( ), 2625 /* State 32 */ new Array( ), 2626 /* State 33 */ new Array( 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2627 /* State 34 */ new Array( 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2628 /* State 35 */ new Array( ), 2629 /* State 36 */ new Array( 24/* "~=" */,46 , 23/* "!=" */,47 , 26/* ">=" */,48 , 25/* "<=" */,49 , 27/* ">" */,50 , 28/* "<" */,51 , 22/* "==" */,52 , 3/* "IF" */,3 , 5/* "WHILE" */,4 , 6/* "DO" */,5 , 7/* "FOR" */,6 , 9/* "USE" */,7 , 11/* "DELETE" */,8 , 10/* "RETURN" */,9 , 18/* "{" */,12 , 20/* ";" */,13 , 46/* "Identifier" */,17 , 31/* "!" */,18 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 , 33/* "-" */,33 , 32/* "+" */,34 ), 2630 /* State 37 */ new Array( 44/* "." */,78 , 38/* "(" */,59 , 16/* "[" */,79 , 37/* "^" */,61 ), 2631 /* State 38 */ new Array( ), 2632 /* State 39 */ new Array( 24/* "~=" */,46 , 23/* "!=" */,47 , 26/* ">=" */,48 , 25/* "<=" */,49 , 27/* ">" */,50 , 28/* "<" */,51 , 22/* "==" */,52 , 3/* "IF" */,3 , 5/* "WHILE" */,4 , 6/* "DO" */,5 , 7/* "FOR" */,6 , 9/* "USE" */,7 , 11/* "DELETE" */,8 , 10/* "RETURN" */,9 , 18/* "{" */,12 , 20/* ";" */,13 , 46/* "Identifier" */,17 , 31/* "!" */,18 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 , 33/* "-" */,33 , 32/* "+" */,34 ), 2633 /* State 40 */ new Array( 5/* "WHILE" */,81 ), 2634 /* State 41 */ new Array( 46/* "Identifier" */,17 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2635 /* State 42 */ new Array( 20/* ";" */,84 ), 2636 /* State 43 */ new Array( ), 2637 /* State 44 */ new Array( ), 2638 /* State 45 */ new Array( ), 2639 /* State 46 */ new Array( 31/* "!" */,18 , 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2640 /* State 47 */ new Array( 31/* "!" */,18 , 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2641 /* State 48 */ new Array( 31/* "!" */,18 , 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2642 /* State 49 */ new Array( 31/* "!" */,18 , 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2643 /* State 50 */ new Array( 31/* "!" */,18 , 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2644 /* State 51 */ new Array( 31/* "!" */,18 , 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2645 /* State 52 */ new Array( 31/* "!" */,18 , 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2646 /* State 53 */ new Array( ), 2647 /* State 54 */ new Array( 19/* "}" */,92 , 3/* "IF" */,3 , 5/* "WHILE" */,4 , 6/* "DO" */,5 , 7/* "FOR" */,6 , 9/* "USE" */,7 , 11/* "DELETE" */,8 , 10/* "RETURN" */,9 , 18/* "{" */,12 , 20/* ";" */,13 , 46/* "Identifier" */,17 , 31/* "!" */,18 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 , 33/* "-" */,33 , 32/* "+" */,34 ), 2648 /* State 55 */ new Array( 31/* "!" */,18 , 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2649 /* State 56 */ new Array( 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2650 /* State 57 */ new Array( 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2651 /* State 58 */ new Array( 46/* "Identifier" */,97 ), 2652 /* State 59 */ new Array( 31/* "!" */,18 , 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2653 /* State 60 */ new Array( 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2654 /* State 61 */ new Array( 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2655 /* State 62 */ new Array( 30/* "&&" */,56 , 29/* "||" */,57 ), 2656 /* State 63 */ new Array( 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2657 /* State 64 */ new Array( 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2658 /* State 65 */ new Array( 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2659 /* State 66 */ new Array( 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2660 /* State 67 */ new Array( 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2661 /* State 68 */ new Array( 39/* ")" */,106 , 24/* "~=" */,46 , 23/* "!=" */,47 , 26/* ">=" */,48 , 25/* "<=" */,49 , 27/* ">" */,50 , 28/* "<" */,51 , 22/* "==" */,52 ), 2662 /* State 69 */ new Array( 46/* "Identifier" */,108 ), 2663 /* State 70 */ new Array( 15/* ">>" */,109 , 40/* "," */,110 ), 2664 /* State 71 */ new Array( ), 2665 /* State 72 */ new Array( 42/* ":" */,111 ), 2666 /* State 73 */ new Array( 17/* "]" */,112 , 40/* "," */,113 ), 2667 /* State 74 */ new Array( 24/* "~=" */,46 , 23/* "!=" */,47 , 26/* ">=" */,48 , 25/* "<=" */,49 , 27/* ">" */,50 , 28/* "<" */,51 , 22/* "==" */,52 ), 2668 /* State 75 */ new Array( ), 2669 /* State 76 */ new Array( ), 2670 /* State 77 */ new Array( 4/* "ELSE" */,114 ), 2671 /* State 78 */ new Array( 46/* "Identifier" */,115 ), 2672 /* State 79 */ new Array( 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2673 /* State 80 */ new Array( ), 2674 /* State 81 */ new Array( 31/* "!" */,18 , 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2675 /* State 82 */ new Array( 20/* ";" */,118 ), 2676 /* State 83 */ new Array( 44/* "." */,58 , 38/* "(" */,59 , 16/* "[" */,60 ), 2677 /* State 84 */ new Array( ), 2678 /* State 85 */ new Array( 30/* "&&" */,56 , 29/* "||" */,57 ), 2679 /* State 86 */ new Array( 30/* "&&" */,56 , 29/* "||" */,57 ), 2680 /* State 87 */ new Array( 30/* "&&" */,56 , 29/* "||" */,57 ), 2681 /* State 88 */ new Array( 30/* "&&" */,56 , 29/* "||" */,57 ), 2682 /* State 89 */ new Array( 30/* "&&" */,56 , 29/* "||" */,57 ), 2683 /* State 90 */ new Array( 30/* "&&" */,56 , 29/* "||" */,57 ), 2684 /* State 91 */ new Array( 30/* "&&" */,56 , 29/* "||" */,57 ), 2685 /* State 92 */ new Array( ), 2686 /* State 93 */ new Array( ), 2687 /* State 94 */ new Array( 24/* "~=" */,46 , 23/* "!=" */,47 , 26/* ">=" */,48 , 25/* "<=" */,49 , 27/* ">" */,50 , 28/* "<" */,51 , 22/* "==" */,52 ), 2688 /* State 95 */ new Array( 32/* "+" */,63 , 33/* "-" */,64 ), 2689 /* State 96 */ new Array( 32/* "+" */,63 , 33/* "-" */,64 ), 2690 /* State 97 */ new Array( 21/* "=" */,-30 ), 2691 /* State 98 */ new Array( 39/* ")" */,119 , 40/* "," */,113 ), 2692 /* State 99 */ new Array( 17/* "]" */,120 , 32/* "+" */,63 , 33/* "-" */,64 ), 2693 /* State 100 */ new Array( ), 2694 /* State 101 */ new Array( 35/* "%" */,65 , 34/* "/" */,66 , 36/* "*" */,67 ), 2695 /* State 102 */ new Array( 35/* "%" */,65 , 34/* "/" */,66 , 36/* "*" */,67 ), 2696 /* State 103 */ new Array( ), 2697 /* State 104 */ new Array( ), 2698 /* State 105 */ new Array( ), 2699 /* State 106 */ new Array( ), 2700 /* State 107 */ new Array( 39/* ")" */,121 , 40/* "," */,122 ), 2701 /* State 108 */ new Array( ), 2702 /* State 109 */ new Array( ), 2703 /* State 110 */ new Array( 46/* "Identifier" */,72 ), 2704 /* State 111 */ new Array( 31/* "!" */,18 , 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2705 /* State 112 */ new Array( ), 2706 /* State 113 */ new Array( 31/* "!" */,18 , 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2707 /* State 114 */ new Array( 3/* "IF" */,3 , 5/* "WHILE" */,4 , 6/* "DO" */,5 , 7/* "FOR" */,6 , 9/* "USE" */,7 , 11/* "DELETE" */,8 , 10/* "RETURN" */,9 , 18/* "{" */,12 , 20/* ";" */,13 , 46/* "Identifier" */,17 , 31/* "!" */,18 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 , 33/* "-" */,33 , 32/* "+" */,34 ), 2708 /* State 115 */ new Array( ), 2709 /* State 116 */ new Array( 17/* "]" */,127 , 32/* "+" */,63 , 33/* "-" */,64 ), 2710 /* State 117 */ new Array( 24/* "~=" */,46 , 23/* "!=" */,47 , 26/* ">=" */,48 , 25/* "<=" */,49 , 27/* ">" */,50 , 28/* "<" */,51 , 22/* "==" */,52 , 20/* ";" */,128 ), 2711 /* State 118 */ new Array( 31/* "!" */,18 , 33/* "-" */,33 , 32/* "+" */,34 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2712 /* State 119 */ new Array( 16/* "[" */,131 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2713 /* State 120 */ new Array( 21/* "=" */,-31 ), 2714 /* State 121 */ new Array( 18/* "{" */,133 ), 2715 /* State 122 */ new Array( 46/* "Identifier" */,134 ), 2716 /* State 123 */ new Array( ), 2717 /* State 124 */ new Array( 24/* "~=" */,46 , 23/* "!=" */,47 , 26/* ">=" */,48 , 25/* "<=" */,49 , 27/* ">" */,50 , 28/* "<" */,51 , 22/* "==" */,52 ), 2718 /* State 125 */ new Array( 24/* "~=" */,46 , 23/* "!=" */,47 , 26/* ">=" */,48 , 25/* "<=" */,49 , 27/* ">" */,50 , 28/* "<" */,51 , 22/* "==" */,52 ), 2719 /* State 126 */ new Array( ), 2720 /* State 127 */ new Array( ), 2721 /* State 128 */ new Array( ), 2722 /* State 129 */ new Array( 24/* "~=" */,46 , 23/* "!=" */,47 , 26/* ">=" */,48 , 25/* "<=" */,49 , 27/* ">" */,50 , 28/* "<" */,51 , 22/* "==" */,52 , 20/* ";" */,135 ), 2723 /* State 130 */ new Array( 40/* "," */,136 ), 2724 /* State 131 */ new Array( 33/* "-" */,33 , 32/* "+" */,34 , 31/* "!" */,18 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2725 /* State 132 */ new Array( 44/* "." */,78 , 38/* "(" */,59 , 16/* "[" */,79 ), 2726 /* State 133 */ new Array( ), 2727 /* State 134 */ new Array( ), 2728 /* State 135 */ new Array( 46/* "Identifier" */,17 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2729 /* State 136 */ new Array( 48/* "Integer" */,22 , 49/* "Float" */,23 , 46/* "Identifier" */,38 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 ), 2730 /* State 137 */ new Array( 17/* "]" */,141 , 32/* "+" */,63 , 33/* "-" */,64 ), 2731 /* State 138 */ new Array( 19/* "}" */,142 , 3/* "IF" */,3 , 5/* "WHILE" */,4 , 6/* "DO" */,5 , 7/* "FOR" */,6 , 9/* "USE" */,7 , 11/* "DELETE" */,8 , 10/* "RETURN" */,9 , 18/* "{" */,12 , 20/* ";" */,13 , 46/* "Identifier" */,17 , 31/* "!" */,18 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 , 33/* "-" */,33 , 32/* "+" */,34 ), 2732 /* State 139 */ new Array( 39/* ")" */,143 ), 2733 /* State 140 */ new Array( 44/* "." */,78 , 38/* "(" */,59 , 16/* "[" */,79 ), 2734 /* State 141 */ new Array( ), 2735 /* State 142 */ new Array( ), 2736 /* State 143 */ new Array( 3/* "IF" */,3 , 5/* "WHILE" */,4 , 6/* "DO" */,5 , 7/* "FOR" */,6 , 9/* "USE" */,7 , 11/* "DELETE" */,8 , 10/* "RETURN" */,9 , 18/* "{" */,12 , 20/* ";" */,13 , 46/* "Identifier" */,17 , 31/* "!" */,18 , 48/* "Integer" */,22 , 49/* "Float" */,23 , 38/* "(" */,24 , 47/* "String" */,25 , 8/* "FUNCTION" */,26 , 14/* "<<" */,27 , 16/* "[" */,28 , 12/* "TRUE" */,29 , 13/* "FALSE" */,30 , 45/* "NaN" */,31 , 33/* "-" */,33 , 32/* "+" */,34 ), 2737 /* State 144 */ new Array( ) 2738 ); 2739 2740 /* Goto-Table */ 2741 var goto_tab = new Array( 2742 /* State 0 */ new Array( 50/* Program */,1 ), 2743 /* State 1 */ new Array( 51/* Stmt */,2 , 61/* Assign */,10 , 54/* Expression */,11 , 60/* Lhs */,14 , 63/* LogExp */,15 , 59/* ExtValue */,16 , 62/* AddSubExp */,19 , 67/* Value */,20 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 ), 2744 /* State 2 */ new Array( ), 2745 /* State 3 */ new Array( 54/* Expression */,36 , 63/* LogExp */,15 , 62/* AddSubExp */,19 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2746 /* State 4 */ new Array( 54/* Expression */,39 , 63/* LogExp */,15 , 62/* AddSubExp */,19 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2747 /* State 5 */ new Array( 51/* Stmt */,40 , 61/* Assign */,10 , 54/* Expression */,11 , 60/* Lhs */,14 , 63/* LogExp */,15 , 59/* ExtValue */,16 , 62/* AddSubExp */,19 , 67/* Value */,20 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 ), 2748 /* State 6 */ new Array( ), 2749 /* State 7 */ new Array( ), 2750 /* State 8 */ new Array( ), 2751 /* State 9 */ new Array( 51/* Stmt */,44 , 61/* Assign */,10 , 54/* Expression */,11 , 60/* Lhs */,14 , 63/* LogExp */,15 , 59/* ExtValue */,16 , 62/* AddSubExp */,19 , 67/* Value */,20 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 ), 2752 /* State 10 */ new Array( ), 2753 /* State 11 */ new Array( ), 2754 /* State 12 */ new Array( 52/* Stmt_List */,54 ), 2755 /* State 13 */ new Array( ), 2756 /* State 14 */ new Array( ), 2757 /* State 15 */ new Array( ), 2758 /* State 16 */ new Array( ), 2759 /* State 17 */ new Array( ), 2760 /* State 18 */ new Array( 63/* LogExp */,62 , 62/* AddSubExp */,19 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2761 /* State 19 */ new Array( ), 2762 /* State 20 */ new Array( ), 2763 /* State 21 */ new Array( ), 2764 /* State 22 */ new Array( ), 2765 /* State 23 */ new Array( ), 2766 /* State 24 */ new Array( 54/* Expression */,68 , 63/* LogExp */,15 , 62/* AddSubExp */,19 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2767 /* State 25 */ new Array( ), 2768 /* State 26 */ new Array( ), 2769 /* State 27 */ new Array( 55/* Prop_List */,70 , 56/* Prop */,71 ), 2770 /* State 28 */ new Array( 53/* Param_List */,73 , 54/* Expression */,74 , 63/* LogExp */,15 , 62/* AddSubExp */,19 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2771 /* State 29 */ new Array( ), 2772 /* State 30 */ new Array( ), 2773 /* State 31 */ new Array( ), 2774 /* State 32 */ new Array( ), 2775 /* State 33 */ new Array( 66/* ExpExp */,75 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2776 /* State 34 */ new Array( 66/* ExpExp */,76 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2777 /* State 35 */ new Array( ), 2778 /* State 36 */ new Array( 51/* Stmt */,77 , 61/* Assign */,10 , 54/* Expression */,11 , 60/* Lhs */,14 , 63/* LogExp */,15 , 59/* ExtValue */,16 , 62/* AddSubExp */,19 , 67/* Value */,20 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 ), 2779 /* State 37 */ new Array( ), 2780 /* State 38 */ new Array( ), 2781 /* State 39 */ new Array( 51/* Stmt */,80 , 61/* Assign */,10 , 54/* Expression */,11 , 60/* Lhs */,14 , 63/* LogExp */,15 , 59/* ExtValue */,16 , 62/* AddSubExp */,19 , 67/* Value */,20 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 ), 2782 /* State 40 */ new Array( ), 2783 /* State 41 */ new Array( 61/* Assign */,82 , 60/* Lhs */,14 , 59/* ExtValue */,83 , 67/* Value */,20 ), 2784 /* State 42 */ new Array( ), 2785 /* State 43 */ new Array( ), 2786 /* State 44 */ new Array( ), 2787 /* State 45 */ new Array( ), 2788 /* State 46 */ new Array( 63/* LogExp */,85 , 62/* AddSubExp */,19 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2789 /* State 47 */ new Array( 63/* LogExp */,86 , 62/* AddSubExp */,19 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2790 /* State 48 */ new Array( 63/* LogExp */,87 , 62/* AddSubExp */,19 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2791 /* State 49 */ new Array( 63/* LogExp */,88 , 62/* AddSubExp */,19 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2792 /* State 50 */ new Array( 63/* LogExp */,89 , 62/* AddSubExp */,19 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2793 /* State 51 */ new Array( 63/* LogExp */,90 , 62/* AddSubExp */,19 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2794 /* State 52 */ new Array( 63/* LogExp */,91 , 62/* AddSubExp */,19 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2795 /* State 53 */ new Array( ), 2796 /* State 54 */ new Array( 51/* Stmt */,93 , 61/* Assign */,10 , 54/* Expression */,11 , 60/* Lhs */,14 , 63/* LogExp */,15 , 59/* ExtValue */,16 , 62/* AddSubExp */,19 , 67/* Value */,20 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 ), 2797 /* State 55 */ new Array( 54/* Expression */,94 , 63/* LogExp */,15 , 62/* AddSubExp */,19 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2798 /* State 56 */ new Array( 62/* AddSubExp */,95 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2799 /* State 57 */ new Array( 62/* AddSubExp */,96 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2800 /* State 58 */ new Array( ), 2801 /* State 59 */ new Array( 53/* Param_List */,98 , 54/* Expression */,74 , 63/* LogExp */,15 , 62/* AddSubExp */,19 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2802 /* State 60 */ new Array( 62/* AddSubExp */,99 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2803 /* State 61 */ new Array( 66/* ExpExp */,100 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2804 /* State 62 */ new Array( ), 2805 /* State 63 */ new Array( 64/* MulDivExp */,101 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2806 /* State 64 */ new Array( 64/* MulDivExp */,102 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2807 /* State 65 */ new Array( 65/* NegExp */,103 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2808 /* State 66 */ new Array( 65/* NegExp */,104 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2809 /* State 67 */ new Array( 65/* NegExp */,105 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2810 /* State 68 */ new Array( ), 2811 /* State 69 */ new Array( 57/* Param_Def_List */,107 ), 2812 /* State 70 */ new Array( ), 2813 /* State 71 */ new Array( ), 2814 /* State 72 */ new Array( ), 2815 /* State 73 */ new Array( ), 2816 /* State 74 */ new Array( ), 2817 /* State 75 */ new Array( ), 2818 /* State 76 */ new Array( ), 2819 /* State 77 */ new Array( ), 2820 /* State 78 */ new Array( ), 2821 /* State 79 */ new Array( 62/* AddSubExp */,116 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2822 /* State 80 */ new Array( ), 2823 /* State 81 */ new Array( 54/* Expression */,117 , 63/* LogExp */,15 , 62/* AddSubExp */,19 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2824 /* State 82 */ new Array( ), 2825 /* State 83 */ new Array( ), 2826 /* State 84 */ new Array( ), 2827 /* State 85 */ new Array( ), 2828 /* State 86 */ new Array( ), 2829 /* State 87 */ new Array( ), 2830 /* State 88 */ new Array( ), 2831 /* State 89 */ new Array( ), 2832 /* State 90 */ new Array( ), 2833 /* State 91 */ new Array( ), 2834 /* State 92 */ new Array( ), 2835 /* State 93 */ new Array( ), 2836 /* State 94 */ new Array( ), 2837 /* State 95 */ new Array( ), 2838 /* State 96 */ new Array( ), 2839 /* State 97 */ new Array( ), 2840 /* State 98 */ new Array( ), 2841 /* State 99 */ new Array( ), 2842 /* State 100 */ new Array( ), 2843 /* State 101 */ new Array( ), 2844 /* State 102 */ new Array( ), 2845 /* State 103 */ new Array( ), 2846 /* State 104 */ new Array( ), 2847 /* State 105 */ new Array( ), 2848 /* State 106 */ new Array( ), 2849 /* State 107 */ new Array( ), 2850 /* State 108 */ new Array( ), 2851 /* State 109 */ new Array( ), 2852 /* State 110 */ new Array( 56/* Prop */,123 ), 2853 /* State 111 */ new Array( 54/* Expression */,124 , 63/* LogExp */,15 , 62/* AddSubExp */,19 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2854 /* State 112 */ new Array( ), 2855 /* State 113 */ new Array( 54/* Expression */,125 , 63/* LogExp */,15 , 62/* AddSubExp */,19 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2856 /* State 114 */ new Array( 51/* Stmt */,126 , 61/* Assign */,10 , 54/* Expression */,11 , 60/* Lhs */,14 , 63/* LogExp */,15 , 59/* ExtValue */,16 , 62/* AddSubExp */,19 , 67/* Value */,20 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 ), 2857 /* State 115 */ new Array( ), 2858 /* State 116 */ new Array( ), 2859 /* State 117 */ new Array( ), 2860 /* State 118 */ new Array( 54/* Expression */,129 , 63/* LogExp */,15 , 62/* AddSubExp */,19 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2861 /* State 119 */ new Array( 58/* Attr_List */,130 , 59/* ExtValue */,132 , 67/* Value */,20 ), 2862 /* State 120 */ new Array( ), 2863 /* State 121 */ new Array( ), 2864 /* State 122 */ new Array( ), 2865 /* State 123 */ new Array( ), 2866 /* State 124 */ new Array( ), 2867 /* State 125 */ new Array( ), 2868 /* State 126 */ new Array( ), 2869 /* State 127 */ new Array( ), 2870 /* State 128 */ new Array( ), 2871 /* State 129 */ new Array( ), 2872 /* State 130 */ new Array( ), 2873 /* State 131 */ new Array( 53/* Param_List */,73 , 62/* AddSubExp */,137 , 64/* MulDivExp */,21 , 54/* Expression */,74 , 65/* NegExp */,32 , 63/* LogExp */,15 , 66/* ExpExp */,35 , 59/* ExtValue */,37 , 67/* Value */,20 ), 2874 /* State 132 */ new Array( ), 2875 /* State 133 */ new Array( 52/* Stmt_List */,138 ), 2876 /* State 134 */ new Array( ), 2877 /* State 135 */ new Array( 61/* Assign */,139 , 60/* Lhs */,14 , 59/* ExtValue */,83 , 67/* Value */,20 ), 2878 /* State 136 */ new Array( 59/* ExtValue */,140 , 67/* Value */,20 ), 2879 /* State 137 */ new Array( ), 2880 /* State 138 */ new Array( 51/* Stmt */,93 , 61/* Assign */,10 , 54/* Expression */,11 , 60/* Lhs */,14 , 63/* LogExp */,15 , 59/* ExtValue */,16 , 62/* AddSubExp */,19 , 67/* Value */,20 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 ), 2881 /* State 139 */ new Array( ), 2882 /* State 140 */ new Array( ), 2883 /* State 141 */ new Array( ), 2884 /* State 142 */ new Array( ), 2885 /* State 143 */ new Array( 51/* Stmt */,144 , 61/* Assign */,10 , 54/* Expression */,11 , 60/* Lhs */,14 , 63/* LogExp */,15 , 59/* ExtValue */,16 , 62/* AddSubExp */,19 , 67/* Value */,20 , 64/* MulDivExp */,21 , 65/* NegExp */,32 , 66/* ExpExp */,35 ), 2886 /* State 144 */ new Array( ) 2887 ); 2888 2889 /* Default-Actions-Table */ 2890 var defact_tab = new Array( 2891 /* State 0 */ 2 , 2892 /* State 1 */ 0 , 2893 /* State 2 */ 1 , 2894 /* State 3 */ -1 , 2895 /* State 4 */ -1 , 2896 /* State 5 */ -1 , 2897 /* State 6 */ -1 , 2898 /* State 7 */ -1 , 2899 /* State 8 */ -1 , 2900 /* State 9 */ -1 , 2901 /* State 10 */ -1 , 2902 /* State 11 */ -1 , 2903 /* State 12 */ 4 , 2904 /* State 13 */ 29 , 2905 /* State 14 */ -1 , 2906 /* State 15 */ 40 , 2907 /* State 16 */ 53 , 2908 /* State 17 */ 65 , 2909 /* State 18 */ -1 , 2910 /* State 19 */ 44 , 2911 /* State 20 */ 62 , 2912 /* State 21 */ 47 , 2913 /* State 22 */ 63 , 2914 /* State 23 */ 64 , 2915 /* State 24 */ -1 , 2916 /* State 25 */ 67 , 2917 /* State 26 */ -1 , 2918 /* State 27 */ 10 , 2919 /* State 28 */ 7 , 2920 /* State 29 */ 71 , 2921 /* State 30 */ 72 , 2922 /* State 31 */ 73 , 2923 /* State 32 */ 51 , 2924 /* State 33 */ -1 , 2925 /* State 34 */ -1 , 2926 /* State 35 */ 56 , 2927 /* State 36 */ -1 , 2928 /* State 37 */ 53 , 2929 /* State 38 */ 65 , 2930 /* State 39 */ -1 , 2931 /* State 40 */ -1 , 2932 /* State 41 */ -1 , 2933 /* State 42 */ -1 , 2934 /* State 43 */ 24 , 2935 /* State 44 */ 25 , 2936 /* State 45 */ 26 , 2937 /* State 46 */ -1 , 2938 /* State 47 */ -1 , 2939 /* State 48 */ -1 , 2940 /* State 49 */ -1 , 2941 /* State 50 */ -1 , 2942 /* State 51 */ -1 , 2943 /* State 52 */ -1 , 2944 /* State 53 */ 27 , 2945 /* State 54 */ -1 , 2946 /* State 55 */ -1 , 2947 /* State 56 */ -1 , 2948 /* State 57 */ -1 , 2949 /* State 58 */ -1 , 2950 /* State 59 */ 7 , 2951 /* State 60 */ -1 , 2952 /* State 61 */ -1 , 2953 /* State 62 */ 43 , 2954 /* State 63 */ -1 , 2955 /* State 64 */ -1 , 2956 /* State 65 */ -1 , 2957 /* State 66 */ -1 , 2958 /* State 67 */ -1 , 2959 /* State 68 */ -1 , 2960 /* State 69 */ 14 , 2961 /* State 70 */ -1 , 2962 /* State 71 */ 9 , 2963 /* State 72 */ -1 , 2964 /* State 73 */ -1 , 2965 /* State 74 */ 6 , 2966 /* State 75 */ 54 , 2967 /* State 76 */ 55 , 2968 /* State 77 */ 18 , 2969 /* State 78 */ -1 , 2970 /* State 79 */ -1 , 2971 /* State 80 */ 20 , 2972 /* State 81 */ -1 , 2973 /* State 82 */ -1 , 2974 /* State 83 */ -1 , 2975 /* State 84 */ 23 , 2976 /* State 85 */ 39 , 2977 /* State 86 */ 38 , 2978 /* State 87 */ 37 , 2979 /* State 88 */ 36 , 2980 /* State 89 */ 35 , 2981 /* State 90 */ 34 , 2982 /* State 91 */ 33 , 2983 /* State 92 */ 28 , 2984 /* State 93 */ 3 , 2985 /* State 94 */ 17 , 2986 /* State 95 */ 42 , 2987 /* State 96 */ 41 , 2988 /* State 97 */ 61 , 2989 /* State 98 */ -1 , 2990 /* State 99 */ -1 , 2991 /* State 100 */ 52 , 2992 /* State 101 */ 46 , 2993 /* State 102 */ 45 , 2994 /* State 103 */ 50 , 2995 /* State 104 */ 49 , 2996 /* State 105 */ 48 , 2997 /* State 106 */ 66 , 2998 /* State 107 */ -1 , 2999 /* State 108 */ 13 , 3000 /* State 109 */ 69 , 3001 /* State 110 */ -1 , 3002 /* State 111 */ -1 , 3003 /* State 112 */ 70 , 3004 /* State 113 */ -1 , 3005 /* State 114 */ -1 , 3006 /* State 115 */ 61 , 3007 /* State 116 */ -1 , 3008 /* State 117 */ -1 , 3009 /* State 118 */ -1 , 3010 /* State 119 */ 59 , 3011 /* State 120 */ 57 , 3012 /* State 121 */ -1 , 3013 /* State 122 */ -1 , 3014 /* State 123 */ 8 , 3015 /* State 124 */ 11 , 3016 /* State 125 */ 5 , 3017 /* State 126 */ 19 , 3018 /* State 127 */ 57 , 3019 /* State 128 */ 21 , 3020 /* State 129 */ -1 , 3021 /* State 130 */ 60 , 3022 /* State 131 */ 7 , 3023 /* State 132 */ 16 , 3024 /* State 133 */ 4 , 3025 /* State 134 */ 12 , 3026 /* State 135 */ -1 , 3027 /* State 136 */ -1 , 3028 /* State 137 */ 44 , 3029 /* State 138 */ -1 , 3030 /* State 139 */ -1 , 3031 /* State 140 */ 15 , 3032 /* State 141 */ 58 , 3033 /* State 142 */ 68 , 3034 /* State 143 */ -1 , 3035 /* State 144 */ 22 3036 ); 3037 3038 3039 3040 /* Symbol labels */ 3041 var labels = new Array( 3042 "Program'" /* Non-terminal symbol */, 3043 "ERROR_RESYNC" /* Terminal symbol */, 3044 "WHITESPACE" /* Terminal symbol */, 3045 "IF" /* Terminal symbol */, 3046 "ELSE" /* Terminal symbol */, 3047 "WHILE" /* Terminal symbol */, 3048 "DO" /* Terminal symbol */, 3049 "FOR" /* Terminal symbol */, 3050 "FUNCTION" /* Terminal symbol */, 3051 "USE" /* Terminal symbol */, 3052 "RETURN" /* Terminal symbol */, 3053 "DELETE" /* Terminal symbol */, 3054 "TRUE" /* Terminal symbol */, 3055 "FALSE" /* Terminal symbol */, 3056 "<<" /* Terminal symbol */, 3057 ">>" /* Terminal symbol */, 3058 "[" /* Terminal symbol */, 3059 "]" /* Terminal symbol */, 3060 "{" /* Terminal symbol */, 3061 "}" /* Terminal symbol */, 3062 ";" /* Terminal symbol */, 3063 "=" /* Terminal symbol */, 3064 "==" /* Terminal symbol */, 3065 "!=" /* Terminal symbol */, 3066 "~=" /* Terminal symbol */, 3067 "<=" /* Terminal symbol */, 3068 ">=" /* Terminal symbol */, 3069 ">" /* Terminal symbol */, 3070 "<" /* Terminal symbol */, 3071 "||" /* Terminal symbol */, 3072 "&&" /* Terminal symbol */, 3073 "!" /* Terminal symbol */, 3074 "+" /* Terminal symbol */, 3075 "-" /* Terminal symbol */, 3076 "/" /* Terminal symbol */, 3077 "%" /* Terminal symbol */, 3078 "*" /* Terminal symbol */, 3079 "^" /* Terminal symbol */, 3080 "(" /* Terminal symbol */, 3081 ")" /* Terminal symbol */, 3082 "," /* Terminal symbol */, 3083 "#" /* Terminal symbol */, 3084 ":" /* Terminal symbol */, 3085 "|" /* Terminal symbol */, 3086 "." /* Terminal symbol */, 3087 "NaN" /* Terminal symbol */, 3088 "Identifier" /* Terminal symbol */, 3089 "String" /* Terminal symbol */, 3090 "Integer" /* Terminal symbol */, 3091 "Float" /* Terminal symbol */, 3092 "Program" /* Non-terminal symbol */, 3093 "Stmt" /* Non-terminal symbol */, 3094 "Stmt_List" /* Non-terminal symbol */, 3095 "Param_List" /* Non-terminal symbol */, 3096 "Expression" /* Non-terminal symbol */, 3097 "Prop_List" /* Non-terminal symbol */, 3098 "Prop" /* Non-terminal symbol */, 3099 "Param_Def_List" /* Non-terminal symbol */, 3100 "Attr_List" /* Non-terminal symbol */, 3101 "ExtValue" /* Non-terminal symbol */, 3102 "Lhs" /* Non-terminal symbol */, 3103 "Assign" /* Non-terminal symbol */, 3104 "AddSubExp" /* Non-terminal symbol */, 3105 "LogExp" /* Non-terminal symbol */, 3106 "MulDivExp" /* Non-terminal symbol */, 3107 "NegExp" /* Non-terminal symbol */, 3108 "ExpExp" /* Non-terminal symbol */, 3109 "Value" /* Non-terminal symbol */, 3110 "$" /* Terminal symbol */ 3111 ); 3112 3113 3114 3115 if( !err_off ) { 3116 err_off = []; 3117 } 3118 if( !err_la ) { 3119 err_la = []; 3120 } 3121 3122 sstack.push(0); 3123 vstack.push(0); 3124 3125 PCB.la = this._lex(PCB); 3126 3127 while( true ) { 3128 PCB.act = 146; 3129 for( i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 ) { 3130 if( act_tab[sstack[sstack.length-1]][i] == PCB.la ) { 3131 PCB.act = act_tab[sstack[sstack.length-1]][i+1]; 3132 break; 3133 } 3134 } 3135 3136 if( PCB.act == 146 ) { 3137 if( ( PCB.act = defact_tab[ sstack[sstack.length-1] ] ) < 0 ) 3138 PCB.act = 146; 3139 else 3140 PCB.act *= -1; 3141 } 3142 3143 //Parse error? Try to recover! 3144 if( PCB.act == 146 ) 3145 { 3146 //Report errors only when error_step is 0, and this is not a 3147 //subsequent error from a previous parse 3148 if( PCB.error_step == 0 ) 3149 { 3150 err_cnt++; 3151 err_off.push( {offset: PCB.offset - PCB.att.length, line: PCB.line} ); 3152 err_la.push([]); 3153 for( i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 ) 3154 err_la[err_la.length-1].push( 3155 labels[act_tab[sstack[sstack.length-1]][i]] ); 3156 } 3157 3158 //Perform error recovery 3159 while( sstack.length > 1 && PCB.act == 146 ) 3160 { 3161 sstack.pop(); 3162 vstack.pop(); 3163 3164 //Try to shift on error token 3165 for( i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 ) 3166 { 3167 if( act_tab[sstack[sstack.length-1]][i] == 1 ) 3168 { 3169 PCB.act = act_tab[sstack[sstack.length-1]][i+1]; 3170 3171 sstack.push( PCB.act ); 3172 vstack.push( '' ); 3173 3174 break; 3175 } 3176 } 3177 } 3178 3179 //Is it better to leave the parser now? 3180 if( sstack.length > 1 && PCB.act != 146 ) 3181 { 3182 //Ok, now try to shift on the next tokens 3183 while( PCB.la != 68 ) 3184 { 3185 PCB.act = 146; 3186 3187 for( i = 0; i < act_tab[sstack[sstack.length-1]].length; i+=2 ) 3188 { 3189 if( act_tab[sstack[sstack.length-1]][i] == PCB.la ) 3190 { 3191 PCB.act = act_tab[sstack[sstack.length-1]][i+1]; 3192 break; 3193 } 3194 } 3195 3196 if( PCB.act != 146 ) 3197 break; 3198 3199 while( ( PCB.la = this._lex( PCB ) ) < 0 ) 3200 PCB.offset++; 3201 } 3202 while( PCB.la != 68 && PCB.act == 146 ) {} 3203 } 3204 3205 if( PCB.act == 146 || PCB.la == 68 ) 3206 { 3207 break; 3208 } 3209 3210 //Try to parse the next three tokens successfully... 3211 PCB.error_step = 3; 3212 } 3213 3214 //Shift 3215 if( PCB.act > 0 ) 3216 { 3217 sstack.push( PCB.act ); 3218 vstack.push( PCB.att ); 3219 3220 PCB.la = this._lex( PCB ); 3221 3222 //Successfull shift and right beyond error recovery? 3223 if( PCB.error_step > 0 ) 3224 PCB.error_step--; 3225 } 3226 //Reduce 3227 else 3228 { 3229 act = PCB.act * -1; 3230 3231 rval = void( 0 ); 3232 3233 switch( act ) 3234 { 3235 case 0: 3236 { 3237 rval = vstack[ vstack.length - 1 ]; 3238 } 3239 break; 3240 case 1: 3241 { 3242 this.execute( vstack[ vstack.length - 1 ] ); 3243 } 3244 break; 3245 case 2: 3246 { 3247 rval = vstack[ vstack.length - 0 ]; 3248 } 3249 break; 3250 case 3: 3251 { 3252 rval = this.createNode('node_op', 'op_none', vstack[ vstack.length - 2 ], vstack[ vstack.length - 1 ] ); 3253 } 3254 break; 3255 case 4: 3256 { 3257 rval = vstack[ vstack.length - 0 ]; 3258 } 3259 break; 3260 case 5: 3261 { 3262 rval = this.createNode('node_op', 'op_param', vstack[ vstack.length - 1 ], vstack[ vstack.length - 3 ] ); 3263 } 3264 break; 3265 case 6: 3266 { 3267 rval = this.createNode('node_op', 'op_param', vstack[ vstack.length - 1 ]); 3268 } 3269 break; 3270 case 7: 3271 { 3272 rval = vstack[ vstack.length - 0 ]; 3273 } 3274 break; 3275 case 8: 3276 { 3277 rval = this.createNode('node_op', 'op_proplst', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ] ); 3278 } 3279 break; 3280 case 9: 3281 { 3282 rval = vstack[ vstack.length - 1 ]; 3283 } 3284 break; 3285 case 10: 3286 { 3287 rval = vstack[ vstack.length - 0 ]; 3288 } 3289 break; 3290 case 11: 3291 { 3292 rval = this.createNode('node_op', 'op_prop', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ] ); 3293 } 3294 break; 3295 case 12: 3296 { 3297 rval = this.createNode('node_op', 'op_paramdef', vstack[ vstack.length - 1 ], vstack[ vstack.length - 3 ]); 3298 } 3299 break; 3300 case 13: 3301 { 3302 rval = this.createNode('node_op', 'op_paramdef', vstack[ vstack.length - 1 ]); 3303 } 3304 break; 3305 case 14: 3306 { 3307 rval = vstack[ vstack.length - 0 ]; 3308 } 3309 break; 3310 case 15: 3311 { 3312 rval = this.createNode('node_op', 'op_param', vstack[ vstack.length - 1 ], vstack[ vstack.length - 3 ] ); 3313 } 3314 break; 3315 case 16: 3316 { 3317 rval = this.createNode('node_op', 'op_param', vstack[ vstack.length - 1 ] ); 3318 } 3319 break; 3320 case 17: 3321 { 3322 rval = this.createNode('node_op', 'op_assign', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ] ); 3323 } 3324 break; 3325 case 18: 3326 { 3327 rval = this.createNode('node_op', 'op_if', vstack[ vstack.length - 2 ], vstack[ vstack.length - 1 ] ); 3328 } 3329 break; 3330 case 19: 3331 { 3332 rval = this.createNode('node_op', 'op_if_else', vstack[ vstack.length - 4 ], vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ] ); 3333 } 3334 break; 3335 case 20: 3336 { 3337 rval = this.createNode('node_op', 'op_while', vstack[ vstack.length - 2 ], vstack[ vstack.length - 1 ] ); 3338 } 3339 break; 3340 case 21: 3341 { 3342 rval = this.createNode('node_op', 'op_do', vstack[ vstack.length - 4 ], vstack[ vstack.length - 2 ] ); 3343 } 3344 break; 3345 case 22: 3346 { 3347 rval = this.createNode('node_op', 'op_for', vstack[ vstack.length - 7 ], vstack[ vstack.length - 5 ], vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); 3348 } 3349 break; 3350 case 23: 3351 { 3352 rval = this.createNode('node_op', 'op_use', vstack[ vstack.length - 2 ] ); 3353 } 3354 break; 3355 case 24: 3356 { 3357 rval = this.createNode('node_op', 'op_delete', vstack[ vstack.length - 1 ]); 3358 } 3359 break; 3360 case 25: 3361 { 3362 rval = this.createNode('node_op', 'op_return', vstack[ vstack.length - 1 ] ); 3363 } 3364 break; 3365 case 26: 3366 { 3367 rval = vstack[ vstack.length - 2 ]; 3368 } 3369 break; 3370 case 27: 3371 { 3372 rval = this.createNode('node_op', 'op_noassign', vstack[ vstack.length - 2 ] ); 3373 } 3374 break; 3375 case 28: 3376 { 3377 rval = vstack[ vstack.length - 2 ]; rval.needsBrackets = true; 3378 } 3379 break; 3380 case 29: 3381 { 3382 rval = this.createNode('node_op', 'op_none' ); 3383 } 3384 break; 3385 case 30: 3386 { 3387 rval = this.createNode('node_op', 'op_lhs', vstack[ vstack.length - 1 ], vstack[ vstack.length - 3 ], 'dot'); 3388 } 3389 break; 3390 case 31: 3391 { 3392 rval = this.createNode('node_op', 'op_lhs', vstack[ vstack.length - 2 ], vstack[ vstack.length - 4 ], 'bracket'); 3393 } 3394 break; 3395 case 32: 3396 { 3397 rval = this.createNode('node_op', 'op_lhs', vstack[ vstack.length - 1 ]); 3398 } 3399 break; 3400 case 33: 3401 { 3402 rval = this.createNode('node_op', 'op_equ', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ] ); 3403 } 3404 break; 3405 case 34: 3406 { 3407 rval = this.createNode('node_op', 'op_lot', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ] ); 3408 } 3409 break; 3410 case 35: 3411 { 3412 rval = this.createNode('node_op', 'op_grt', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ] ); 3413 } 3414 break; 3415 case 36: 3416 { 3417 rval = this.createNode('node_op', 'op_loe', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ] ); 3418 } 3419 break; 3420 case 37: 3421 { 3422 rval = this.createNode('node_op', 'op_gre', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ] ); 3423 } 3424 break; 3425 case 38: 3426 { 3427 rval = this.createNode('node_op', 'op_neq', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ] ); 3428 } 3429 break; 3430 case 39: 3431 { 3432 rval = this.createNode('node_op', 'op_approx', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ] ); 3433 } 3434 break; 3435 case 40: 3436 { 3437 rval = vstack[ vstack.length - 1 ]; 3438 } 3439 break; 3440 case 41: 3441 { 3442 rval = this.createNode('node_op', 'op_or', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); 3443 } 3444 break; 3445 case 42: 3446 { 3447 rval = this.createNode('node_op', 'op_and', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); 3448 } 3449 break; 3450 case 43: 3451 { 3452 rval = this.createNode('node_op', 'op_not', vstack[ vstack.length - 1 ]); 3453 } 3454 break; 3455 case 44: 3456 { 3457 rval = vstack[ vstack.length - 1 ]; 3458 } 3459 break; 3460 case 45: 3461 { 3462 rval = this.createNode('node_op', 'op_sub', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ] ); 3463 } 3464 break; 3465 case 46: 3466 { 3467 rval = this.createNode('node_op', 'op_add', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ] ); 3468 } 3469 break; 3470 case 47: 3471 { 3472 rval = vstack[ vstack.length - 1 ]; 3473 } 3474 break; 3475 case 48: 3476 { 3477 rval = this.createNode('node_op', 'op_mul', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ] ); 3478 } 3479 break; 3480 case 49: 3481 { 3482 rval = this.createNode('node_op', 'op_div', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ] ); 3483 } 3484 break; 3485 case 50: 3486 { 3487 rval = this.createNode('node_op', 'op_mod', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ] ); 3488 } 3489 break; 3490 case 51: 3491 { 3492 rval = vstack[ vstack.length - 1 ]; 3493 } 3494 break; 3495 case 52: 3496 { 3497 rval = this.createNode('node_op', 'op_exp', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ] ); 3498 } 3499 break; 3500 case 53: 3501 { 3502 rval = vstack[ vstack.length - 1 ]; 3503 } 3504 break; 3505 case 54: 3506 { 3507 rval = this.createNode('node_op', 'op_neg', vstack[ vstack.length - 1 ] ); 3508 } 3509 break; 3510 case 55: 3511 { 3512 rval = vstack[ vstack.length - 1 ]; 3513 } 3514 break; 3515 case 56: 3516 { 3517 rval = vstack[ vstack.length - 1 ]; 3518 } 3519 break; 3520 case 57: 3521 { 3522 rval = this.createNode('node_op', 'op_extvalue', vstack[ vstack.length - 4 ], vstack[ vstack.length - 2 ]); 3523 } 3524 break; 3525 case 58: 3526 { 3527 rval = this.createNode('node_op', 'op_extvalue', this.createNode('node_op', 'op_execfun', vstack[ vstack.length - 7 ], vstack[ vstack.length - 5 ]), vstack[ vstack.length - 2 ]); 3528 } 3529 break; 3530 case 59: 3531 { 3532 rval = this.createNode('node_op', 'op_execfun', vstack[ vstack.length - 4 ], vstack[ vstack.length - 2 ]); 3533 } 3534 break; 3535 case 60: 3536 { 3537 rval = this.createNode('node_op', 'op_execfun', vstack[ vstack.length - 5 ], vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ], true); 3538 } 3539 break; 3540 case 61: 3541 { 3542 rval = this.createNode('node_op', 'op_property', vstack[ vstack.length - 3 ], vstack[ vstack.length - 1 ]); 3543 } 3544 break; 3545 case 62: 3546 { 3547 rval = vstack[ vstack.length - 1 ]; 3548 } 3549 break; 3550 case 63: 3551 { 3552 rval = this.createNode('node_const', vstack[ vstack.length - 1 ] ); 3553 } 3554 break; 3555 case 64: 3556 { 3557 rval = this.createNode('node_const', vstack[ vstack.length - 1 ] ); 3558 } 3559 break; 3560 case 65: 3561 { 3562 rval = this.createNode('node_var', vstack[ vstack.length - 1 ] ); 3563 } 3564 break; 3565 case 66: 3566 { 3567 rval = vstack[ vstack.length - 2 ]; 3568 } 3569 break; 3570 case 67: 3571 { 3572 rval = this.createNode('node_str', vstack[ vstack.length - 1 ]); 3573 } 3574 break; 3575 case 68: 3576 { 3577 rval = this.createNode('node_op', 'op_function', vstack[ vstack.length - 5 ], vstack[ vstack.length - 2 ]); 3578 } 3579 break; 3580 case 69: 3581 { 3582 rval = this.createNode('node_op', 'op_proplst_val', vstack[ vstack.length - 2 ]); 3583 } 3584 break; 3585 case 70: 3586 { 3587 rval = this.createNode('node_op', 'op_array', vstack[ vstack.length - 2 ]); 3588 } 3589 break; 3590 case 71: 3591 { 3592 rval = this.createNode('node_const_bool', vstack[ vstack.length - 1 ] ); 3593 } 3594 break; 3595 case 72: 3596 { 3597 rval = this.createNode('node_const_bool', vstack[ vstack.length - 1 ] ); 3598 } 3599 break; 3600 case 73: 3601 { 3602 rval = NaN; 3603 } 3604 break; 3605 } 3606 3607 3608 3609 for( i = 0; i < pop_tab[act][1]; i++ ) 3610 { 3611 sstack.pop(); 3612 vstack.pop(); 3613 } 3614 3615 //Get goto-table entry 3616 PCB.act = 146; 3617 for( i = 0; i < goto_tab[sstack[sstack.length-1]].length; i+=2 ) 3618 { 3619 if( goto_tab[sstack[sstack.length-1]][i] == pop_tab[act][0] ) 3620 { 3621 PCB.act = goto_tab[sstack[sstack.length-1]][i+1]; 3622 break; 3623 } 3624 } 3625 3626 //Goal symbol match? 3627 if( act == 0 ) //Don't use PCB.act here! 3628 break; 3629 3630 //...and push it! 3631 sstack.push( PCB.act ); 3632 vstack.push( rval ); 3633 } 3634 } 3635 3636 return err_cnt; 3637 } 3638 3639 }); 3640 3641 3642 3643 3644