X-Git-Url: http://git.roojs.org/?p=gnome.introspection-doc-generator;a=blobdiff_plain;f=JSDOC%2FTokenReader.vala;h=699aea499eed05413093f991ede88c97733a27b6;hp=a06c1db40d53144baa36619c3c0a642589f775c0;hb=32210f938b140061c5af2ab70d6b0c009b723653;hpb=82eb6c096ae99e6ba2abf77c2569d5e6fd7a0e5c diff --git a/JSDOC/TokenReader.vala b/JSDOC/TokenReader.vala index a06c1db..699aea4 100644 --- a/JSDOC/TokenReader.vala +++ b/JSDOC/TokenReader.vala @@ -2,22 +2,7 @@ // test code - -void main() { - var tr = new JSDOC.TokenReader(); - tr.keepDocs =true; - tr.keepWhite = true; - tr.keepComments = true; - tr.sepIdents = true; - tr.collapseWhite = false; - tr.filename = "test"; - string str; - FileUtils.get_contents("/home/alan/gitlive/gnome.introspection-doc-generator/JSDOC/Walker2.js", out str); - - var toks = tr.tokenize(new JSDOC.TextStream(str)); // dont merge xxx + . + yyyy etc. - toks.dump(); -} - + //const Token = imports.Token.Token; //const Lang = imports.Lang.Lang; @@ -73,7 +58,7 @@ namespace JSDOC { public void dump() { foreach(var token in this.tokens) { - print(token.asString()); + print(token.asString() +"\n"); } } @@ -213,7 +198,7 @@ namespace JSDOC { public bool read_word (TextStream stream, TokenArray tokens) { string found = ""; - while (!stream.lookEOF() && Lang.isWordChar((string)stream.look())) { + while (!stream.lookEOF() && Lang.isWordChar(stream.look().to_string())) { found += stream.next(); } @@ -277,7 +262,12 @@ namespace JSDOC { { string found = ""; - while (!stream.lookEOF() && Lang.punc(found + (string)stream.look()).length > 0) { + while (!stream.lookEOF()) { + var ns = stream.look().to_string(); + + if (null == Lang.punc(found + ns )) { + break; + } found += stream.next(); } @@ -415,12 +405,16 @@ namespace JSDOC { (stream.look() == '<' && stream.look(1) == '!' && stream.look(2) == '-' && stream.look(3) == '-' && (""!=(found=stream.next(4)))) ) { var line = this.line; - while (!stream.lookEOF() && !Lang.isNewline((string)stream.look())) { + while (!stream.lookEOF()) { + //print(stream.look().to_string()); + if ( Lang.isNewline(stream.look().to_string())) { + break; + } found += stream.next(); } - //if (!stream.lookEOF()) { // what? << eat the EOL? + if (!stream.lookEOF()) { // lookinng for end of line... if we got it, then do not eat the character.. found += stream.next(); - //} + } if (this.keepComments) { tokens.push(new Token(found, "COMM", "SINGLE_LINE_COMM", line)); } @@ -443,10 +437,10 @@ namespace JSDOC { while (!stream.lookEOF()) { if (stream.look() == '\\') { - if (Lang.isNewline((string)stream.look(1))) { + if (Lang.isNewline(stream.look(1).to_string())) { do { stream.next(); - } while (!stream.lookEOF() && Lang.isNewline((string)stream.look())); + } while (!stream.lookEOF() && Lang.isNewline(stream.look().to_string())); str += "\\\n"; } else { @@ -505,7 +499,7 @@ namespace JSDOC { var found = ""; - while (!stream.lookEOF() && Lang.isNumber(found+(string)stream.look())){ + while (!stream.lookEOF() && Lang.isNumber(found+stream.look().to_string())){ found += stream.next(); } @@ -529,7 +523,7 @@ namespace JSDOC { var found = stream.next(2); while (!stream.lookEOF()) { - if (Lang.isHexDec(found) && !Lang.isHexDec(found+(string)stream.look())) { // done + if (Lang.isHexDec(found) && !Lang.isHexDec(found+stream.look().to_string())) { // done tokens.push(new Token(found, "NUMB", "HEX_DEC", this.line)); return true; } @@ -570,7 +564,7 @@ namespace JSDOC { if (stream.look() == '/') { regex += stream.next(); - while (GLib.Regex.match_simple("[gmi]", (string)stream.look())) { + while (GLib.Regex.match_simple("[gmi]", stream.look().to_string())) { regex += stream.next(); }