| Server IP : 85.214.239.14  /  Your IP : 216.73.216.181 Web Server : Apache/2.4.65 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/3/root/proc/self/root/usr/share/doc/re2c/examples/go/fill/ | 
| Upload File : | 
// Code generated by re2c, DO NOT EDIT.
//line "go/fill/02_fill.re":1
//go:generate re2go $INPUT -o $OUTPUT
package main
import (
	"os"
	"strings"
)
//line "go/fill/02_fill.go":12
var YYMAXFILL int = 1
//line "go/fill/02_fill.re":9
const BUFSIZE int = 4096
type Input struct {
	file *os.File
	buf  []byte
	cur  int
	tok  int
	lim  int
	eof  bool
}
func fill(in *Input, need int) int {
	if in.eof { return -1 } // unexpected EOF
	// Error: lexeme too long. In real life can reallocate a larger buffer.
	if in.tok < need { return -2 }
	// Shift buffer contents (discard everything up to the current token).
	copy(in.buf[0:], in.buf[in.tok:in.lim])
	in.cur -= in.tok
	in.lim -= in.tok
	in.tok = 0
	// Fill free space at the end of buffer with new data from file.
	n, _ := in.file.Read(in.buf[in.lim:BUFSIZE])
	in.lim += n
	// If read less than expected, this is end of input => add zero padding
	// so that the lexer can access characters at the end of buffer.
	if in.lim < BUFSIZE {
		in.eof = true
		for i := 0; i < YYMAXFILL; i += 1 { in.buf[in.lim+i] = 0 }
		in.lim += YYMAXFILL
	}
	return 0
}
func lex(in *Input) int {
	count := 0
	for {
		in.tok = in.cur
	
//line "go/fill/02_fill.go":59
{
	var yych byte
	if (in.lim-in.cur < 1) {
		if r := fill(in, 1); r != 0 { return r }
	}
	yych = in.buf[in.cur]
	switch (yych) {
	case 0x00:
		goto yy1
	case ' ':
		goto yy3
	case '\'':
		goto yy5
	default:
		goto yy2
	}
yy1:
	in.cur += 1
//line "go/fill/02_fill.re":61
	{
			// Check that it is the sentinel, not some unexpected null.
			if in.tok == in.lim - YYMAXFILL { return count } else { return -1 }
		}
//line "go/fill/02_fill.go":83
yy2:
	in.cur += 1
//line "go/fill/02_fill.re":67
	{ return -1 }
//line "go/fill/02_fill.go":88
yy3:
	in.cur += 1
	if (in.lim-in.cur < 1) {
		if r := fill(in, 1); r != 0 { return r }
	}
	yych = in.buf[in.cur]
	switch (yych) {
	case ' ':
		goto yy3
	default:
		goto yy4
	}
yy4:
//line "go/fill/02_fill.re":66
	{ continue }
//line "go/fill/02_fill.go":104
yy5:
	in.cur += 1
	if (in.lim-in.cur < 1) {
		if r := fill(in, 1); r != 0 { return r }
	}
	yych = in.buf[in.cur]
	switch (yych) {
	case '\'':
		goto yy6
	case '\\':
		goto yy7
	default:
		goto yy5
	}
yy6:
	in.cur += 1
//line "go/fill/02_fill.re":65
	{ count += 1; continue }
//line "go/fill/02_fill.go":123
yy7:
	in.cur += 1
	if (in.lim-in.cur < 1) {
		if r := fill(in, 1); r != 0 { return r }
	}
	goto yy5
}
//line "go/fill/02_fill.re":68
	}
}
func main() () {
	fname := "input"
	content := "'qu\000tes' 'are' 'fine: \\'' ";
	// Prepare input file: a few times the size of the buffer, containing
	// strings with zeroes and escaped quotes.
	f, _ := os.Create(fname)
	f.WriteString(strings.Repeat(content, BUFSIZE))
	f.Seek(0, 0)
	count := 3 * BUFSIZE // number of quoted strings written to file
	// Prepare lexer state: all offsets are at the end of buffer.
	// This immediately triggers YYFILL, as the YYLESSTHAN condition is true.
	in := &Input{
		file: f,
		buf:  make([]byte, BUFSIZE+YYMAXFILL),
		cur:  BUFSIZE,
		tok:  BUFSIZE,
		lim:  BUFSIZE,
		eof:  false,
	}
	// Run the lexer.
	if lex(in) != count { panic("error"); }
	// Cleanup: remove input file.
	f.Close();
	os.Remove(fname);
}