// Code generated by goyacc sunrpc.y. DO NOT EDIT.

//line sunrpc.y:20
// Copyright 2017 The go-libvirt Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//
// Code generated by goyacc. DO NOT EDIT.
//
// To regenerate, run 'go generate' in internal/lvgen.
//

package lvgen

import __yyfmt__ "fmt"

//line sunrpc.y:40

import (
//"fmt"
)

//line sunrpc.y:49
type yySymType struct {
	yys int
	val string
}

const BOOL = 57346
const CASE = 57347
const CONST = 57348
const DEFAULT = 57349
const DOUBLE = 57350
const ENUM = 57351
const FLOAT = 57352
const OPAQUE = 57353
const STRING = 57354
const STRUCT = 57355
const SWITCH = 57356
const TYPEDEF = 57357
const UNION = 57358
const UNSIGNED = 57359
const VOID = 57360
const HYPER = 57361
const INT = 57362
const SHORT = 57363
const CHAR = 57364
const IDENTIFIER = 57365
const CONSTANT = 57366
const ERROR = 57367
const PROGRAM = 57368
const VERSION = 57369
const METADATACOMMENT = 57370
const PROCIDENTIFIER = 57371

var yyToknames = [...]string{
	"$end",
	"error",
	"$unk",
	"BOOL",
	"CASE",
	"CONST",
	"DEFAULT",
	"DOUBLE",
	"ENUM",
	"FLOAT",
	"OPAQUE",
	"STRING",
	"STRUCT",
	"SWITCH",
	"TYPEDEF",
	"UNION",
	"UNSIGNED",
	"VOID",
	"HYPER",
	"INT",
	"SHORT",
	"CHAR",
	"IDENTIFIER",
	"CONSTANT",
	"ERROR",
	"PROGRAM",
	"VERSION",
	"METADATACOMMENT",
	"PROCIDENTIFIER",
	"';'",
	"'{'",
	"'}'",
	"','",
	"'='",
	"'['",
	"']'",
	"'<'",
	"'>'",
	"'*'",
	"'('",
	"')'",
	"':'",
}

var yyStatenames = [...]string{}

const yyEofCode = 1
const yyErrCode = 2
const yyInitialStackSize = 16

//line sunrpc.y:279

//line yacctab:1
var yyExca = [...]int{
	-1, 1,
	1, -1,
	-2, 0,
}

const yyPrivate = 57344

const yyLast = 157

var yyAct = [...]int{
	89, 82, 36, 119, 111, 81, 64, 70, 32, 55,
	58, 137, 134, 136, 108, 125, 90, 91, 83, 66,
	37, 106, 78, 31, 79, 105, 139, 61, 123, 101,
	74, 96, 41, 93, 76, 65, 40, 10, 39, 43,
	42, 13, 75, 30, 14, 38, 126, 48, 49, 50,
	51, 47, 115, 97, 84, 73, 114, 103, 60, 67,
	54, 52, 29, 59, 61, 118, 142, 135, 127, 116,
	77, 98, 80, 85, 16, 72, 66, 92, 11, 94,
	95, 10, 90, 91, 88, 13, 100, 12, 14, 62,
	63, 87, 99, 102, 104, 69, 27, 25, 15, 23,
	20, 18, 110, 2, 107, 117, 113, 109, 48, 49,
	50, 51, 46, 8, 112, 45, 7, 44, 4, 113,
	28, 124, 128, 121, 130, 122, 86, 71, 131, 8,
	26, 132, 7, 129, 4, 133, 138, 120, 53, 140,
	141, 24, 68, 22, 35, 34, 33, 21, 19, 57,
	56, 17, 9, 6, 5, 3, 1,
}

var yyPact = [...]int{
	72, -1000, -1000, 44, -1000, -1000, -1000, -1000, -1000, -1000,
	78, 77, -1000, 76, 74, 73, 72, 31, -1000, 9,
	-1000, 28, 30, -1000, -1000, -1000, 29, -1000, -1000, 35,
	66, -1000, -1000, -1000, -1000, -1000, -4, -1000, 89, -1000,
	-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
	-1000, -1000, -1000, 81, 48, 23, -3, 8, 0, -2,
	-1000, -1000, -1000, -1000, -13, 53, -1000, -1000, 28, -22,
	22, 43, 68, -1000, 35, 59, 59, -1, 59, -7,
	-1000, 21, 41, 28, -5, 48, 26, -1000, -1000, -1000,
	-1000, -1000, -1000, 59, -11, -17, -1000, -1000, 28, -27,
	53, 59, -1000, 28, -1000, -1000, -1000, -1000, 25, -1000,
	-1000, 20, 39, 42, 118, -6, 28, -25, -1000, 14,
	38, 59, -1000, 59, -1000, 28, -1000, 118, -1000, -30,
	37, -28, -1000, -31, 28, -1000, -8, 28, -1000, 59,
	-1000, 36, -1000,
}

var yyPgo = [...]int{
	0, 156, 103, 0, 155, 117, 154, 153, 115, 112,
	152, 151, 9, 150, 149, 10, 148, 147, 1, 8,
	146, 145, 144, 2, 6, 20, 143, 142, 5, 141,
	138, 3, 137, 135, 133, 130, 7, 127, 126, 4,
	114, 105,
}

var yyR1 = [...]int{
	0, 1, 3, 3, 2, 2, 4, 4, 4, 4,
	4, 4, 5, 12, 12, 13, 13, 13, 13, 15,
	11, 14, 6, 6, 16, 17, 7, 18, 18, 18,
	18, 19, 23, 23, 23, 23, 23, 23, 23, 23,
	23, 23, 23, 25, 25, 25, 25, 24, 20, 21,
	21, 22, 27, 8, 26, 28, 28, 30, 9, 29,
	31, 31, 33, 32, 34, 32, 10, 35, 36, 36,
	37, 38, 39, 39, 40, 41,
}

var yyR2 = [...]int{
	0, 1, 1, 1, 2, 3, 1, 1, 1, 1,
	1, 1, 5, 1, 3, 1, 3, 3, 4, 1,
	1, 1, 4, 4, 1, 0, 3, 1, 1, 1,
	1, 2, 1, 2, 1, 1, 1, 1, 1, 1,
	1, 1, 1, 1, 1, 1, 1, 1, 5, 5,
	4, 3, 0, 6, 1, 2, 3, 0, 10, 1,
	2, 3, 0, 5, 0, 4, 7, 1, 2, 3,
	8, 1, 2, 3, 8, 1,
}

var yyChk = [...]int{
	-1000, -1, -2, -4, -5, -6, -7, -8, -9, -10,
	9, 6, 15, 13, 16, 26, 30, -11, 23, -16,
	23, -17, -26, 23, -29, 23, -35, 23, -2, 31,
	34, -18, -19, -20, -21, -22, -23, -25, 17, 10,
	8, 4, 12, 11, -5, -8, -9, 23, 19, 20,
	21, 22, 31, -30, 31, -12, -13, -14, -15, 28,
	23, 29, 23, 24, -24, 39, 23, -25, -27, 14,
	-36, -37, 27, 32, 33, 34, 34, -15, 35, 37,
	-24, -28, -18, 40, 32, 30, -38, 23, -12, -3,
	23, 24, -3, 34, -3, -3, 38, 32, 30, -19,
	-23, 34, -36, 31, -3, 36, 38, -28, 41, -24,
	-3, -39, -40, -23, 31, 32, 30, -41, 23, -31,
	-32, 5, 7, 34, -39, 40, 32, 30, -3, -34,
	-3, -23, -31, -33, 42, 30, 41, 42, -18, 34,
	-18, -3, 30,
}

var yyDef = [...]int{
	0, -2, 1, 0, 6, 7, 8, 9, 10, 11,
	0, 0, 25, 0, 0, 0, 4, 0, 20, 0,
	24, 0, 0, 54, 57, 59, 0, 67, 5, 0,
	0, 26, 27, 28, 29, 30, 0, 32, 0, 34,
	35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
	45, 46, 52, 0, 0, 0, 13, 15, 0, 0,
	21, 19, 22, 23, 31, 0, 47, 33, 0, 0,
	0, 0, 0, 12, 0, 0, 0, 0, 0, 0,
	51, 0, 0, 0, 0, 68, 0, 71, 14, 16,
	2, 3, 17, 0, 0, 0, 50, 53, 55, 0,
	0, 0, 69, 0, 18, 48, 49, 56, 0, 31,
	66, 0, 0, 0, 0, 0, 72, 0, 75, 0,
	0, 0, 64, 0, 73, 0, 58, 60, 62, 0,
	0, 0, 61, 0, 0, 70, 0, 0, 65, 0,
	63, 0, 74,
}

var yyTok1 = [...]int{
	1, 3, 3, 3, 3, 3, 3, 3, 3, 3,
	3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
	3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
	3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
	40, 41, 39, 3, 33, 3, 3, 3, 3, 3,
	3, 3, 3, 3, 3, 3, 3, 3, 42, 30,
	37, 34, 38, 3, 3, 3, 3, 3, 3, 3,
	3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
	3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
	3, 35, 3, 36, 3, 3, 3, 3, 3, 3,
	3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
	3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
	3, 3, 3, 31, 3, 32,
}

var yyTok2 = [...]int{
	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,
}

var yyTok3 = [...]int{
	0,
}

var yyErrorMessages = [...]struct {
	state int
	token int
	msg   string
}{}

//line yaccpar:1

/*	parser for yacc output	*/

var (
	yyDebug        = 0
	yyErrorVerbose = false
)

type yyLexer interface {
	Lex(lval *yySymType) int
	Error(s string)
}

type yyParser interface {
	Parse(yyLexer) int
	Lookahead() int
}

type yyParserImpl struct {
	lval  yySymType
	stack [yyInitialStackSize]yySymType
	char  int
}

func (p *yyParserImpl) Lookahead() int {
	return p.char
}

func yyNewParser() yyParser {
	return &yyParserImpl{}
}

const yyFlag = -1000

func yyTokname(c int) string {
	if c >= 1 && c-1 < len(yyToknames) {
		if yyToknames[c-1] != "" {
			return yyToknames[c-1]
		}
	}
	return __yyfmt__.Sprintf("tok-%v", c)
}

func yyStatname(s int) string {
	if s >= 0 && s < len(yyStatenames) {
		if yyStatenames[s] != "" {
			return yyStatenames[s]
		}
	}
	return __yyfmt__.Sprintf("state-%v", s)
}

func yyErrorMessage(state, lookAhead int) string {
	const TOKSTART = 4

	if !yyErrorVerbose {
		return "syntax error"
	}

	for _, e := range yyErrorMessages {
		if e.state == state && e.token == lookAhead {
			return "syntax error: " + e.msg
		}
	}

	res := "syntax error: unexpected " + yyTokname(lookAhead)

	// To match Bison, suggest at most four expected tokens.
	expected := make([]int, 0, 4)

	// Look for shiftable tokens.
	base := yyPact[state]
	for tok := TOKSTART; tok-1 < len(yyToknames); tok++ {
		if n := base + tok; n >= 0 && n < yyLast && yyChk[yyAct[n]] == tok {
			if len(expected) == cap(expected) {
				return res
			}
			expected = append(expected, tok)
		}
	}

	if yyDef[state] == -2 {
		i := 0
		for yyExca[i] != -1 || yyExca[i+1] != state {
			i += 2
		}

		// Look for tokens that we accept or reduce.
		for i += 2; yyExca[i] >= 0; i += 2 {
			tok := yyExca[i]
			if tok < TOKSTART || yyExca[i+1] == 0 {
				continue
			}
			if len(expected) == cap(expected) {
				return res
			}
			expected = append(expected, tok)
		}

		// If the default action is to accept or reduce, give up.
		if yyExca[i+1] != 0 {
			return res
		}
	}

	for i, tok := range expected {
		if i == 0 {
			res += ", expecting "
		} else {
			res += " or "
		}
		res += yyTokname(tok)
	}
	return res
}

func yylex1(lex yyLexer, lval *yySymType) (char, token int) {
	token = 0
	char = lex.Lex(lval)
	if char <= 0 {
		token = yyTok1[0]
		goto out
	}
	if char < len(yyTok1) {
		token = yyTok1[char]
		goto out
	}
	if char >= yyPrivate {
		if char < yyPrivate+len(yyTok2) {
			token = yyTok2[char-yyPrivate]
			goto out
		}
	}
	for i := 0; i < len(yyTok3); i += 2 {
		token = yyTok3[i+0]
		if token == char {
			token = yyTok3[i+1]
			goto out
		}
	}

out:
	if token == 0 {
		token = yyTok2[1] /* unknown char */
	}
	if yyDebug >= 3 {
		__yyfmt__.Printf("lex %s(%d)\n", yyTokname(token), uint(char))
	}
	return char, token
}

func yyParse(yylex yyLexer) int {
	return yyNewParser().Parse(yylex)
}

func (yyrcvr *yyParserImpl) Parse(yylex yyLexer) int {
	var yyn int
	var yyVAL yySymType
	var yyDollar []yySymType
	_ = yyDollar // silence set and not used
	yyS := yyrcvr.stack[:]

	Nerrs := 0   /* number of errors */
	Errflag := 0 /* error recovery flag */
	yystate := 0
	yyrcvr.char = -1
	yytoken := -1 // yyrcvr.char translated into internal numbering
	defer func() {
		// Make sure we report no lookahead when not parsing.
		yystate = -1
		yyrcvr.char = -1
		yytoken = -1
	}()
	yyp := -1
	goto yystack

ret0:
	return 0

ret1:
	return 1

yystack:
	/* put a state and value onto the stack */
	if yyDebug >= 4 {
		__yyfmt__.Printf("char %v in %v\n", yyTokname(yytoken), yyStatname(yystate))
	}

	yyp++
	if yyp >= len(yyS) {
		nyys := make([]yySymType, len(yyS)*2)
		copy(nyys, yyS)
		yyS = nyys
	}
	yyS[yyp] = yyVAL
	yyS[yyp].yys = yystate

yynewstate:
	yyn = yyPact[yystate]
	if yyn <= yyFlag {
		goto yydefault /* simple state */
	}
	if yyrcvr.char < 0 {
		yyrcvr.char, yytoken = yylex1(yylex, &yyrcvr.lval)
	}
	yyn += yytoken
	if yyn < 0 || yyn >= yyLast {
		goto yydefault
	}
	yyn = yyAct[yyn]
	if yyChk[yyn] == yytoken { /* valid shift */
		yyrcvr.char = -1
		yytoken = -1
		yyVAL = yyrcvr.lval
		yystate = yyn
		if Errflag > 0 {
			Errflag--
		}
		goto yystack
	}

yydefault:
	/* default state action */
	yyn = yyDef[yystate]
	if yyn == -2 {
		if yyrcvr.char < 0 {
			yyrcvr.char, yytoken = yylex1(yylex, &yyrcvr.lval)
		}

		/* look through exception table */
		xi := 0
		for {
			if yyExca[xi+0] == -1 && yyExca[xi+1] == yystate {
				break
			}
			xi += 2
		}
		for xi += 2; ; xi += 2 {
			yyn = yyExca[xi+0]
			if yyn < 0 || yyn == yytoken {
				break
			}
		}
		yyn = yyExca[xi+1]
		if yyn < 0 {
			goto ret0
		}
	}
	if yyn == 0 {
		/* error ... attempt to resume parsing */
		switch Errflag {
		case 0: /* brand new error */
			yylex.Error(yyErrorMessage(yystate, yytoken))
			Nerrs++
			if yyDebug >= 1 {
				__yyfmt__.Printf("%s", yyStatname(yystate))
				__yyfmt__.Printf(" saw %s\n", yyTokname(yytoken))
			}
			fallthrough

		case 1, 2: /* incompletely recovered error ... try again */
			Errflag = 3

			/* find a state where "error" is a legal shift action */
			for yyp >= 0 {
				yyn = yyPact[yyS[yyp].yys] + yyErrCode
				if yyn >= 0 && yyn < yyLast {
					yystate = yyAct[yyn] /* simulate a shift of "error" */
					if yyChk[yystate] == yyErrCode {
						goto yystack
					}
				}

				/* the current p has no shift on "error", pop stack */
				if yyDebug >= 2 {
					__yyfmt__.Printf("error recovery pops state %d\n", yyS[yyp].yys)
				}
				yyp--
			}
			/* there is no state on the stack with an error shift ... abort */
			goto ret1

		case 3: /* no shift yet; clobber input char */
			if yyDebug >= 2 {
				__yyfmt__.Printf("error recovery discards %s\n", yyTokname(yytoken))
			}
			if yytoken == yyEofCode {
				goto ret1
			}
			yyrcvr.char = -1
			yytoken = -1
			goto yynewstate /* try again in the same state */
		}
	}

	/* reduction by production yyn */
	if yyDebug >= 2 {
		__yyfmt__.Printf("reduce %v in:\n\t%v\n", yyn, yyStatname(yystate))
	}

	yynt := yyn
	yypt := yyp
	_ = yypt // guard against "declared and not used"

	yyp -= yyR2[yyn]
	// yyp is now the index of $0. Perform the default action. Iff the
	// reduced production is ε, $1 is possibly out of range.
	if yyp+1 >= len(yyS) {
		nyys := make([]yySymType, len(yyS)*2)
		copy(nyys, yyS)
		yyS = nyys
	}
	yyVAL = yyS[yyp+1]

	/* consult goto table to find next state */
	yyn = yyR1[yyn]
	yyg := yyPgo[yyn]
	yyj := yyg + yyS[yyp].yys + 1

	if yyj >= yyLast {
		yystate = yyAct[yyg]
	} else {
		yystate = yyAct[yyj]
		if yyChk[yystate] != -yyn {
			yystate = yyAct[yyg]
		}
	}
	// dummy call; replaced with literal code
	switch yynt {

	case 12:
		yyDollar = yyS[yypt-5 : yypt+1]
//line sunrpc.y:88
		{
			StartEnum(yyDollar[2].val)
		}
	case 15:
		yyDollar = yyS[yypt-1 : yypt+1]
//line sunrpc.y:97
		{
			err := AddEnumAutoVal(yyDollar[1].val)
			if err != nil {
				yylex.Error(err.Error())
				return 1
			}
		}
	case 16:
		yyDollar = yyS[yypt-3 : yypt+1]
//line sunrpc.y:104
		{
			err := AddEnumVal(yyDollar[1].val, yyDollar[3].val)
			if err != nil {
				yylex.Error(err.Error())
				return 1
			}
		}
	case 17:
		yyDollar = yyS[yypt-3 : yypt+1]
//line sunrpc.y:111
		{
			err := AddProcEnumVal(yyDollar[1].val, yyDollar[3].val, "")
			if err != nil {
				yylex.Error(err.Error())
				return 1
			}
		}
	case 18:
		yyDollar = yyS[yypt-4 : yypt+1]
//line sunrpc.y:118
		{
			err := AddProcEnumVal(yyDollar[2].val, yyDollar[4].val, yyDollar[1].val)
			if err != nil {
				yylex.Error(err.Error())
				return 1
			}
		}
	case 23:
		yyDollar = yyS[yypt-4 : yypt+1]
//line sunrpc.y:144
		{
			err := AddConst(yyDollar[2].val, yyDollar[4].val)
			if err != nil {
				yylex.Error(err.Error())
				return 1
			}
		}
	case 25:
		yyDollar = yyS[yypt-1 : yypt+1]
//line sunrpc.y:158
		{
			StartTypedef()
		}
	case 31:
		yyDollar = yyS[yypt-2 : yypt+1]
//line sunrpc.y:169
		{
			AddDeclaration(yyDollar[2].val, yyDollar[1].val)
		}
	case 33:
		yyDollar = yyS[yypt-2 : yypt+1]
//line sunrpc.y:174
		{
			yyVAL.val = "u" + yyDollar[2].val
		}
	case 34:
		yyDollar = yyS[yypt-1 : yypt+1]
//line sunrpc.y:175
		{
			yyVAL.val = "float32"
		}
	case 35:
		yyDollar = yyS[yypt-1 : yypt+1]
//line sunrpc.y:176
		{
			yyVAL.val = "float64"
		}
	case 36:
		yyDollar = yyS[yypt-1 : yypt+1]
//line sunrpc.y:177
		{
			yyVAL.val = "bool"
		}
	case 37:
		yyDollar = yyS[yypt-1 : yypt+1]
//line sunrpc.y:178
		{
			yyVAL.val = "string"
		}
	case 38:
		yyDollar = yyS[yypt-1 : yypt+1]
//line sunrpc.y:179
		{
			yyVAL.val = "byte"
		}
	case 43:
		yyDollar = yyS[yypt-1 : yypt+1]
//line sunrpc.y:187
		{
			yyVAL.val = "int64"
		}
	case 44:
		yyDollar = yyS[yypt-1 : yypt+1]
//line sunrpc.y:188
		{
			yyVAL.val = "int32"
		}
	case 45:
		yyDollar = yyS[yypt-1 : yypt+1]
//line sunrpc.y:189
		{
			yyVAL.val = "int16"
		}
	case 46:
		yyDollar = yyS[yypt-1 : yypt+1]
//line sunrpc.y:190
		{
			yyVAL.val = "int8"
		}
	case 48:
		yyDollar = yyS[yypt-5 : yypt+1]
//line sunrpc.y:198
		{
			AddFixedArray(yyDollar[2].val, yyDollar[1].val, yyDollar[4].val)
		}
	case 49:
		yyDollar = yyS[yypt-5 : yypt+1]
//line sunrpc.y:202
		{
			AddVariableArray(yyDollar[2].val, yyDollar[1].val, yyDollar[4].val)
		}
	case 50:
		yyDollar = yyS[yypt-4 : yypt+1]
//line sunrpc.y:203
		{
			AddVariableArray(yyDollar[2].val, yyDollar[1].val, "")
		}
	case 51:
		yyDollar = yyS[yypt-3 : yypt+1]
//line sunrpc.y:211
		{
			AddOptValue(yyDollar[3].val, yyDollar[1].val)
		}
	case 52:
		yyDollar = yyS[yypt-3 : yypt+1]
//line sunrpc.y:215
		{
			StartStruct(yyDollar[2].val)
		}
	case 53:
		yyDollar = yyS[yypt-6 : yypt+1]
//line sunrpc.y:215
		{
			AddStruct()
		}
	case 57:
		yyDollar = yyS[yypt-2 : yypt+1]
//line sunrpc.y:228
		{
			StartUnion(yyDollar[2].val)
		}
	case 58:
		yyDollar = yyS[yypt-10 : yypt+1]
//line sunrpc.y:228
		{
			AddUnion()
		}
	case 62:
		yyDollar = yyS[yypt-2 : yypt+1]
//line sunrpc.y:241
		{
			StartCase(yyDollar[2].val)
		}
	case 63:
		yyDollar = yyS[yypt-5 : yypt+1]
//line sunrpc.y:241
		{
			AddCase()
		}
	case 64:
		yyDollar = yyS[yypt-1 : yypt+1]
//line sunrpc.y:242
		{
			StartCase("default")
		}
	case 65:
		yyDollar = yyS[yypt-4 : yypt+1]
//line sunrpc.y:242
		{
			AddCase()
		}
	}
	goto yystack /* stack new state and value */
}
