golint changes, lose the underscores

This commit is contained in:
Miek Gieben 2015-02-19 10:45:59 +00:00
parent acee6af0bc
commit b02ae55fbe
5 changed files with 115 additions and 115 deletions

View File

@ -172,9 +172,9 @@ func parseKey(r io.Reader, file string) (map[string]string, error) {
for l := range c { for l := range c {
// It should alternate // It should alternate
switch l.value { switch l.value {
case _KEY: case zKey:
k = l.token k = l.token
case _VALUE: case zValue:
if k == "" { if k == "" {
return nil, &ParseError{file, "no private key seen", l} return nil, &ParseError{file, "no private key seen", l}
} }
@ -204,14 +204,14 @@ func klexer(s *scan, c chan lex) {
} }
l.token = str l.token = str
if key { if key {
l.value = _KEY l.value = zKey
c <- l c <- l
// Next token is a space, eat it // Next token is a space, eat it
s.tokenText() s.tokenText()
key = false key = false
str = "" str = ""
} else { } else {
l.value = _VALUE l.value = zValue
} }
case ';': case ';':
commt = true commt = true
@ -220,7 +220,7 @@ func klexer(s *scan, c chan lex) {
// Reset a comment // Reset a comment
commt = false commt = false
} }
l.value = _VALUE l.value = zValue
l.token = str l.token = str
c <- l c <- l
str = "" str = ""
@ -237,7 +237,7 @@ func klexer(s *scan, c chan lex) {
if len(str) > 0 { if len(str) > 0 {
// Send remainder // Send remainder
l.token = str l.token = str
l.value = _VALUE l.value = zValue
c <- l c <- l
} }
} }

View File

@ -91,9 +91,9 @@ func PrivateHandle(rtypestr string, rtype uint16, generator func() PrivateRdata)
// TODO(miek): we could also be returning _QUOTE, this might or might not // TODO(miek): we could also be returning _QUOTE, this might or might not
// be an issue (basically parsing TXT becomes hard) // be an issue (basically parsing TXT becomes hard)
switch l = <-c; l.value { switch l = <-c; l.value {
case _NEWLINE, _EOF: case zNewline, zEOF:
break FETCH break FETCH
case _STRING: case zString:
text = append(text, l.token) text = append(text, l.token)
} }
} }

View File

@ -55,7 +55,7 @@ func generate(l lex, c chan lex, t chan *Token, o string) string {
s := "" s := ""
BuildRR: BuildRR:
l = <-c l = <-c
if l.value != _NEWLINE && l.value != _EOF { if l.value != zNewline && l.value != zEOF {
s += l.token s += l.token
goto BuildRR goto BuildRR
} }

140
zscan.go
View File

@ -29,22 +29,22 @@ const maxUint16 = 1<<16 - 1
// * Handle braces - anywhere. // * Handle braces - anywhere.
const ( const (
// Zonefile // Zonefile
_EOF = iota zEOF = iota
_STRING zString
_BLANK zBlank
_QUOTE zQuote
_NEWLINE zNewline
_RRTYPE zRrtpe
_OWNER zOwner
_CLASS zClass
_DIRORIGIN // $ORIGIN zDirOrigin // $ORIGIN
_DIRTTL // $TTL zDirTtl // $TTL
_DIRINCLUDE // $INCLUDE zDirInclude // $INCLUDE
_DIRGENERATE // $GENERATE zDirGenerate // $GENERATE
// Privatekey file // Privatekey file
_VALUE zValue
_KEY zKey
_EXPECT_OWNER_DIR // Ownername _EXPECT_OWNER_DIR // Ownername
_EXPECT_OWNER_BL // Whitespace after the ownername _EXPECT_OWNER_BL // Whitespace after the ownername
@ -210,9 +210,9 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
h.Ttl = defttl h.Ttl = defttl
h.Class = ClassINET h.Class = ClassINET
switch l.value { switch l.value {
case _NEWLINE: // Empty line case zNewline:
st = _EXPECT_OWNER_DIR st = _EXPECT_OWNER_DIR
case _OWNER: case zOwner:
h.Name = l.token h.Name = l.token
if l.token[0] == '@' { if l.token[0] == '@' {
h.Name = origin h.Name = origin
@ -230,26 +230,26 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
} }
prevName = h.Name prevName = h.Name
st = _EXPECT_OWNER_BL st = _EXPECT_OWNER_BL
case _DIRTTL: case zDirTtl:
st = _EXPECT_DIRTTL_BL st = _EXPECT_DIRTTL_BL
case _DIRORIGIN: case zDirOrigin:
st = _EXPECT_DIRORIGIN_BL st = _EXPECT_DIRORIGIN_BL
case _DIRINCLUDE: case zDirInclude:
st = _EXPECT_DIRINCLUDE_BL st = _EXPECT_DIRINCLUDE_BL
case _DIRGENERATE: case zDirGenerate:
st = _EXPECT_DIRGENERATE_BL st = _EXPECT_DIRGENERATE_BL
case _RRTYPE: // Everthing has been omitted, this is the first thing on the line case zRrtpe:
h.Name = prevName h.Name = prevName
h.Rrtype = l.torc h.Rrtype = l.torc
st = _EXPECT_RDATA st = _EXPECT_RDATA
case _CLASS: // First thing on the line is the class case zClass:
h.Name = prevName h.Name = prevName
h.Class = l.torc h.Class = l.torc
st = _EXPECT_ANY_NOCLASS_BL st = _EXPECT_ANY_NOCLASS_BL
case _BLANK: case zBlank:
// Discard, can happen when there is nothing on the // Discard, can happen when there is nothing on the
// line except the RR type // line except the RR type
case _STRING: // First thing on the is the ttl case zString:
if ttl, ok := stringToTtl(l.token); !ok { if ttl, ok := stringToTtl(l.token); !ok {
t <- &Token{Error: &ParseError{f, "not a TTL", l}} t <- &Token{Error: &ParseError{f, "not a TTL", l}}
return return
@ -265,22 +265,22 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
return return
} }
case _EXPECT_DIRINCLUDE_BL: case _EXPECT_DIRINCLUDE_BL:
if l.value != _BLANK { if l.value != zBlank {
t <- &Token{Error: &ParseError{f, "no blank after $INCLUDE-directive", l}} t <- &Token{Error: &ParseError{f, "no blank after $INCLUDE-directive", l}}
return return
} }
st = _EXPECT_DIRINCLUDE st = _EXPECT_DIRINCLUDE
case _EXPECT_DIRINCLUDE: case _EXPECT_DIRINCLUDE:
if l.value != _STRING { if l.value != zString {
t <- &Token{Error: &ParseError{f, "expecting $INCLUDE value, not this...", l}} t <- &Token{Error: &ParseError{f, "expecting $INCLUDE value, not this...", l}}
return return
} }
neworigin := origin // There may be optionally a new origin set after the filename, if not use current one neworigin := origin // There may be optionally a new origin set after the filename, if not use current one
l := <-c l := <-c
switch l.value { switch l.value {
case _BLANK: case zBlank:
l := <-c l := <-c
if l.value == _STRING { if l.value == zString {
if _, ok := IsDomainName(l.token); !ok { if _, ok := IsDomainName(l.token); !ok {
t <- &Token{Error: &ParseError{f, "bad origin name", l}} t <- &Token{Error: &ParseError{f, "bad origin name", l}}
return return
@ -296,7 +296,7 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
neworigin = l.token neworigin = l.token
} }
} }
case _NEWLINE, _EOF: case zNewline, zEOF:
// Ok // Ok
default: default:
t <- &Token{Error: &ParseError{f, "garbage after $INCLUDE", l}} t <- &Token{Error: &ParseError{f, "garbage after $INCLUDE", l}}
@ -315,13 +315,13 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
parseZone(r1, l.token, neworigin, t, include+1) parseZone(r1, l.token, neworigin, t, include+1)
st = _EXPECT_OWNER_DIR st = _EXPECT_OWNER_DIR
case _EXPECT_DIRTTL_BL: case _EXPECT_DIRTTL_BL:
if l.value != _BLANK { if l.value != zBlank {
t <- &Token{Error: &ParseError{f, "no blank after $TTL-directive", l}} t <- &Token{Error: &ParseError{f, "no blank after $TTL-directive", l}}
return return
} }
st = _EXPECT_DIRTTL st = _EXPECT_DIRTTL
case _EXPECT_DIRTTL: case _EXPECT_DIRTTL:
if l.value != _STRING { if l.value != zString {
t <- &Token{Error: &ParseError{f, "expecting $TTL value, not this...", l}} t <- &Token{Error: &ParseError{f, "expecting $TTL value, not this...", l}}
return return
} }
@ -337,13 +337,13 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
} }
st = _EXPECT_OWNER_DIR st = _EXPECT_OWNER_DIR
case _EXPECT_DIRORIGIN_BL: case _EXPECT_DIRORIGIN_BL:
if l.value != _BLANK { if l.value != zBlank {
t <- &Token{Error: &ParseError{f, "no blank after $ORIGIN-directive", l}} t <- &Token{Error: &ParseError{f, "no blank after $ORIGIN-directive", l}}
return return
} }
st = _EXPECT_DIRORIGIN st = _EXPECT_DIRORIGIN
case _EXPECT_DIRORIGIN: case _EXPECT_DIRORIGIN:
if l.value != _STRING { if l.value != zString {
t <- &Token{Error: &ParseError{f, "expecting $ORIGIN value, not this...", l}} t <- &Token{Error: &ParseError{f, "expecting $ORIGIN value, not this...", l}}
return return
} }
@ -365,13 +365,13 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
} }
st = _EXPECT_OWNER_DIR st = _EXPECT_OWNER_DIR
case _EXPECT_DIRGENERATE_BL: case _EXPECT_DIRGENERATE_BL:
if l.value != _BLANK { if l.value != zBlank {
t <- &Token{Error: &ParseError{f, "no blank after $GENERATE-directive", l}} t <- &Token{Error: &ParseError{f, "no blank after $GENERATE-directive", l}}
return return
} }
st = _EXPECT_DIRGENERATE st = _EXPECT_DIRGENERATE
case _EXPECT_DIRGENERATE: case _EXPECT_DIRGENERATE:
if l.value != _STRING { if l.value != zString {
t <- &Token{Error: &ParseError{f, "expecting $GENERATE value, not this...", l}} t <- &Token{Error: &ParseError{f, "expecting $GENERATE value, not this...", l}}
return return
} }
@ -381,20 +381,20 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
} }
st = _EXPECT_OWNER_DIR st = _EXPECT_OWNER_DIR
case _EXPECT_OWNER_BL: case _EXPECT_OWNER_BL:
if l.value != _BLANK { if l.value != zBlank {
t <- &Token{Error: &ParseError{f, "no blank after owner", l}} t <- &Token{Error: &ParseError{f, "no blank after owner", l}}
return return
} }
st = _EXPECT_ANY st = _EXPECT_ANY
case _EXPECT_ANY: case _EXPECT_ANY:
switch l.value { switch l.value {
case _RRTYPE: case zRrtpe:
h.Rrtype = l.torc h.Rrtype = l.torc
st = _EXPECT_RDATA st = _EXPECT_RDATA
case _CLASS: case zClass:
h.Class = l.torc h.Class = l.torc
st = _EXPECT_ANY_NOCLASS_BL st = _EXPECT_ANY_NOCLASS_BL
case _STRING: // TTL is this case case zString:
if ttl, ok := stringToTtl(l.token); !ok { if ttl, ok := stringToTtl(l.token); !ok {
t <- &Token{Error: &ParseError{f, "not a TTL", l}} t <- &Token{Error: &ParseError{f, "not a TTL", l}}
return return
@ -408,23 +408,23 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
return return
} }
case _EXPECT_ANY_NOCLASS_BL: case _EXPECT_ANY_NOCLASS_BL:
if l.value != _BLANK { if l.value != zBlank {
t <- &Token{Error: &ParseError{f, "no blank before class", l}} t <- &Token{Error: &ParseError{f, "no blank before class", l}}
return return
} }
st = _EXPECT_ANY_NOCLASS st = _EXPECT_ANY_NOCLASS
case _EXPECT_ANY_NOTTL_BL: case _EXPECT_ANY_NOTTL_BL:
if l.value != _BLANK { if l.value != zBlank {
t <- &Token{Error: &ParseError{f, "no blank before TTL", l}} t <- &Token{Error: &ParseError{f, "no blank before TTL", l}}
return return
} }
st = _EXPECT_ANY_NOTTL st = _EXPECT_ANY_NOTTL
case _EXPECT_ANY_NOTTL: case _EXPECT_ANY_NOTTL:
switch l.value { switch l.value {
case _CLASS: case zClass:
h.Class = l.torc h.Class = l.torc
st = _EXPECT_RRTYPE_BL st = _EXPECT_RRTYPE_BL
case _RRTYPE: case zRrtpe:
h.Rrtype = l.torc h.Rrtype = l.torc
st = _EXPECT_RDATA st = _EXPECT_RDATA
default: default:
@ -433,7 +433,7 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
} }
case _EXPECT_ANY_NOCLASS: case _EXPECT_ANY_NOCLASS:
switch l.value { switch l.value {
case _STRING: // TTL case zString:
if ttl, ok := stringToTtl(l.token); !ok { if ttl, ok := stringToTtl(l.token); !ok {
t <- &Token{Error: &ParseError{f, "not a TTL", l}} t <- &Token{Error: &ParseError{f, "not a TTL", l}}
return return
@ -442,7 +442,7 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
// defttl = ttl // don't set the def ttl anymore // defttl = ttl // don't set the def ttl anymore
} }
st = _EXPECT_RRTYPE_BL st = _EXPECT_RRTYPE_BL
case _RRTYPE: case zRrtpe:
h.Rrtype = l.torc h.Rrtype = l.torc
st = _EXPECT_RDATA st = _EXPECT_RDATA
default: default:
@ -450,13 +450,13 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) {
return return
} }
case _EXPECT_RRTYPE_BL: case _EXPECT_RRTYPE_BL:
if l.value != _BLANK { if l.value != zBlank {
t <- &Token{Error: &ParseError{f, "no blank before RR type", l}} t <- &Token{Error: &ParseError{f, "no blank before RR type", l}}
return return
} }
st = _EXPECT_RRTYPE st = _EXPECT_RRTYPE
case _EXPECT_RRTYPE: case _EXPECT_RRTYPE:
if l.value != _RRTYPE { if l.value != zRrtpe {
t <- &Token{Error: &ParseError{f, "unknown RR type", l}} t <- &Token{Error: &ParseError{f, "unknown RR type", l}}
return return
} }
@ -538,31 +538,31 @@ func zlexer(s *scan, c chan lex) {
// Space directly in the beginning, handled in the grammar // Space directly in the beginning, handled in the grammar
} else if owner { } else if owner {
// If we have a string and its the first, make it an owner // If we have a string and its the first, make it an owner
l.value = _OWNER l.value = zOwner
l.token = string(str[:stri]) l.token = string(str[:stri])
l.tokenUpper = strings.ToUpper(l.token) l.tokenUpper = strings.ToUpper(l.token)
l.length = stri l.length = stri
// escape $... start with a \ not a $, so this will work // escape $... start with a \ not a $, so this will work
switch l.tokenUpper { switch l.tokenUpper {
case "$TTL": case "$TTL":
l.value = _DIRTTL l.value = zDirTtl
case "$ORIGIN": case "$ORIGIN":
l.value = _DIRORIGIN l.value = zDirOrigin
case "$INCLUDE": case "$INCLUDE":
l.value = _DIRINCLUDE l.value = zDirInclude
case "$GENERATE": case "$GENERATE":
l.value = _DIRGENERATE l.value = zDirGenerate
} }
debug.Printf("[7 %+v]", l.token) debug.Printf("[7 %+v]", l.token)
c <- l c <- l
} else { } else {
l.value = _STRING l.value = zString
l.token = string(str[:stri]) l.token = string(str[:stri])
l.tokenUpper = strings.ToUpper(l.token) l.tokenUpper = strings.ToUpper(l.token)
l.length = stri l.length = stri
if !rrtype { if !rrtype {
if t, ok := StringToType[l.tokenUpper]; ok { if t, ok := StringToType[l.tokenUpper]; ok {
l.value = _RRTYPE l.value = zRrtpe
l.torc = t l.torc = t
rrtype = true rrtype = true
} else { } else {
@ -573,13 +573,13 @@ func zlexer(s *scan, c chan lex) {
c <- l c <- l
return return
} else { } else {
l.value = _RRTYPE l.value = zRrtpe
l.torc = t l.torc = t
} }
} }
} }
if t, ok := StringToClass[l.tokenUpper]; ok { if t, ok := StringToClass[l.tokenUpper]; ok {
l.value = _CLASS l.value = zClass
l.torc = t l.torc = t
} else { } else {
if strings.HasPrefix(l.tokenUpper, "CLASS") { if strings.HasPrefix(l.tokenUpper, "CLASS") {
@ -589,7 +589,7 @@ func zlexer(s *scan, c chan lex) {
c <- l c <- l
return return
} else { } else {
l.value = _CLASS l.value = zClass
l.torc = t l.torc = t
} }
} }
@ -601,7 +601,7 @@ func zlexer(s *scan, c chan lex) {
stri = 0 stri = 0
// I reverse space stuff here // I reverse space stuff here
if !space && !commt { if !space && !commt {
l.value = _BLANK l.value = zBlank
l.token = " " l.token = " "
l.length = 1 l.length = 1
debug.Printf("[5 %+v]", l.token) debug.Printf("[5 %+v]", l.token)
@ -623,7 +623,7 @@ func zlexer(s *scan, c chan lex) {
break break
} }
if stri > 0 { if stri > 0 {
l.value = _STRING l.value = zString
l.token = string(str[:stri]) l.token = string(str[:stri])
l.length = stri l.length = stri
debug.Printf("[4 %+v]", l.token) debug.Printf("[4 %+v]", l.token)
@ -659,7 +659,7 @@ func zlexer(s *scan, c chan lex) {
if brace == 0 { if brace == 0 {
owner = true owner = true
owner = true owner = true
l.value = _NEWLINE l.value = zNewline
l.token = "\n" l.token = "\n"
l.length = 1 l.length = 1
l.comment = string(com[:comi]) l.comment = string(com[:comi])
@ -677,14 +677,14 @@ func zlexer(s *scan, c chan lex) {
if brace == 0 { if brace == 0 {
// If there is previous text, we should output it here // If there is previous text, we should output it here
if stri != 0 { if stri != 0 {
l.value = _STRING l.value = zString
l.token = string(str[:stri]) l.token = string(str[:stri])
l.tokenUpper = strings.ToUpper(l.token) l.tokenUpper = strings.ToUpper(l.token)
l.length = stri l.length = stri
if !rrtype { if !rrtype {
if t, ok := StringToType[l.tokenUpper]; ok { if t, ok := StringToType[l.tokenUpper]; ok {
l.value = _RRTYPE l.value = zRrtpe
l.torc = t l.torc = t
rrtype = true rrtype = true
} }
@ -692,7 +692,7 @@ func zlexer(s *scan, c chan lex) {
debug.Printf("[2 %+v]", l.token) debug.Printf("[2 %+v]", l.token)
c <- l c <- l
} }
l.value = _NEWLINE l.value = zNewline
l.token = "\n" l.token = "\n"
l.length = 1 l.length = 1
debug.Printf("[1 %+v]", l.token) debug.Printf("[1 %+v]", l.token)
@ -736,7 +736,7 @@ func zlexer(s *scan, c chan lex) {
space = false space = false
// send previous gathered text and the quote // send previous gathered text and the quote
if stri != 0 { if stri != 0 {
l.value = _STRING l.value = zString
l.token = string(str[:stri]) l.token = string(str[:stri])
l.length = stri l.length = stri
@ -746,7 +746,7 @@ func zlexer(s *scan, c chan lex) {
} }
// send quote itself as separate token // send quote itself as separate token
l.value = _QUOTE l.value = zQuote
l.token = "\"" l.token = "\""
l.length = 1 l.length = 1
c <- l c <- l
@ -798,7 +798,7 @@ func zlexer(s *scan, c chan lex) {
// Send remainder // Send remainder
l.token = string(str[:stri]) l.token = string(str[:stri])
l.length = stri l.length = stri
l.value = _STRING l.value = zString
debug.Printf("[%+v]", l.token) debug.Printf("[%+v]", l.token)
c <- l c <- l
} }
@ -930,15 +930,15 @@ func slurpRemainder(c chan lex, f string) (*ParseError, string) {
l := <-c l := <-c
com := "" com := ""
switch l.value { switch l.value {
case _BLANK: case zBlank:
l = <-c l = <-c
com = l.comment com = l.comment
if l.value != _NEWLINE && l.value != _EOF { if l.value != zNewline && l.value != zEOF {
return &ParseError{f, "garbage after rdata", l}, "" return &ParseError{f, "garbage after rdata", l}, ""
} }
case _NEWLINE: case zNewline:
com = l.comment com = l.comment
case _EOF: case zEOF:
default: default:
return &ParseError{f, "garbage after rdata", l}, "" return &ParseError{f, "garbage after rdata", l}, ""
} }

View File

@ -48,11 +48,11 @@ func setRR(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
func endingToString(c chan lex, errstr, f string) (string, *ParseError, string) { func endingToString(c chan lex, errstr, f string) (string, *ParseError, string) {
s := "" s := ""
l := <-c // _STRING l := <-c // _STRING
for l.value != _NEWLINE && l.value != _EOF { for l.value != zNewline && l.value != zEOF {
switch l.value { switch l.value {
case _STRING: case zString:
s += l.token s += l.token
case _BLANK: // Ok case zBlank: // Ok
default: default:
return "", &ParseError{f, errstr, l}, "" return "", &ParseError{f, errstr, l}, ""
} }
@ -68,21 +68,21 @@ func endingToTxtSlice(c chan lex, errstr, f string) ([]string, *ParseError, stri
quote := false quote := false
l := <-c l := <-c
var s []string var s []string
switch l.value == _QUOTE { switch l.value == zQuote {
case true: // A number of quoted string case true: // A number of quoted string
s = make([]string, 0) s = make([]string, 0)
empty := true empty := true
for l.value != _NEWLINE && l.value != _EOF { for l.value != zNewline && l.value != zEOF {
switch l.value { switch l.value {
case _STRING: case zString:
empty = false empty = false
s = append(s, l.token) s = append(s, l.token)
case _BLANK: case zBlank:
if quote { if quote {
// _BLANK can only be seen in between txt parts. // _BLANK can only be seen in between txt parts.
return nil, &ParseError{f, errstr, l}, "" return nil, &ParseError{f, errstr, l}, ""
} }
case _QUOTE: case zQuote:
if empty && quote { if empty && quote {
s = append(s, "") s = append(s, "")
} }
@ -98,7 +98,7 @@ func endingToTxtSlice(c chan lex, errstr, f string) ([]string, *ParseError, stri
} }
case false: // Unquoted text record case false: // Unquoted text record
s = make([]string, 1) s = make([]string, 1)
for l.value != _NEWLINE && l.value != _EOF { for l.value != zNewline && l.value != zEOF {
s[0] += l.token s[0] += l.token
l = <-c l = <-c
} }
@ -723,17 +723,17 @@ func setNAPTR(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
// Flags // Flags
<-c // _BLANK <-c // _BLANK
l = <-c // _QUOTE l = <-c // _QUOTE
if l.value != _QUOTE { if l.value != zQuote {
return nil, &ParseError{f, "bad NAPTR Flags", l}, "" return nil, &ParseError{f, "bad NAPTR Flags", l}, ""
} }
l = <-c // Either String or Quote l = <-c // Either String or Quote
if l.value == _STRING { if l.value == zString {
rr.Flags = l.token rr.Flags = l.token
l = <-c // _QUOTE l = <-c // _QUOTE
if l.value != _QUOTE { if l.value != zQuote {
return nil, &ParseError{f, "bad NAPTR Flags", l}, "" return nil, &ParseError{f, "bad NAPTR Flags", l}, ""
} }
} else if l.value == _QUOTE { } else if l.value == zQuote {
rr.Flags = "" rr.Flags = ""
} else { } else {
return nil, &ParseError{f, "bad NAPTR Flags", l}, "" return nil, &ParseError{f, "bad NAPTR Flags", l}, ""
@ -742,17 +742,17 @@ func setNAPTR(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
// Service // Service
<-c // _BLANK <-c // _BLANK
l = <-c // _QUOTE l = <-c // _QUOTE
if l.value != _QUOTE { if l.value != zQuote {
return nil, &ParseError{f, "bad NAPTR Service", l}, "" return nil, &ParseError{f, "bad NAPTR Service", l}, ""
} }
l = <-c // Either String or Quote l = <-c // Either String or Quote
if l.value == _STRING { if l.value == zString {
rr.Service = l.token rr.Service = l.token
l = <-c // _QUOTE l = <-c // _QUOTE
if l.value != _QUOTE { if l.value != zQuote {
return nil, &ParseError{f, "bad NAPTR Service", l}, "" return nil, &ParseError{f, "bad NAPTR Service", l}, ""
} }
} else if l.value == _QUOTE { } else if l.value == zQuote {
rr.Service = "" rr.Service = ""
} else { } else {
return nil, &ParseError{f, "bad NAPTR Service", l}, "" return nil, &ParseError{f, "bad NAPTR Service", l}, ""
@ -761,17 +761,17 @@ func setNAPTR(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
// Regexp // Regexp
<-c // _BLANK <-c // _BLANK
l = <-c // _QUOTE l = <-c // _QUOTE
if l.value != _QUOTE { if l.value != zQuote {
return nil, &ParseError{f, "bad NAPTR Regexp", l}, "" return nil, &ParseError{f, "bad NAPTR Regexp", l}, ""
} }
l = <-c // Either String or Quote l = <-c // Either String or Quote
if l.value == _STRING { if l.value == zString {
rr.Regexp = l.token rr.Regexp = l.token
l = <-c // _QUOTE l = <-c // _QUOTE
if l.value != _QUOTE { if l.value != zQuote {
return nil, &ParseError{f, "bad NAPTR Regexp", l}, "" return nil, &ParseError{f, "bad NAPTR Regexp", l}, ""
} }
} else if l.value == _QUOTE { } else if l.value == zQuote {
rr.Regexp = "" rr.Regexp = ""
} else { } else {
return nil, &ParseError{f, "bad NAPTR Regexp", l}, "" return nil, &ParseError{f, "bad NAPTR Regexp", l}, ""
@ -927,9 +927,9 @@ Altitude:
// And now optionally the other values // And now optionally the other values
l = <-c l = <-c
count := 0 count := 0
for l.value != _NEWLINE && l.value != _EOF { for l.value != zNewline && l.value != zEOF {
switch l.value { switch l.value {
case _STRING: case zString:
switch count { switch count {
case 0: // Size case 0: // Size
if e, m, ok := stringToCm(l.token); !ok { if e, m, ok := stringToCm(l.token); !ok {
@ -951,7 +951,7 @@ Altitude:
} }
} }
count++ count++
case _BLANK: case zBlank:
// Ok // Ok
default: default:
return nil, &ParseError{f, "bad LOC Size, HorizPre or VertPre", l}, "" return nil, &ParseError{f, "bad LOC Size, HorizPre or VertPre", l}, ""
@ -988,9 +988,9 @@ func setHIP(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
// RendezvousServers (if any) // RendezvousServers (if any)
l = <-c l = <-c
var xs []string var xs []string
for l.value != _NEWLINE && l.value != _EOF { for l.value != zNewline && l.value != zEOF {
switch l.value { switch l.value {
case _STRING: case zString:
if l.token == "@" { if l.token == "@" {
xs = append(xs, o) xs = append(xs, o)
continue continue
@ -1003,7 +1003,7 @@ func setHIP(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
l.token = appendOrigin(l.token, o) l.token = appendOrigin(l.token, o)
} }
xs = append(xs, l.token) xs = append(xs, l.token)
case _BLANK: case zBlank:
// Ok // Ok
default: default:
return nil, &ParseError{f, "bad HIP RendezvousServers", l}, "" return nil, &ParseError{f, "bad HIP RendezvousServers", l}, ""
@ -1194,11 +1194,11 @@ func setNSEC(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
ok bool ok bool
) )
l = <-c l = <-c
for l.value != _NEWLINE && l.value != _EOF { for l.value != zNewline && l.value != zEOF {
switch l.value { switch l.value {
case _BLANK: case zBlank:
// Ok // Ok
case _STRING: case zString:
if k, ok = StringToType[l.tokenUpper]; !ok { if k, ok = StringToType[l.tokenUpper]; !ok {
if k, ok = typeToInt(l.tokenUpper); !ok { if k, ok = typeToInt(l.tokenUpper); !ok {
return nil, &ParseError{f, "bad NSEC TypeBitMap", l}, "" return nil, &ParseError{f, "bad NSEC TypeBitMap", l}, ""
@ -1259,11 +1259,11 @@ func setNSEC3(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
ok bool ok bool
) )
l = <-c l = <-c
for l.value != _NEWLINE && l.value != _EOF { for l.value != zNewline && l.value != zEOF {
switch l.value { switch l.value {
case _BLANK: case zBlank:
// Ok // Ok
case _STRING: case zString:
if k, ok = StringToType[l.tokenUpper]; !ok { if k, ok = StringToType[l.tokenUpper]; !ok {
if k, ok = typeToInt(l.tokenUpper); !ok { if k, ok = typeToInt(l.tokenUpper); !ok {
return nil, &ParseError{f, "bad NSEC3 TypeBitMap", l}, "" return nil, &ParseError{f, "bad NSEC3 TypeBitMap", l}, ""
@ -1413,11 +1413,11 @@ func setWKS(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
k int k int
err error err error
) )
for l.value != _NEWLINE && l.value != _EOF { for l.value != zNewline && l.value != zEOF {
switch l.value { switch l.value {
case _BLANK: case zBlank:
// Ok // Ok
case _STRING: case zString:
if k, err = net.LookupPort(proto, l.token); err != nil { if k, err = net.LookupPort(proto, l.token); err != nil {
if i, e := strconv.Atoi(l.token); e != nil { // If a number use that if i, e := strconv.Atoi(l.token); e != nil { // If a number use that
rr.BitMap = append(rr.BitMap, uint16(i)) rr.BitMap = append(rr.BitMap, uint16(i))