Skip to content

Commit

Permalink
asm/lexer: Fix bug in lexComment (not dropping leading semicolon) whi…
Browse files Browse the repository at this point in the history
…ch was spotted by a failing test case. Updates #8.
  • Loading branch information
mewmew committed Jan 16, 2015
1 parent af31e48 commit c64673e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions asm/lexer/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,16 @@ func lexComment(l *lexer) stateFn {
l.errorf("illegal UTF-8 encoding")
case eof:
// Ignore trailing carriage return characters.
s := strings.TrimRight(l.input[l.start:l.cur], "\r")
s := l.input[l.start+1 : l.cur] // skip leading semicolon (;)
s = strings.TrimRight(s, "\r")
l.emitCustom(token.Comment, s)
l.emitEOF()
// Terminate the lexer with a nil state function.
return nil
case '\n':
// Ignore trailing carriage return and newline characters.
s := strings.TrimRight(l.input[l.start:l.cur], "\r\n")
s := l.input[l.start+1 : l.cur] // skip leading semicolon (;)
s = strings.TrimRight(s, "\r\n")
l.emitCustom(token.Comment, s)
return lexToken
}
Expand Down

0 comments on commit c64673e

Please sign in to comment.