From db8800dcdac60a48ef4a4f084940581222e643ad Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Thu, 20 Apr 2023 12:33:04 +0100 Subject: Replaces the start and end terminals of strings with a single terminal, with " as a literal for it --- walk/walk.go | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'walk/walk.go') diff --git a/walk/walk.go b/walk/walk.go index 72fbe11..5c1ca75 100644 --- a/walk/walk.go +++ b/walk/walk.go @@ -99,22 +99,19 @@ func (value ValueNumber) String() string { } func (value ValueNumber) atomness() {} -type StartString struct {} -func (value StartString) atomness() {} - -type EndString struct {} -func (value EndString) atomness() {} +type StringTerminal struct {} +func (value StringTerminal) atomness() {} type StringAtom rune func (value StringAtom) atomness() {} type ValueString string func (value ValueString) Pieces(out chan<- Atom) { - out<-StartString{} + out<-StringTerminal{} for _, char := range value { out<-StringAtom(char) } - out<-EndString{} + out<-StringTerminal{} } func (value ValueString) String() string { return fmt.Sprintf("\"%s\"", string(value)) @@ -456,7 +453,6 @@ type CompoundError int const ( CompoundRuneOutsideString CompoundError = iota - CompoundEndStringOutsideString CompoundUnknownAtom CompoundMissingEnd CompoundInvalidStringAtom @@ -466,8 +462,6 @@ func (err CompoundError) Error() string { switch err { case CompoundRuneOutsideString: return "Compound Error: Rune Outside String" - case CompoundEndStringOutsideString: - return "Compound Error: End String Outside String" case CompoundUnknownAtom: return "Compound Error: Unknown Atom" case CompoundMissingEnd: @@ -508,10 +502,7 @@ func Compound(in <-chan Atom) <-chan CompoundResult { case StringAtom: out<-CompoundResult{nil, CompoundRuneOutsideString} break outer - case EndString: - out<-CompoundResult{nil, CompoundEndStringOutsideString} - break outer - case StartString: + case StringTerminal: default: out<-CompoundResult{nil, CompoundUnknownAtom} break outer @@ -525,7 +516,7 @@ func Compound(in <-chan Atom) <-chan CompoundResult { break outer } switch v := atom.(type) { - case EndString: + case StringTerminal: break loop case StringAtom: builder.WriteRune(rune(v)) -- cgit v1.2.3