Questions tagged [lark]

6 questions
1
vote
1 answer

How do you make an "opposite" pattern? - Needed to define a grammar with lark

The regex [a-zA-Z-]+:: matches strings like one-name::. I would like a regex that will do the opposite. Is there an "automated" way to build such a regex? I can't just check the failure of the first regex, as I have to use a "negated" regex with…
projetmbc
  • 1,332
  • 11
  • 26
1
vote
1 answer

Use lark to analyze reST markup language like sections

I would like to define one basic grammar such as to start to work with lark. Here is my M(not)WE. from lark import Lark GRAMMAR = r""" ?start: _NL* (day_heading)* day_heading : "==" _NL day_nb _NL "==" _NL+ (paragraph _NL)* day_nb :…
projetmbc
  • 1,332
  • 11
  • 26
0
votes
0 answers

How to recursively read many include files with lark?

For this config file format: # comments here # next an empty commment line # include "parseconf/dir_with_many_files" Thing1 "objname" { InnerThing "inner_thing_name" { IP_Address = "10.12.14.1" Hostname = "abc.fred.com" …
tuck1s
  • 1,002
  • 9
  • 28
0
votes
2 answers

Accept an optional substring with Lark's LALR(1) parser

I would like to use Lark to generate a standalone parser for a small rational language of mine. This needs to be a LALR(1) parser. It should accept the following input: (lorem) consectetur adipiscing elit (lorem) [ipsum dolor sit amet] consectetur…
Aristide
  • 3,606
  • 2
  • 30
  • 50
0
votes
1 answer

define statement only works if followed by an assignment in Lark grammar

I am creating a parser with Lark. The parser works fine for most of the tests I ran, but failed with the define keyword. It only works if it is followed by an assignement. define a = 10 works just fine, but define b is not treated as a define…
Mstrdav
  • 91
  • 1
  • 5
0
votes
0 answers

Lark : Storing and/or passing data to Transformer

In Lark parser how do I pass out of bound data to the Transformer, so I can process the text differently based on the value of the argument f.e.. lets say I can modify the Parser, then i want a behavior as if ... parser.parse(txt,…
sten
  • 7,028
  • 9
  • 41
  • 63