Discussion about PostLexer API
See original GitHub issueThis is a greatly simplified version of what I want to do:
from lark import Lark, Token
class SimplePostLex:
def process(self, stream):
for t in stream:
return Token.new_borrow_position('B', t.value, t)
@property
def always_accept(self):
return 'A',
p = Lark("""
start: B
A: "A"
%declare B
""", parser='lalr', postlex=SimplePostLex())
p.parse('A')
This does not work since the lexer does not accept A
-Tokens, even though I told him to do so. It works if I include an A
Token somewhere in the grammar.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Parser or postlex causing an error in Lark - Stack Overflow
Providing a PostLexer changes the default parser/lexer combo from earley/dynamic to earley/basic , since the dynamic parser can't handle the ...
Read more >Topics API: developer guide
The design of the Topics API is currently under discussion as an explainer, which is only the first step in the standardization process....
Read more >lex - When an error happens, how can I display all tokens matched ...
It's possible to collect all the tokens by writing a postlexer. Another way is to parse using the interactive parser. Mind if I...
Read more >Notepad++ / Discussion / [READ ONLY] Open Discussion: Notepad ...
Have had no problem with it post lexer removal. Might be the interaction between the external lexer & the main program munged something...
Read more >Guppy: trying to make parsing simple, fun, and powerful
To start discussion, I'll introduce the biggest fundamental problem ... guppy might provide an API for traversing the tree with selectors.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t like
always_accept
as a feature of the PostLexer either. That is simply not the place it belongs. (It changes the behavior of the Lexer even though it is supposed to happen afterwards). It would be better inside the grammar.I am not sure if I like the idea of being able to edit the ignore list:
Fixed in #708