This commit is contained in:
Araq 2013-04-13 01:09:15 +02:00
commit 18fbaab216
4 changed files with 45 additions and 22 deletions

View file

@ -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

View file

@ -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.}