summaryrefslogtreecommitdiff
path: root/conf
diff options
context:
space:
mode:
authorSilvan Jegen <s.jegen@gmail.com>2017-01-15 20:04:53 +0100
committerSilvan Jegen <s.jegen@gmail.com>2017-01-15 20:04:53 +0100
commitc003fdf2182432a25892467bf1a456049f4b1c1d (patch)
tree540b5719ba61a409a5b50a0b051d15d1e8228ba9 /conf
parent7ae918084e0a38041565d28b904515dc7695e66b (diff)
Implement Stringer interface for the token type
Diffstat (limited to 'conf')
-rw-r--r--conf/parser.go4
-rw-r--r--conf/scanner.go8
2 files changed, 10 insertions, 2 deletions
diff --git a/conf/parser.go b/conf/parser.go
index 75f610c..4f58713 100644
--- a/conf/parser.go
+++ b/conf/parser.go
@@ -49,11 +49,11 @@ func (p *parser) startparsing() {
p.last = p.cur
p.cur, err = p.s.Scan()
for err == nil {
- fmt.Fprintf(os.Stderr, "tokentype: %d, token: %q offset: %d, line: %d\n", p.cur.Type, p.cur.Lit, p.cur.Offset, p.cur.LineNr)
+ 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()
}
- fmt.Fprintf(os.Stderr, "Error: tokentype: %d, 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)
}
func (p *parser) module(name string) {
diff --git a/conf/scanner.go b/conf/scanner.go
index 9bd7a4b..54546aa 100644
--- a/conf/scanner.go
+++ b/conf/scanner.go
@@ -20,6 +20,14 @@ const (
IfStatement
)
+var tokentypestrings []string = []string{Name: "Name", Literal: "Literal",
+ DeliOpen: "Opening delimiter", DeliClose: "Closing delimiter",
+ Nothing: "Nothing", IfStatement: "If statement"}
+
+func (tt tokentype) String() string {
+ return tokentypestrings[tt]
+}
+
type token struct {
Type tokentype
Offset int