X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=JSDOC%2FTokenReader.vala;h=191b7a8fd475ec63aed376e7645d62d817fd561e;hb=0b04c89e1c84750ed956063de8c86087a35f999d;hp=487bf3d28d4ffb77eba836b1d21381a3da1ba9d1;hpb=006131fa9b4c2f6f9e16904aa0a30aca5e431038;p=gnome.introspection-doc-generator diff --git a/JSDOC/TokenReader.vala b/JSDOC/TokenReader.vala index 487bf3d..191b7a8 100644 --- a/JSDOC/TokenReader.vala +++ b/JSDOC/TokenReader.vala @@ -14,7 +14,10 @@ namespace JSDOC { public class TokenArray: Object { - Gee.ArrayList tokens; + public Gee.ArrayList tokens; + public int length { + get { return this.tokens.size } + } public TokenArray() { @@ -38,6 +41,9 @@ namespace JSDOC { public void push (Token t) { this.tokens.add(t); } + public Token get(int i) { + return this.tokens.get(i); + } } @@ -84,12 +90,9 @@ namespace JSDOC { var tokens = new TokenArray(); bool eof; - while (true) { + while (!stream.lookEOF()) { + - stream.look(0, out eof) - if (eof) { - break; - } if (this.read_mlcomment(stream, tokens)) continue; if (this.read_slcomment(stream, tokens)) continue; if (this.read_dbquote(stream, tokens)) continue; @@ -103,8 +106,8 @@ namespace JSDOC { // if execution reaches here then an error has happened tokens.push( - new Token(stream.next(), "TOKN", "UNKNOWN_TOKEN", this.line - )); + new Token(stream.next(), "TOKN", "UNKNOWN_TOKEN", this.line) + ); } @@ -121,21 +124,21 @@ namespace JSDOC { * @arg {Number} offset where to start reading from * @return {Number} position of token */ - findPuncToken : function(tokens, data, n) { + public int findPuncToken(TokenArray tokens, string data, int n) { n = n || tokens.length -1; var stack = 0; while (n > -1) { - if (!stack && tokens[n].data == data) { + if (!stack && tokens.get(n).data == data) { return n; } - if (tokens[n].data == ')' || tokens[n].data == '}') { + if (tokens.get(n).data == ')' || tokens.get(n).data == '}') { stack++; n--; continue; } - if (stack && (tokens[n].data == '{' || tokens[n].data == '(')) { + if (stack && (tokens.get(n).data == '{' || tokens.get(n).data == '(')) { stack--; n--; continue; @@ -154,9 +157,11 @@ namespace JSDOC { * @arg {Number} offset where to start.. * @return {Token} the token */ - lastSym : function(tokens, n) { + public Token lastSym(TokenArray tokens, int n) { for (var i = n-1; i >= 0; i--) { - if (!(tokens[i].is("WHIT") || tokens[i].is("COMM"))) return tokens[i]; + if (!(tokens.get(i).is("WHIT") || tokens.get(i).is("COMM"))) { + return tokens.get(i); + } } return null; }, @@ -166,7 +171,7 @@ namespace JSDOC { /** @returns {Boolean} Was the token found? */ - read_word : function(/**JSDOC.TokenStream*/stream, tokens) { + public bool read_word (TokenStream stream, TokenArray tokens) { var found = ""; while (!stream.look().eof && Lang.isWordChar(stream.look())) { found += stream.next();