Skip to content

Commit

Permalink
fix doubling of certain comments
Browse files Browse the repository at this point in the history
  • Loading branch information
arnetheduck committed Dec 11, 2023
1 parent b8fb2d7 commit 850c363
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/phparser.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2649,9 +2649,9 @@ proc parseEnum(p: var Parser): PNode =
symPragma.add(a)
symPragma.add(pragma)

let symInd = p.currInd
comments.add commentLookahead(p)

comments.add commentLookahead(p)
let symInd = p.currInd
if p.tok.indent >= 0 and p.tok.indent <= p.currInd:
p.skipped = splitComments(comments, symPragma, symInd, clPostfix)

Expand Down Expand Up @@ -3256,9 +3256,10 @@ proc parseStmt(p: var Parser): PNode =
p.hasProgress = false
if p.tok.tokType in {tkElse, tkElif}:
break
# Allow this too, see tests/parser/tifexprs

let a = complexOrSimpleStmt(p)
# Allow this too, see tests/parser/tifexprs
let
a = complexOrSimpleStmt(p)
if a.kind == nkEmpty and not p.hasProgress:
debugEcho 3

Expand Down
5 changes: 2 additions & 3 deletions src/phrenderer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1108,10 +1108,9 @@ proc gstmts(g: var TSrcGen; n: PNode; c: TContext; doIndent = true) =
if doIndent:
indentNL(g)

gprefixes(g, n)

var lastKind = nkStmtList
if n.kind in {nkStmtList, nkStmtListExpr, nkStmtListType}:
gprefixes(g, n)
for i in 0 ..< n.len:
# This groups sections by their kind, giving a bit of air between "parts"
# of code - we don't do it before control flow because there, the code
Expand All @@ -1132,11 +1131,11 @@ proc gstmts(g: var TSrcGen; n: PNode; c: TContext; doIndent = true) =
gcoms(g)

lastKind = n[i].kind
gpostfixes(g, n)
else:
gsub(g, n)
gcoms(g)

gpostfixes(g, n)
if doIndent:
dedent(g)

Expand Down

0 comments on commit 850c363

Please sign in to comment.