<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/main/parse.go
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2023-04-20 14:20:28 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2023-04-20 14:20:28 +0100
commitc6d69701744c2b42b11680ae60f53c69bab1af63 (patch)
tree856c8efb3e08a4b967777cacde0c988b42a4731d /main/parse.go
parent651a2650eb7d7471e0903b210a97ed1b15b6fe77 (diff)
downloadstred-go-c6d69701744c2b42b11680ae60f53c69bab1af63.tar
Add a shorthand for subexes that start and end with `, ~, = or "
Diffstat (limited to 'main/parse.go')
-rw-r--r--main/parse.go8
1 files changed, 7 insertions, 1 deletions
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()