114 questions
0 votes
0 answers
38 views
Context-sensitive rules in lark LARL parser
I'm building a LALR grammar for a language where ">" can be either a) the greater-than operator b) the closing bracket of a "<" ... ">" construct (tuple literal) ...
1 vote
1 answer
72 views
optional Newline at end of file messes up lark grammar parsing
I have a file contents. if the final line has a NL at the end, i get 2 token trees as expected, but of the file doesn't have a final NL, i end up with 3 trees which is unwanted. How do i get lark to ...
2 votes
1 answer
78 views
Why does this grammar work using the Earley parser but not LALR(1)
I wrote this grammar to describe a simple patch procedure we use at work, operating on source code files. Engineers check in files of the form: {ignored space} //find_start {possible comment or ...
0 votes
1 answer
60 views
Python package Lark does not build the grammar correctly
I would need to build a Tree that would retrieve something like this using Lark package: start expr or_expr and_expr comp_expr identifier Name comparator ...
0 votes
0 answers
30 views
no matches for a rule in lark grammar
I'd like to catch some word in text (say, "var"). So the rules rules = r""" start: expr+ expr: var | anything var.2: VAR anything: ANYTHING ANYTHING: /[\...
0 votes
0 answers
48 views
Multiple Aliases for a Terminal or Rule
Can one assign multiple aliases for a terminal or rule in Lark ? Consider the following grammar coordinate : "(" X "," Y ")" %import common.SIGNED_NUMBER -> X %import ...
0 votes
1 answer
87 views
Handling the presence or absence of a token in EBNF / Lark
I'm making early steps with the Lark library in Python and am really looking forward to replacing a lot of awful if statements with an EBNF parser..! The task here is interpreting the times written in ...
2 votes
2 answers
139 views
LALR Grammar for transforming text to csv
I have a processor trace output that has the following format: Time Cycle PC Instr Decoded instruction Register and memory contents 905ns 86 00000e36 00a005b3 c.add ...
1 vote
0 answers
58 views
How to extract a string according to rule of python lark ebnf?
I would like to parse the following PlantUML which likes flow-charts, by using python lark package. The syntax of each action is based on verilog-hdl. PlantUML @startuml :[7:0] a; :write(reg01, 8'h01, ...
0 votes
1 answer
124 views
Unclear reason for terminal collision
I am new to lexers and parsers in general and to working with Lark in particular. I am using the versions lark 1.1.9 and interegular 0.3.3. I started writing a grammar which produces a warning when ...
1 vote
0 answers
40 views
Avoid doubling every rule for NEWLINE vs DOUBLE_NEWLINE
I want blank new lines to be syntactically significant (optimization for leaf leaning trees [[[a, b], c, d], e, [g], f] == [a b | c d | e [g] f] but with \n\n instead of |). But the only way I can ...
0 votes
1 answer
187 views
Lark: how to inline rule. DRY
I dont want the func rule here, it's merely to avoid repetition. func: monad | dyad | builtin dyad: "{" dyad* func+ "}" | func+ ":" monad: "(" monad* func+ &...
0 votes
1 answer
128 views
Disambiguating expressions in Lark syntax
I have a (Lark) grammar that I think should be unambiguous, but depending on the version of Lark, fails to parse in one way or another: import lark syntax = r""" stmt: mov_stmt | ...
0 votes
2 answers
177 views
Why is my example to parse bold text with Lark not working?
I defined the following grammar: from lark import Lark grammar = r''' start: ( bold_text | text) bold_text.2: "**" text "**" text.1: /.+/ ''' parser = Lark(grammar, ...
1 vote
1 answer
160 views
SQL Select Statement Parser not returning JOIN type
I want to parse through a SQL Select Statement that has all the features a normal SQL dialect like MySQL has too. I looked for parsing libraries in python but couldn't find one that is doing the job. ...