// put spaces into prefix of tokens..
- void spaces () {
+ void spaces ()
+ {
var ar = new Gee.ArrayList<Token>()
var pref = new Gee.ArrayList<Token>();
- collapse : function(ar) {
+ Gee.ArrayList<Token> collapse(ar)
+ {
- var st = new TokenStream(ar);
- var ret = [];
+ var st = new TokenStream(ar);
+ var ret = new Gee.ArrayList<Token>();
while (true) {
var tok = st.look(1,true);
- if (!tok || !tok.is) {
+ if (tok == null) {
// Seed.print(TokenStream.toString(ret));
return ret;
}
// console.log(tok.data);
+
switch(tok.type) {
case "VOID":
return ret; //EOF
var start = st.cursor;
st.next(1);
var add = st.balance(tok.data);
- if (!add) {
- console.dump(tok);
- console.dump(start + '...' + st.cursor);
- console.dump(st.tokens);
+ // if (!add) {
+ //console.dump(tok);
+ //console.dump(start + '...' + st.cursor);
+ //console.dump(st.tokens);
- }
- if (add) {
- add.shift();
+ //}
+ if (add.size > 0) {
+ add.remove_at(0); // remove the first element... (as it's the
}
//Seed.print("ADD");
//Seed.print(JSON.stringify(add, null,4));
- var toks = add ? this.collapse(add) : [];
- tok.items = false;
- tok.props = false;
-
+ var toks = add.size > 0 ? this.collapse(add) : add;
+ tok.items = new Gee.ArrayList<Token>(); //?? needed?
+ tok.props = new Gee.HashMap<string,Gee.ArrayList<Token>>();
+
- if (tok.data != '{') {
+ if (tok.data != "{") {
// paramters or array elements..
- tok.items = this.toItems(toks, [',']);
+ tok.items = this.toItems(toks, ","]);
} else {
// check for types.. it could be a list of statements.. or object
+ // format "{" "xXXX" ":" << looks for the ':'.. seems to work.. not sure if it's foolproof...
var ost = new TokenStream(toks);
//console.dump(ost.look(2,true) );
if (ost.look(2,true) && ost.look(2,true).data == ":") {
+ // object properties...
tok.props = this.toProps(toks);
} else {
// list of statemetns..
- tok.items = this.toItems(toks,[ ';', '{'] );;
+ tok.items = this.toItems(toks, ";{");;
}