Add privatekey parser that does not use Ragel

This commit is contained in:
Miek Gieben 2011-12-15 13:03:51 +01:00
parent 94ec863ffc
commit 643ee5f5f2
2 changed files with 9 additions and 3 deletions

View File

@ -14,6 +14,7 @@ GOFILES=\
dnssec.go\ dnssec.go\
edns.go\ edns.go\
keygen.go\ keygen.go\
kscan.go\
msg.go\ msg.go\
nsec3.go \ nsec3.go \
qnamestring.go\ qnamestring.go\

View File

@ -15,6 +15,7 @@ import (
// * Handle comments: ; // * Handle comments: ;
// * Handle braces. // * Handle braces.
const ( const (
// Zonefile
_EOF = iota // Don't let it start with zero _EOF = iota // Don't let it start with zero
_STRING _STRING
_BLANK _BLANK
@ -23,6 +24,10 @@ const (
_OWNER _OWNER
_CLASS _CLASS
// Privatekey file
_VALUE
_KEY
_EXPECT_OWNER // Ownername _EXPECT_OWNER // Ownername
_EXPECT_OWNER_BL // Whitespace after the ownername _EXPECT_OWNER_BL // Whitespace after the ownername
_EXPECT_ANY // Expect rrtype, ttl or class _EXPECT_ANY // Expect rrtype, ttl or class
@ -82,7 +87,7 @@ func ParseZone(r io.Reader, cr chan RR) {
s.Mode = 0 s.Mode = 0
s.Whitespace = 0 s.Whitespace = 0
// Start the lexer // Start the lexer
go lexer(s, c) go zlexer(s, c)
// 5 possible beginnings of a line, _ is a space // 5 possible beginnings of a line, _ is a space
// 1. _OWNER _ _RRTYPE -> class/ttl omitted // 1. _OWNER _ _RRTYPE -> class/ttl omitted
// 2. _OWNER _ _STRING _ _RRTYPE -> class omitted // 2. _OWNER _ _STRING _ _RRTYPE -> class omitted
@ -216,8 +221,8 @@ func (l Lex) String() string {
return "" return ""
} }
// lexer scans the sourcefile and returns tokens on the channel c. // zlexer scans the sourcefile and returns tokens on the channel c.
func lexer(s scanner.Scanner, c chan Lex) { func zlexer(s scanner.Scanner, c chan Lex) {
var l Lex var l Lex
str := "" // Hold the current read text str := "" // Hold the current read text
quote := false quote := false