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