4 * @prop data {String} raw value of token
5 * @prop type {String} type of token
6 * TOKN (unknown) - name is UNKNOWN_TOKEN
8 * KEYW (keyword) - name is upper case version of keyword
9 * NAME (name/identifier) - name is NAME
10 * COMM (comment) - name is MULTI_LINE_COMM, JSDOC, SINGLE_LINE_COMM
11 * PUNC (puctuation) - name is String description of punctionan (eg LEFTPARAM)
12 * WHIT (white space) - name is SPACE,NEWLINE
13 * STRN (string) - name is DOBULE_QUOTE, SINGLE_QUOTE
14 * NUMB (number) - name is OCTAL,DECIMAL,HEC_DEC
15 * REGX (reg.expression) - name is REGX
16 * @prop name {String} see type details above
17 * @prop identifier {Identifier} identifier class if relivant
23 * Script.TOKidentifier - type == 'NAME'
24 * Script.TOKassign = data == '='
25 * Script.TOKsemicolon data == '';
34 public class Token : Object {
44 public string outData;
46 public string identifier;
48 // used to stuff tokens together when building a tree..
49 public Gee.ArrayList<Gee.ArrayList<Token>> items;
51 // props??? what's this???
53 public Token(string data, string type, string name, int line = -1)
60 this.outData = null; // used by packer/scopeparser
61 this.identifier = null; // used by scope
65 this.items = new Gee.ArrayList<Gee.ArrayList<Token>>();
68 public string asString()
70 return "line:%d, type %s, name %s, data : %s , outData: %s".printf(
75 this.outData == null ? "" : this.outData
81 public string toRaw(int lvl = 0)
87 foreach(var ai in this.items ) {
90 foreach( var it in ai) {
91 str += it.toRaw(lvl+1);
96 /* -- what is a prop..
98 for (var i in this.props) {
99 ret += this.props[i].key.toRaw(lvl+1) + ' : ';
100 this.props[i].val.forEach( function(e) {
109 return this.prefix + ret;
117 eval( "_tmp = " + this.data);
120 return "ERROR unparsable" + this.data;
126 public bool is(string what) {
127 return this.name == what || this.type == what;