From 1e66aaece6ea7cd3c705ca56ce5558e8f87681b8 Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Sun, 21 Apr 2024 17:16:01 +0100 Subject: Add substitute next commands --- subex/parse.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'subex') 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} -- cgit v1.2.3