From 1ea77385f3de06b276ad77210963c6af14395e83 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sat, 15 Jan 2011 13:34:51 +0100 Subject: [PATCH] Add first stab a yacc grammar+lexer --- Makefile | 3 +++ dns.y | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/Makefile b/Makefile index a61017dd..4a1779d8 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/dns.y b/dns.y index 005a4fed..1fd92f31 100644 --- a/dns.y +++ b/dns.y @@ -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 RR_A RR_NS RR_MX RR_CNAME RR_AAAA RR_DNSKEY RR_RRSIG RR_DS + +/* + * Other elements of the Resource Records + */ +%token TTL +%token CLASS +%token STR +%% +rr: name TTL CLASS + { + + }; + +name: label + | name '.' label + +label: STR +%% + +type DnsLex int