Skip to content

Commit

Permalink
Merge pull request #30 from 422404/fix/token-column-number
Browse files Browse the repository at this point in the history
Nodes column number now starts at 1 as it should be
  • Loading branch information
422404 committed Mar 26, 2022
2 parents 87ef8d0 + 3ef0d7f commit 05ffd58
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/kotlin/org/actorlang/parser/impl/AntlrParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class AntlrParser : ActorLangBaseVisitor<Node>(), Parser {
}

private fun sourcePosition(token: Token) =
Position(token.line, token.charPositionInLine, token.inputStream.sourceName)
Position(token.line, token.charPositionInLine + 1, token.inputStream.sourceName)

private fun createBinaryOpOrExpressionNode(
type: BinaryOpType,
Expand Down
15 changes: 15 additions & 0 deletions src/test/kotlin/org/actorlang/parser/impl/AntlrParserTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.actorlang.parser.impl

import org.junit.jupiter.api.Test
import kotlin.test.assertEquals

class AntlrParserTest {

@Test
fun `Nodes line and column both start at 1`() {
val parser = AntlrParserFactory().createParser()
val rootNode = parser.parse("a = 42", "<test>")
assertEquals(1, rootNode.startPosition.line)
assertEquals(1, rootNode.startPosition.column)
}
}

0 comments on commit 05ffd58

Please sign in to comment.