JsTemplate/Link.js
[gnome.introspection-doc-generator] / JSDOC / TokenStream.js
index 6cced95..32ce52f 100644 (file)
@@ -1,17 +1,34 @@
 //<script type="text/javscript">
 
-imports['Object.js'].load(Object);
 
-JSDOC   = imports['JSDOC.js'].JSDOC;
-console = imports['console.js'].console;
-Token   = imports['JSDOC/Token.js'].Token;
-Lang    = imports['JSDOC/Lang.js'].Lang;
+XObject = imports.XObject.XObject;
+
+
+console = imports.console.console;
+Token   = imports.Token.Token;
+Lang    = imports.Lang.Lang;
+
 
 /**
-       @constructor
-*/
+ * @class TokenStream
+ * 
+ * BC notes:
+ * 
+ * nextT => nextTok
+ * lookT => lookTok
+ * 
+ */
+       
  
-TokenStream = Object.define(
+TokenStream = XObject.define(
+
+    /**
+     * @constructor
+     * 
+     * 
+     */
+
     function(tokens) {
      
         
@@ -34,7 +51,9 @@ TokenStream = Object.define(
             if (typeof n == "undefined") n = 0;
 
             if (considerWhitespace == true) {
-                if (this.cursor+n < 0 || this.cursor+n > this.tokens.length) return {};
+                if (this.cursor+n < 0 || this.cursor+n > (this.tokens.length -1)) {
+                    return new Token("", "VOID", "START_OF_STREAM");
+                }
                 return this.tokens[this.cursor+n];
             }
             else {
@@ -97,9 +116,9 @@ TokenStream = Object.define(
                     if (n > -1) {
                         i = 0; continue;
                     }
-                    return return new Token("", "VOID", "END_OF_STREAM");
+                    return   new Token("", "VOID", "END_OF_STREAM");
                 }
-                else if (i > this.tokens.length) return false;
+                else if (i > this.tokens.length) return  new Token("", "VOID", "END_OF_STREAM");
 
                 if (i != this.cursor && (this.tokens[i] === undefined || this.tokens[i].is("WHIT") || this.tokens[i].is("COMM"))) {
                     if (n < 0) i--; else i++;
@@ -112,14 +131,16 @@ TokenStream = Object.define(
                 count++;
                 (n < 0)? i-- : i++;
             }
-
+        // should never get here..
             return false; // because null isn't an object and caller always expects an object;
             
         },
 
         /**
-            @type JSDOC.Token|JSDOC.Token[]| null!
-        */
+         *  @return {Token|null}
+         */
+            
+           
         next : function(/**Number*/howMany) {
             if (typeof howMany == "undefined") howMany = 1;
             if (howMany < 1) return null;