lark-parser / lark

Lark is a parsing toolkit for Python, built with a focus on ergonomics, performance and modularity.
MIT License
4.81k stars 409 forks source link

Add Tree.find_token() method #1467

Open makukha opened 3 weeks ago

makukha commented 3 weeks ago

Resolves #1466.

makukha commented 3 weeks ago

I put this method outside of "standalone" scope as it uses scan_values() that is not included as well. Not sure if this is correct.

makukha commented 3 weeks ago

@erezsh ready for review.

erezsh commented 3 weeks ago

Overall looks good. A few requests:

makukha commented 3 weeks ago

I changed isinstance(v, Token) to not isinstance(v, Tree) (same as in _pretty()) to avoid importing Token.

@erezsh ready for review.