diff --git a/Makefile b/Makefile index cadfb7df..3e1de474 100644 --- a/Makefile +++ b/Makefile @@ -28,3 +28,7 @@ _examples: examples: gomake -C _examples + +# yes, hardcoded path, yes ugly, yes deal with it +zparse.go: zparse.rl + /home/miekg/svn/ragel/ragel/ragel -Z -G2 -o $@ $< diff --git a/zparse.rl b/zparse.rl index e69de29b..0bdf377a 100644 --- a/zparse.rl +++ b/zparse.rl @@ -0,0 +1,60 @@ +package main + +import ( + "os" + "fmt" +) + +%%{ + machine z; + write data; +}%% + +func zparse(data string) (res int, err os.Error) { + cs, p, pe := 0, 0, len(data) + + %%{ + action out { fmt.Printf("%s\n", data) } + action defTtl { fmt.Printf("%s\n", data) } + action setTtl { fmt.Printf("%s\n", data) } + + qtype = ('IN'i|'CS'i|'CH'i|'HS'i|'ANY'i|'NONE'i); + ttl = digit+; + blank = [ \t]+; + qname = any+; + + # RDATA definition + rdata_a = any+; + rdata_dnskey = any+; + + lhs = qname? blank %defTtl ( + (ttl %setTtl blank (qtype blank)?) + | (qtype blank (ttl %setTtl blank)?) + )?; + + # RR definitions + rhs = ( + ('A'i blank rdata_a) %out + | ('DNSKEY'i blank rdata_dnskey) %out + ); + + rr = lhs rhs; + + write init; + write exec; + }%% + + if cs < z_first_final { + // No clue what I'm doing what so ever + if p == pe { + return 0, os.ErrorString("unexpected eof") + } else { + return 0, os.ErrorString(fmt.Sprintf("error at position %d", p)) + } + } + return 0 ,nil +} + +func main() { + +}