diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-01-17 21:42:13 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2016-01-17 21:42:13 +0100 |
commit | 71cf1f650e2812e43ed5a6edfb36666cfc145fdd (patch) | |
tree | 91305d15cfac1b31a0b0817666408b17f7222bfa | |
parent | 2c2ab6884c1055dedc9dbafbeeb492fecf251ea8 (diff) | |
download | Nim-71cf1f650e2812e43ed5a6edfb36666cfc145fdd.tar.gz |
fixes multiline comments
-rw-r--r-- | compiler/lexer.nim | 6 | ||||
-rw-r--r-- | tests/parser/tmultiline_comments.nim | 16 |
2 files changed, 20 insertions, 2 deletions
diff --git a/compiler/lexer.nim b/compiler/lexer.nim index 4c1dd366b..e51d8db8a 100644 --- a/compiler/lexer.nim +++ b/compiler/lexer.nim @@ -934,8 +934,10 @@ proc skip(L: var TLexer, tok: var TToken) = if buf[pos+1] == '#': break if buf[pos+1] == '[': skipMultiLineComment(L, tok, pos+2, false) - return - while buf[pos] notin {CR, LF, nimlexbase.EndOfFile}: inc(pos) + pos = L.bufpos + buf = L.buf + else: + while buf[pos] notin {CR, LF, nimlexbase.EndOfFile}: inc(pos) else: break # EndOfFile also leaves the loop L.bufpos = pos diff --git a/tests/parser/tmultiline_comments.nim b/tests/parser/tmultiline_comments.nim index 16abc7c3f..72832479d 100644 --- a/tests/parser/tmultiline_comments.nim +++ b/tests/parser/tmultiline_comments.nim @@ -7,6 +7,8 @@ proc main* = Yay, that is so cool. ]## echo "foo bar" + for s in ["one", "two", #["three",]# "four"]: + echo s var foo #[ Test the new inline comments ]#: int = 3 ##[ A @@ -16,3 +18,17 @@ novel documentation comment ]# ]## echo $foo + + #[Comment here. + Multiple lines + are not a problem.]# + + #[ #[ Multiline comment in already + commented out code. ]# + proc p[T](x: T) = discard + ]# + +proc bar = + ##[Long documentation comment + here. + ]## |