<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/subex/parse.go
diff options
context:
space:
mode:
Diffstat (limited to 'subex/parse.go')
-rw-r--r--subex/parse.go40
1 files changed, 20 insertions, 20 deletions
diff --git a/subex/parse.go b/subex/parse.go
index 4e7a3f6..de53e2a 100644
--- a/subex/parse.go
+++ b/subex/parse.go
@@ -57,7 +57,7 @@ func parseNonStringLiteral(l RuneReader) (literals []walk.Atom) {
if err != nil {
panic("Invalid number literal")
}
- literals = append(literals, walk.ValueNumber(number))
+ literals = append(literals, walk.NewAtomNumber(number))
continue
}
switch r {
@@ -67,30 +67,30 @@ func parseNonStringLiteral(l RuneReader) (literals []walk.Atom) {
continue
case 'n':
if accept(l, "u") && accept(l, "l") && accept(l, "l") {
- literals = append(literals, walk.ValueNull{})
+ literals = append(literals, walk.NewAtomNull())
} else {
panic("Invalid literal")
}
case 't':
if accept(l, "r") && accept(l, "u") && accept(l, "e") {
- literals = append(literals, walk.ValueBool(true))
+ literals = append(literals, walk.NewAtomBool(true))
} else {
panic("Invalid literal")
}
case 'f':
if accept(l, "a") && accept(l, "l") && accept(l, "s") && accept(l, "e") {
- literals = append(literals, walk.ValueBool(false))
+ literals = append(literals, walk.NewAtomBool(false))
} else {
panic("Invalid literal")
}
case '{':
- literals = append(literals, walk.MapBegin)
+ literals = append(literals, walk.NewAtomTerminal(walk.MapBegin))
case '}':
- literals = append(literals, walk.MapEnd)
+ literals = append(literals, walk.NewAtomTerminal(walk.MapEnd))
case '[':
- literals = append(literals, walk.ArrayBegin)
+ literals = append(literals, walk.NewAtomTerminal(walk.ArrayBegin))
case ']':
- literals = append(literals, walk.ArrayEnd)
+ literals = append(literals, walk.NewAtomTerminal(walk.ArrayEnd))
default:
panic("Invalid literal")
}
@@ -180,9 +180,9 @@ func parseReplacement(l RuneReader) (output []OutputContent) {
output = append(output, OutputAtomLiteral {literal})
}
case '"':
- output = append(output, OutputAtomLiteral {walk.StringTerminal{}})
+ output = append(output, OutputAtomLiteral {walk.NewAtomStringTerminal()})
default:
- output = append(output, OutputAtomLiteral{atom: walk.StringAtom(r)})
+ output = append(output, OutputAtomLiteral{atom: walk.NewAtomStringRune(r)})
}
}
return output
@@ -207,7 +207,7 @@ func parseRangeSubex(l RuneReader) map[walk.Atom]walk.Atom {
froms = append(froms, literals...)
continue
} else if fromsStart == '"' {
- froms = append(froms, walk.StringTerminal{})
+ froms = append(froms, walk.NewAtomStringTerminal())
continue
}
if accept(l, "-") {
@@ -217,10 +217,10 @@ func parseRangeSubex(l RuneReader) map[walk.Atom]walk.Atom {
fromsEnd = fromsStart
}
for i := fromsStart; i <= fromsEnd; i += 1 {
- froms = append(froms, walk.StringAtom(i))
+ froms = append(froms, walk.NewAtomStringRune(i))
}
} else {
- froms = append(froms, walk.StringAtom(fromsStart))
+ froms = append(froms, walk.NewAtomStringRune(fromsStart))
}
}
if len(froms) == 0 {
@@ -238,7 +238,7 @@ func parseRangeSubex(l RuneReader) map[walk.Atom]walk.Atom {
tos = append(tos, literals...)
continue
} else if tosStart == '"' {
- tos = append(tos, walk.StringTerminal{})
+ tos = append(tos, walk.NewAtomStringTerminal())
continue
}
if accept(l, "-") {
@@ -248,10 +248,10 @@ func parseRangeSubex(l RuneReader) map[walk.Atom]walk.Atom {
tosEnd = tosStart
}
for i := tosStart; i <= tosEnd; i += 1 {
- tos = append(tos, walk.StringAtom(i))
+ tos = append(tos, walk.NewAtomStringRune(i))
}
} else {
- tos = append(tos, walk.StringAtom(tosStart))
+ tos = append(tos, walk.NewAtomStringRune(tosStart))
}
}
} else {
@@ -296,12 +296,12 @@ func parseSubex(l RuneReader, minPower int) SubexAST {
case '^':
replacement := parseReplacement(l)
replacement = append(
- []OutputContent{OutputAtomLiteral {walk.StringTerminal{}}},
+ []OutputContent{OutputAtomLiteral {walk.NewAtomStringTerminal()}},
replacement...
)
replacement = append(
replacement,
- OutputAtomLiteral {walk.StringTerminal{}},
+ OutputAtomLiteral {walk.NewAtomStringTerminal()},
)
lhs = SubexASTOutput {replacement}
case '.':
@@ -317,7 +317,7 @@ func parseSubex(l RuneReader, minPower int) SubexAST {
case ',':
lhs = SubexASTCopyValue{}
case '"':
- lhs = SubexASTCopyAtom {walk.StringTerminal{}}
+ lhs = SubexASTCopyAtom {walk.NewAtomStringTerminal()}
case '~':
literals := parseNonStringLiteral(l)
var replacement []OutputContent
@@ -326,7 +326,7 @@ func parseSubex(l RuneReader, minPower int) SubexAST {
}
lhs = SubexASTOutput {replacement}
default:
- lhs = SubexASTCopyAtom{Atom: walk.StringAtom(r)}
+ lhs = SubexASTCopyAtom{Atom: walk.NewAtomStringRune(r)}
}
loop: for {
if minPower <= 20 {