<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/walk
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2023-04-20 12:33:04 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2023-04-20 12:33:04 +0100
commitdb8800dcdac60a48ef4a4f084940581222e643ad (patch)
treee2fa532501fbe03fec801262b4e286d4a8323a24 /walk
parent3d5730276b8866c3458f163f3050fe2daea259e3 (diff)
downloadstred-go-db8800dcdac60a48ef4a4f084940581222e643ad.tar
Replaces the start and end terminals of strings with a single terminal, with " as a literal for it
Diffstat (limited to 'walk')
-rw-r--r--walk/walk.go21
1 files changed, 6 insertions, 15 deletions
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))