Skip to content

Commit 0c41b40

Browse files
committed
[BUG] lexer: line continuations with single line comments had duplicated new lines
1 parent 4ef2383 commit 0c41b40

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

kdl.nimble

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Package
22

3-
version = "0.2.1"
3+
version = "0.2.2"
44
author = "Patitotective"
55
description = "KDL document language Nim implementation"
66
license = "MIT"

src/kdl/lexer.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ proc tokenSingleLineComment*() {.lexing: tkEmpty.} =
375375
lexer.consume 2
376376
377377
while not lexer.eof(): # Consume until a new line or EOF
378-
if lexer.tokenNewLine():
378+
if lexer.tokenNewLine(addToStack = addToStack):
379379
break
380380
lexer.consume()
381381
@@ -386,7 +386,7 @@ proc tokenLineCont*() {.lexing: tkLineCont.} =
386386
lexer.consume()
387387
388388
lexer.skipwhitespaces()
389-
if not lexer.tokenSingleLineComment() and not lexer.tokenNewLine(addToStack = false):
389+
if not lexer.tokenSingleLineComment(addToStack = false) and not lexer.tokenNewLine(addToStack = false):
390390
lexer.error "Expected a new line"
391391
392392
proc tokenLitMatches() {.lexing: tkEmpty.} =

tests/test_cases/examples/website.kdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ html lang="en" {
66
meta \
77
name="description" \
88
content="kdl is a document language, mostly based on SDLang, with xml-like semantics that looks like you're invoking a bunch of CLI commands!"
9-
title "kdl - Kat's Document Language"
9+
title "kdl - Kat's Document Language" // Comment
1010
link rel="stylesheet" href="/styles/global.css"
1111
}
1212
body {

0 commit comments

Comments
 (0)