From 3500e0f4aa3626508455b9a59ada3e81e5c9ca01 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Fri, 16 Dec 2011 19:34:30 +0100 Subject: [PATCH] Make Lex a private type: lex --- kscan.go | 6 +++--- zscan.go | 16 ++++++++-------- zscan_rr.go | 34 +++++++++++++++++----------------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/kscan.go b/kscan.go index 5eb13279..8af9b93e 100644 --- a/kscan.go +++ b/kscan.go @@ -94,7 +94,7 @@ func readPrivateKeyECDSA(m map[string]string) (PrivateKey, error) { func ParseKey(r io.Reader) (map[string]string, error) { var s scanner.Scanner m := make(map[string]string) - c := make(chan Lex) + c := make(chan lex) k := "" s.Init(r) s.Mode = 0 @@ -119,8 +119,8 @@ func ParseKey(r io.Reader) (map[string]string, error) { } // klexer scans the sourcefile and returns tokens on the channel c. -func klexer(s scanner.Scanner, c chan Lex) { - var l Lex +func klexer(s scanner.Scanner, c chan lex) { + var l lex str := "" // Hold the current read text commt := false key := true diff --git a/zscan.go b/zscan.go index 3d55876a..aab9e9b3 100644 --- a/zscan.go +++ b/zscan.go @@ -45,7 +45,7 @@ const ( type ParseError struct { err string - lex Lex + lex lex } func (e *ParseError) Error() string { @@ -56,7 +56,7 @@ func (e *ParseError) Error() string { return s } -type Lex struct { +type lex struct { token string // text of the token value int // value: _STRING, _BLANK, etc. line int // line in the file @@ -94,7 +94,7 @@ func NewRR(s string) (RR, error) { func ParseZone(r io.Reader, t chan Token) { defer close(t) var s scanner.Scanner - c := make(chan Lex) + c := make(chan lex) s.Init(r) s.Mode = 0 s.Whitespace = 0 @@ -222,8 +222,8 @@ func ParseZone(r io.Reader, t chan Token) { // I could save my token here...? l r, e := setRR(h, c) if e != nil { - // If e.Lex is nil than we have encounter a unknown RR type - // in that case we substitute our current Lex token + // If e.lex is nil than we have encounter a unknown RR type + // in that case we substitute our current lex token if e.lex.token == "" && e.lex.value == 0 { e.lex = l // Uh, dirty } @@ -236,7 +236,7 @@ func ParseZone(r io.Reader, t chan Token) { } } -func (l Lex) String() string { +func (l lex) String() string { switch l.value { case _STRING: return l.token @@ -255,8 +255,8 @@ func (l Lex) String() string { } // zlexer scans the sourcefile and returns tokens on the channel c. -func zlexer(s scanner.Scanner, c chan Lex) { - var l Lex +func zlexer(s scanner.Scanner, c chan lex) { + var l lex str := "" // Hold the current read text quote := false space := false diff --git a/zscan_rr.go b/zscan_rr.go index a58e581c..e9583618 100644 --- a/zscan_rr.go +++ b/zscan_rr.go @@ -13,7 +13,7 @@ import ( // or immediately a _NEWLINE. If this is not the case we flag // an *ParseError: garbage after rdata. -func setRR(h RR_Header, c chan Lex) (RR, *ParseError) { +func setRR(h RR_Header, c chan lex) (RR, *ParseError) { var r RR e := new(ParseError) switch h.Rrtype { @@ -92,12 +92,12 @@ func setRR(h RR_Header, c chan Lex) (RR, *ParseError) { default: // Don't the have the token the holds the RRtype, but we substitute that in the // calling function when lex is empty. - return nil, &ParseError{"Unknown RR type", Lex{}} + return nil, &ParseError{"Unknown RR type", lex{}} } return r, e } -func slurpRemainder(c chan Lex) *ParseError { +func slurpRemainder(c chan lex) *ParseError { l := <-c if _DEBUG { fmt.Printf("%v\n", l) @@ -122,7 +122,7 @@ func slurpRemainder(c chan Lex) *ParseError { return nil } -func setA(h RR_Header, c chan Lex) (RR, *ParseError) { +func setA(h RR_Header, c chan lex) (RR, *ParseError) { rr := new(RR_A) rr.Hdr = h @@ -134,7 +134,7 @@ func setA(h RR_Header, c chan Lex) (RR, *ParseError) { return rr, nil } -func setAAAA(h RR_Header, c chan Lex) (RR, *ParseError) { +func setAAAA(h RR_Header, c chan lex) (RR, *ParseError) { rr := new(RR_AAAA) rr.Hdr = h @@ -146,7 +146,7 @@ func setAAAA(h RR_Header, c chan Lex) (RR, *ParseError) { return rr, nil } -func setNS(h RR_Header, c chan Lex) (RR, *ParseError) { +func setNS(h RR_Header, c chan lex) (RR, *ParseError) { rr := new(RR_NS) rr.Hdr = h @@ -158,7 +158,7 @@ func setNS(h RR_Header, c chan Lex) (RR, *ParseError) { return rr, nil } -func setMX(h RR_Header, c chan Lex) (RR, *ParseError) { +func setMX(h RR_Header, c chan lex) (RR, *ParseError) { rr := new(RR_MX) rr.Hdr = h @@ -177,7 +177,7 @@ func setMX(h RR_Header, c chan Lex) (RR, *ParseError) { return rr, nil } -func setCNAME(h RR_Header, c chan Lex) (RR, *ParseError) { +func setCNAME(h RR_Header, c chan lex) (RR, *ParseError) { rr := new(RR_CNAME) rr.Hdr = h @@ -189,7 +189,7 @@ func setCNAME(h RR_Header, c chan Lex) (RR, *ParseError) { return rr, nil } -func setSOA(h RR_Header, c chan Lex) (RR, *ParseError) { +func setSOA(h RR_Header, c chan lex) (RR, *ParseError) { rr := new(RR_SOA) rr.Hdr = h @@ -234,7 +234,7 @@ func setSOA(h RR_Header, c chan Lex) (RR, *ParseError) { return rr, nil } -func setRRSIG(h RR_Header, c chan Lex) (RR, *ParseError) { +func setRRSIG(h RR_Header, c chan lex) (RR, *ParseError) { rr := new(RR_RRSIG) rr.Hdr = h l := <-c @@ -310,7 +310,7 @@ func setRRSIG(h RR_Header, c chan Lex) (RR, *ParseError) { return rr, nil } -func setNSEC(h RR_Header, c chan Lex) (RR, *ParseError) { +func setNSEC(h RR_Header, c chan lex) (RR, *ParseError) { rr := new(RR_NSEC) rr.Hdr = h @@ -341,7 +341,7 @@ func setNSEC(h RR_Header, c chan Lex) (RR, *ParseError) { return rr, nil } -func setNSEC3(h RR_Header, c chan Lex) (RR, *ParseError) { +func setNSEC3(h RR_Header, c chan lex) (RR, *ParseError) { rr := new(RR_NSEC3) rr.Hdr = h @@ -396,7 +396,7 @@ func setNSEC3(h RR_Header, c chan Lex) (RR, *ParseError) { } /* -func setNSEC3PARAM(h RR_Header, c chan Lex) (RR, *ParseError) { +func setNSEC3PARAM(h RR_Header, c chan lex) (RR, *ParseError) { rr := new(RR_NSEC3PARAM) rr.Hdr = h l := <-c @@ -421,7 +421,7 @@ func setNSEC3PARAM(h RR_Header, c chan Lex) (RR, *ParseError) { } */ -func setSSHFP(h RR_Header, c chan Lex) (RR, *ParseError) { +func setSSHFP(h RR_Header, c chan lex) (RR, *ParseError) { rr := new(RR_SSHFP) rr.Hdr = h @@ -444,7 +444,7 @@ func setSSHFP(h RR_Header, c chan Lex) (RR, *ParseError) { return rr, nil } -func setDNSKEY(h RR_Header, c chan Lex) (RR, *ParseError) { +func setDNSKEY(h RR_Header, c chan lex) (RR, *ParseError) { rr := new(RR_DNSKEY) rr.Hdr = h @@ -486,7 +486,7 @@ func setDNSKEY(h RR_Header, c chan Lex) (RR, *ParseError) { } // DLV and TA are the same -func setDS(h RR_Header, c chan Lex) (RR, *ParseError) { +func setDS(h RR_Header, c chan lex) (RR, *ParseError) { rr := new(RR_DS) rr.Hdr = h l := <-c @@ -527,7 +527,7 @@ func setDS(h RR_Header, c chan Lex) (RR, *ParseError) { return rr, nil } -func setTXT(h RR_Header, c chan Lex) (RR, *ParseError) { +func setTXT(h RR_Header, c chan lex) (RR, *ParseError) { rr := new(RR_TXT) rr.Hdr = h