1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343
|
// Code generated by re2go, DO NOT EDIT.
//line "codegen/go/005_posix_captures.re":1
//go:generate re2go $INPUT -o $OUTPUT
package main
import "reflect"
//line "codegen/go/005_posix_captures.go":9
const YYMAXNMATCH = 5
//line "codegen/go/005_posix_captures.re":6
func Lex(str string) (int, []int) {
var cursor, marker, yynmatch int
yypmatch := make([]int, YYMAXNMATCH*2)
//line "codegen/go/005_posix_captures.go":19
var yyt1 int
var yyt2 int
var yyt3 int
var yyt4 int
var yyt5 int
var yyt6 int
var yyt7 int
//line "codegen/go/005_posix_captures.re":12
//line "codegen/go/005_posix_captures.go":31
{
var yych byte
yych = str[cursor]
switch (yych) {
case 0x00:
yyt1 = cursor
yyt2 = -1
yyt3 = -1
yyt4 = -1
goto yy1
case 'a':
yyt1 = cursor
yyt3 = cursor
goto yy4
case 'b':
yyt1 = cursor
yyt3 = -1
yyt4 = -1
yyt5 = cursor
goto yy5
case 'c':
yyt1 = cursor
yyt3 = -1
yyt4 = -1
yyt5 = -1
yyt6 = -1
yyt7 = cursor
goto yy6
default:
goto yy2
}
yy1:
cursor += 1
yynmatch = 5
yypmatch[0] = yyt1
yypmatch[3] = yyt2
yypmatch[5] = yyt3
yypmatch[7] = yyt4
yypmatch[1] = cursor
yypmatch[2] = yyt3
yypmatch[4] = yyt3
yypmatch[6] = yyt4
yypmatch[8] = yyt2
yypmatch[9] = yyt2
yyt3 = -1
if (yypmatch[2] != yyt3) {
yypmatch[2] += -1
}
if (yypmatch[4] != yyt3) {
yypmatch[4] += -1
}
if (yypmatch[6] != yyt3) {
yypmatch[6] += -1
}
if (yypmatch[8] != yyt3) {
yypmatch[8] += -1
}
//line "codegen/go/005_posix_captures.re":40
{
return yynmatch, yypmatch
}
//line "codegen/go/005_posix_captures.go":93
yy2:
cursor += 1
yy3:
//line "codegen/go/005_posix_captures.re":28
{
return -1, nil
}
//line "codegen/go/005_posix_captures.go":101
yy4:
cursor += 1
marker = cursor
yych = str[cursor]
switch (yych) {
case 0x00:
yyt2 = -1
yyt4 = cursor
yyt5 = -1
yyt6 = -1
yyt7 = -1
goto yy7
case 'a':
goto yy8
case 'b':
goto yy10
case 'c':
yyt3 = cursor
yyt4 = -1
goto yy11
default:
goto yy3
}
yy5:
cursor += 1
marker = cursor
yych = str[cursor]
switch (yych) {
case 0x00:
yyt2 = -1
yyt6 = cursor
yyt7 = -1
goto yy7
case 'b':
goto yy12
default:
goto yy3
}
yy6:
cursor += 1
marker = cursor
yych = str[cursor]
switch (yych) {
case 0x00:
yyt2 = cursor
goto yy7
case 'c':
goto yy13
default:
goto yy3
}
yy7:
cursor += 1
yynmatch = 5
yypmatch[2] = yyt1
yypmatch[4] = yyt3
yypmatch[5] = yyt4
yypmatch[6] = yyt5
yypmatch[7] = yyt6
yypmatch[8] = yyt7
yypmatch[9] = yyt2
yypmatch[0] = yyt1
yypmatch[1] = cursor
yypmatch[3] = cursor
yypmatch[3] += -1
//line "codegen/go/005_posix_captures.re":36
{
return yynmatch, yypmatch
}
//line "codegen/go/005_posix_captures.go":171
yy8:
cursor += 1
yych = str[cursor]
switch (yych) {
case 0x00:
yyt2 = -1
yyt4 = cursor
yyt5 = -1
yyt6 = -1
yyt7 = -1
goto yy7
case 'a':
goto yy8
case 'b':
goto yy14
default:
goto yy9
}
yy9:
cursor = marker
goto yy3
yy10:
cursor += 1
yych = str[cursor]
switch (yych) {
case 'c':
yyt2 = cursor
goto yy15
default:
goto yy9
}
yy11:
cursor += 1
yych = str[cursor]
switch (yych) {
case 0x00:
yyt2 = cursor
goto yy1
case 'a':
goto yy16
default:
goto yy9
}
yy12:
cursor += 1
yych = str[cursor]
switch (yych) {
case 0x00:
yyt2 = -1
yyt6 = cursor
yyt7 = -1
goto yy7
case 'b':
goto yy12
default:
goto yy9
}
yy13:
cursor += 1
yych = str[cursor]
switch (yych) {
case 0x00:
yyt2 = cursor
goto yy7
case 'c':
goto yy13
default:
goto yy9
}
yy14:
cursor += 1
yych = str[cursor]
switch (yych) {
case 'c':
yyt2 = cursor
goto yy17
default:
goto yy9
}
yy15:
cursor += 1
yych = str[cursor]
switch (yych) {
case 'a':
goto yy16
default:
goto yy18
}
yy16:
cursor += 1
yych = str[cursor]
switch (yych) {
case 'b':
yyt3 = cursor
goto yy20
case 'c':
yyt3 = cursor
yyt4 = -1
goto yy11
default:
goto yy9
}
yy17:
cursor += 1
yych = str[cursor]
yy18:
switch (yych) {
case 0x00:
goto yy19
case 'c':
goto yy17
default:
goto yy9
}
yy19:
cursor += 1
yynmatch = 4
yypmatch[2] = yyt1
yypmatch[6] = yyt2
yypmatch[0] = yyt1
yypmatch[1] = cursor
yypmatch[3] = yyt2
yypmatch[3] += -1
yypmatch[4] = yyt2
yypmatch[4] += -1
yypmatch[5] = yyt2
yypmatch[7] = cursor
yypmatch[7] += -1
//line "codegen/go/005_posix_captures.re":32
{
return yynmatch, yypmatch
}
//line "codegen/go/005_posix_captures.go":304
yy20:
cursor += 1
yych = str[cursor]
switch (yych) {
case 'c':
yyt4 = cursor
goto yy11
default:
goto yy9
}
}
//line "codegen/go/005_posix_captures.re":43
}
func main() {
var n int
var m []int
n, m = Lex("aabcc\000")
if !(n == 4 && reflect.DeepEqual(m[0:2*n], []int{0, 6, 0, 2, 2, 3, 3, 5})) {
panic("failed on aabcc")
}
n, m = Lex("aaa\000")
if !(n == 5 && reflect.DeepEqual(m[0:2*n], []int{0, 4, 0, 3, 0, 3, -1, -1, -1, -1})) {
panic("failed on aaa")
}
n, m = Lex("acabc\000")
if !(n == 5 && reflect.DeepEqual(m[0:2*n], []int{0, 6, 2, 5, 2, 3, 3, 4, 4, 5})) {
panic("failed on acabc")
}
n, m = Lex("abcac\000")
if !(n == 5 && reflect.DeepEqual(m[0:2*n], []int{0, 6, 3, 5, 3, 4, -1, -1, 4, 5})) {
panic("failed on abcac")
}
n, m = Lex("ab\000")
if !(n == -1 && m == nil) {
panic("failed on ab")
}
}
|