2015-01-11 21:38:45 +01:00
|
|
|
//line lang.y:6
|
|
|
|
package lang
|
|
|
|
|
|
|
|
import __yyfmt__ "fmt"
|
|
|
|
|
|
|
|
//line lang.y:6
|
|
|
|
import (
|
|
|
|
"github.com/hashicorp/terraform/config/lang/ast"
|
|
|
|
)
|
|
|
|
|
|
|
|
//line lang.y:14
|
|
|
|
type parserSymType struct {
|
2015-01-11 22:03:37 +01:00
|
|
|
yys int
|
|
|
|
node ast.Node
|
|
|
|
nodeList []ast.Node
|
|
|
|
str string
|
2015-01-12 09:28:47 +01:00
|
|
|
token *parserToken
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
|
|
|
|
2015-01-12 09:28:47 +01:00
|
|
|
const PROGRAM_BRACKET_LEFT = 57346
|
|
|
|
const PROGRAM_BRACKET_RIGHT = 57347
|
|
|
|
const PROGRAM_STRING_START = 57348
|
|
|
|
const PROGRAM_STRING_END = 57349
|
|
|
|
const PAREN_LEFT = 57350
|
|
|
|
const PAREN_RIGHT = 57351
|
|
|
|
const COMMA = 57352
|
2015-02-26 20:32:39 +01:00
|
|
|
const ARITH_OP = 57353
|
|
|
|
const IDENTIFIER = 57354
|
|
|
|
const INTEGER = 57355
|
|
|
|
const FLOAT = 57356
|
|
|
|
const STRING = 57357
|
2015-01-11 21:38:45 +01:00
|
|
|
|
2015-10-28 17:17:14 +01:00
|
|
|
var parserToknames = [...]string{
|
|
|
|
"$end",
|
|
|
|
"error",
|
|
|
|
"$unk",
|
2015-01-11 21:38:45 +01:00
|
|
|
"PROGRAM_BRACKET_LEFT",
|
|
|
|
"PROGRAM_BRACKET_RIGHT",
|
2015-01-11 22:59:24 +01:00
|
|
|
"PROGRAM_STRING_START",
|
|
|
|
"PROGRAM_STRING_END",
|
2015-01-11 22:03:37 +01:00
|
|
|
"PAREN_LEFT",
|
|
|
|
"PAREN_RIGHT",
|
|
|
|
"COMMA",
|
2015-02-26 20:32:39 +01:00
|
|
|
"ARITH_OP",
|
2015-01-12 09:28:47 +01:00
|
|
|
"IDENTIFIER",
|
2015-01-12 17:53:27 +01:00
|
|
|
"INTEGER",
|
|
|
|
"FLOAT",
|
2015-01-12 09:28:47 +01:00
|
|
|
"STRING",
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
2015-10-28 17:17:14 +01:00
|
|
|
var parserStatenames = [...]string{}
|
2015-01-11 21:38:45 +01:00
|
|
|
|
|
|
|
const parserEofCode = 1
|
|
|
|
const parserErrCode = 2
|
|
|
|
const parserMaxDepth = 200
|
|
|
|
|
2015-02-26 23:39:04 +01:00
|
|
|
//line lang.y:165
|
2015-01-11 21:38:45 +01:00
|
|
|
|
|
|
|
//line yacctab:1
|
2015-10-28 17:17:14 +01:00
|
|
|
var parserExca = [...]int{
|
2015-01-11 21:38:45 +01:00
|
|
|
-1, 1,
|
|
|
|
1, -1,
|
|
|
|
-2, 0,
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:39:04 +01:00
|
|
|
const parserNprod = 19
|
2015-01-11 21:38:45 +01:00
|
|
|
const parserPrivate = 57344
|
|
|
|
|
|
|
|
var parserTokenNames []string
|
|
|
|
var parserStates []string
|
|
|
|
|
2015-02-26 23:39:04 +01:00
|
|
|
const parserLast = 30
|
2015-01-11 21:38:45 +01:00
|
|
|
|
2015-10-28 17:17:14 +01:00
|
|
|
var parserAct = [...]int{
|
2015-01-11 21:38:45 +01:00
|
|
|
|
2015-02-26 23:39:04 +01:00
|
|
|
9, 20, 16, 16, 7, 7, 3, 18, 10, 8,
|
|
|
|
1, 17, 14, 12, 13, 6, 6, 19, 8, 22,
|
|
|
|
15, 23, 24, 11, 2, 25, 16, 21, 4, 5,
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
2015-10-28 17:17:14 +01:00
|
|
|
var parserPact = [...]int{
|
2015-01-11 21:38:45 +01:00
|
|
|
|
2015-02-26 23:39:04 +01:00
|
|
|
1, -1000, 1, -1000, -1000, -1000, -1000, 0, -1000, 15,
|
|
|
|
0, 1, -1000, -1000, -1, -1000, 0, -8, 0, -1000,
|
|
|
|
-1000, 12, -9, -1000, 0, -9,
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
2015-10-28 17:17:14 +01:00
|
|
|
var parserPgo = [...]int{
|
2015-01-11 21:38:45 +01:00
|
|
|
|
2015-02-26 23:39:04 +01:00
|
|
|
0, 0, 29, 28, 23, 6, 27, 10,
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
2015-10-28 17:17:14 +01:00
|
|
|
var parserR1 = [...]int{
|
2015-01-11 21:38:45 +01:00
|
|
|
|
2015-02-26 23:26:14 +01:00
|
|
|
0, 7, 7, 4, 4, 5, 5, 2, 1, 1,
|
2015-02-26 23:39:04 +01:00
|
|
|
1, 1, 1, 1, 1, 6, 6, 6, 3,
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
2015-10-28 17:17:14 +01:00
|
|
|
var parserR2 = [...]int{
|
2015-01-11 21:38:45 +01:00
|
|
|
|
2015-02-26 23:39:04 +01:00
|
|
|
0, 0, 1, 1, 2, 1, 1, 3, 3, 1,
|
|
|
|
1, 1, 3, 1, 4, 0, 3, 1, 1,
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
2015-10-28 17:17:14 +01:00
|
|
|
var parserChk = [...]int{
|
2015-01-11 21:38:45 +01:00
|
|
|
|
2015-02-26 23:26:14 +01:00
|
|
|
-1000, -7, -4, -5, -3, -2, 15, 4, -5, -1,
|
2015-02-26 23:39:04 +01:00
|
|
|
8, -4, 13, 14, 12, 5, 11, -1, 8, -1,
|
|
|
|
9, -6, -1, 9, 10, -1,
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
2015-10-28 17:17:14 +01:00
|
|
|
var parserDef = [...]int{
|
2015-01-11 21:38:45 +01:00
|
|
|
|
2015-02-26 23:39:04 +01:00
|
|
|
1, -2, 2, 3, 5, 6, 18, 0, 4, 0,
|
|
|
|
0, 9, 10, 11, 13, 7, 0, 0, 15, 12,
|
|
|
|
8, 0, 17, 14, 0, 16,
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
2015-10-28 17:17:14 +01:00
|
|
|
var parserTok1 = [...]int{
|
2015-01-11 21:38:45 +01:00
|
|
|
|
|
|
|
1,
|
|
|
|
}
|
2015-10-28 17:17:14 +01:00
|
|
|
var parserTok2 = [...]int{
|
2015-01-11 21:38:45 +01:00
|
|
|
|
2015-01-11 22:59:24 +01:00
|
|
|
2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
2015-02-26 20:32:39 +01:00
|
|
|
12, 13, 14, 15,
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
2015-10-28 17:17:14 +01:00
|
|
|
var parserTok3 = [...]int{
|
2015-01-11 21:38:45 +01:00
|
|
|
0,
|
|
|
|
}
|
|
|
|
|
2015-10-28 17:17:14 +01:00
|
|
|
var parserErrorMessages = [...]struct {
|
|
|
|
state int
|
|
|
|
token int
|
|
|
|
msg string
|
|
|
|
}{}
|
|
|
|
|
2015-01-11 21:38:45 +01:00
|
|
|
//line yaccpar:1
|
|
|
|
|
|
|
|
/* parser for yacc output */
|
|
|
|
|
2015-10-28 17:17:14 +01:00
|
|
|
var (
|
|
|
|
parserDebug = 0
|
|
|
|
parserErrorVerbose = false
|
|
|
|
)
|
2015-01-11 21:38:45 +01:00
|
|
|
|
|
|
|
type parserLexer interface {
|
|
|
|
Lex(lval *parserSymType) int
|
|
|
|
Error(s string)
|
|
|
|
}
|
|
|
|
|
2015-10-28 17:17:14 +01:00
|
|
|
type parserParser interface {
|
|
|
|
Parse(parserLexer) int
|
|
|
|
Lookahead() int
|
|
|
|
}
|
|
|
|
|
|
|
|
type parserParserImpl struct {
|
|
|
|
lookahead func() int
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *parserParserImpl) Lookahead() int {
|
|
|
|
return p.lookahead()
|
|
|
|
}
|
|
|
|
|
|
|
|
func parserNewParser() parserParser {
|
|
|
|
p := &parserParserImpl{
|
|
|
|
lookahead: func() int { return -1 },
|
|
|
|
}
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
2015-01-11 21:38:45 +01:00
|
|
|
const parserFlag = -1000
|
|
|
|
|
|
|
|
func parserTokname(c int) string {
|
2015-10-28 17:17:14 +01:00
|
|
|
if c >= 1 && c-1 < len(parserToknames) {
|
|
|
|
if parserToknames[c-1] != "" {
|
|
|
|
return parserToknames[c-1]
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return __yyfmt__.Sprintf("tok-%v", c)
|
|
|
|
}
|
|
|
|
|
|
|
|
func parserStatname(s int) string {
|
|
|
|
if s >= 0 && s < len(parserStatenames) {
|
|
|
|
if parserStatenames[s] != "" {
|
|
|
|
return parserStatenames[s]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return __yyfmt__.Sprintf("state-%v", s)
|
|
|
|
}
|
|
|
|
|
2015-10-28 17:17:14 +01:00
|
|
|
func parserErrorMessage(state, lookAhead int) string {
|
|
|
|
const TOKSTART = 4
|
|
|
|
|
|
|
|
if !parserErrorVerbose {
|
|
|
|
return "syntax error"
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, e := range parserErrorMessages {
|
|
|
|
if e.state == state && e.token == lookAhead {
|
|
|
|
return "syntax error: " + e.msg
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
res := "syntax error: unexpected " + parserTokname(lookAhead)
|
|
|
|
|
|
|
|
// To match Bison, suggest at most four expected tokens.
|
|
|
|
expected := make([]int, 0, 4)
|
|
|
|
|
|
|
|
// Look for shiftable tokens.
|
|
|
|
base := parserPact[state]
|
|
|
|
for tok := TOKSTART; tok-1 < len(parserToknames); tok++ {
|
|
|
|
if n := base + tok; n >= 0 && n < parserLast && parserChk[parserAct[n]] == tok {
|
|
|
|
if len(expected) == cap(expected) {
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
expected = append(expected, tok)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if parserDef[state] == -2 {
|
|
|
|
i := 0
|
|
|
|
for parserExca[i] != -1 || parserExca[i+1] != state {
|
|
|
|
i += 2
|
|
|
|
}
|
|
|
|
|
|
|
|
// Look for tokens that we accept or reduce.
|
|
|
|
for i += 2; parserExca[i] >= 0; i += 2 {
|
|
|
|
tok := parserExca[i]
|
|
|
|
if tok < TOKSTART || parserExca[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 parserExca[i+1] != 0 {
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, tok := range expected {
|
|
|
|
if i == 0 {
|
|
|
|
res += ", expecting "
|
|
|
|
} else {
|
|
|
|
res += " or "
|
|
|
|
}
|
|
|
|
res += parserTokname(tok)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
func parserlex1(lex parserLexer, lval *parserSymType) (char, token int) {
|
|
|
|
token = 0
|
|
|
|
char = lex.Lex(lval)
|
2015-01-11 21:38:45 +01:00
|
|
|
if char <= 0 {
|
2015-10-28 17:17:14 +01:00
|
|
|
token = parserTok1[0]
|
2015-01-11 21:38:45 +01:00
|
|
|
goto out
|
|
|
|
}
|
|
|
|
if char < len(parserTok1) {
|
2015-10-28 17:17:14 +01:00
|
|
|
token = parserTok1[char]
|
2015-01-11 21:38:45 +01:00
|
|
|
goto out
|
|
|
|
}
|
|
|
|
if char >= parserPrivate {
|
|
|
|
if char < parserPrivate+len(parserTok2) {
|
2015-10-28 17:17:14 +01:00
|
|
|
token = parserTok2[char-parserPrivate]
|
2015-01-11 21:38:45 +01:00
|
|
|
goto out
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for i := 0; i < len(parserTok3); i += 2 {
|
2015-10-28 17:17:14 +01:00
|
|
|
token = parserTok3[i+0]
|
|
|
|
if token == char {
|
|
|
|
token = parserTok3[i+1]
|
2015-01-11 21:38:45 +01:00
|
|
|
goto out
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
2015-10-28 17:17:14 +01:00
|
|
|
if token == 0 {
|
|
|
|
token = parserTok2[1] /* unknown char */
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
|
|
|
if parserDebug >= 3 {
|
2015-10-28 17:17:14 +01:00
|
|
|
__yyfmt__.Printf("lex %s(%d)\n", parserTokname(token), uint(char))
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
2015-10-28 17:17:14 +01:00
|
|
|
return char, token
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func parserParse(parserlex parserLexer) int {
|
2015-10-28 17:17:14 +01:00
|
|
|
return parserNewParser().Parse(parserlex)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (parserrcvr *parserParserImpl) Parse(parserlex parserLexer) int {
|
2015-01-11 21:38:45 +01:00
|
|
|
var parsern int
|
|
|
|
var parserlval parserSymType
|
|
|
|
var parserVAL parserSymType
|
2015-10-28 17:17:14 +01:00
|
|
|
var parserDollar []parserSymType
|
|
|
|
_ = parserDollar // silence set and not used
|
2015-01-11 21:38:45 +01:00
|
|
|
parserS := make([]parserSymType, parserMaxDepth)
|
|
|
|
|
|
|
|
Nerrs := 0 /* number of errors */
|
|
|
|
Errflag := 0 /* error recovery flag */
|
|
|
|
parserstate := 0
|
|
|
|
parserchar := -1
|
2015-10-28 17:17:14 +01:00
|
|
|
parsertoken := -1 // parserchar translated into internal numbering
|
|
|
|
parserrcvr.lookahead = func() int { return parserchar }
|
|
|
|
defer func() {
|
|
|
|
// Make sure we report no lookahead when not parsing.
|
|
|
|
parserstate = -1
|
|
|
|
parserchar = -1
|
|
|
|
parsertoken = -1
|
|
|
|
}()
|
2015-01-11 21:38:45 +01:00
|
|
|
parserp := -1
|
|
|
|
goto parserstack
|
|
|
|
|
|
|
|
ret0:
|
|
|
|
return 0
|
|
|
|
|
|
|
|
ret1:
|
|
|
|
return 1
|
|
|
|
|
|
|
|
parserstack:
|
|
|
|
/* put a state and value onto the stack */
|
|
|
|
if parserDebug >= 4 {
|
2015-10-28 17:17:14 +01:00
|
|
|
__yyfmt__.Printf("char %v in %v\n", parserTokname(parsertoken), parserStatname(parserstate))
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
parserp++
|
|
|
|
if parserp >= len(parserS) {
|
|
|
|
nyys := make([]parserSymType, len(parserS)*2)
|
|
|
|
copy(nyys, parserS)
|
|
|
|
parserS = nyys
|
|
|
|
}
|
|
|
|
parserS[parserp] = parserVAL
|
|
|
|
parserS[parserp].yys = parserstate
|
|
|
|
|
|
|
|
parsernewstate:
|
|
|
|
parsern = parserPact[parserstate]
|
|
|
|
if parsern <= parserFlag {
|
|
|
|
goto parserdefault /* simple state */
|
|
|
|
}
|
|
|
|
if parserchar < 0 {
|
2015-10-28 17:17:14 +01:00
|
|
|
parserchar, parsertoken = parserlex1(parserlex, &parserlval)
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
2015-10-28 17:17:14 +01:00
|
|
|
parsern += parsertoken
|
2015-01-11 21:38:45 +01:00
|
|
|
if parsern < 0 || parsern >= parserLast {
|
|
|
|
goto parserdefault
|
|
|
|
}
|
|
|
|
parsern = parserAct[parsern]
|
2015-10-28 17:17:14 +01:00
|
|
|
if parserChk[parsern] == parsertoken { /* valid shift */
|
2015-01-11 21:38:45 +01:00
|
|
|
parserchar = -1
|
2015-10-28 17:17:14 +01:00
|
|
|
parsertoken = -1
|
2015-01-11 21:38:45 +01:00
|
|
|
parserVAL = parserlval
|
|
|
|
parserstate = parsern
|
|
|
|
if Errflag > 0 {
|
|
|
|
Errflag--
|
|
|
|
}
|
|
|
|
goto parserstack
|
|
|
|
}
|
|
|
|
|
|
|
|
parserdefault:
|
|
|
|
/* default state action */
|
|
|
|
parsern = parserDef[parserstate]
|
|
|
|
if parsern == -2 {
|
|
|
|
if parserchar < 0 {
|
2015-10-28 17:17:14 +01:00
|
|
|
parserchar, parsertoken = parserlex1(parserlex, &parserlval)
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* look through exception table */
|
|
|
|
xi := 0
|
|
|
|
for {
|
|
|
|
if parserExca[xi+0] == -1 && parserExca[xi+1] == parserstate {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
xi += 2
|
|
|
|
}
|
|
|
|
for xi += 2; ; xi += 2 {
|
|
|
|
parsern = parserExca[xi+0]
|
2015-10-28 17:17:14 +01:00
|
|
|
if parsern < 0 || parsern == parsertoken {
|
2015-01-11 21:38:45 +01:00
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
parsern = parserExca[xi+1]
|
|
|
|
if parsern < 0 {
|
|
|
|
goto ret0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if parsern == 0 {
|
|
|
|
/* error ... attempt to resume parsing */
|
|
|
|
switch Errflag {
|
|
|
|
case 0: /* brand new error */
|
2015-10-28 17:17:14 +01:00
|
|
|
parserlex.Error(parserErrorMessage(parserstate, parsertoken))
|
2015-01-11 21:38:45 +01:00
|
|
|
Nerrs++
|
|
|
|
if parserDebug >= 1 {
|
|
|
|
__yyfmt__.Printf("%s", parserStatname(parserstate))
|
2015-10-28 17:17:14 +01:00
|
|
|
__yyfmt__.Printf(" saw %s\n", parserTokname(parsertoken))
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
|
|
|
|
case 1, 2: /* incompletely recovered error ... try again */
|
|
|
|
Errflag = 3
|
|
|
|
|
|
|
|
/* find a state where "error" is a legal shift action */
|
|
|
|
for parserp >= 0 {
|
|
|
|
parsern = parserPact[parserS[parserp].yys] + parserErrCode
|
|
|
|
if parsern >= 0 && parsern < parserLast {
|
|
|
|
parserstate = parserAct[parsern] /* simulate a shift of "error" */
|
|
|
|
if parserChk[parserstate] == parserErrCode {
|
|
|
|
goto parserstack
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the current p has no shift on "error", pop stack */
|
|
|
|
if parserDebug >= 2 {
|
|
|
|
__yyfmt__.Printf("error recovery pops state %d\n", parserS[parserp].yys)
|
|
|
|
}
|
|
|
|
parserp--
|
|
|
|
}
|
|
|
|
/* there is no state on the stack with an error shift ... abort */
|
|
|
|
goto ret1
|
|
|
|
|
|
|
|
case 3: /* no shift yet; clobber input char */
|
|
|
|
if parserDebug >= 2 {
|
2015-10-28 17:17:14 +01:00
|
|
|
__yyfmt__.Printf("error recovery discards %s\n", parserTokname(parsertoken))
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
2015-10-28 17:17:14 +01:00
|
|
|
if parsertoken == parserEofCode {
|
2015-01-11 21:38:45 +01:00
|
|
|
goto ret1
|
|
|
|
}
|
|
|
|
parserchar = -1
|
2015-10-28 17:17:14 +01:00
|
|
|
parsertoken = -1
|
2015-01-11 21:38:45 +01:00
|
|
|
goto parsernewstate /* try again in the same state */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reduction by production parsern */
|
|
|
|
if parserDebug >= 2 {
|
|
|
|
__yyfmt__.Printf("reduce %v in:\n\t%v\n", parsern, parserStatname(parserstate))
|
|
|
|
}
|
|
|
|
|
|
|
|
parsernt := parsern
|
|
|
|
parserpt := parserp
|
|
|
|
_ = parserpt // guard against "declared and not used"
|
|
|
|
|
|
|
|
parserp -= parserR2[parsern]
|
2015-10-28 17:17:14 +01:00
|
|
|
// parserp is now the index of $0. Perform the default action. Iff the
|
|
|
|
// reduced production is ε, $1 is possibly out of range.
|
|
|
|
if parserp+1 >= len(parserS) {
|
|
|
|
nyys := make([]parserSymType, len(parserS)*2)
|
|
|
|
copy(nyys, parserS)
|
|
|
|
parserS = nyys
|
|
|
|
}
|
2015-01-11 21:38:45 +01:00
|
|
|
parserVAL = parserS[parserp+1]
|
|
|
|
|
|
|
|
/* consult goto table to find next state */
|
|
|
|
parsern = parserR1[parsern]
|
|
|
|
parserg := parserPgo[parsern]
|
|
|
|
parserj := parserg + parserS[parserp].yys + 1
|
|
|
|
|
|
|
|
if parserj >= parserLast {
|
|
|
|
parserstate = parserAct[parserg]
|
|
|
|
} else {
|
|
|
|
parserstate = parserAct[parserj]
|
|
|
|
if parserChk[parserstate] != -parsern {
|
|
|
|
parserstate = parserAct[parserg]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// dummy call; replaced with literal code
|
|
|
|
switch parsernt {
|
|
|
|
|
|
|
|
case 1:
|
2015-10-28 17:17:14 +01:00
|
|
|
parserDollar = parserS[parserpt-0 : parserpt+1]
|
2015-02-26 23:33:56 +01:00
|
|
|
//line lang.y:35
|
2015-01-11 21:38:45 +01:00
|
|
|
{
|
2015-01-13 19:27:31 +01:00
|
|
|
parserResult = &ast.LiteralNode{
|
|
|
|
Value: "",
|
2015-01-15 05:58:46 +01:00
|
|
|
Typex: ast.TypeString,
|
2015-01-13 19:27:31 +01:00
|
|
|
Posx: ast.Pos{Column: 1, Line: 1},
|
|
|
|
}
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
|
|
|
case 2:
|
2015-10-28 17:17:14 +01:00
|
|
|
parserDollar = parserS[parserpt-1 : parserpt+1]
|
2015-02-26 23:33:56 +01:00
|
|
|
//line lang.y:43
|
2015-01-11 21:38:45 +01:00
|
|
|
{
|
2015-10-28 17:17:14 +01:00
|
|
|
parserResult = parserDollar[1].node
|
2015-01-14 21:18:51 +01:00
|
|
|
|
|
|
|
// We want to make sure that the top value is always a Concat
|
|
|
|
// so that the return value is always a string type from an
|
|
|
|
// interpolation.
|
|
|
|
//
|
|
|
|
// The logic for checking for a LiteralNode is a little annoying
|
|
|
|
// because functionally the AST is the same, but we do that because
|
|
|
|
// it makes for an easy literal check later (to check if a string
|
|
|
|
// has any interpolations).
|
2015-10-28 17:17:14 +01:00
|
|
|
if _, ok := parserDollar[1].node.(*ast.Concat); !ok {
|
|
|
|
if n, ok := parserDollar[1].node.(*ast.LiteralNode); !ok || n.Typex != ast.TypeString {
|
2015-01-14 21:18:51 +01:00
|
|
|
parserResult = &ast.Concat{
|
2015-10-28 17:17:14 +01:00
|
|
|
Exprs: []ast.Node{parserDollar[1].node},
|
|
|
|
Posx: parserDollar[1].node.Pos(),
|
2015-01-14 21:18:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
|
|
|
case 3:
|
2015-10-28 17:17:14 +01:00
|
|
|
parserDollar = parserS[parserpt-1 : parserpt+1]
|
2015-02-26 23:33:56 +01:00
|
|
|
//line lang.y:66
|
2015-01-13 19:27:31 +01:00
|
|
|
{
|
2015-10-28 17:17:14 +01:00
|
|
|
parserVAL.node = parserDollar[1].node
|
2015-01-13 19:27:31 +01:00
|
|
|
}
|
|
|
|
case 4:
|
2015-10-28 17:17:14 +01:00
|
|
|
parserDollar = parserS[parserpt-2 : parserpt+1]
|
2015-02-26 23:33:56 +01:00
|
|
|
//line lang.y:70
|
2015-01-11 21:38:45 +01:00
|
|
|
{
|
2015-01-11 22:59:24 +01:00
|
|
|
var result []ast.Node
|
2015-10-28 17:17:14 +01:00
|
|
|
if c, ok := parserDollar[1].node.(*ast.Concat); ok {
|
|
|
|
result = append(c.Exprs, parserDollar[2].node)
|
2015-01-11 22:59:24 +01:00
|
|
|
} else {
|
2015-10-28 17:17:14 +01:00
|
|
|
result = []ast.Node{parserDollar[1].node, parserDollar[2].node}
|
2015-01-11 22:59:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
parserVAL.node = &ast.Concat{
|
|
|
|
Exprs: result,
|
2015-01-12 09:28:47 +01:00
|
|
|
Posx: result[0].Pos(),
|
2015-01-11 22:03:37 +01:00
|
|
|
}
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
2015-01-13 19:27:31 +01:00
|
|
|
case 5:
|
2015-10-28 17:17:14 +01:00
|
|
|
parserDollar = parserS[parserpt-1 : parserpt+1]
|
2015-02-26 23:33:56 +01:00
|
|
|
//line lang.y:86
|
2015-01-11 21:38:45 +01:00
|
|
|
{
|
2015-10-28 17:17:14 +01:00
|
|
|
parserVAL.node = parserDollar[1].node
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
2015-01-13 19:27:31 +01:00
|
|
|
case 6:
|
2015-10-28 17:17:14 +01:00
|
|
|
parserDollar = parserS[parserpt-1 : parserpt+1]
|
2015-02-26 23:33:56 +01:00
|
|
|
//line lang.y:90
|
2015-01-11 21:38:45 +01:00
|
|
|
{
|
2015-10-28 17:17:14 +01:00
|
|
|
parserVAL.node = parserDollar[1].node
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
2015-01-13 19:27:31 +01:00
|
|
|
case 7:
|
2015-10-28 17:17:14 +01:00
|
|
|
parserDollar = parserS[parserpt-3 : parserpt+1]
|
2015-02-26 23:33:56 +01:00
|
|
|
//line lang.y:96
|
2015-01-11 22:03:37 +01:00
|
|
|
{
|
2015-10-28 17:17:14 +01:00
|
|
|
parserVAL.node = parserDollar[2].node
|
2015-01-11 22:03:37 +01:00
|
|
|
}
|
2015-01-13 19:27:31 +01:00
|
|
|
case 8:
|
2015-10-28 17:17:14 +01:00
|
|
|
parserDollar = parserS[parserpt-3 : parserpt+1]
|
2015-02-26 23:33:56 +01:00
|
|
|
//line lang.y:102
|
2015-01-11 22:03:37 +01:00
|
|
|
{
|
2015-10-28 17:17:14 +01:00
|
|
|
parserVAL.node = parserDollar[2].node
|
2015-01-11 22:03:37 +01:00
|
|
|
}
|
2015-01-13 19:27:31 +01:00
|
|
|
case 9:
|
2015-10-28 17:17:14 +01:00
|
|
|
parserDollar = parserS[parserpt-1 : parserpt+1]
|
2015-02-26 23:33:56 +01:00
|
|
|
//line lang.y:106
|
2015-02-26 23:39:04 +01:00
|
|
|
{
|
2015-10-28 17:17:14 +01:00
|
|
|
parserVAL.node = parserDollar[1].node
|
2015-02-26 23:39:04 +01:00
|
|
|
}
|
|
|
|
case 10:
|
2015-10-28 17:17:14 +01:00
|
|
|
parserDollar = parserS[parserpt-1 : parserpt+1]
|
2015-02-26 23:39:04 +01:00
|
|
|
//line lang.y:110
|
2015-01-11 22:03:37 +01:00
|
|
|
{
|
2015-01-12 17:53:27 +01:00
|
|
|
parserVAL.node = &ast.LiteralNode{
|
2015-10-28 17:17:14 +01:00
|
|
|
Value: parserDollar[1].token.Value.(int),
|
2015-01-15 05:58:46 +01:00
|
|
|
Typex: ast.TypeInt,
|
2015-10-28 17:17:14 +01:00
|
|
|
Posx: parserDollar[1].token.Pos,
|
2015-01-12 17:53:27 +01:00
|
|
|
}
|
2015-01-11 22:03:37 +01:00
|
|
|
}
|
2015-02-26 23:39:04 +01:00
|
|
|
case 11:
|
2015-10-28 17:17:14 +01:00
|
|
|
parserDollar = parserS[parserpt-1 : parserpt+1]
|
2015-02-26 23:39:04 +01:00
|
|
|
//line lang.y:118
|
2015-01-11 22:03:37 +01:00
|
|
|
{
|
2015-01-12 17:53:27 +01:00
|
|
|
parserVAL.node = &ast.LiteralNode{
|
2015-10-28 17:17:14 +01:00
|
|
|
Value: parserDollar[1].token.Value.(float64),
|
2015-01-15 05:58:46 +01:00
|
|
|
Typex: ast.TypeFloat,
|
2015-10-28 17:17:14 +01:00
|
|
|
Posx: parserDollar[1].token.Pos,
|
2015-01-12 17:53:27 +01:00
|
|
|
}
|
2015-01-11 22:03:37 +01:00
|
|
|
}
|
2015-02-26 23:39:04 +01:00
|
|
|
case 12:
|
2015-10-28 17:17:14 +01:00
|
|
|
parserDollar = parserS[parserpt-3 : parserpt+1]
|
2015-02-26 23:39:04 +01:00
|
|
|
//line lang.y:126
|
2015-01-11 22:03:37 +01:00
|
|
|
{
|
2015-02-26 23:26:14 +01:00
|
|
|
parserVAL.node = &ast.Arithmetic{
|
2015-10-28 17:17:14 +01:00
|
|
|
Op: parserDollar[2].token.Value.(ast.ArithmeticOp),
|
|
|
|
Exprs: []ast.Node{parserDollar[1].node, parserDollar[3].node},
|
|
|
|
Posx: parserDollar[1].node.Pos(),
|
2015-02-26 23:26:14 +01:00
|
|
|
}
|
2015-01-11 22:03:37 +01:00
|
|
|
}
|
2015-01-13 19:27:31 +01:00
|
|
|
case 13:
|
2015-10-28 17:17:14 +01:00
|
|
|
parserDollar = parserS[parserpt-1 : parserpt+1]
|
2015-02-26 23:33:56 +01:00
|
|
|
//line lang.y:134
|
2015-01-11 22:59:24 +01:00
|
|
|
{
|
2015-10-28 17:17:14 +01:00
|
|
|
parserVAL.node = &ast.VariableAccess{Name: parserDollar[1].token.Value.(string), Posx: parserDollar[1].token.Pos}
|
2015-01-11 22:59:24 +01:00
|
|
|
}
|
2015-01-13 19:27:31 +01:00
|
|
|
case 14:
|
2015-10-28 17:17:14 +01:00
|
|
|
parserDollar = parserS[parserpt-4 : parserpt+1]
|
2015-02-26 23:39:04 +01:00
|
|
|
//line lang.y:138
|
2015-01-12 17:53:27 +01:00
|
|
|
{
|
2015-10-28 17:17:14 +01:00
|
|
|
parserVAL.node = &ast.Call{Func: parserDollar[1].token.Value.(string), Args: parserDollar[3].nodeList, Posx: parserDollar[1].token.Pos}
|
2015-01-12 17:53:27 +01:00
|
|
|
}
|
2015-02-26 23:26:14 +01:00
|
|
|
case 15:
|
2015-10-28 17:17:14 +01:00
|
|
|
parserDollar = parserS[parserpt-0 : parserpt+1]
|
2015-02-26 23:33:56 +01:00
|
|
|
//line lang.y:143
|
2015-02-26 20:32:39 +01:00
|
|
|
{
|
2015-02-26 23:39:04 +01:00
|
|
|
parserVAL.nodeList = nil
|
2015-02-26 20:32:39 +01:00
|
|
|
}
|
2015-02-26 23:26:14 +01:00
|
|
|
case 16:
|
2015-10-28 17:17:14 +01:00
|
|
|
parserDollar = parserS[parserpt-3 : parserpt+1]
|
2015-02-26 23:33:56 +01:00
|
|
|
//line lang.y:147
|
2015-02-26 20:32:39 +01:00
|
|
|
{
|
2015-10-28 17:17:14 +01:00
|
|
|
parserVAL.nodeList = append(parserDollar[1].nodeList, parserDollar[3].node)
|
2015-02-26 20:32:39 +01:00
|
|
|
}
|
2015-02-26 23:26:14 +01:00
|
|
|
case 17:
|
2015-10-28 17:17:14 +01:00
|
|
|
parserDollar = parserS[parserpt-1 : parserpt+1]
|
2015-02-26 23:39:04 +01:00
|
|
|
//line lang.y:151
|
|
|
|
{
|
2015-10-28 17:17:14 +01:00
|
|
|
parserVAL.nodeList = append(parserVAL.nodeList, parserDollar[1].node)
|
2015-02-26 23:39:04 +01:00
|
|
|
}
|
|
|
|
case 18:
|
2015-10-28 17:17:14 +01:00
|
|
|
parserDollar = parserS[parserpt-1 : parserpt+1]
|
2015-02-26 23:39:04 +01:00
|
|
|
//line lang.y:157
|
2015-01-11 21:38:45 +01:00
|
|
|
{
|
2015-01-12 09:28:47 +01:00
|
|
|
parserVAL.node = &ast.LiteralNode{
|
2015-10-28 17:17:14 +01:00
|
|
|
Value: parserDollar[1].token.Value.(string),
|
2015-01-15 05:58:46 +01:00
|
|
|
Typex: ast.TypeString,
|
2015-10-28 17:17:14 +01:00
|
|
|
Posx: parserDollar[1].token.Pos,
|
2015-01-12 09:28:47 +01:00
|
|
|
}
|
2015-01-11 21:38:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
goto parserstack /* stack new state and value */
|
|
|
|
}
|