From c64673eb4fa6fc053e64093d56c2a140c2bdb793 Mon Sep 17 00:00:00 2001 From: mewmew Date: Fri, 16 Jan 2015 19:57:09 +0100 Subject: [PATCH] asm/lexer: Fix bug in lexComment (not dropping leading semicolon) which was spotted by a failing test case. Updates #8. --- asm/lexer/state.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/asm/lexer/state.go b/asm/lexer/state.go index f3a4d217..0f3a6e95 100644 --- a/asm/lexer/state.go +++ b/asm/lexer/state.go @@ -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 }