hcl: continue to simplify hcl ast

This commit is contained in:
Mitchell Hashimoto 2014-08-03 22:02:57 -07:00
parent 783acc2aa1
commit 481bfbf3c0
2 changed files with 19 additions and 27 deletions

View File

@ -109,9 +109,7 @@ block:
{ {
$$ = ast.AssignmentNode{ $$ = ast.AssignmentNode{
K: $1, K: $1,
Value: ast.ListNode{ Value: $2,
Elem: []ast.Node{$2},
},
} }
} }
| blockId block | blockId block
@ -123,9 +121,7 @@ block:
$$ = ast.AssignmentNode{ $$ = ast.AssignmentNode{
K: $1, K: $1,
Value: ast.ListNode{ Value: obj,
Elem: []ast.Node{obj},
},
} }
} }

View File

@ -57,7 +57,7 @@ const hclEofCode = 1
const hclErrCode = 2 const hclErrCode = 2
const hclMaxDepth = 200 const hclMaxDepth = 200
//line parse.y:203 //line parse.y:199
//line yacctab:1 //line yacctab:1
var hclExca = []int{ var hclExca = []int{
@ -431,13 +431,11 @@ hcldefault:
{ {
hclVAL.aitem = ast.AssignmentNode{ hclVAL.aitem = ast.AssignmentNode{
K: hclS[hclpt-1].str, K: hclS[hclpt-1].str,
Value: ast.ListNode{ Value: hclS[hclpt-0].obj,
Elem: []ast.Node{hclS[hclpt-0].obj},
},
} }
} }
case 12: case 12:
//line parse.y:118 //line parse.y:116
{ {
obj := ast.ObjectNode{ obj := ast.ObjectNode{
K: hclS[hclpt-0].aitem.Key(), K: hclS[hclpt-0].aitem.Key(),
@ -446,38 +444,36 @@ hcldefault:
hclVAL.aitem = ast.AssignmentNode{ hclVAL.aitem = ast.AssignmentNode{
K: hclS[hclpt-1].str, K: hclS[hclpt-1].str,
Value: ast.ListNode{ Value: obj,
Elem: []ast.Node{obj},
},
} }
} }
case 13: case 13:
//line parse.y:134 //line parse.y:130
{ {
hclVAL.str = hclS[hclpt-0].str hclVAL.str = hclS[hclpt-0].str
} }
case 14: case 14:
//line parse.y:138 //line parse.y:134
{ {
hclVAL.str = hclS[hclpt-0].str hclVAL.str = hclS[hclpt-0].str
} }
case 15: case 15:
//line parse.y:144 //line parse.y:140
{ {
hclVAL.list = []ast.Node{hclS[hclpt-0].listitem} hclVAL.list = []ast.Node{hclS[hclpt-0].listitem}
} }
case 16: case 16:
//line parse.y:148 //line parse.y:144
{ {
hclVAL.list = append(hclS[hclpt-2].list, hclS[hclpt-0].listitem) hclVAL.list = append(hclS[hclpt-2].list, hclS[hclpt-0].listitem)
} }
case 17: case 17:
//line parse.y:154 //line parse.y:150
{ {
hclVAL.listitem = hclS[hclpt-0].item hclVAL.listitem = hclS[hclpt-0].item
} }
case 18: case 18:
//line parse.y:158 //line parse.y:154
{ {
hclVAL.listitem = ast.LiteralNode{ hclVAL.listitem = ast.LiteralNode{
Type: ast.ValueTypeString, Type: ast.ValueTypeString,
@ -485,7 +481,7 @@ hcldefault:
} }
} }
case 19: case 19:
//line parse.y:167 //line parse.y:163
{ {
hclVAL.item = ast.LiteralNode{ hclVAL.item = ast.LiteralNode{
Type: ast.ValueTypeInt, Type: ast.ValueTypeInt,
@ -493,7 +489,7 @@ hcldefault:
} }
} }
case 20: case 20:
//line parse.y:174 //line parse.y:170
{ {
fs := fmt.Sprintf("%d.%s", hclS[hclpt-1].num, hclS[hclpt-0].str) fs := fmt.Sprintf("%d.%s", hclS[hclpt-1].num, hclS[hclpt-0].str)
f, err := strconv.ParseFloat(fs, 64) f, err := strconv.ParseFloat(fs, 64)
@ -507,17 +503,17 @@ hcldefault:
} }
} }
case 21: case 21:
//line parse.y:189 //line parse.y:185
{ {
hclVAL.num = hclS[hclpt-0].num * -1 hclVAL.num = hclS[hclpt-0].num * -1
} }
case 22: case 22:
//line parse.y:193 //line parse.y:189
{ {
hclVAL.num = hclS[hclpt-0].num hclVAL.num = hclS[hclpt-0].num
} }
case 23: case 23:
//line parse.y:199 //line parse.y:195
{ {
hclVAL.str = strconv.FormatInt(int64(hclS[hclpt-0].num), 10) hclVAL.str = strconv.FormatInt(int64(hclS[hclpt-0].num), 10)
} }