summaryrefslogtreecommitdiff
path: root/conf
diff options
context:
space:
mode:
authorSilvan Jegen <s.jegen@gmail.com>2017-01-18 18:53:05 +0100
committerSilvan Jegen <s.jegen@gmail.com>2017-01-18 18:53:05 +0100
commit6dfe33a83a67d8fb9e431290e0c4ca86675f1b8f (patch)
tree3055ab07a779257cb6328cc185092431c941015a /conf
parent7acce76accb4d30e9968248bc4062dcac22fb9e3 (diff)
Don't loop in advanceOneToken
Diffstat (limited to 'conf')
-rw-r--r--conf/parser.go14
1 files changed, 5 insertions, 9 deletions
diff --git a/conf/parser.go b/conf/parser.go
index 3d584f6..b22e6aa 100644
--- a/conf/parser.go
+++ b/conf/parser.go
@@ -59,19 +59,15 @@ func (p *parser) advanceOneToken(place string) {
p.last = p.cur
p.cur, err = p.s.Scan()
- for err == nil {
- fmt.Fprintf(os.Stderr, "tokentype: %v, token: %q offset: %d, line: %d\n", p.cur.Type, p.cur.Lit, p.cur.Offset, p.cur.LineNr)
- p.last = p.cur
- p.cur, err = p.s.Scan()
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Error: tokentype: %v, token: %q, err: %v\n", p.cur.Type, p.cur.Lit, err)
}
- fmt.Fprintf(os.Stderr, "Error: tokentype: %v, token: %q, err: %v\n", p.cur.Type, p.cur.Lit, err)
+ fmt.Fprintf(os.Stderr, "tokentype: %v, token: %q\n", p.cur.Type, p.cur.Lit)
}
func (p *parser) module(firstname string) {
p.advanceOneToken("module")
- fmt.Fprintf(os.Stderr, "tokentype: %d, token: %q\n", p.cur.Type, p.cur.Lit)
-
if p.cur.Lit != firstname {
fmt.Fprintf(os.Stderr, "error when parsing module. We were expecting name %q but got %q at line %d offset %d.\n", firstname, p.cur.Lit, p.cur.LineNr, p.cur.Offset)
}
@@ -117,7 +113,7 @@ func (p *parser) object() {
func (p *parser) keyvalue() bool {
p.advanceOneToken("keyvalue")
- fmt.Fprintf(os.Stderr, "keyvalue: tokentype: %d, token: %q\n", p.cur.Type, p.cur.Lit)
+ fmt.Fprintf(os.Stderr, "keyvalue: tokentype: %v, token: %q\n", p.cur.Type, p.cur.Lit)
if p.cur.Type != Literal {
fmt.Fprintf(os.Stderr, "error when parsing keyvalue. Was expecting a name but got %q at line %d offset %d.\n", p.cur.Lit, p.cur.LineNr, p.cur.Offset)
}
@@ -138,7 +134,7 @@ func (p *parser) keyvalue() bool {
return false
}
- fmt.Fprintf(os.Stderr, "peeked %q (type %d) at line %d offset %d.\n", tok.Lit, tok.Type, tok.LineNr, tok.Offset)
+ fmt.Fprintf(os.Stderr, "peeked %q (type %v) at line %d offset %d.\n", tok.Lit, tok.Type, tok.LineNr, tok.Offset)
if tok.Type == ObjectClose {
p.advanceOneToken("keyvaluelast")
return false