<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/subex
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2024-04-21 17:16:01 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2024-04-21 17:16:01 +0100
commit1e66aaece6ea7cd3c705ca56ce5558e8f87681b8 (patch)
tree2fff87e4abfb0727e028854c006577eccfeee370 /subex
parent7162ae8c641314846f0b565d7614ac8d71dbd628 (diff)
downloadstred-go-1e66aaece6ea7cd3c705ca56ce5558e8f87681b8.tar
Add substitute next commands
Diffstat (limited to 'subex')
-rw-r--r--subex/parse.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/subex/parse.go b/subex/parse.go
index d825f75..b6bf2f6 100644
--- a/subex/parse.go
+++ b/subex/parse.go
@@ -516,7 +516,14 @@ func parseSubex(l RuneReader, minPower int, inType Type) (lhs SubexAST, outType
lhs = SubexASTCopyNumber{}
case '`':
outType = inType
- lhs = parseValueReplacement(l, '`')
+ switch inType {
+ case ValueType:
+ lhs = parseValueReplacement(l, '`')
+ case RuneType:
+ lhs = parseRuneReplacement(l, '`')
+ default:
+ panic("Invalid inType")
+ }
case ' ':
if inType == RuneType {
outType = RuneType
@@ -540,6 +547,7 @@ func parseSubex(l RuneReader, minPower int, inType Type) (lhs SubexAST, outType
loop: for {
if minPower <= 20 {
next, outType2 := parseSubex(l, 21, inType)
+ // TODO: next might legitimately be SubexASTEmpty, e.g. ``
if next != nil && (next != SubexASTEmpty{}) {
outType = resolveTypes(outType, outType2)
lhs = SubexASTConcat{lhs, next}