Add first stab a yacc grammar+lexer

This commit is contained in:
Miek Gieben 2011-01-15 13:34:51 +01:00
parent b9195afa5a
commit 1ea77385f3
2 changed files with 36 additions and 0 deletions

View File

@ -15,7 +15,10 @@ GOFILES=\
dnssec.go\
keygen.go\
string.go\
y.go\
y.go: dns.y
goyacc dns.y
include $(GOROOT)/src/Make.pkg

33
dns.y
View File

@ -6,3 +6,36 @@ package dns
// A yacc parser for DNS Resource Records contained in strings
%}
%union {
string string
rrtype uint16
class uint16
ttl uint16
}
/*
* Types known to package dns
*/
%token <rrtype> RR_A RR_NS RR_MX RR_CNAME RR_AAAA RR_DNSKEY RR_RRSIG RR_DS
/*
* Other elements of the Resource Records
*/
%token <ttl> TTL
%token <class> CLASS
%token <string> STR
%%
rr: name TTL CLASS
{
};
name: label
| name '.' label
label: STR
%%
type DnsLex int