From f04ec7504e7ff3a3df376298c4353496fd840e1a Mon Sep 17 00:00:00 2001 From: Erez Shinan Date: Fri, 31 Oct 2025 17:40:05 -0500 Subject: [PATCH] lexer: Always init line_ctr, for a more predictable interface, even if not needed --- lark/lexer.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lark/lexer.py b/lark/lexer.py index 9aa10c2e..0b483d17 100644 --- a/lark/lexer.py +++ b/lark/lexer.py @@ -429,6 +429,8 @@ def __init__(self, text: TextSlice, line_ctr: Optional[LineCounter] = None, last if not (text.start <= line_ctr.char_pos <= text.end): raise ValueError("LineCounter.char_pos is out of bounds") + else: + line_ctr = line_ctr or LineCounter('\n') self.text = text self.line_ctr = line_ctr