public class TokenArray: Object {
- Gee.ArrayList<Token> tokens;
+ public Gee.ArrayList<Token> tokens;
+ public int length {
+ get { return this.tokens.size }
+ }
public TokenArray()
{
}
return null;
}
- public Token? lastSym = function() {
+ public Token? lastSym () {
for (var i = this.tokens.length-1; i >= 0; i--) {
if (!(this.tokens.get(i).is("WHIT") || this.tokens.get(i).is("COMM"))) {
return this.tokens.get(i);
}
return null;
}
+ public void push (Token t) {
+ this.tokens.add(t);
+ }
+ public Token get(int i) {
+ return this.tokens.get(i);
+ }
}
this.line =1;
var tokens = new TokenArray();
-
- while (!stream.look().eof) {
+ bool eof;
+ while (true) {
+
+ 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;
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));
+ tokens.push(
+ new Token(stream.next(), "TOKN", "UNKNOWN_TOKEN", this.line)
+ );
}
* @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) {
n--;
continue;
}
- if (stack && (tokens[n].data == '{' || tokens[n].data == '(')) {
+ if (stack && (tokens.get(n]).data == '{' || tokens[n].data == '(')) {
stack--;
n--;
continue;