diff options
author | Charlie Stanton <charlie@shtanton.xyz> | 2024-04-21 17:16:01 +0100 |
---|---|---|
committer | Charlie Stanton <charlie@shtanton.xyz> | 2024-04-21 17:16:01 +0100 |
commit | 1e66aaece6ea7cd3c705ca56ce5558e8f87681b8 (patch) | |
tree | 2fff87e4abfb0727e028854c006577eccfeee370 /subex | |
parent | 7162ae8c641314846f0b565d7614ac8d71dbd628 (diff) | |
download | stred-go-1e66aaece6ea7cd3c705ca56ce5558e8f87681b8.tar |
Add substitute next commands
Diffstat (limited to 'subex')
-rw-r--r-- | subex/parse.go | 10 |
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} |