Skip to content

Commit

Permalink
Merge pull request #37 from nasa9084/fix-comment
Browse files Browse the repository at this point in the history
Comments must be separated from other tokens by white space characters
  • Loading branch information
goccy authored Nov 12, 2019
2 parents 97cdb16 + 6db264d commit b6878e0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
8 changes: 8 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,14 @@ d: e # comment
a:
b: c
d: e
`,
},
{
`
a: b#notcomment
`,
`
a: b#notcomment
`,
},
{
Expand Down
16 changes: 9 additions & 7 deletions scanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,15 @@ func (s *Scanner) scan(ctx *Context) (pos int) {
return
}
case '#':
s.addBufferedTokenIfExists(ctx)
token, progress := s.scanComment(ctx)
ctx.addToken(token)
s.progressColumn(ctx, progress)
s.progressLine(ctx)
pos += progress
return
if ctx.bufferedSrc() == "" || ctx.previousChar() == ' ' {
s.addBufferedTokenIfExists(ctx)
token, progress := s.scanComment(ctx)
ctx.addToken(token)
s.progressColumn(ctx, progress)
s.progressLine(ctx)
pos += progress
return
}
case '\'', '"':
if ctx.bufferedSrc() == "" {
token, progress := s.scanQuote(ctx, c)
Expand Down

0 comments on commit b6878e0

Please sign in to comment.