namespace JSDOC {
-public class Collapse : TokenStream {
+ public class Collapse : TokenStream {
- public Collapse(Gee.ArrayList<Token> tokens)
- {
- parent(ar);;
-
- this.spaces();
- ar = this.collapse(this.tokens);
-
- this.tokens = ar;
-
- // console.dump(ar);
-
- },
- TokenStream,
- {
+ public Collapse(Gee.ArrayList<Token> tokens)
+ {
+ parent(ar);;
+
+ this.spaces();
+
+ ar = this.collapse(this.tokens);
+
+ this.tokens = ar;
+
+ // console.dump(ar);
+
+ }
+
+ // put spaces into prefix of tokens..
- spaces : function () {
- var ar = [];
- var pref = [];
+ void spaces ()
+ {
+ var ar = new Gee.ArrayList<Token>()
+ var pref = new Gee.ArrayList<Token>();
- var tok;
+
- for (var i = 0; i < this.tokens.length; i ++) {
- tok = this.tokens[i];
+ for (var i = 0; i < this.tokens.size; i ++) {
+ var tok = this.tokens[i];
if (tok.is("COMM") || tok.is("WHIT")) {
- pref.push(tok);
+ pref.add(tok);
continue;
}
tok.prefix = '';
- if (pref.length) {
- pref.forEach( function(e) {
- if (!e) {
- return;
- }
+ if (pref.size > 0) {
+ foreach(e in pref) {
tok.prefix += e.data;
- })
+ }
+ pref = new Gee.ArrayList<Token>(); // reset pref..
}
- ar.push(tok);
- pref= [];
+ ar.add(tok);
+
+
}
this.tokens = ar;
},
- 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, ";{");;
}