add sane debugging

This commit is contained in:
Miek Gieben 2013-03-04 09:40:45 +01:00
parent 99d23ee4a7
commit c413442565
1 changed files with 20 additions and 6 deletions

View File

@ -3,11 +3,22 @@ package dns
import (
"fmt"
"io"
"log"
"os"
"strconv"
"strings"
)
type debugging bool
const debug debugging = false
func (d debugging) Printf(format string, args ...interface{}) {
if d {
log.Printf(format, args...)
}
}
var _DEBUG = false // Only used when debugging the parser itself.
const maxTok = 2048 // Largest token we can return.
@ -75,12 +86,13 @@ func (e *ParseError) Error() (s string) {
}
type lex struct {
token string // text of the token
err bool // when true, token text has lexer error
value uint8 // value: _STRING, _BLANK, etc.
line int // line in the file
column int // column in the file
torc uint16 // type or class as parsed in the lexer, we only need to look this up in the grammar
token string // text of the token
err bool // when true, token text has lexer error
value uint8 // value: _STRING, _BLANK, etc.
line int // line in the file
column int // column in the file
torc uint16 // type or class as parsed in the lexer, we only need to look this up in the grammar
comment string // any comment text seen
}
// Tokens are returned when a zone file is parsed.
@ -458,6 +470,8 @@ func zlexer(s *scan, c chan lex) {
var l lex
str := make([]byte, maxTok) // Should be enough for any token
stri := 0 // Offset in str (0 means empty)
com := make([]byte, maxTok) // Hold comment text
comi := 0
quote := false
escape := false
space := false