<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/main/parse.go
diff options
context:
space:
mode:
Diffstat (limited to 'main/parse.go')
-rw-r--r--main/parse.go33
1 files changed, 17 insertions, 16 deletions
diff --git a/main/parse.go b/main/parse.go
index 5466a02..73c7913 100644
--- a/main/parse.go
+++ b/main/parse.go
@@ -4,6 +4,7 @@ import (
"strings"
"strconv"
"fmt"
+ "main/walk"
)
type parser struct {
@@ -130,9 +131,9 @@ func (p *parser) parseFilter(minPower int) Filter {
return lhs
}
-func (p *parser) parseLiterals() (items []WalkItem) {
- var path Path
- var value WalkValue
+func (p *parser) parseLiterals() (items []walk.WalkItem) {
+ var path walk.Path
+ var value walk.WalkValue
loop: for {
token := p.next()
switch token.typ {
@@ -141,17 +142,17 @@ func (p *parser) parseLiterals() (items []WalkItem) {
break loop
case TokenComma:
case TokenNullLiteral:
- value = ValueNull{}
+ value = walk.ValueNull{}
case TokenTrueLiteral:
- value = ValueBool(true)
+ value = walk.ValueBool(true)
case TokenFalseLiteral:
- value = ValueBool(false)
+ value = walk.ValueBool(false)
case TokenNumberLiteral:
numberLiteral, err := strconv.ParseFloat(token.val, 64)
if err != nil {
panic("Error parsing number literal to float64")
}
- value = ValueNumber(numberLiteral)
+ value = walk.ValueNumber(numberLiteral)
case TokenDoubleQuote:
stringToken := p.next()
if stringToken.typ != TokenStringLiteral {
@@ -167,29 +168,29 @@ func (p *parser) parseLiterals() (items []WalkItem) {
if path != nil {
panic("Expected value after path:")
}
- path = Path{stringLiteral}
+ path = walk.Path{stringLiteral}
} else {
p.rewind(colon)
- value = ValueString(stringLiteral)
+ value = walk.ValueString(stringLiteral)
}
case TokenTerminalLiteral:
switch token.val {
case "{":
- value = MapBegin
+ value = walk.MapBegin
case "}":
- value = MapEnd
+ value = walk.MapEnd
case "[":
- value = ArrayBegin
+ value = walk.ArrayBegin
case "]":
- value = ArrayEnd
+ value = walk.ArrayEnd
default:
panic("Invalid terminal token")
}
}
if value != nil {
- items = append(items, WalkItem {
- path: path,
- value: value,
+ items = append(items, walk.WalkItem {
+ Path: path,
+ Value: value,
})
path = nil
value = nil