Root Zanli
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
usr
/
share
/
doc
/
re2c
/
examples
/
go
/
reuse
/
Filename :
reuse.go
back
Copy
// Code generated by re2c, DO NOT EDIT. //line "go/reuse/reuse.re":1 //go:generate re2go $INPUT -o $OUTPUT --input-encoding utf8 // This example supports multiple input encodings: UTF-8 and UTF-32. // Both lexers are generated from the same rules block, and the use // blocks add only encoding-specific configurations. package main import "testing" //line "go/reuse/reuse.re":20 func lexUTF8(str []uint8) int { var cursor, marker int //line "go/reuse/reuse.go":20 { var yych uint8 yych = str[cursor] switch (yych) { case 0xE2: goto yy4 default: goto yy2 } yy2: cursor += 1 yy3: //line "go/reuse/reuse.re":19 { return 1; } //line "go/reuse/reuse.go":35 yy4: cursor += 1 marker = cursor yych = str[cursor] switch (yych) { case 0x88: goto yy5 default: goto yy3 } yy5: cursor += 1 yych = str[cursor] switch (yych) { case 0x80: goto yy7 default: goto yy6 } yy6: cursor = marker goto yy3 yy7: cursor += 1 yych = str[cursor] switch (yych) { case 'x': goto yy8 default: goto yy6 } yy8: cursor += 1 yych = str[cursor] switch (yych) { case ' ': goto yy9 default: goto yy6 } yy9: cursor += 1 yych = str[cursor] switch (yych) { case 0xE2: goto yy10 default: goto yy6 } yy10: cursor += 1 yych = str[cursor] switch (yych) { case 0x88: goto yy11 default: goto yy6 } yy11: cursor += 1 yych = str[cursor] switch (yych) { case 0x83: goto yy12 default: goto yy6 } yy12: cursor += 1 yych = str[cursor] switch (yych) { case 'y': goto yy13 default: goto yy6 } yy13: cursor += 1 //line "go/reuse/reuse.re":18 { return 0; } //line "go/reuse/reuse.go":116 } //line "go/reuse/reuse.re":27 } func lexUTF32(str []uint32) int { var cursor, marker int //line "go/reuse/reuse.go":125 { var yych uint32 yych = str[cursor] if (yych == 0x00002200) { goto yy19 } cursor += 1 yy18: //line "go/reuse/reuse.re":19 { return 1; } //line "go/reuse/reuse.go":136 yy19: cursor += 1 marker = cursor yych = str[cursor] if (yych != 'x') { goto yy18 } cursor += 1 yych = str[cursor] if (yych == ' ') { goto yy22 } yy21: cursor = marker goto yy18 yy22: cursor += 1 yych = str[cursor] if (yych != 0x00002203) { goto yy21 } cursor += 1 yych = str[cursor] if (yych != 'y') { goto yy21 } cursor += 1 //line "go/reuse/reuse.re":18 { return 0; } //line "go/reuse/reuse.go":166 } //line "go/reuse/reuse.re":35 } func TestLex(t *testing.T) { s8 := []uint8{0xe2, 0x88, 0x80, 0x78, 0x20, 0xe2, 0x88, 0x83, 0x79}; if lexUTF8(s8) != 0 { t.Errorf("utf8 failed") } s32 := []uint32{0x2200, 0x78, 0x20, 0x2203, 0x79}; if lexUTF32(s32) != 0 { t.Errorf("utf32 failed") } }