Parser verbose mode
This commit is contained in:
parent
bda13e01db
commit
23577d7274
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue