summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-04-13 01:09:15 +0200
committerAraq <rumpf_a@web.de>2013-04-13 01:09:15 +0200
commit18fbaab216e3dc59011b871849ebcf4bfab94afd (patch)
treeb564b6b4ce28e551484b36a2659762af10e25ea7 /compiler
parent3cb3813eed378d753807a07f434234ce2d4c5159 (diff)
downloadNim-18fbaab216e3dc59011b871849ebcf4bfab94afd.tar.gz
fixes #310
Diffstat (limited to 'compiler')
-rw-r--r--compiler/lexer.nim3
-rw-r--r--compiler/parser.nim4
2 files changed, 5 insertions, 2 deletions
diff --git a/compiler/lexer.nim b/compiler/lexer.nim
index 02f63aee8..9cf5ccb2b 100644
--- a/compiler/lexer.nim
+++ b/compiler/lexer.nim
@@ -675,6 +675,8 @@ proc scanComment(L: var TLexer, tok: var TToken) =
   # a comment ends if the next line does not start with the # on the same
   # column after only whitespace
   tok.tokType = tkComment
+  # iNumber contains the number of '\n' in the token
+  tok.iNumber = 0
   var col = getColNumber(L, pos)
   while true:
     var lastBackslash = -1
@@ -699,6 +701,7 @@ proc scanComment(L: var TLexer, tok: var TToken) =
     if buf[pos] == '#' and (col == indent or lastBackslash > 0):
       tok.literal.add "\n"
       col = indent
+      inc tok.iNumber
     else:
       if buf[pos] > ' ': 
         L.indentAhead = indent
diff --git a/compiler/parser.nim b/compiler/parser.nim
index 81adecac2..769aa7a3e 100644
--- a/compiler/parser.nim
+++ b/compiler/parser.nim
@@ -1207,9 +1207,9 @@ proc parseRoutine(p: var TParser, kind: TNodeKind): PNode =
     addSon(result, ast.emptyNode)
   indAndComment(p, result)    # XXX: document this in the grammar!
   
-proc newCommentStmt(p: var TParser): PNode = 
+proc newCommentStmt(p: var TParser): PNode =
   result = newNodeP(nkCommentStmt, p)
-  result.info.line = result.info.line - int16(1)
+  result.info.line = result.info.line - int16(1) - int16(p.tok.iNumber)
 
 type 
   TDefParser = proc (p: var TParser): PNode {.nimcall.}