stred

Stred: Streaming Tree Editor. Like sed but for JSON
git clone http://shtanton.xyz/git/repo/stred
Log | Files | Refs

commit 44c5809b8c3af1be85d97673cc5a9585a65ef8f0
parent db8800dcdac60a48ef4a4f084940581222e643ad
Author: Charlie Stanton <charlie@shtanton.xyz>
Date:   Thu, 20 Apr 2023 13:57:09 +0100

Remove the @, ~ and # syntax for terminal literals

Diffstat:
Msubex/parse.go | 30------------------------------
1 file changed, 0 insertions(+), 30 deletions(-)

diff --git a/subex/parse.go b/subex/parse.go @@ -33,20 +33,6 @@ func expectBracket(l RuneReader, ifLeft walk.Atom, ifRight walk.Atom) walk.Atom } } -// Having just read termType, read in a bracket and return the corresponding Atom -func parseTerminatorAtomLiteral(termType rune, l RuneReader) walk.Atom { - switch termType { - case '@': - return expectBracket(l, walk.ArrayBegin, walk.ArrayEnd) - case '~': - return expectBracket(l, walk.StringTerminal{}, walk.StringTerminal{}) - case '#': - return expectBracket(l, walk.MapBegin, walk.MapEnd) - default: - return nil - } -} - func isNumericRune(r rune) bool { return '0' <= r && r <= '9' || r == '.' } @@ -186,8 +172,6 @@ func parseReplacement(l RuneReader) (output []OutputContent) { panic("Missing slot character") } output = append(output, OutputLoad{slot: slot}) - case '@', '~', '#': - output = append(output, OutputAtomLiteral{atom: parseTerminatorAtomLiteral(r, l)}) case '`': literals := parseNonStringLiteral(l) for _, literal := range literals { @@ -223,12 +207,6 @@ func parseRangeSubex(l RuneReader) map[walk.Atom]walk.Atom { } else if fromsStart == '"' { froms = append(froms, walk.StringTerminal{}) continue - } else { - atom := parseTerminatorAtomLiteral(fromsStart, l) - if atom != nil { - froms = append(froms, atom) - continue - } } if accept(l, "-") { fromsEnd := l.Next() @@ -260,12 +238,6 @@ func parseRangeSubex(l RuneReader) map[walk.Atom]walk.Atom { } else if tosStart == '"' { tos = append(tos, walk.StringTerminal{}) continue - } else { - atom := parseTerminatorAtomLiteral(tosStart, l) - if atom != nil { - tos = append(tos, atom) - continue - } } if accept(l, "-") { tosEnd := l.Next() @@ -317,8 +289,6 @@ func parseSubex(l RuneReader, minPower int) SubexAST { lhs = SubexASTCopyAny{} case '"': lhs = SubexASTCopyAtom {walk.StringTerminal{}} - case '@', '#', '~': - lhs = SubexASTCopyAtom{atom: parseTerminatorAtomLiteral(r, l)} case '`': literals := parseNonStringLiteral(l) lhs = SubexASTEmpty{}