question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generate parser for ignored tokens

See original GitHub issue

Is there an easy and failure-proof way to generate a parser (in fact, a lexer) from the ignored tokens of a ‘.lark’ declaration? Let us say we have a grammar.lark file with the following contents:

...
%import .x (A, B, C)
%ignore A
%ignore B
%ignore C

Is there a way to get a parser for the grammar start: (A|B|C)+ without having to write such a grammar explicitly?

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:25 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
erezshcommented, Nov 7, 2022
>>> p = Lark(...)
>>> r'start: (%s)+' % '|'.join(p.ignore_tokens)
'start: (A|B|C)+'
0reactions
pharmpy-dev-123commented, Nov 9, 2022

I understand but I do not know what is in grammar_string when I am solving for the general case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ignore tokens in the token characters?
I have the following token definition in my lexer defining a CharacterString (e.g. 'abcd'): CharacterString: Apostrophe (Alphanumeric)* ...
Read more >
Ignoring tokens in the parser
Hi all, I'm writing a PHP parser with PLY, which you can find here: http://github.com/ramen/phply. The lexer is designed to be as close...
Read more >
JavaCC | The most popular parser generator for use with Java ...
MyParserTokenManager.java - The generated token manager (or scanner/lexical analyzer). ... This option is ignored if either of options USER_TOKEN_MANAGER ...
Read more >
moo-ignore
Moo-ignore is a wrapper around the moo tokenizer/lexer generator that provides a nearley.js compatible lexer with the capacity to ignore ...
Read more >
Parsing Simple Data
(...)+ loop to match sequences of characters and tokens. Access token objects via labeling elements. Have the lexer ignore whitespace and track line...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found