X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=JSDOC%2FWalker2.js;h=fdcc3c04f46537bb6d41f2d2e26a9fbbb1257ff0;hb=6faf99e1c6ed2443b2f5dba0433ab7cab3342eb8;hp=7be5639ad47ce8cef60245f05e4641801f3bbec2;hpb=2eecfa6b259c0d43a1cc53337641e3530867e594;p=gnome.introspection-doc-generator diff --git a/JSDOC/Walker2.js b/JSDOC/Walker2.js index 7be5639..fdcc3c0 100644 --- a/JSDOC/Walker2.js +++ b/JSDOC/Walker2.js @@ -148,20 +148,20 @@ Walker2 = XObject.define( var scopeLen = this.scopes.length; if (this.ts.cursor < 1) { - this.ts.cursor--; // hopeflly this kludge will work - } - + // this.ts.cursor--; // hopeflly this kludge will work + } + //print(JSON.stringify(this.ts, null, 4)); Seed.quit(); - while (false != (token = this.ts.next())) { - //print("TOK"+ token.toString()); + while (null != (token = this.ts.next())) { + print("TOK"+ token.toString()); // this.timerPrint("parseScope AFTER lookT: " + token.toString()); - if (token.tokN == Script.TOKwhitespace) { + if (token.is('WHIT')) { - if (!token._isDoc) { + if (token.name != 'JSDOC') { continue; //skip. } if (this.currentDoc) { @@ -169,7 +169,6 @@ Walker2 = XObject.define( this.addSymbol('', true); - //throw "Unconsumed Doc (TOKwhitespace): " + this.currentDoc.toSource(); } @@ -208,8 +207,8 @@ Walker2 = XObject.define( // things that stop comments carrying on...?? if (this.currentDoc && ( - token.tokN == Script.TOKsemicolon || - token.tokN == Script.TOKrbrace)) { + token.tokN.data == ';' || + token.tokN.data == '}')) { this.addSymbol('', true); //throw "Unconsumed Doc ("+ token.toString() +"): " + this.currentDoc.toSource(); } @@ -219,18 +218,18 @@ Walker2 = XObject.define( // var a = b; - if (token.tokN == Script.TOKvar && + if (token.name == 'VAR' && - this.ts.lookT(1).tokN == Script.TOKidentifier && - this.ts.lookT(2).tokN == Script.TOKassign && - this.ts.lookT(3).tokN == Script.TOKidentifier && - this.ts.lookT(4).tokN == Script.TOKsemicolon + this.ts.lookTok(1).type == 'NAME' && + this.ts.lookTok(2).data == '-' && + this.ts.lookTok(3).type == 'NAME' && + this.ts.lookTok(4).data == ';' ) { - //print("SET ALIAS:" + this.ts.lookT(1).data +'=' + this.ts.lookT(3).data); + //print("SET ALIAS:" + this.ts.lookTok(1).data +'=' + this.ts.lookTok(3).data); - aliases[this.ts.lookT(1).data] = this.ts.lookT(3).data; + aliases[this.ts.lookTok(1).data] = this.ts.lookTok(3).data; } @@ -244,7 +243,7 @@ Walker2 = XObject.define( // a << scope // xxx.applyIf(a, { // a << scope - if (token.tokN == Script.TOKidentifier) { + if (token.type = 'NAME') { //print("TOK(ident)"+ token.toString()); @@ -253,28 +252,29 @@ Walker2 = XObject.define( if (/\.extend$/.test(token.data) && - this.ts.lookT(1).tokN == Script.TOKlparen && - this.ts.lookT(2).tokN == Script.TOKidentifier && - this.ts.lookT(3).tokN == Script.TOKcomma && - this.ts.lookT(4).tokN == Script.TOKidentifier && - this.ts.lookT(5).tokN == Script.TOKcomma && - this.ts.lookT(6).tokN == Script.TOKlbrace + this.ts.lookTok(1).data == '(' && + this.ts.lookTok(2).type == 'NAME' && + this.ts.lookTok(3).data == ',' && + this.ts.lookTok(4).type == 'NAME' && + this.ts.lookTok(5).data == ',' && + this.ts.lookTok(6).data == '{' + ) { // ignore test for ( a and , - this.ts.nextT(); /// ( - token = this.ts.nextT(); // a + this.ts.nextTok(); /// ( + token = this.ts.nextTok(); // a scopeName = token.data; if (this.currentDoc) { this.addSymbol(scopeName,false,'OBJECT'); } - this.ts.nextT(); // , - this.ts.nextT(); // b + this.ts.nextTok(); // , + this.ts.nextTok(); // b - this.ts.nextT(); // , - token = this.ts.nextT(); // { + this.ts.nextTok(); // , + token = this.ts.nextTok(); // { scopeName = fixAlias(scopeName); @@ -293,25 +293,25 @@ Walker2 = XObject.define( // a = Roo.extend(parentname, { if (/\.extend$/.test(token.data) && - this.ts.lookT(-2).tokN == Script.TOKidentifier && - this.ts.lookT(-1).tokN == Script.TOKassign && - this.ts.lookT(1).tokN == Script.TOKlparen && - this.ts.lookT(2).tokN == Script.TOKidentifier && - this.ts.lookT(3).tokN == Script.TOKcomma && - this.ts.lookT(4).tokN == Script.TOKlbrace + this.ts.lookTok(-2).type == 'NAME' && + this.ts.lookTok(-1).data == '=' && + this.ts.lookTok(1).data == '(' && + this.ts.lookTok(2).type == 'NAME' && + this.ts.lookTok(3).data == ',' && + this.ts.lookTok(4).data == '{' ) { // ignore test for ( a and , - token = this.ts.lookT(-2); + token = this.ts.lookTok(-2); scopeName = token.data; if (this.currentDoc) { this.addSymbol(scopeName,false,'OBJECT'); } - this.ts.nextT(); /// ( - this.ts.nextT(); // parent + this.ts.nextTok(); /// ( + this.ts.nextTok(); // parent - this.ts.nextT(); // , - token = this.ts.nextT(); // { + this.ts.nextTok(); // , + token = this.ts.nextTok(); // { scopeName = fixAlias(scopeName); @@ -328,19 +328,20 @@ Walker2 = XObject.define( } - + // apply ( XXXX, { + if (/\.(applyIf|apply)$/.test(token.data) && - this.ts.lookT(1).tokN == Script.TOKlparen && - this.ts.lookT(2).tokN == Script.TOKidentifier && - this.ts.lookT(3).tokN == Script.TOKcomma && - this.ts.lookT(4).tokN == Script.TOKlbrace + this.ts.lookTok(1).data == '(' && + this.ts.lookTok(2).type == 'NAME' && + this.ts.lookTok(3).data == ',' && + this.ts.lookTok(4).data == '{' ) { - this.ts.nextT(); /// ( + this.ts.nextTok(); /// ( //print("GOT : applyIF!"); - token = this.ts.nextT(); // b + token = this.ts.nextTok(); // b scopeName = token.data; @@ -351,8 +352,8 @@ Walker2 = XObject.define( - this.ts.nextT(); /// , - this.ts.nextT(); // { + this.ts.nextTok(); /// , + this.ts.nextTok(); // { scopeName = fixAlias(scopeName); var fnScope = new Scope(this.braceNesting, scope, token.n, scopeName); this.indexedScopes[this.ts.cursor] = fnScope; @@ -369,11 +370,19 @@ Walker2 = XObject.define( // change scope to xxxx - if ( this.ts.lookT(1).tokN == Script.TOKassign && - this.ts.lookT(2).tokN == Script.TOKnew && - this.ts.lookT(3).tokN == Script.TOKidentifier && - this.ts.lookT(4).tokN == Script.TOKlparen && - this.ts.lookT(5).tokN == Script.TOKlbrace + print(JSON.stringify([ + this.ts.lookTok(1).data + this.ts.lookTok(2).name + this.ts.lookTok(3).type + this.ts.lookTok(4).data + this.ts.lookTok(5).data + ], null, 4)); + + if ( this.ts.lookTok(1).data == '=' && + this.ts.lookTok(2).name == 'NEW' && + this.ts.lookTok(3).type == 'NAME' && + this.ts.lookTok(4).data == '(' && + this.ts.lookTok(5).data == '{' ) { scopeName = token.data; if (this.currentDoc) { @@ -381,11 +390,11 @@ Walker2 = XObject.define( } - this.ts.nextT(); /// = - this.ts.nextT(); /// new - this.ts.nextT(); /// yyy - this.ts.nextT(); /// ( - this.ts.nextT(); /// { + this.ts.nextTok(); /// = + this.ts.nextTok(); /// new + this.ts.nextTok(); /// yyy + this.ts.nextTok(); /// ( + this.ts.nextTok(); /// { scopeName = fixAlias(scopeName); var fnScope = new Scope(this.braceNesting, scope, token.n, scopeName); @@ -430,16 +439,16 @@ Walker2 = XObject.define( // ident = function () var atype = 'OBJECT'; - if (((this.ts.lookT(1).tokN == Script.TOKcolon )|| (this.ts.lookT(1).tokN == Script.TOKassign)) && - (this.ts.lookT(2).tokN == Script.TOKfunction) + if (((this.ts.lookTok(1).data == ':' )|| (this.ts.lookTok(1).data == '=')) && + (this.ts.lookTok(2).name == "FUNCTION") ) { atype = 'FUNCTION'; } - //print("ADD SYM:" + atype + ":" + token.toString() + this.ts.lookT(1).toString() + this.ts.lookT(2).toString()); + //print("ADD SYM:" + atype + ":" + token.toString() + this.ts.lookTok(1).toString() + this.ts.lookTok(2).toString()); this.addSymbol( - this.ts.lookT(-1).tokN == Script.TOKdot ? token.data : fixAlias(token.data), + this.ts.lookTok(-1).tokN == Script.TOKdot ? token.data : fixAlias(token.data), false, atype); @@ -449,7 +458,7 @@ Walker2 = XObject.define( continue; // dont care about other idents.. } - if (token.tokN == Script.TOKstring) { + if (token.type == "STRN") { if (this.currentDoc) { this.addSymbol(token.data.substring(1,token.data.length-1),false,'OBJECT'); @@ -459,7 +468,7 @@ Walker2 = XObject.define( // really we only have to deal with object constructs and function calls that change the scope... - if (token.tokN == Script.TOKfunction) { + if (token.name == 'FUNCTION') { // see if we have an unconsumed doc... @@ -479,12 +488,12 @@ Walker2 = XObject.define( //$this$=foo.prototype|$private$|foo.prototype if ( - (this.ts.lookT(-1).tokN == Script.TOKassign) && - (this.ts.lookT(-2).tokN == Script.TOKidentifier) + (this.ts.lookTok(-1).data == '=') && + (this.ts.lookTok(-2).type == 'NAME') ) { - scopeName = this.ts.lookT(-2).data; - this.ts.balanceN(Script.TOKlparen); - token = this.ts.nextT(); // should be { + scopeName = this.ts.lookTok(-2).data; + this.ts.balanceN('('); + token = this.ts.nextTok(); // should be { //print("FOO=FUNCITON() {}" + this.ts.context() + "\n" + token.toString()); @@ -511,13 +520,13 @@ Walker2 = XObject.define( //$private$ if ( - (this.ts.lookT(-1).tokN == Script.TOKnew) && - (this.ts.lookT(-2).tokN == Script.TOKassign) - (this.ts.lookT(-3).tokN == Script.TOKidentifier) + (this.ts.lookTok(-1).name == 'NEW') && + (this.ts.lookTok(-2).data == '=') && + (this.ts.lookTok(-3).type = 'FUNCTION') ) { //scopeName = this.ts.look(-3).data; this.ts.balanceN(Script.TOKlparen); - token = this.ts.nextT(); // should be { + token = this.ts.nextTok(); // should be { scopeName = fixAlias(scopeName); var fnScope = new Scope(this.braceNesting, scope, token.n, '$private$'); this.indexedScopes[this.ts.cursor] = fnScope; @@ -540,18 +549,18 @@ Walker2 = XObject.define( // no change to scoping.. //print("checking for : function() {"); - //print( [this.ts.lookT(-3).type , this.ts.lookT(-2).type , this.ts.lookT(-1).type ].join(":")); + //print( [this.ts.lookTok(-3).type , this.ts.lookTok(-2).type , this.ts.lookTok(-1).type ].join(":")); if ( - (this.ts.lookT(-1).tokN == Script.TOKcolon) && - (this.ts.lookT(-2).tokN == Script.TOKidentifier) && - (this.ts.lookT(-3).tokN == Script.TOKlbrace || this.ts.lookT(-3).tokN == Script.TOKcomma) + (this.ts.lookTok(-1).data == ':') && + (this.ts.lookTok(-2).type == 'NAME') && + (this.ts.lookTok(-3).data == '(' || this.ts.lookTok(-3).data== ',') ) { //print("got for : function() {"); //scopeName = this.ts.look(-3).data; this.ts.balanceN(Script.TOKlparen); //print(token.toString()) - token = this.ts.nextT(); // should be { + token = this.ts.nextTok(); // should be { //print(token.toString()) scopeName = fixAlias(scopeName); var fnScope = new Scope(this.braceNesting, scope, token.n, ''); @@ -569,11 +578,11 @@ Walker2 = XObject.define( //$this$=foo if ( - (this.ts.lookT(1).tokN == Script.TOKidentifier) + (this.ts.lookTok(1).type == 'NAME') ) { //scopeName = this.ts.look(-3).data; - this.ts.balanceN(Script.TOKlparen); - token = this.ts.nextT(); // should be { + this.ts.balanceN('('); + token = this.ts.nextTok(); // should be { var fnScope = new Scope(this.braceNesting, scope, token.n, ''); this.indexedScopes[this.ts.cursor] = fnScope; @@ -592,16 +601,16 @@ Walker2 = XObject.define( // RETURN function(...) { if ( - // (this.ts.lookT(-1).tokN == Script.TOKlparen) && - (this.ts.lookT(1).tokN != Script.TOKidentifier) + // (this.ts.lookTok(-1).tokN == Script.TOKlparen) && + (this.ts.lookTok(1).name != 'NAME') - // (this.ts.lookT(-2).tokN == Script.TOKnew) && - // (this.ts.lookT(-3).tokN == Script.TOKassign) && - // (this.ts.lookT(-4).tokN == Script.TOKidentifier) + // (this.ts.lookTok(-2).tokN == Script.TOKnew) && + // (this.ts.lookTok(-3).tokN == Script.TOKassign) && + // (this.ts.lookTok(-4).tokN == Script.TOKidentifier) ) { //scopeName = this.ts.look(-3).data; - this.ts.balanceN(Script.TOKlparen); - token = this.ts.nextT(); // should be { + this.ts.balanceN('('); + token = this.ts.nextTok(); // should be { var fnScope = new Scope(this.braceNesting, scope, token.n, '$private$'); this.indexedScopes[this.ts.cursor] = fnScope; //scope = ; @@ -625,16 +634,16 @@ Walker2 = XObject.define( } // end checking for TOKfunction - if (token.tokN == Script.TOKlbrace) { + if (token.data == '{') { // foo = { // !var!!! //$this$=foo|Foo if ( - (this.ts.lookT(-1).tokN == Script.TOKassign) && - (this.ts.lookT(-2).tokN == Script.TOKidentifier) && - (this.ts.lookT(-3).tokN != Script.TOKvar) + (this.ts.lookTok(-1).data == '=') && + (this.ts.lookTok(-2).type == 'NAME') && + (this.ts.lookTok(-3).nane != 'VAR') ) { scopeName = this.ts.look(-2).data; @@ -656,12 +665,12 @@ Walker2 = XObject.define( //print("GOT LBRACE : check for :"); if ( - (this.ts.lookT(-1).tokN == Script.TOKcolon) && - (this.ts.lookT(-2).tokN == Script.TOKidentifier) && - (this.ts.lookT(-3).tokN != Script.TOKvar) + (this.ts.lookTok(-1).data == ':') && + (this.ts.lookTok(-2).type == 'NAME') && + (this.ts.lookTok(-3).name != 'VAR') ) { - scopeName = this.ts.lookT(-2).data; + scopeName = this.ts.lookTok(-2).data; scopeName = fixAlias(scopeName); var fnScope = new Scope(this.braceNesting, scope, token.n, scopeName); this.indexedScopes[this.ts.cursor] = fnScope; @@ -682,7 +691,7 @@ Walker2 = XObject.define( continue; } - if (token.tokN == Script.TOKrbrace) { + if (token.data == '{') { if (this.currentDoc) {