// Code generated by re2go, DO NOT EDIT.
//line "go/submatch/01_stags.re":1
//go:generate re2go $INPUT -o $OUTPUT --api simple
package main

import "reflect"

type SemVer struct { major, minor, patch int }

func s2n(s string) int { // convert pre-parsed string to a number
	n := 0
	for _, c := range s { n = n*10 + int(c-'0') }
	return n
}

func parse(yyinput string) *SemVer {
	var yycursor, yymarker int

	// Final tag variables available in semantic action.
	
//line "go/submatch/01_stags.go":22
var t1 int;var t2 int;var t3 int;var t4 int;var t5 int;
//line "go/submatch/01_stags.re":18


	// Intermediate tag variables used by the lexer (must be autogenerated).
	
//line "go/submatch/01_stags.go":29
var yyt1 int;var yyt2 int;var yyt3 int;var yyt4 int;
//line "go/submatch/01_stags.re":21


	
//line "go/submatch/01_stags.go":35
{
	var yych byte
	yych = yyinput[yycursor]
	switch (yych) {
	case '0','1','2','3','4','5','6','7','8','9':
		yyt1 = yycursor
		goto yy3
	default:
		goto yy1
	}
yy1:
	yycursor += 1
yy2:
//line "go/submatch/01_stags.re":37
	{ return nil }
//line "go/submatch/01_stags.go":51
yy3:
	yycursor += 1
	yymarker = yycursor
	yych = yyinput[yycursor]
	switch (yych) {
	case '.':
		goto yy4
	case '0','1','2','3','4','5','6','7','8','9':
		goto yy6
	default:
		goto yy2
	}
yy4:
	yycursor += 1
	yych = yyinput[yycursor]
	switch (yych) {
	case '0','1','2','3','4','5','6','7','8','9':
		yyt2 = yycursor
		goto yy7
	default:
		goto yy5
	}
yy5:
	yycursor = yymarker
	goto yy2
yy6:
	yycursor += 1
	yych = yyinput[yycursor]
	switch (yych) {
	case '.':
		goto yy4
	case '0','1','2','3','4','5','6','7','8','9':
		goto yy6
	default:
		goto yy5
	}
yy7:
	yycursor += 1
	yych = yyinput[yycursor]
	switch (yych) {
	case 0x00:
		yyt3 = yycursor
		yyt4 = -1
		goto yy8
	case '.':
		yyt3 = yycursor
		goto yy9
	case '0','1','2','3','4','5','6','7','8','9':
		goto yy7
	default:
		goto yy5
	}
yy8:
	yycursor += 1
	t1 = yyt1
	t3 = yyt2
	t4 = yyt3
	t5 = yyt4
	t2 = yyt2
	t2 -= 1
//line "go/submatch/01_stags.re":30
	{
			major := s2n(yyinput[t1:t2])
			minor := s2n(yyinput[t3:t4])
			patch := 0
			if t5 != -1 { patch = s2n(yyinput[t5:yycursor-1]) }
			return &SemVer{major, minor, patch}
		}
//line "go/submatch/01_stags.go":120
yy9:
	yycursor += 1
	yych = yyinput[yycursor]
	switch (yych) {
	case '0','1','2','3','4','5','6','7','8','9':
		yyt4 = yycursor
		goto yy10
	default:
		goto yy5
	}
yy10:
	yycursor += 1
	yych = yyinput[yycursor]
	switch (yych) {
	case 0x00:
		goto yy8
	case '0','1','2','3','4','5','6','7','8','9':
		goto yy10
	default:
		goto yy5
	}
}
//line "go/submatch/01_stags.re":38

}

func main() {
	assert_eq := func(x, y *SemVer) {
		if !reflect.DeepEqual(x, y) { panic("error") }
	}
	assert_eq(parse("23.34\000"), &SemVer{23, 34, 0})
	assert_eq(parse("1.2.9999\000"), &SemVer{1, 2, 9999})
	assert_eq(parse("1.a\000"), nil)
}
