From 481bfbf3c00fcd9b09c01db2a360d8804643207a Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 3 Aug 2014 22:02:57 -0700 Subject: [PATCH] hcl: continue to simplify hcl ast --- hcl/parse.y | 8 ++------ hcl/y.go | 38 +++++++++++++++++--------------------- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/hcl/parse.y b/hcl/parse.y index 07470fe..79789a0 100644 --- a/hcl/parse.y +++ b/hcl/parse.y @@ -109,9 +109,7 @@ block: { $$ = ast.AssignmentNode{ K: $1, - Value: ast.ListNode{ - Elem: []ast.Node{$2}, - }, + Value: $2, } } | blockId block @@ -123,9 +121,7 @@ block: $$ = ast.AssignmentNode{ K: $1, - Value: ast.ListNode{ - Elem: []ast.Node{obj}, - }, + Value: obj, } } diff --git a/hcl/y.go b/hcl/y.go index c7a81fb..8ac2a72 100644 --- a/hcl/y.go +++ b/hcl/y.go @@ -57,7 +57,7 @@ const hclEofCode = 1 const hclErrCode = 2 const hclMaxDepth = 200 -//line parse.y:203 +//line parse.y:199 //line yacctab:1 var hclExca = []int{ @@ -430,14 +430,12 @@ hcldefault: //line parse.y:109 { hclVAL.aitem = ast.AssignmentNode{ - K: hclS[hclpt-1].str, - Value: ast.ListNode{ - Elem: []ast.Node{hclS[hclpt-0].obj}, - }, + K: hclS[hclpt-1].str, + Value: hclS[hclpt-0].obj, } } case 12: - //line parse.y:118 + //line parse.y:116 { obj := ast.ObjectNode{ K: hclS[hclpt-0].aitem.Key(), @@ -445,39 +443,37 @@ hcldefault: } hclVAL.aitem = ast.AssignmentNode{ - K: hclS[hclpt-1].str, - Value: ast.ListNode{ - Elem: []ast.Node{obj}, - }, + K: hclS[hclpt-1].str, + Value: obj, } } case 13: - //line parse.y:134 + //line parse.y:130 { hclVAL.str = hclS[hclpt-0].str } case 14: - //line parse.y:138 + //line parse.y:134 { hclVAL.str = hclS[hclpt-0].str } case 15: - //line parse.y:144 + //line parse.y:140 { hclVAL.list = []ast.Node{hclS[hclpt-0].listitem} } case 16: - //line parse.y:148 + //line parse.y:144 { hclVAL.list = append(hclS[hclpt-2].list, hclS[hclpt-0].listitem) } case 17: - //line parse.y:154 + //line parse.y:150 { hclVAL.listitem = hclS[hclpt-0].item } case 18: - //line parse.y:158 + //line parse.y:154 { hclVAL.listitem = ast.LiteralNode{ Type: ast.ValueTypeString, @@ -485,7 +481,7 @@ hcldefault: } } case 19: - //line parse.y:167 + //line parse.y:163 { hclVAL.item = ast.LiteralNode{ Type: ast.ValueTypeInt, @@ -493,7 +489,7 @@ hcldefault: } } case 20: - //line parse.y:174 + //line parse.y:170 { fs := fmt.Sprintf("%d.%s", hclS[hclpt-1].num, hclS[hclpt-0].str) f, err := strconv.ParseFloat(fs, 64) @@ -507,17 +503,17 @@ hcldefault: } } case 21: - //line parse.y:189 + //line parse.y:185 { hclVAL.num = hclS[hclpt-0].num * -1 } case 22: - //line parse.y:193 + //line parse.y:189 { hclVAL.num = hclS[hclpt-0].num } case 23: - //line parse.y:199 + //line parse.y:195 { hclVAL.str = strconv.FormatInt(int64(hclS[hclpt-0].num), 10) }