From b193b9be8a8d26dcafbba5bf3deecf4c2070097f Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Tue, 11 Jul 2023 13:44:00 -0700 Subject: [PATCH] cleanup --- d2ast/d2ast.go | 6 ------ d2ir/compile.go | 6 ------ d2parser/parse.go | 3 --- .../TestCompile2/vars/basic/edge_label.exp.json | 2 +- .../TestCompile2/vars/basic/label.exp.json | 2 +- .../TestCompile2/vars/basic/nested.exp.json | 2 +- .../TestCompile2/vars/basic/number.exp.json | 11 +++++++---- .../TestCompile2/vars/basic/style.exp.json | 2 +- .../TestCompile2/vars/boards/layer.exp.json | 4 ++-- .../TestCompile2/vars/boards/overlay.exp.json | 16 ++++++++-------- .../TestCompile2/vars/boards/replace.exp.json | 4 ++-- .../TestCompile2/vars/boards/scenario.exp.json | 4 ++-- .../TestCompile2/vars/override/label.exp.json | 2 +- 13 files changed, 26 insertions(+), 38 deletions(-) diff --git a/d2ast/d2ast.go b/d2ast/d2ast.go index 25d325cf51..6313dbe0dc 100644 --- a/d2ast/d2ast.go +++ b/d2ast/d2ast.go @@ -423,7 +423,6 @@ func (s *BlockString) value() {} func (a *Array) value() {} func (m *Map) value() {} func (i *Import) value() {} -func (i *Substitution) value() {} func (n *Null) scalar() {} func (b *Boolean) scalar() {} @@ -924,7 +923,6 @@ type ValueBox struct { Array *Array `json:"array,omitempty"` Map *Map `json:"map,omitempty"` Import *Import `json:"import,omitempty"` - Substitution *Substitution `json:"substitution,omitempty"` } func (vb ValueBox) Unbox() Value { @@ -949,8 +947,6 @@ func (vb ValueBox) Unbox() Value { return vb.Map case vb.Import != nil: return vb.Import - case vb.Substitution != nil: - return vb.Substitution default: return nil } @@ -979,8 +975,6 @@ func MakeValueBox(v Value) ValueBox { vb.Map = v case *Import: vb.Import = v - case *Substitution: - vb.Substitution = v } return vb } diff --git a/d2ir/compile.go b/d2ir/compile.go index 4a7ef23c0b..9b880b767a 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -109,11 +109,6 @@ func (c *compiler) resolveSubstitutions(refctx *RefContext) { } switch { - case refctx.Key.Value.Substitution != nil: - resolvedField := c.resolveSubstitution(varsMap, refctx.Key, refctx.Key.Value.Substitution) - if resolvedField != nil { - refctx.Key.Value = d2ast.MakeValueBox(resolvedField.Primary().Value) - } case refctx.Key.Value.UnquotedString != nil: for i, box := range refctx.Key.Value.UnquotedString.Value { if box.Substitution != nil { @@ -245,7 +240,6 @@ func (c *compiler) compileMap(dst *Map, ast, scopeAST *d2ast.Map) { } func (c *compiler) compileKey(refctx *RefContext) { - // resolve substitutions here c.resolveSubstitutions(refctx) if len(refctx.Key.Edges) == 0 { c.compileField(refctx.ScopeMap, refctx.Key.Key, refctx) diff --git a/d2parser/parse.go b/d2parser/parse.go index 490505e4d2..fa64531a31 100644 --- a/d2parser/parse.go +++ b/d2parser/parse.go @@ -1596,9 +1596,6 @@ func (p *parser) parseValue() d2ast.ValueBox { case '@': box.Import = p.parseImport(false) return box - case '$': - box.Substitution = p.parseSubstitution(false) - return box } p.replay(r) diff --git a/testdata/d2compiler/TestCompile2/vars/basic/edge_label.exp.json b/testdata/d2compiler/TestCompile2/vars/basic/edge_label.exp.json index 9f1b92d8d8..f58e674290 100644 --- a/testdata/d2compiler/TestCompile2/vars/basic/edge_label.exp.json +++ b/testdata/d2compiler/TestCompile2/vars/basic/edge_label.exp.json @@ -111,7 +111,7 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/edge_label.d2,2:5:14-2:13:22", + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/edge_label.d2,4:8:33-4:9:34", "value": [ { "string": "im a var" diff --git a/testdata/d2compiler/TestCompile2/vars/basic/label.exp.json b/testdata/d2compiler/TestCompile2/vars/basic/label.exp.json index 3d376033f1..2e0d918a0a 100644 --- a/testdata/d2compiler/TestCompile2/vars/basic/label.exp.json +++ b/testdata/d2compiler/TestCompile2/vars/basic/label.exp.json @@ -88,7 +88,7 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/label.d2,2:5:14-2:13:22", + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/label.d2,4:4:29-4:5:30", "value": [ { "string": "im a var" diff --git a/testdata/d2compiler/TestCompile2/vars/basic/nested.exp.json b/testdata/d2compiler/TestCompile2/vars/basic/nested.exp.json index 37a8d38196..6fd7ef7619 100644 --- a/testdata/d2compiler/TestCompile2/vars/basic/nested.exp.json +++ b/testdata/d2compiler/TestCompile2/vars/basic/nested.exp.json @@ -181,7 +181,7 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/nested.d2,4:14:49-4:17:52", + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/nested.d2,9:14:85-9:15:86", "value": [ { "string": "red" diff --git a/testdata/d2compiler/TestCompile2/vars/basic/number.exp.json b/testdata/d2compiler/TestCompile2/vars/basic/number.exp.json index a7a5fb0e59..37d67c845d 100644 --- a/testdata/d2compiler/TestCompile2/vars/basic/number.exp.json +++ b/testdata/d2compiler/TestCompile2/vars/basic/number.exp.json @@ -108,10 +108,13 @@ }, "primary": {}, "value": { - "number": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/number.d2,2:10:19-2:11:20", - "raw": "2", - "value": "2" + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/number.d2,5:15:44-5:16:45", + "value": [ + { + "string": "2" + } + ] } } } diff --git a/testdata/d2compiler/TestCompile2/vars/basic/style.exp.json b/testdata/d2compiler/TestCompile2/vars/basic/style.exp.json index 43318c7222..47d41ae5d3 100644 --- a/testdata/d2compiler/TestCompile2/vars/basic/style.exp.json +++ b/testdata/d2compiler/TestCompile2/vars/basic/style.exp.json @@ -123,7 +123,7 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/style.d2,2:17:26-2:20:29", + "range": "d2/testdata/d2compiler/TestCompile2/vars/basic/style.d2,5:14:52-5:15:53", "value": [ { "string": "red" diff --git a/testdata/d2compiler/TestCompile2/vars/boards/layer.exp.json b/testdata/d2compiler/TestCompile2/vars/boards/layer.exp.json index 7bde70cfec..a489426334 100644 --- a/testdata/d2compiler/TestCompile2/vars/boards/layer.exp.json +++ b/testdata/d2compiler/TestCompile2/vars/boards/layer.exp.json @@ -136,7 +136,7 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/layer.d2,2:5:14-2:13:22", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/layer.d2,7:8:51-7:9:52", "value": [ { "string": "im a var" @@ -269,7 +269,7 @@ }, "primary": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/layer.d2,2:5:14-2:13:22", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/layer.d2,7:8:51-7:9:52", "value": [ { "string": "im a var" diff --git a/testdata/d2compiler/TestCompile2/vars/boards/overlay.exp.json b/testdata/d2compiler/TestCompile2/vars/boards/overlay.exp.json index 01550e52ad..24b73c55d9 100644 --- a/testdata/d2compiler/TestCompile2/vars/boards/overlay.exp.json +++ b/testdata/d2compiler/TestCompile2/vars/boards/overlay.exp.json @@ -197,7 +197,7 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,2:5:14-2:13:22", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,10:7:89-10:8:90", "value": [ { "string": "im x var" @@ -229,7 +229,7 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,8:9:67-8:17:75", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,11:7:101-11:8:102", "value": [ { "string": "im y var" @@ -380,7 +380,7 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,2:5:14-2:13:22", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,19:7:173-19:8:174", "value": [ { "string": "im x var" @@ -412,7 +412,7 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,17:9:151-17:17:159", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,20:7:185-20:8:186", "value": [ { "string": "im y var" @@ -576,7 +576,7 @@ }, "primary": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,2:5:14-2:13:22", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,19:7:173-19:8:174", "value": [ { "string": "im x var" @@ -607,7 +607,7 @@ }, "primary": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,17:9:151-17:17:159", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,20:7:185-20:8:186", "value": [ { "string": "im y var" @@ -855,7 +855,7 @@ }, "primary": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,2:5:14-2:13:22", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,10:7:89-10:8:90", "value": [ { "string": "im x var" @@ -886,7 +886,7 @@ }, "primary": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,8:9:67-8:17:75", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/overlay.d2,11:7:101-11:8:102", "value": [ { "string": "im y var" diff --git a/testdata/d2compiler/TestCompile2/vars/boards/replace.exp.json b/testdata/d2compiler/TestCompile2/vars/boards/replace.exp.json index ad2348046f..75089a991a 100644 --- a/testdata/d2compiler/TestCompile2/vars/boards/replace.exp.json +++ b/testdata/d2compiler/TestCompile2/vars/boards/replace.exp.json @@ -197,7 +197,7 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/replace.d2,8:9:67-8:26:84", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/replace.d2,10:7:98-10:8:99", "value": [ { "string": "im replaced x var" @@ -330,7 +330,7 @@ }, "primary": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/replace.d2,8:9:67-8:26:84", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/replace.d2,10:7:98-10:8:99", "value": [ { "string": "im replaced x var" diff --git a/testdata/d2compiler/TestCompile2/vars/boards/scenario.exp.json b/testdata/d2compiler/TestCompile2/vars/boards/scenario.exp.json index 8c02a62f5b..dbf4881e38 100644 --- a/testdata/d2compiler/TestCompile2/vars/boards/scenario.exp.json +++ b/testdata/d2compiler/TestCompile2/vars/boards/scenario.exp.json @@ -136,7 +136,7 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/scenario.d2,2:5:14-2:13:22", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/scenario.d2,7:8:54-7:9:55", "value": [ { "string": "im a var" @@ -269,7 +269,7 @@ }, "primary": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/scenario.d2,2:5:14-2:13:22", + "range": "d2/testdata/d2compiler/TestCompile2/vars/boards/scenario.d2,7:8:54-7:9:55", "value": [ { "string": "im a var" diff --git a/testdata/d2compiler/TestCompile2/vars/override/label.exp.json b/testdata/d2compiler/TestCompile2/vars/override/label.exp.json index 10ff44f21b..72267b6260 100644 --- a/testdata/d2compiler/TestCompile2/vars/override/label.exp.json +++ b/testdata/d2compiler/TestCompile2/vars/override/label.exp.json @@ -88,7 +88,7 @@ "primary": {}, "value": { "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile2/vars/override/label.d2,2:5:14-2:13:22", + "range": "d2/testdata/d2compiler/TestCompile2/vars/override/label.d2,4:4:29-4:5:30", "value": [ { "string": "im a var"