Update vendored hashicorp/hil

This commit is contained in:
Radek Simko 2016-02-07 20:43:23 +00:00
parent 8b3f4a82b0
commit d437ca5924
5 changed files with 173 additions and 104 deletions

2
Godeps/Godeps.json generated
View File

@ -499,7 +499,7 @@
},
{
"ImportPath": "github.com/hashicorp/hil",
"Rev": "075475a7408f16568f5cf79656dbcb053ac6196b"
"Rev": "42518c6f01625b5e6948a6a0e6a0792df126c548"
},
{
"ImportPath": "github.com/hashicorp/logutils",

View File

@ -122,6 +122,25 @@ expr:
Posx: $1.Pos,
}
}
| ARITH_OP expr
{
// This is REALLY jank. We assume that a singular ARITH_OP
// means 0 ARITH_OP expr, which... is weird. We don't want to
// support *, /, etc., only -. We should fix this later with a pure
// Go scanner/parser.
if $1.Value.(ast.ArithmeticOp) != ast.ArithmeticOpSub {
panic("Unary - is only allowed")
}
$$ = &ast.Arithmetic{
Op: $1.Value.(ast.ArithmeticOp),
Exprs: []ast.Node{
&ast.LiteralNode{Value: 0, Typex: ast.TypeInt},
$2,
},
Posx: $2.Pos(),
}
}
| expr ARITH_OP expr
{
$$ = &ast.Arithmetic{

View File

@ -6,7 +6,6 @@ import (
"github.com/hashicorp/hil/ast"
)
var parserErrors []error
var parserLock sync.Mutex
var parserResult ast.Node
@ -19,7 +18,6 @@ func Parse(v string) (ast.Node, error) {
defer parserLock.Unlock()
// Reset our globals
parserErrors = nil
parserResult = nil
// Create the lexer

82
vendor/github.com/hashicorp/hil/y.go generated vendored
View File

@ -53,7 +53,7 @@ const parserEofCode = 1
const parserErrCode = 2
const parserMaxDepth = 200
//line lang.y:165
//line lang.y:184
//line yacctab:1
var parserExca = [...]int{
@ -62,51 +62,52 @@ var parserExca = [...]int{
-2, 0,
}
const parserNprod = 19
const parserNprod = 20
const parserPrivate = 57344
var parserTokenNames []string
var parserStates []string
const parserLast = 30
const parserLast = 34
var parserAct = [...]int{
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,
9, 7, 3, 16, 22, 8, 17, 17, 20, 17,
1, 18, 6, 23, 8, 19, 25, 26, 21, 11,
2, 24, 7, 4, 5, 0, 10, 27, 0, 14,
15, 12, 13, 6,
}
var parserPact = [...]int{
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,
-3, -1000, -3, -1000, -1000, -1000, -1000, 18, -1000, -2,
18, -3, -1000, -1000, 18, 0, -1000, 18, -5, -1000,
18, -1000, -1000, 7, -4, -1000, 18, -4,
}
var parserPgo = [...]int{
0, 0, 29, 28, 23, 6, 27, 10,
0, 0, 24, 23, 19, 2, 13, 10,
}
var parserR1 = [...]int{
0, 7, 7, 4, 4, 5, 5, 2, 1, 1,
1, 1, 1, 1, 1, 6, 6, 6, 3,
1, 1, 1, 1, 1, 1, 6, 6, 6, 3,
}
var parserR2 = [...]int{
0, 0, 1, 1, 2, 1, 1, 3, 3, 1,
1, 1, 3, 1, 4, 0, 3, 1, 1,
1, 1, 2, 3, 1, 4, 0, 3, 1, 1,
}
var parserChk = [...]int{
-1000, -7, -4, -5, -3, -2, 15, 4, -5, -1,
8, -4, 13, 14, 12, 5, 11, -1, 8, -1,
9, -6, -1, 9, 10, -1,
8, -4, 13, 14, 11, 12, 5, 11, -1, -1,
8, -1, 9, -6, -1, 9, 10, -1,
}
var parserDef = [...]int{
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,
1, -2, 2, 3, 5, 6, 19, 0, 4, 0,
0, 9, 10, 11, 0, 14, 7, 0, 0, 12,
16, 13, 8, 0, 18, 15, 0, 17,
}
var parserTok1 = [...]int{
@ -567,8 +568,29 @@ parserdefault:
}
}
case 12:
parserDollar = parserS[parserpt-3 : parserpt+1]
parserDollar = parserS[parserpt-2 : parserpt+1]
//line lang.y:126
{
// This is REALLY jank. We assume that a singular ARITH_OP
// means 0 ARITH_OP expr, which... is weird. We don't want to
// support *, /, etc., only -. We should fix this later with a pure
// Go scanner/parser.
if parserDollar[1].token.Value.(ast.ArithmeticOp) != ast.ArithmeticOpSub {
panic("Unary - is only allowed")
}
parserVAL.node = &ast.Arithmetic{
Op: parserDollar[1].token.Value.(ast.ArithmeticOp),
Exprs: []ast.Node{
&ast.LiteralNode{Value: 0, Typex: ast.TypeInt},
parserDollar[2].node,
},
Posx: parserDollar[2].node.Pos(),
}
}
case 13:
parserDollar = parserS[parserpt-3 : parserpt+1]
//line lang.y:145
{
parserVAL.node = &ast.Arithmetic{
Op: parserDollar[2].token.Value.(ast.ArithmeticOp),
@ -576,39 +598,39 @@ parserdefault:
Posx: parserDollar[1].node.Pos(),
}
}
case 13:
case 14:
parserDollar = parserS[parserpt-1 : parserpt+1]
//line lang.y:134
//line lang.y:153
{
parserVAL.node = &ast.VariableAccess{Name: parserDollar[1].token.Value.(string), Posx: parserDollar[1].token.Pos}
}
case 14:
case 15:
parserDollar = parserS[parserpt-4 : parserpt+1]
//line lang.y:138
//line lang.y:157
{
parserVAL.node = &ast.Call{Func: parserDollar[1].token.Value.(string), Args: parserDollar[3].nodeList, Posx: parserDollar[1].token.Pos}
}
case 15:
case 16:
parserDollar = parserS[parserpt-0 : parserpt+1]
//line lang.y:143
//line lang.y:162
{
parserVAL.nodeList = nil
}
case 16:
case 17:
parserDollar = parserS[parserpt-3 : parserpt+1]
//line lang.y:147
//line lang.y:166
{
parserVAL.nodeList = append(parserDollar[1].nodeList, parserDollar[3].node)
}
case 17:
case 18:
parserDollar = parserS[parserpt-1 : parserpt+1]
//line lang.y:151
//line lang.y:170
{
parserVAL.nodeList = append(parserVAL.nodeList, parserDollar[1].node)
}
case 18:
case 19:
parserDollar = parserS[parserpt-1 : parserpt+1]
//line lang.y:157
//line lang.y:176
{
parserVAL.node = &ast.LiteralNode{
Value: parserDollar[1].token.Value.(string),

View File

@ -51,9 +51,9 @@ state 5
state 6
literal: STRING. (18)
literal: STRING. (19)
. reduce 18 (src line 155)
. reduce 19 (src line 174)
state 7
@ -61,7 +61,8 @@ state 7
PROGRAM_BRACKET_LEFT shift 7
PAREN_LEFT shift 10
IDENTIFIER shift 14
ARITH_OP shift 14
IDENTIFIER shift 15
INTEGER shift 12
FLOAT shift 13
STRING shift 6
@ -83,8 +84,8 @@ state 9
interpolation: PROGRAM_BRACKET_LEFT expr.PROGRAM_BRACKET_RIGHT
expr: expr.ARITH_OP expr
PROGRAM_BRACKET_RIGHT shift 15
ARITH_OP shift 16
PROGRAM_BRACKET_RIGHT shift 16
ARITH_OP shift 17
. error
@ -93,13 +94,14 @@ state 10
PROGRAM_BRACKET_LEFT shift 7
PAREN_LEFT shift 10
IDENTIFIER shift 14
ARITH_OP shift 14
IDENTIFIER shift 15
INTEGER shift 12
FLOAT shift 13
STRING shift 6
. error
expr goto 17
expr goto 18
interpolation goto 5
literal goto 4
literalModeTop goto 11
@ -130,25 +132,12 @@ state 13
state 14
expr: IDENTIFIER. (13)
expr: IDENTIFIER.PAREN_LEFT args PAREN_RIGHT
PAREN_LEFT shift 18
. reduce 13 (src line 133)
state 15
interpolation: PROGRAM_BRACKET_LEFT expr PROGRAM_BRACKET_RIGHT. (7)
. reduce 7 (src line 94)
state 16
expr: expr ARITH_OP.expr
expr: ARITH_OP.expr
PROGRAM_BRACKET_LEFT shift 7
PAREN_LEFT shift 10
IDENTIFIER shift 14
ARITH_OP shift 14
IDENTIFIER shift 15
INTEGER shift 12
FLOAT shift 13
STRING shift 6
@ -160,104 +149,145 @@ state 16
literalModeTop goto 11
literalModeValue goto 3
state 15
expr: IDENTIFIER. (14)
expr: IDENTIFIER.PAREN_LEFT args PAREN_RIGHT
PAREN_LEFT shift 20
. reduce 14 (src line 152)
state 16
interpolation: PROGRAM_BRACKET_LEFT expr PROGRAM_BRACKET_RIGHT. (7)
. reduce 7 (src line 94)
state 17
expr: PAREN_LEFT expr.PAREN_RIGHT
expr: expr.ARITH_OP expr
PAREN_RIGHT shift 20
ARITH_OP shift 16
. error
state 18
expr: IDENTIFIER PAREN_LEFT.args PAREN_RIGHT
args: . (15)
expr: expr ARITH_OP.expr
PROGRAM_BRACKET_LEFT shift 7
PAREN_LEFT shift 10
IDENTIFIER shift 14
ARITH_OP shift 14
IDENTIFIER shift 15
INTEGER shift 12
FLOAT shift 13
STRING shift 6
. reduce 15 (src line 142)
. error
expr goto 22
expr goto 21
interpolation goto 5
literal goto 4
literalModeTop goto 11
literalModeValue goto 3
args goto 21
state 18
expr: PAREN_LEFT expr.PAREN_RIGHT
expr: expr.ARITH_OP expr
PAREN_RIGHT shift 22
ARITH_OP shift 17
. error
state 19
expr: ARITH_OP expr. (12)
expr: expr.ARITH_OP expr
expr: expr ARITH_OP expr. (12)
. reduce 12 (src line 125)
state 20
expr: IDENTIFIER PAREN_LEFT.args PAREN_RIGHT
args: . (16)
PROGRAM_BRACKET_LEFT shift 7
PAREN_LEFT shift 10
ARITH_OP shift 14
IDENTIFIER shift 15
INTEGER shift 12
FLOAT shift 13
STRING shift 6
. reduce 16 (src line 161)
expr goto 24
interpolation goto 5
literal goto 4
literalModeTop goto 11
literalModeValue goto 3
args goto 23
state 21
expr: expr.ARITH_OP expr
expr: expr ARITH_OP expr. (13)
. reduce 13 (src line 144)
state 22
expr: PAREN_LEFT expr PAREN_RIGHT. (8)
. reduce 8 (src line 100)
state 21
state 23
expr: IDENTIFIER PAREN_LEFT args.PAREN_RIGHT
args: args.COMMA expr
PAREN_RIGHT shift 23
COMMA shift 24
PAREN_RIGHT shift 25
COMMA shift 26
. error
state 22
expr: expr.ARITH_OP expr
args: expr. (17)
ARITH_OP shift 16
. reduce 17 (src line 150)
state 23
expr: IDENTIFIER PAREN_LEFT args PAREN_RIGHT. (14)
. reduce 14 (src line 137)
state 24
expr: expr.ARITH_OP expr
args: expr. (18)
ARITH_OP shift 17
. reduce 18 (src line 169)
state 25
expr: IDENTIFIER PAREN_LEFT args PAREN_RIGHT. (15)
. reduce 15 (src line 156)
state 26
args: args COMMA.expr
PROGRAM_BRACKET_LEFT shift 7
PAREN_LEFT shift 10
IDENTIFIER shift 14
ARITH_OP shift 14
IDENTIFIER shift 15
INTEGER shift 12
FLOAT shift 13
STRING shift 6
. error
expr goto 25
expr goto 27
interpolation goto 5
literal goto 4
literalModeTop goto 11
literalModeValue goto 3
state 25
state 27
expr: expr.ARITH_OP expr
args: args COMMA expr. (16)
args: args COMMA expr. (17)
ARITH_OP shift 16
. reduce 16 (src line 146)
ARITH_OP shift 17
. reduce 17 (src line 165)
15 terminals, 8 nonterminals
19 grammar rules, 26/2000 states
20 grammar rules, 28/2000 states
0 shift/reduce, 0 reduce/reduce conflicts reported
57 working sets used
memory: parser 35/30000
21 extra closures
45 shift entries, 1 exceptions
14 goto entries
23 entries saved by goto default
Optimizer space used: output 30/30000
30 table entries, 0 zero
maximum spread: 15, maximum offset: 24
memory: parser 40/30000
23 extra closures
57 shift entries, 1 exceptions
15 goto entries
27 entries saved by goto default
Optimizer space used: output 34/30000
34 table entries, 2 zero
maximum spread: 15, maximum offset: 26