JSDOC/TokenReader.js
[gnome.introspection-doc-generator] / JSDOC / TokenReader.js
index fb22a3d..5e5cec8 100644 (file)
@@ -63,7 +63,6 @@ const TokenReader = XObject.define(
                 if (this.read_regx(stream, tokens))      continue;
                 if (this.read_numb(stream, tokens))      continue;
                 if (this.read_punc(stream, tokens))      continue;
-                if(typeof(tokens) == 'undefined') {console.log('empty????');}
                 if (this.read_newline(stream, tokens))   continue;
                 if (this.read_space(stream, tokens))     continue;
                 if (this.read_word(stream, tokens))      continue;
@@ -259,9 +258,8 @@ const TokenReader = XObject.define(
             if (this.collapseWhite) {
                 found = "\n";
             }
-            if (this.keepWhite) {
-                console.log(typeof(tokens));
-                var last = tokens.pop();
+             if (this.keepWhite) {
+                var last = tokens ? tokens.pop() : false;
                 if (last && last.name != "WHIT") {
                     tokens.push(last);
                 }
@@ -466,12 +464,25 @@ const TokenReader = XObject.define(
                 )
             ) {
                 var regex = stream.next();
-                
+                var unbrace = false;
                 while (!stream.look().eof) {
+                    
+                    if (stream.look() == "[") { // escape sequence
+                        in_brace = true;
+                        continue;
+                    }
+                    
+                    if (in_brace && stream.look() == "[") { // escape sequence
+                        in_brace = true;
+                        continue;
+                    }
+                    
                     if (stream.look() == "\\") { // escape sequence
                         regex += stream.next(2);
+                        continue;
                     }
-                    else if (stream.look() == "/") {
+                    
+                    if (!in_brace && stream.look() == "/") {
                         regex += stream.next();
                         
                         while (/[gmi]/.test(stream.look())) {
@@ -481,9 +492,9 @@ const TokenReader = XObject.define(
                         tokens.push(new Token(regex, "REGX", "REGX", this.line));
                         return true;
                     }
-                    else {
-                        regex += stream.next();
-                    }
+                    
+                    regex += stream.next();
+                    
                 }
                 // error: unterminated regex
             }