/* Some portions: Copyright (c) 2008, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 2.5.1 */ // create org.antlr module if (typeof org == "undefined" || !org) { var org = {}; } if (typeof org.antlr == "undefined" || !org.antlr) { /** * The org.antlr global namespace object. If antlr is already defined, the * existing antlr object will not be overwritten so that defined * namespaces are preserved. * @namespace org.antlr */ org.antlr = {}; } /** * The global JavaScript object. */ org.antlr.global = (function() { return this; }).call(null); /** * Returns the namespace specified and creates it if it doesn't exist. * * Be careful when naming packages. Reserved words may work in some browsers * and not others. For instance, the following will fail in Safari: *
* org.antlr.namespace("really.long.nested.namespace"); ** This fails because "long" is a future reserved word in ECMAScript * * @static * @param {Array.
* Safari 1.3.2 (312.6): 312.8.1 <-- Reports 312.8 -- currently the * latest available for Mac OSX 10.3. * Safari 2.0.2: 416 <-- hasOwnProperty introduced * Safari 2.0.4: 418 <-- preventDefault fixed * Safari 2.0.4 (419.3): 418.9.1 <-- One version of Safari may run * different versions of webkit * Safari 2.0.4 (419.3): 419 <-- Tiger installations that have been * updated, but not updated * to the latest patch. * Webkit 212 nightly: 522+ <-- Safari 3.0 precursor (with native SVG * and many major issues fixed). * 3.x yahoo.com, flickr:422 <-- Safari 3.x hacks the user agent * string when hitting yahoo.com and * flickr.com. * Safari 3.0.4 (523.12):523.12 <-- First Tiger release - automatic update * from 2.x via the 10.4.11 OS patch * Webkit nightly 1/2008:525+ <-- Supports DOMContentLoaded event. * yahoo.com user agent hack removed. * ** http://developer.apple.com/internet/safari/uamatrix.html * @property webkit * @type float */ webkit: 0, /** * The mobile property will be set to a string containing any relevant * user agent information when a modern mobile browser is detected. * Currently limited to Safari on the iPhone/iPod Touch, Nokia N-series * devices with the WebKit-based browser, and Opera Mini. * @property mobile * @type string */ mobile: null, /** * Adobe AIR version number or 0. Only populated if webkit is detected. * Example: 1.0 * @property air * @type float */ air: 0, /** * Is this the Rhino interpreter? * @property rhino * @type Boolean */ rhino: false }; var ua, m; try { ua = navigator.userAgent; // Modern KHTML browsers should qualify as Safari X-Grade if ((/KHTML/).test(ua)) { o.webkit=1; } // Modern WebKit browsers are at least X-Grade m=ua.match(/AppleWebKit\/([^\s]*)/); if (m&&m[1]) { o.webkit=parseFloat(m[1]); // Mobile browser check if (/ Mobile\//.test(ua)) { o.mobile = "Apple"; // iPhone or iPod Touch } else { m=ua.match(/NokiaN[^\/]*/); if (m) { o.mobile = m[0]; // Nokia N-series, ex: NokiaN95 } } m=ua.match(/AdobeAIR\/([^\s]*)/); if (m) { o.air = m[0]; // Adobe AIR 1.0 or better } } if (!o.webkit) { // not webkit // @todo check Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr) m=ua.match(/Opera[\s\/]([^\s]*)/); if (m&&m[1]) { o.opera=parseFloat(m[1]); m=ua.match(/Opera Mini[^;]*/); if (m) { o.mobile = m[0]; // ex: Opera Mini/2.0.4509/1316 } } else { // not opera or webkit m=ua.match(/MSIE\s([^;]*)/); if (m&&m[1]) { o.ie=parseFloat(m[1]); } else { // not opera, webkit, or ie m=ua.match(/Gecko\/([^\s]*)/); if (m) { o.gecko=1; // Gecko detected, look for revision m=ua.match(/rv:([^\s\)]*)/); if (m&&m[1]) { o.gecko=parseFloat(m[1]); } } } } } } catch(e) { // ignore this if we're not in a browser } try { if (typeof window=="undefined" && typeof loadClass!="undefined") { o.rhino = true; } } catch(e) {} return o; }(); /** * JavaScript runtime library code. * @name org.antlr.runtime * @namespace */ /** * JavaScript runtime library tree parser code. * @name org.antlr.runtime.tree * @namespace */ org.antlr.namespace("org.antlr.runtime.tree"); /** * Provides the language utilites and extensions used by the library * @namespace org.antlr.lang */ org.antlr.lang = org.antlr.lang || /** @lends org.antlr.lang */ { /** * Determines whether or not the provided object is an array. * Testing typeof/instanceof/constructor of arrays across frame * boundaries isn't possible in Safari unless you have a reference * to the other frame to test against its Array prototype. To * handle this case, we test well-known array properties instead. * properties. * @param {any} o The object being testing * @return {boolean} the result */ isArray: function(o) { if (o) { var l = org.antlr.lang; return l.isNumber(o.length) && l.isFunction(o.splice); } return false; }, /** * Determines whether or not the provided object is a boolean * @param {any} o The object being testing * @return {boolean} the result */ isBoolean: function(o) { return typeof o === 'boolean'; }, /** * Determines whether or not the provided object is a function * @param {any} o The object being testing * @return {boolean} the result */ isFunction: function(o) { return typeof o === 'function'; }, /** * Determines whether or not the provided object is null * @param {any} o The object being testing * @return {boolean} the result */ isNull: function(o) { return o === null; }, /** * Determines whether or not the provided object is a legal number * @param {any} o The object being testing * @return {boolean} the result */ isNumber: function(o) { return typeof o === 'number' && isFinite(o); }, /** * Determines whether or not the provided object is of type object * or function * @param {any} o The object being testing * @return {boolean} the result */ isObject: function(o) { return (o && (typeof o === 'object' || org.antlr.lang.isFunction(o))) || false; }, /** * Determines whether or not the provided object is a string * @param {any} o The object being testing * @return {boolean} the result */ isString: function(o) { return typeof o === 'string'; }, /** * Determines whether or not the provided object is undefined * @param {any} o The object being testing * @return {boolean} the result */ isUndefined: function(o) { return typeof o === 'undefined'; }, /** * IE will not enumerate native functions in a derived object even if the * function was overridden. This is a workaround for specific functions * we care about on the Object prototype. * @param {Function} r the object to receive the augmentation * @param {Function} s the object that supplies the properties to augment * @private */ _IEEnumFix: function(r, s) { if (org.antlr.env.ua.ie) { var add=["toString", "valueOf"], i; for (i=0;i