1 //<Script type="text/javascript">
3 XObject = imports.XObject.XObject;
5 console = imports.console.console;
9 * Token of a JS file eg. a keyword, identifier, punctionaion etc..
13 * TOKN (unknown) - name is UNKNOWN_TOKEN
15 * KEYW (keyword) - name is upper case version of keyword
16 * NAME (name/identifier) - name is NAME
17 * COMM (comment) - name is MULTI_LINE_COMM, JSDOC, SINGLE_LINE_COMM
18 * PUNC (puctuation) - name is String description of punctionan (eg LEFTPARAM)
19 * WHIT (white space) - name is SPACE,NEWLINE
20 * STRN (string) - name is DOBULE_QUOTE, SINGLE_QUOTE
21 * NUMB (number) - name is OCTAL,DECIMAL,HEC_DEC
22 * REGX (reg.expression) - name is REGX
27 * Script.TOKidentifier - type == 'NAME'
28 * Script.TOKassign = data == '='
29 * Script.TOKsemicolon data == '';
35 * @param {String} data raw value of token
36 * @param {String} type type of token
37 * @param {String} name see type details above
38 * @param {JSDOC.Identifier} identifier identifier class if relivant
41 Token = XObject.define(
42 function(data, type, name, line) {
48 this.outData = false; // used by packer/scopeparser
49 this.identifier = false; // used by scope
56 /** @type {String} The raw text of the token */
58 /** @type {String} The type of the token */
60 /** @type {String} name of the token (eg. "MULTI_LINE_COMM" ) - see table above */
62 /** @type {Number} line the token occurs on. */
64 /** @type {String} white or comment prefix for rebuilding source*/
66 /** @type {String} used by packer/ scopeparser to store what is actually output for this */
67 outData : false,// used by packer/scopeparser
68 /** @type {String} the identifier refered to (mangled by packer) */
69 identifier : false, // used by scope
70 /** @type {Number} numberic identifier for token */
72 /** @type {String} the comments that come before the token? (TBC) */
74 /** @type {JSDOC.DocTag} assigned in JSDOC.Compiler that relates to this token. */
79 return 'line:' + this.line + ', type:' + this.type +
80 ', name:' + this.name + ', data:' + this.data +
81 ((this.outData === false) ? '' : ( 'outData : ' + this.outData));
94 this.items.forEach( function(ai) {
97 ai.forEach( function(it) {
98 str += it.toRaw(lvl + 1);
107 for (var i in this.props) {
108 ret += this.props[i].key.toRaw(lvl+1) + ' : ';
109 this.props[i].val.forEach( function(e) {
118 return this.prefix + ret;
126 eval( "_tmp = " + this.data);
129 return "ERROR unparsable" + this.data;
135 is : function(what) {
136 return this.name === what || this.type === what;