//<Script type="text/javascript">
-XObject
-Scope
-DocComment
-Symbol
-Parser
+XObject = imports.XObject.XObject;
+
+Scope = imports.Scope.Scope;
+DocComment = imports.DocComment.DocComment;
+Symbol = imports.Symbol.Symbol;
+Parser = imports.Parser.Parser;
+
/**
* Scope stuff
*
this.mode = 'BUILDING_SYMBOL_TREE';
this.parseScope(this.globalScope);
+
},
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())) {
+ 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('COMM')) {
- if (!token._isDoc) {
+ if (token.name != 'JSDOC') {
+ //print("Walker2 : spce is not JSDOC");
continue; //skip.
}
if (this.currentDoc) {
this.addSymbol('', true);
-
//throw "Unconsumed Doc (TOKwhitespace): " + this.currentDoc.toSource();
}
// it's a scope changer..
if (newDoc.getTag("scope").length) {
- //print(newDoc.getTag("scope").toSource());
+ //print("Walker2 : doctag changes scope");
//throw "done";
scope.ident = '$private$|' + newDoc.getTag("scope")[0].desc;
continue;
if (newDoc.getTag("scopeAlias").length) {
//print(newDoc.getTag("scopeAlias").toSource());
// @scopeAlias a=b
+ //print("Walker2 : doctag changes scope (alias)");
var sal = newDoc.getTag("scopeAlias")[0].desc.split("=");
aliases[sal[0]] = sal[1];
/// got a doc comment..
//token.data might be this.??? (not sure though)
+ //print("Walker2 : setting currentDoc");
this.currentDoc = newDoc;
continue;
}
// things that stop comments carrying on...??
if (this.currentDoc && (
- token.tokN == Script.TOKsemicolon ||
- token.tokN == Script.TOKrbrace)) {
+ token.data == ';' ||
+ token.data == '}')) {
this.addSymbol('', true);
//throw "Unconsumed Doc ("+ token.toString() +"): " + this.currentDoc.toSource();
}
// 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;
}
// a << scope
// xxx.applyIf(a, {
// a << scope
- if (token.tokN == Script.TOKidentifier) {
+ if (token.type = 'NAME') {
//print("TOK(ident)"+ token.toString());
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);
// 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);
}
+ // apply ( XXXX, {
+ /*
+ print(JSON.stringify([
+ token.data,
+ this.ts.lookTok(1).data ,
+ this.ts.lookTok(2).type ,
+ this.ts.lookTok(3).data ,
+ this.ts.lookTok(4).data
+ ], null, 4));
+ */
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;
if (this.currentDoc) {
this.addSymbol(scopeName,false,'OBJECT');
-
}
- this.ts.nextT(); /// ,
- this.ts.nextT(); // {
- scopeName = fixAlias(scopeName);
+ 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;
scope = fnScope;
// xxx = new yyy ( {
// 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) {
}
- 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);
// 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).data == '.' ? token.data : fixAlias(token.data),
false,
atype);
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');
// 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...
//$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());
scopeName = fixAlias(scopeName);
var fnScope = new Scope(this.braceNesting, scope, token.n,
'$this$='+scopeName+'.prototype|$private$|'+scopeName+'.prototype');
+
this.indexedScopes[this.ts.cursor] = fnScope;
//scope = fnScope;
//this.scopesIn(fnScope);
//$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;
// 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, '');
//$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;
// 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 = ;
} // 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;
//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;
continue;
}
- if (token.tokN == Script.TOKrbrace) {
+ if (token.data == '{') {
if (this.currentDoc) {
addSymbol: function(lastIdent, appendIt, atype )
{
-
+ print("addSymbol : " + lastIdent);
/*if (!this.currentDoc.tags.length) {
return;
}
- var token = this.ts.cur();
+ var token = this.ts.lookTok(0);
if (typeof(appendIt) == 'undefined') {
appendIt= false;
}