go fmt ./...
This commit is contained in:
parent
b307273223
commit
4bd9c94f82
@ -13,6 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type TokenType int
|
type TokenType int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
BareString TokenType = iota
|
BareString TokenType = iota
|
||||||
QuotedString
|
QuotedString
|
||||||
@ -199,7 +200,7 @@ func lexQuotedString(l *Lexer) lexerFunc {
|
|||||||
l.outbuf.WriteRune(r)
|
l.outbuf.WriteRune(r)
|
||||||
buf := l.outbuf.Bytes()
|
buf := l.outbuf.Bytes()
|
||||||
|
|
||||||
if r == '"' && buf[len(buf) - 2] != '\\' {
|
if r == '"' && buf[len(buf)-2] != '\\' {
|
||||||
l.emit(QuotedString)
|
l.emit(QuotedString)
|
||||||
return lexWhitespace
|
return lexWhitespace
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ package parse
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"strconv"
|
"strconv"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ func parseBareString(tok *lex.Token) types.Elem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if tok.Val[0] != ':' {
|
if tok.Val[0] != ':' {
|
||||||
return types.GoType{":"+tok.Val}
|
return types.GoType{":" + tok.Val}
|
||||||
}
|
}
|
||||||
|
|
||||||
return types.GoType{tok.Val}
|
return types.GoType{tok.Val}
|
||||||
@ -100,10 +100,10 @@ func (p *Parser) parseToken(tok *lex.Token) (types.Elem, error) {
|
|||||||
if tok.Val == "(" {
|
if tok.Val == "(" {
|
||||||
return seq.NewList(series...), nil
|
return seq.NewList(series...), nil
|
||||||
} else if tok.Val == "{" {
|
} else if tok.Val == "{" {
|
||||||
if len(series) % 2 != 0 {
|
if len(series)%2 != 0 {
|
||||||
return nil, fmt.Errorf("hash must have even number of elements")
|
return nil, fmt.Errorf("hash must have even number of elements")
|
||||||
}
|
}
|
||||||
kvs := make([]*seq.KV, 0, len(series) / 2)
|
kvs := make([]*seq.KV, 0, len(series)/2)
|
||||||
for i := 0; i < len(series); i += 2 {
|
for i := 0; i < len(series); i += 2 {
|
||||||
kv := seq.KV{series[i], series[i+1]}
|
kv := seq.KV{series[i], series[i+1]}
|
||||||
kvs = append(kvs, &kv)
|
kvs = append(kvs, &kv)
|
||||||
@ -118,7 +118,6 @@ func (p *Parser) parseToken(tok *lex.Token) (types.Elem, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (p *Parser) readUntil(closer string) ([]types.Elem, error) {
|
func (p *Parser) readUntil(closer string) ([]types.Elem, error) {
|
||||||
series := make([]types.Elem, 0, 4)
|
series := make([]types.Elem, 0, 4)
|
||||||
for {
|
for {
|
||||||
|
Loading…
Reference in New Issue
Block a user