/// next reads the next rune from the bufferred reader. Returns the rune(0) if /// an error occurs (or io.EOF is returned). private char Next() { var(ch, size, err) = _buf.ReadRune(); if (err) { // advance for error reporting _srcPos.Column++; _srcPos.Offset += size; _lastCharLen = size; return(EOF); } if (ch == GoBuffer.RuneError && size == 1) { _srcPos.Column++; _srcPos.Offset += size; _lastCharLen = size; Err("illegal UTF-8 encoding"); return(ch); } // remember last position _prevPos = _srcPos; _srcPos.Column++; _lastCharLen = size; _srcPos.Offset += size; if (ch == '\n') { _srcPos.Line++; _lastLineLen = _srcPos.Column; _srcPos.Column = 0; } // If we see a null character with data left, then that is an error if (ch == '\x00' && _buf.Len() > 0) { Err("unexpected null character (0x00)"); return(EOF); } // debug // fmt.Printf("ch: %q, offset:column: %d:%d\n", ch, s.srcPos.Offset, s.srcPos.Column) return(ch); }