string text;
int cursor;
+ int length;
public TextStream (string text = "")
{
this.text = text;
+ this.length = text.char_count()
this.cursor = 0;
}
public char look(int n = 0)
{
- if (this.cursor+n < 0 || this.cursor+n >= this.text.length) {
+ if (this.cursor+n < 0 || this.cursor+n >= this.length) {
return '\0';
}
return this.text[this.cursor+n];
public bool lookEOF(int n = 0)
{
- if (this.cursor+n < 0 || this.cursor+n >= this.text.length) {
+ if (this.cursor+n < 0 || this.cursor+n >= this.length)) {
return true;
}
return false
char pulled;
for (var i = 0; i < n; i++) {
- if (this.cursor+i < this.text.length) {
+ if (this.cursor+i < this.length) {
pulled += this.text.get_char(this.cursor+i);
} else {
eof =true;