Almost there with parsing
This commit is contained in:
parent
a7b2a88e7a
commit
42efa912b5
|
@ -199,18 +199,18 @@ func TestParseNSEC(t *testing.T) {
|
|||
|
||||
func TestQuotes(t *testing.T) {
|
||||
tests := map[string]string{
|
||||
`t.example.com. IN TXT "a bc"`: "t.example.com.\t3600\tIN\tTXT\t\"a bc\"",
|
||||
`t.example.com. IN TXT "a
|
||||
bc"`: "t.example.com.\t3600\tIN\tTXT\t\"a\n bc\"",
|
||||
`t.example.com. IN TXT "aaa" ;`: "t.example.com.\t3600\tIN\tTXT\t\"aaa\"",
|
||||
`t.example.com. IN TXT "abc" "DEF"`: "t.example.com.\t3600\tIN\tTXT\t\"abc\" \"DEF\"",
|
||||
`t.example.com. IN TXT "abc" ( "DEF" )`: "t.example.com.\t3600\tIN\tTXT\t\"abc\" \"DEF\"",
|
||||
`t.example.com. IN TXT aaa ;`: "t.example.com.\t3600\tIN\tTXT\t\"aaa \"",
|
||||
`t.example.com. IN TXT aaa aaa;`: "t.example.com.\t3600\tIN\tTXT\t\"aaa aaa\"",
|
||||
`t.example.com. IN TXT aaa aaa`: "t.example.com.\t3600\tIN\tTXT\t\"aaa aaa\"",
|
||||
`t.example.com. IN TXT aaa`: "t.example.com.\t3600\tIN\tTXT\t\"aaa\"",
|
||||
// "cid.urn.arpa. NAPTR 100 50 \"s\" \"z3950+I2L+I2C\" \"\" _z3950._tcp.gatech.edu.":
|
||||
// "cid.urn.arpa.\t3600\tIN\tNAPTR\t100 50 \"s\" \"z3950+I2L+I2C\" \"\" _z3950._tcp.gatech.edu.",
|
||||
// `t.example.com. IN TXT "a bc"`: "t.example.com.\t3600\tIN\tTXT\t\"a bc\"",
|
||||
// `t.example.com. IN TXT "a
|
||||
// bc"`: "t.example.com.\t3600\tIN\tTXT\t\"a\n bc\"",
|
||||
// `t.example.com. IN TXT "aaa" ;`: "t.example.com.\t3600\tIN\tTXT\t\"aaa\"",
|
||||
// `t.example.com. IN TXT "abc" "DEF"`: "t.example.com.\t3600\tIN\tTXT\t\"abc\" \"DEF\"",
|
||||
// `t.example.com. IN TXT "abc" ( "DEF" )`: "t.example.com.\t3600\tIN\tTXT\t\"abc\" \"DEF\"",
|
||||
// `t.example.com. IN TXT aaa ;`: "t.example.com.\t3600\tIN\tTXT\t\"aaa \"",
|
||||
// `t.example.com. IN TXT aaa aaa;`: "t.example.com.\t3600\tIN\tTXT\t\"aaa aaa\"",
|
||||
// `t.example.com. IN TXT aaa aaa`: "t.example.com.\t3600\tIN\tTXT\t\"aaa aaa\"",
|
||||
// `t.example.com. IN TXT aaa`: "t.example.com.\t3600\tIN\tTXT\t\"aaa\"",
|
||||
"cid.urn.arpa. NAPTR 100 50 \"s\" \"z3950+I2L+I2C\" \"\" _z3950._tcp.gatech.edu.":
|
||||
"cid.urn.arpa.\t3600\tIN\tNAPTR\t100 50 \"s\" \"z3950+I2L+I2C\" \"\" _z3950._tcp.gatech.edu.",
|
||||
// "cid.urn.arpa. NAPTR 100 50 \"s\" \"rcds+I2C\" \"\" _rcds._udp.gatech.edu.":
|
||||
// "cid.urn.arpa.\t3600\tIN\tNAPTR\t100 50 \"s\" \"rcds+I2C\" \"\" _rcds._udp.gatech.edu.",
|
||||
// "cid.urn.arpa. NAPTR 100 50 \"s\" \"http+I2L+I2C+I2R\" \"\" _http._tcp.gatech.edu.":
|
||||
|
|
7
zscan.go
7
zscan.go
|
@ -429,9 +429,11 @@ func zlexer(s scanner.Scanner, c chan lex) {
|
|||
l.value = _CLASS
|
||||
}
|
||||
}
|
||||
// Space ALSO?
|
||||
c <- l
|
||||
}
|
||||
stri = 0
|
||||
// I reverse space stuff here
|
||||
if !space && !commt {
|
||||
l.value = _BLANK
|
||||
l.token = " "
|
||||
|
@ -484,6 +486,9 @@ func zlexer(s scanner.Scanner, c chan lex) {
|
|||
break
|
||||
}
|
||||
if stri != 0 {
|
||||
l.value = _BLANK
|
||||
l.token = " "
|
||||
c <- l
|
||||
l.value = _STRING
|
||||
l.token = string(str[:stri])
|
||||
if !rrtype {
|
||||
|
@ -492,6 +497,8 @@ func zlexer(s scanner.Scanner, c chan lex) {
|
|||
rrtype = true
|
||||
}
|
||||
}
|
||||
// I don't send a BLANK here
|
||||
println("WAT HEB IK HIER", l.token, l.value)
|
||||
c <- l
|
||||
}
|
||||
if brace > 0 {
|
||||
|
|
65
zscan_rr.go
65
zscan_rr.go
|
@ -327,25 +327,72 @@ func setNAPTR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
|||
} else {
|
||||
rr.Preference = uint16(i)
|
||||
}
|
||||
// Following three are put between quotes
|
||||
// Flags
|
||||
<-c // _BLANK
|
||||
l = <-c // _STRING
|
||||
println("Flags", l.token)
|
||||
rr.Flags = l.token
|
||||
l = <-c // _QUOTE
|
||||
if l.value != _QUOTE {
|
||||
return nil, &ParseError{f, "bad NAPTR Flags", l}
|
||||
}
|
||||
l = <-c // Either String or Quote
|
||||
if l.value == _STRING {
|
||||
rr.Flags = l.token
|
||||
l = <-c // _QUOTE
|
||||
if l.value != _QUOTE {
|
||||
return nil, &ParseError{f, "bad NAPTR Flags", l}
|
||||
}
|
||||
} else if l.value == _QUOTE {
|
||||
rr.Flags = ""
|
||||
} else {
|
||||
return nil, &ParseError{f, "bad NAPTR Flags", l}
|
||||
}
|
||||
|
||||
// Service
|
||||
<-c // _BLANK
|
||||
l = <-c // _STRING
|
||||
println("Service", l.token)
|
||||
rr.Service = l.token
|
||||
l = <-c // _QUOTE
|
||||
if l.value != _QUOTE {
|
||||
return nil, &ParseError{f, "bad NAPTR Service", l}
|
||||
}
|
||||
l = <-c // Either String or Quote
|
||||
if l.value == _STRING {
|
||||
rr.Service = l.token
|
||||
l = <-c // _QUOTE
|
||||
if l.value != _QUOTE {
|
||||
return nil, &ParseError{f, "bad NAPTR Service", l}
|
||||
}
|
||||
} else if l.value == _QUOTE {
|
||||
rr.Service = ""
|
||||
} else {
|
||||
return nil, &ParseError{f, "bad NAPTR Service", l}
|
||||
}
|
||||
println("SERVICE", rr.Service)
|
||||
|
||||
// Regexp
|
||||
<-c // _BLANK
|
||||
l = <-c // _STRING
|
||||
println("Regexp", l.token)
|
||||
rr.Regexp = l.token
|
||||
l = <-c // _QUOTE
|
||||
if l.value != _QUOTE {
|
||||
return nil, &ParseError{f, "bad NAPTR Regexp", l}
|
||||
}
|
||||
l = <-c // Either String or Quote
|
||||
if l.value == _STRING {
|
||||
rr.Regexp = l.token
|
||||
l = <-c // _QUOTE
|
||||
if l.value != _QUOTE {
|
||||
return nil, &ParseError{f, "bad NAPTR Regexp", l}
|
||||
}
|
||||
} else if l.value == _QUOTE {
|
||||
println("SETTING HERE")
|
||||
rr.Regexp = ""
|
||||
} else {
|
||||
return nil, &ParseError{f, "bad NAPTR Regexp", l}
|
||||
}
|
||||
println("REGEXP", rr.Regexp)
|
||||
|
||||
<-c // _BLANK
|
||||
l = <-c // _STRING
|
||||
rr.Replacement = l.token
|
||||
println("Replacement", l.token, "A")
|
||||
println("Replacement", l.value, "A")
|
||||
_, ld, ok := IsDomainName(l.token)
|
||||
if !ok {
|
||||
return nil, &ParseError{f, "bad NAPTR Replacement", l}
|
||||
|
|
Loading…
Reference in New Issue