X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=JSDOC%2FTokenReader.vala;h=b49ffcc7aa7417f8e0ad40b00c7796f26574516f;hb=3c210fbae8a299e248847e55c22441a7e3cae8cb;hp=66034d18c928d301cbb9bdde7b626ae849cdf015;hpb=6da0001189ab14d648ae3211aca41b614780a43f;p=gnome.introspection-doc-generator diff --git a/JSDOC/TokenReader.vala b/JSDOC/TokenReader.vala index 66034d1..b49ffcc 100644 --- a/JSDOC/TokenReader.vala +++ b/JSDOC/TokenReader.vala @@ -242,9 +242,9 @@ namespace JSDOC { */ public bool read_punc (TokenStream stream, TokenArray tokens) { - var found = ""; + string found = ""; var name; - while (!stream.look().eof && Lang.punc(found + stream.look())) { + while (!stream.lookEOF() && Lang.punc(found + stream.look()).length > 0) { found += stream.next(); } @@ -261,46 +261,53 @@ namespace JSDOC { if (this.ignoreBadGrammer) { print("\n" + this.filename + ':' + this.line + " Error - comma found before " + found); } else { - - throw { - name : "ArgumentError", - message: "\n" + this.filename + ':' + this.line + " Error - comma found before " + found - } + throw new TokenReader_Error.ArgumentError( + this.filename + ":" + this.line + " comma found before " + found + + ); + } } tokens.push(new Token(found, "PUNC", Lang.punc(found), this.line)); return true; - }, + } /** @returns {Boolean} Was the token found? */ - read_space : function(/**JSDOC.TokenStream*/stream, tokens) { + public bool read_space (TokenStream stream, TokenArray tokens) + { var found = ""; - while (!stream.look().eof && Lang.isSpace(stream.look()) && !Lang.isNewline(stream.look())) { + while (!stream.lookEOF() && Lang.isSpace(stream.look()) && !Lang.isNewline(stream.look())) { found += stream.next(); } if (found === "") { return false; } - //print("WHITE = " + JSON.stringify(found)); - if (this.collapseWhite) found = " "; - if (this.keepWhite) tokens.push(new Token(found, "WHIT", "SPACE", this.line)); + //print("WHITE = " + JSON.stringify(found)); + + + if (this.collapseWhite) { + found = " "; // this might work better if it was a '\n' ??? + } + if (this.keepWhite) { + tokens.push(new Token(found, "WHIT", "SPACE", this.line)); + } return true; - }, + } /** @returns {Boolean} Was the token found? */ - read_newline : function(/**JSDOC.TokenStream*/stream, tokens) { + public bool read_newline (TokenStream stream, TokenArray tokens) var found = ""; var line = this.line; - while (!stream.look().eof && Lang.isNewline(stream.look())) { + while (!stream.lookEOF() && Lang.isNewline(stream.look())) { this.line++; found += stream.next(); } @@ -308,6 +315,11 @@ namespace JSDOC { if (found === "") { return false; } + + // if we found a new line, then we could check if previous character was a ';' - if so we can drop it. + // otherwise generally keep it.. in which case it should reduce our issue with stripping new lines.. + + //this.line++; if (this.collapseWhite) { found = "\n";