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 ( type (
// Holds the state of parser // Holds the state of parser
Parser struct { Parser struct {
lex *lexer.Lexer lex *lexer.Lexer
ctx *context ctx *context
sels map[string]*context sels map[string]*context
res chan Match res chan Match
verbose bool
} }
Match struct { Match struct {
Sel string 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 // Parse all and return matches
func (p *Parser) Parse() map[string][]interface{} { func (p *Parser) Parse() map[string][]interface{} {
p.ParseStream() p.ParseStream()
@ -166,7 +171,9 @@ func (p *Parser) next() lexer.Item {
panic(item) panic(item)
} }
fmt.Println(item) if p.verbose {
fmt.Println(item)
}
return item return item
} else { } else {
panic("EOF reached") panic("EOF reached")