From c6d69701744c2b42b11680ae60f53c69bab1af63 Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Thu, 20 Apr 2023 14:20:28 +0100 Subject: Add a shorthand for subexes that start and end with `, ~, = or " --- main/parse.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main/parse.go b/main/parse.go index 7c87d15..ab22d93 100644 --- a/main/parse.go +++ b/main/parse.go @@ -42,7 +42,13 @@ func (p *parser) parseSubex() subex.SubexState { if subexProgramToken.typ != TokenSubex { panic("Missing subex from substitution") } - reader := subex.NewStringRuneReader(subexProgramToken.val) + var subexProgram string + if delim.val == "=" || delim.val == "~" || delim.val == "\"" || delim.val == "`" { + subexProgram = delim.val + subexProgramToken.val + delim.val + } else { + subexProgram = subexProgramToken.val + } + reader := subex.NewStringRuneReader(subexProgram) subexAST := subex.Parse(reader) subex := subex.CompileTransducer(subexAST) delim = p.next() -- cgit v1.2.3