if (typeof n == "undefined") n = 0;
if (considerWhitespace == true) {
- if (this.cursor+n < 0 || this.cursor+n > this.tokens.length) return {};
+ if (this.cursor+n < 0 || this.cursor+n > (this.tokens.length -1)) {
+ return new Token("", "VOID", "START_OF_STREAM");
+ }
return this.tokens[this.cursor+n];
}
else {
var i = this.cursor;
while (true) {
- print(i);
+ // print(i);
if (i < 0) {
if (n > -1) {
i = 0; continue;
}
+ return new Token("", "VOID", "END_OF_STREAM");
}
- else if (i > this.tokens.length) return false;
+ else if (i > this.tokens.length) return new Token("", "VOID", "END_OF_STREAM");
if (i != this.cursor && (this.tokens[i] === undefined || this.tokens[i].is("WHIT") || this.tokens[i].is("COMM"))) {
if (n < 0) i--; else i++;
count++;
(n < 0)? i-- : i++;
}
-
+ // should never get here..
return false; // because null isn't an object and caller always expects an object;
},