1
0
Fork 0

Parser verbose mode

This commit is contained in:
Gregory Eremin 2015-02-18 23:05:45 +07:00
parent bda13e01db
commit 23577d7274
1 changed files with 12 additions and 5 deletions

View File

@ -12,10 +12,11 @@ import (
type (
// Holds the state of parser
Parser struct {
lex *lexer.Lexer
ctx *context
sels map[string]*context
res chan Match
lex *lexer.Lexer
ctx *context
sels map[string]*context
res chan Match
verbose bool
}
Match struct {
Sel string
@ -35,6 +36,10 @@ func New(buf buffer.Bufferer, sels []string) *Parser {
}
}
func (p *Parser) Debug() {
p.verbose = true
}
// Parse all and return matches
func (p *Parser) Parse() map[string][]interface{} {
p.ParseStream()
@ -166,7 +171,9 @@ func (p *Parser) next() lexer.Item {
panic(item)
}
fmt.Println(item)
if p.verbose {
fmt.Println(item)
}
return item
} else {
panic("EOF reached")