this.braceNesting = 0;
this.scopes = [];
-
+ print(JSON.stringify(this.ts.tokens, null,4));
this.globalScope = new Scope(-1, false, -1, '');
while (true) {
token = this.ts.nextTok();
//!this.debug|| print( token.toString());
- //print('SCOPE-VAR-VAL:' + token.toString());
+ print('SCOPE-VAR-VAL:' + JSON.stringify(token, null, 4));
if (!token) { // can return false at EOF!
break;
}
} else {
//var bn = this.braceNesting;
var bn = this.braceNesting;
- this.parseExpression();
+ var nts = [];
+ while (true) {
+ var n = this.ts.lookTok();
+ print(n.toString());
+ if (!n || n.data == ',') {
+ break;
+ }
+ nts.push(n);
+ this.ts.nextTok();
+ }
+ if (nts.length) {
+ var TS = this.ts;
+ this.ts = new TokenStream(nts);
+ this.parseExpression();
+ this.ts = TS;
+ }
+
this.braceNesting = bn;
//this.braceNesting = bn;
//this.logR("parseScope DONE : <B>ParseExpression</B> - tok is:" + this.ts.lookT(0).toString());
}
token = this.ts.nextTok();
}
-
+ // return function() {....
+ if (token.name == "RETURN") {
+ token = this.ts.nextTok();
+ }
+ if (token.name == "FUNCTION") {
+ token = this.ts.nextTok();
+ }
//assert token.getType() == Token.LP;
if (this.mode == 'BUILDING_SYMBOL_TREE') {
fnScope = new Scope(1, currentScope, token.n, '', token);
fnScope = this.indexedScopes[token.id];
}
//if (this.mode == 'BUILDING_SYMBOL_TREE')
- print('FUNC-PARSE:' + JSON.stringify(token,null,4));
+ // print('FUNC-PARSE:' + JSON.stringify(token,null,4));
// Parse function arguments.
var args = token.items;
for (var argpos =0; argpos < args.length; argpos++) {