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