From 5089fe689f17a3489b6be76588b8fc7f93d70e55 Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Wed, 19 Apr 2023 14:13:32 +0100 Subject: Adds a dummy method to atom so the compiler checks that only valid atoms are allowed --- subex/parse.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'subex') 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 { -- cgit v1.2.3