Questions tagged [lark-parser]

Questions about the Lark parser project

Use this tag when asking questions about the Lark parser project (https://github.com/lark-parser/lark)

97 questions
0
votes
1 answer

recognizing multi-line sections with lark grammar

I'm trying to write a simple grammar to parse text with multi-line sections.. I'm not able to wrap my head around how to do it. Here's the grammar that I've written so far - would appreciate any help here. ps: I realize that lark is overkill for…
RoyM
  • 1,118
  • 1
  • 9
  • 28
0
votes
0 answers

Python LARK: terminal character inside text confusion

I'm trying to parse using Python Lark the output of a plan from a database. Here's my grammar: start: op op: command "(" op ")" "[" text "]" | command "(" op ")" "[" text "]" WORD | command "(" op ")" "[" text "]" "," op | command…
0
votes
0 answers

How to "catch" terminals in Lark-based parser using the 'dynamic' lexers

This is a follow-up question to my previous: Why do we need to specify the standard Lark lexer to be able to catch comment terminals? I need to "catch" and save comments in the DSL parsed by the Lark-based parser. It seems to work well when using…
Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
0
votes
0 answers

Lark serialisation

I'm using python lark to parse a domain specific language and I havn't yet made the grammar file of the quality required to use lalr parsing. The parsing of a simple file is therefore taking over 3 seconds. Is there a simple way to serialise the…
jhylands
  • 984
  • 8
  • 16
0
votes
2 answers

Python Lark parser: no versions I've installed seem to have the .pretty() print method

Problem: # From example at https://github.com/lark-parser/lark/blob/master/examples/json_parser.py from lark import Lark, Transformer, v_args parse = json_parser.parse json_grammar = r""" ... """ ### Create the JSON parser with Lark, using the LALR…
Mark Bennett
  • 1,446
  • 2
  • 19
  • 37
0
votes
1 answer

How can I get a list of variable names from a lark-parser Tree?

I am using python 3.8.5 and lark-parser 0.11.2. I have a question about Visitors. I have a grammar for my needs and Lark is working great. I have a case where, under some conditions, I want to evaluate a returned parse tree and scan it to get a,…
7 Reeds
  • 2,419
  • 3
  • 32
  • 64
0
votes
1 answer

Is there a way to make a Terminal match every NAME except for specific keywords?

I am using lark to parse some text and needed a way to match a NAME that did not have certain keywords in it. I have the keywords listed out in a terminal I am just not sure how to make the terminal I need using it. Here is the way I formatted my…
Asra
  • 151
  • 1
  • 11
0
votes
1 answer

Removal of regex terminal from AST returned by lark-parser

I am interested in parsing typical output of a website crawler using lark. Here is an example of some sample output based on my own github website: -------------------------------------------------------------------- All found…
user32882
  • 5,094
  • 5
  • 43
  • 82
0
votes
2 answers

Unambiguous gramar for let e1 in e2

I was trying to create an let grammar my idea was somthing like this start : let let : "let" ID ("=" let)? in let | atom atom : ANYTHING | "(" let ")" ID : /[a-z]+/ The idea is to parse expressions like this let A = B in C or let A in B or both…
geckos
  • 5,687
  • 1
  • 41
  • 53
0
votes
1 answer

Grammar rules for parsing optional keywords from list of words with LALR

I have strings with words like this: "ABC Some other stuff" (normaly there is a short letter combination at the beginning) "Some other stuff" (sometimes there is nothing interesting) "HFG 54 Some other stuff and even more" (sometimes there is an…
HrkBrkkl
  • 613
  • 5
  • 22
0
votes
1 answer

How should I define a NOT operator which supports both NOT and AND NOT in LARK

This is how my current code looks like, it only supports a AND NOT b. Is there a way to make it also return the same tree for a NOT b? Any suggestions will be appreciated. from lark import Lark grammar = r''' start: or_test ?or_test:…
Harrison
  • 2,560
  • 7
  • 29
  • 55
0
votes
0 answers

Lark parser Indenter class not working while using lark.visitors.Interpreter class

So I'm making a programming language using the lark library in python, up until now, I was using the class Transformer(), but now I've switched to the lark.visitors.Interpreter() class. I've been copying over my progress from Transformer to…
0
votes
1 answer

Lark parser parsing input in wrong order

So I'm making a programming language in python using lark, and when I parse an input such as print("HI"); x = input("Number: "); It parses the input statement before the print statement. Below is somewhat what my code looks like. from lark import…
0
votes
1 answer

Lark transformer returning Tree while parsing multiple statements

I'm making a programming language using Lark, and I'm trying to parse multiple statements from a file. When I parse print("HI"); print("HI"); It returns Tree('start', ['HI', HI']) But when I parse print("Hi"); It returns Hi Heres what my grammar…
0
votes
2 answers

How can I parse a string with unicode characters in lark-parser in python

I'm trying to use lark parser in Python to parse some sql strings. Some of the statements have unicode characters in them, causing the parser to throw error (strings with ó,é). I'm using the following lines to define strings in my .lark…