Browse Source
Handle eof in comments and do not prematurely close file handler
master
v0.2.3
No known key found for this signature in database
GPG Key ID: A2ECAB73CE12147F
2 changed files with
1 additions and
2 deletions
-
parser.go
-
scanner.go
|
|
|
@ -40,7 +40,6 @@ func NewParser(reader io.Reader) *Parser { |
|
|
|
// NewFileParser will create and initialize a new Parser from a provided from a filename string
|
|
|
|
func NewFileParser(filename string) (*Parser, error) { |
|
|
|
reader, err := os.Open(filename) |
|
|
|
defer reader.Close() |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
@ -167,7 +167,7 @@ func (scanner *Scanner) parseComment() { |
|
|
|
scanner.curTok.Literal = "" |
|
|
|
for { |
|
|
|
scanner.readRune() |
|
|
|
if scanner.curCh == '\n' { |
|
|
|
if scanner.curCh == '\n' || scanner.curCh == eof { |
|
|
|
break |
|
|
|
} |
|
|
|
scanner.curTok.Literal += string(scanner.curCh) |
|
|
|
|