More tweaks for parsing
This commit is contained in:
parent
a5baf52283
commit
4d5f6d66e2
10
zscan.go
10
zscan.go
|
@ -9,9 +9,7 @@ import (
|
|||
)
|
||||
|
||||
// Only used when debugging the parser itself.
|
||||
var _DEBUG = false
|
||||
|
||||
|
||||
var _DEBUG = true
|
||||
|
||||
// Tokinize a RFC 1035 zone file. The tokenizer will normalize it:
|
||||
// * Add ownernames if they are left blank;
|
||||
|
@ -51,8 +49,10 @@ type ParseError struct {
|
|||
}
|
||||
|
||||
func (e *ParseError) Error() string {
|
||||
s := e.err + ": `" + e.lex.token + "' at line: " + strconv.Itoa(e.lex.line) +
|
||||
" and column: " + strconv.Itoa(e.lex.column)
|
||||
va := strconv.Itoa(e.lex.value)
|
||||
s := e.err + ": `" + e.lex.token + "' (value: " + va + ") at line: " +
|
||||
strconv.Itoa(e.lex.line) + " and column: " +
|
||||
strconv.Itoa(e.lex.column)
|
||||
return s
|
||||
}
|
||||
|
||||
|
|
|
@ -88,24 +88,24 @@ func setRR(h RR_Header, c chan Lex) (RR, *ParseError) {
|
|||
func slurpRemainder(c chan Lex) *ParseError {
|
||||
l := <-c
|
||||
if _DEBUG {
|
||||
fmt.Printf("%\v", l)
|
||||
fmt.Printf("%v\n", l)
|
||||
}
|
||||
switch l.value {
|
||||
case _BLANK:
|
||||
l = <-c
|
||||
if _DEBUG {
|
||||
fmt.Printf("%\v", l)
|
||||
fmt.Printf("%v\n", l)
|
||||
}
|
||||
if l.value != _NEWLINE && l.value != _EOF {
|
||||
return &ParseError{"garbage after rdata", l}
|
||||
}
|
||||
// Ok
|
||||
case _NEWLINE:
|
||||
// Ok
|
||||
// Ok
|
||||
case _EOF:
|
||||
// Ok
|
||||
default:
|
||||
return &ParseError{"garbage after rdata", l}
|
||||
return &ParseError{"garbage after directly rdata", l}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue