var parensNesting = 0;
var isObjectLitAr = [ false ];
- while (token = this.ts.lookT()) {
+ while (token = this.ts.look()) {
//println("<i>"+token.data+"</i>");
- switch (token.type) {
+ switch (token.data.toUpperCase()) {
- case 'semicolon':
- case 'comma':
+ case ';':
+ case ',':
if (this.braceNesting == expressionBraceNesting &&
bracketNesting == 0 &&
parensNesting == 0) {
}
break;
- case 'function':
+ case 'FUNCTION':
this.parseFunctionDeclaration();
break;
- case 'lbrace': //Token.LC:
+ case '{': //Token.LC:
isObjectLitAr.push(false);
this.braceNesting++;
break;
- case 'rbrace': //Token.RC:
+ case '}': //Token.RC:
this.braceNesting--;
isObjectLitAr.pop();
// assert braceNesting >= expressionBraceNesting;
break;
- case 'lbracket': //Token.LB:
+ case '[': //Token.LB:
bracketNesting++;
break;
- case 'rbracket': //Token.RB:
+ case ']': //Token.RB:
bracketNesting--;
break;
- case 'lparen': //Token.LP:
+ case '(': //Token.LP:
parensNesting++;
break;
- case 'rparen': //Token.RP:
+ case ')': //Token.RP:
parensNesting--;
break;
-
-
+ }
+ switch(token.type) {
- case 'string': // used for object lit detection..
- if (this.ts.lookT(-1).isType('lbrace') && this.ts.lookT(1).isType('colon')) {
+ case 'STRN': // used for object lit detection..
+ if (this.ts.look(-1).data == "{" && this.ts.look(1).data == ":" ) {
// then we are in an object lit.. -> we need to flag the brace as such...
isObjectLitAr.pop();
isObjectLitAr.push(true);
var isInObjectLitAr = isObjectLitAr[isObjectLitAr.length-1];
- if (isInObjectLitAr && this.ts.lookT(1).isType('colon') &&
- ( this.ts.lookT(-11).isType('lbrace') || this.ts.lookT(-1).isType('comma'))) {
+ if (isInObjectLitAr && this.ts.look(1).data = ":" &&
+ ( this.ts.look(-1).data == "{" || this.ts.look(-1).data == "," )) {
// see if we can replace..
// remove the quotes..
var str = token.data.substring(1,token.data.length-1);
}
break;
*/
- case 'identifier':
+ case 'NAME':
+ case 'KEYW':
symbol = token.data;
- if (this.ts.lookT(-1).isType('lbrace') && this.ts.lookT(1).isType('colon')) {
+ if (this.ts.look(-1).data == "{" && this.ts.look(1).data == ":") {
// then we are in an object lit.. -> we need to flag the brace as such...
isObjectLitAr.pop();
isObjectLitAr.push(true);
break;
}
var isInObjectLitAr = isObjectLitAr[isObjectLitAr.length-1];
- if (isInObjectLitAr && this.ts.lookT(-1).isType('comma') && this.ts.lookT(1).isType('colon')) {
+ if (isInObjectLitAr && this.ts.look(-1).data == "," && this.ts.look(1).data == ":") {
break;
}
- if (this.ts.lookT(-1).isType('dot')) {
+ if (this.ts.look(-1).data == ".") {
//skip '.'
break;
}
// Parse function arguments.
var argpos = 0;
- while (!this.ts.lookT().isType('rparen')) { //(token = consumeToken()).getType() != Token.RP) {
+ while (!this.ts.look().isType('rparen')) { //(token = consumeToken()).getType() != Token.RP) {
token = this.ts.nextT();
//assert token.getType() == Token.NAME ||
this.braceNesting++;
token = this.ts.nextT();
- if (token.isType('string') && this.ts.lookT(1).isType('semicolon')) {
+ if (token.isType('string') && this.ts.look(1).isType('semicolon')) {
/*
NOT SUPPORTED YET!?!!?!