1 //<Script type="text/javascript">
3 XObject = imports.XObject.XObject;
5 console = imports.console.console;
10 * @prop data {String} raw value of token
11 * @prop type {String} type of token
12 * TOKN (unknown) - name is UNKNOWN_TOKEN
14 * KEYW (keyword) - name is upper case version of keyword
15 * NAME (name/identifier) - name is NAME
16 * COMM (comment) - name is MULTI_LINE_COMM, JSDOC, SINGLE_LINE_COMM
17 * PUNC (puctuation) - name is String description of punctionan (eg LEFTPARAM)
18 * WHIT (white space) - name is SPACE,NEWLINE
19 * STRN (string) - name is DOBULE_QUOTE, SINGLE_QUOTE
20 * NUMB (number) - name is OCTAL,DECIMAL,HEC_DEC
21 * REGX (reg.expression) - name is REGX
22 * @prop name {String} see type details above
23 * @prop identifier {Identifier} identifier class if relivant
29 * Script.TOKidentifier - type == 'NAME'
30 * Script.TOKassign = data == '='
31 * Script.TOKsemicolon data == '';
37 Token = XObject.define(
38 function(data, type, name, line) {
44 this.outData = false; // used by packer/scopeparser
45 this.identifier = false; // used by scope
54 return 'line:' + this.line + ', type:' + this.type +
55 ', name:' + this.name + ', data:' + this.data +
56 ((this.outData === false) ? '' : ( 'outData : ' + this.outData));
69 this.items.forEach( function(ai) {
72 ai.forEach( function(it) {
73 str += it.toRaw(lvl + 1);
82 for (var i in this.props) {
83 ret += this.props[i].key.toRaw(lvl+1) + ' : ';
84 this.props[i].val.forEach( function(e) {
93 return this.prefix + ret;
101 eval( "_tmp = " + this.data);
104 return "ERROR unparsable" + this.data;
110 is : function(what) {
111 return this.name === what || this.type === what;