Parse comments in the lexer

This commit is contained in:
Miek Gieben 2013-03-04 09:58:09 +01:00
parent a5e9f8010d
commit ff062b8157
1 changed files with 24 additions and 0 deletions

View File

@ -488,6 +488,13 @@ func zlexer(s *scan, c chan lex) {
c <- l c <- l
return return
} }
if comi > maxTok {
l.token = "com length insufficient for parsing"
l.err = true
debug.Printf("[%+v]", l.token)
c <- l
return
}
switch x { switch x {
case ' ', '\t': case ' ', '\t':
@ -499,6 +506,8 @@ func zlexer(s *scan, c chan lex) {
} }
escape = false escape = false
if commt { if commt {
com[comi] = x
comi++
break break
} }
if stri == 0 { if stri == 0 {
@ -595,6 +604,8 @@ func zlexer(s *scan, c chan lex) {
stri = 0 stri = 0
} }
commt = true commt = true
com[comi] = ';'
comi++
case '\r': case '\r':
// discard // discard
// this means it can also not be used as rdata // this means it can also not be used as rdata
@ -620,7 +631,11 @@ func zlexer(s *scan, c chan lex) {
l.token = "\n" l.token = "\n"
debug.Printf("[3 %+v]", l.token) debug.Printf("[3 %+v]", l.token)
c <- l c <- l
comi = 0
break
} }
com[comi] = ' ' // convert newline to space
comi++
break break
} }
@ -647,10 +662,13 @@ func zlexer(s *scan, c chan lex) {
commt = false commt = false
rrtype = false rrtype = false
owner = true owner = true
comi = 0
} }
case '\\': case '\\':
// quote? // quote?
if commt { if commt {
com[comi] = x
comi++
break break
} }
if escape { if escape {
@ -664,6 +682,8 @@ func zlexer(s *scan, c chan lex) {
escape = true escape = true
case '"': case '"':
if commt { if commt {
com[comi] = x
comi++
break break
} }
if escape { if escape {
@ -692,6 +712,8 @@ func zlexer(s *scan, c chan lex) {
break break
} }
if commt { if commt {
com[comi] = x
comi++
break break
} }
if escape { if escape {
@ -715,6 +737,8 @@ func zlexer(s *scan, c chan lex) {
} }
default: default:
if commt { if commt {
com[comi] = x
comi++
break break
} }
escape = false escape = false