<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/subex
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2023-04-19 14:13:32 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2023-04-19 14:13:32 +0100
commit5089fe689f17a3489b6be76588b8fc7f93d70e55 (patch)
treee3b6a09634deab4e46d832396ac7bd54704480b0 /subex
parentca161b26e9b6a253837e5ec4e0cf318bd0ee7903 (diff)
downloadstred-go-5089fe689f17a3489b6be76588b8fc7f93d70e55.tar
Adds a dummy method to atom so the compiler checks that only valid atoms are allowed
Diffstat (limited to 'subex')
-rw-r--r--subex/parse.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/subex/parse.go b/subex/parse.go
index 8b3a553..d6ef995 100644
--- a/subex/parse.go
+++ b/subex/parse.go
@@ -109,7 +109,7 @@ func parseReplacement(l *RuneReader) (output []OutputContent) {
case '@', '~', '#':
output = append(output, OutputAtomLiteral{atom: parseTerminatorAtomLiteral(r, l)})
default:
- output = append(output, OutputAtomLiteral{atom: r})
+ output = append(output, OutputAtomLiteral{atom: walk.StringAtom(r)})
}
}
return output
@@ -143,10 +143,10 @@ func parseRangeSubex(l *RuneReader) map[walk.Atom]walk.Atom {
fromsEnd = fromsStart
}
for i := fromsStart; i <= fromsEnd; i += 1 {
- froms = append(froms, i)
+ froms = append(froms, walk.StringAtom(i))
}
} else {
- froms = append(froms, fromsStart)
+ froms = append(froms, walk.StringAtom(fromsStart))
}
}
if len(froms) == 0 {
@@ -173,10 +173,10 @@ func parseRangeSubex(l *RuneReader) map[walk.Atom]walk.Atom {
tosEnd = tosStart
}
for i := tosStart; i <= tosEnd; i += 1 {
- tos = append(tos, i)
+ tos = append(tos, walk.StringAtom(i))
}
} else {
- tos = append(tos, tosStart)
+ tos = append(tos, walk.StringAtom(tosStart))
}
}
} else {
@@ -217,7 +217,7 @@ func parseSubex(l *RuneReader, minPower int) SubexAST {
case '@', '#', '~':
lhs = SubexASTCopyAtom{atom: parseTerminatorAtomLiteral(r, l)}
default:
- lhs = SubexASTCopyAtom{atom: r}
+ lhs = SubexASTCopyAtom{atom: walk.StringAtom(r)}
}
loop: for {
if minPower <= 0 {