JSDOC/TokenReader.js
authorAlan Knowles <alan@roojs.com>
Wed, 23 Nov 2011 03:25:53 +0000 (11:25 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 23 Nov 2011 03:25:53 +0000 (11:25 +0800)
JSDOC/TokenReader.js

index b7db27d..82a6264 100644 (file)
@@ -76,6 +76,9 @@ TokenReader = XObject.define(
             
             var incode = this.lang == 'php' ?  0 : -1;
             
+            
+            
+            
             while (!stream.look().eof) {
                 
                 
@@ -90,6 +93,8 @@ TokenReader = XObject.define(
                         continue;
                     }
                 }
+                if (this.read_shebang(stream, tokens))      continue; 
+
                 if (this.read_mlcomment(stream, tokens)) continue;
                 if (this.read_slcomment(stream, tokens)) continue;
                 if (this.read_dbquote(stream, tokens))   continue;
@@ -100,7 +105,6 @@ TokenReader = XObject.define(
                 if (this.read_newline(stream, tokens))   continue;
                 if (this.read_space(stream, tokens))     continue;
                 if (this.read_word(stream, tokens))      continue;
-                
                 // if execution reaches here then an error has happened
                 tokens.push(new Token(stream.next(), "TOKN", "UNKNOWN_TOKEN", this.line));
             }
@@ -475,11 +479,30 @@ TokenReader = XObject.define(
             }
             return false;
         },
+       /**
+         * read_shebang ( #!/usr/bin/seed
+         * @param {JSDOC.TokenStream} stream the text stream
+         * @param {Array} tokens
+         *  @returns {Boolean} Was the token found?
+         */
+        read_shebang : function(/**JSDOC.TokenStream*/stream, tokens)
+        {
+            if (stream.cursor != 0) {
+                return false;
+            }
+            
+            if (stream.look() == '#' && stream.look(1) == '!') {
+                while (stream.next() != "\n") { }; //eof?
+                return true;
+            }
+            return false; 
+        },
+        
         /**
-         * read_codestart (currently on PHP supported?)
+         * read_codeend (currently on PHP supported?)
          *  @returns {Boolean} Was the token found?
          */
-        read_codestart : function(/**JSDOC.TokenStream*/stream, tokens)
+        read_codeend : function(/**JSDOC.TokenStream*/stream, tokens)
         {
             var found = ''; 
             if (stream.look() == '?' && stream.look(1) == '>') {
@@ -490,10 +513,10 @@ TokenReader = XObject.define(
         },
         
         /**
-         * read_codeend (currently on PHP supported?)
+         * read_codestart (currently on PHP supported?)
          *  @returns {Boolean} Was the token found?
          */
-        read_codeend: function(/**JSDOC.TokenStream*/stream, tokens) {
+        read_codestart : function(/**JSDOC.TokenStream*/stream, tokens) {
             var found = ''; 
             
             while (!stream.look().eof) {