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 == '';
35 public class TokenKeyMap : Object {
37 public Gee.ArrayList<Token> vals;
41 this.key = new Token("","VOID", "VOID");
42 this.vals = new Gee.ArrayList<Token>();
48 public class Token : Object {
56 public string prefix; // white space prefix... (when outputing with WS)
58 public string outData;
60 public Identifier identifier;
62 // used to stuff tokens together when building a tree..
63 public Gee.ArrayList<Gee.ArrayList<Token>> items;
64 // for a object definition, key -> array of tokens..
65 public Gee.HashMap<string,TokenKeyMap> props;
67 // props??? what's this???
69 public Token(string data, string type, string name, int line = -1)
76 this.outData = ""; // used by packer/scopeparser
77 this.identifier = null; // used by scope
81 this.items = new Gee.ArrayList<Gee.ArrayList<Token>>();
82 this.props = new Gee.HashMap<string,TokenKeyMap>();
85 public string asString()
87 return "line:%d, type %s, name %s, data : %s , outData: %s".printf(
92 this.outData == null ? "" : this.outData
98 public void dump(string indent)
100 print("%s%s\n",indent, this.asString());
101 if (this.items.size > 0) {
103 for (var i = 0;i < this.items.size; i++) {
104 print("%s --ITEMS[%d] [ \n",indent,i);
105 for (var j = 0;j < this.items[i].size; j++) {
106 this.items[i][j].dump(indent + " ");
110 if (this.props.size > 0) {
111 var m = this.props.map_iterator();
113 print("%s --KEY %s :: \n",indent,m.get_key());
114 var vals = m.get_value().vals;
115 for (var i = 0;i < vals.size; i++) {
117 vals[i].dump(indent + " ");
127 public string toRaw(int lvl = 0)
131 var ret = this.data ;
133 foreach(var ai in this.items ) {
134 // supposed to iterate properties???
136 //foreach( var it in ai) {
137 // str += it.toRaw(lvl+1);
142 /* -- what is a prop..
144 for (var i in this.props) {
145 ret += this.props[i].key.toRaw(lvl+1) + ' : ';
146 this.props[i].val.forEach( function(e) {
155 return this.prefix + ret;
163 eval( "_tmp = " + this.data);
166 return "ERROR unparsable" + this.data;
172 public bool is(string what) {
173 return this.name == what || this.type == what;