lark-parser / lark

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

Update parse_tree_builder.py #1291

Closed jmishra01 closed 1 year ago

jmishra01 commented 1 year ago

List function is not required, and rule check in callback dict should be after loop

erezsh commented 1 year ago

Hello! Thanks for the PR. You're right about moving the rule check up in the loop. But I prefer that you avoid changing lines only for cosmetic reasons, especially when it's very subjective, like removing blank lines that separate code blocks.

jmishra01 commented 1 year ago

Revert changing lines changes.

erezsh commented 1 year ago

@jmishra01 Thanks. Also, we're calling list() both times so that self.rule_builders can be permanent, which means create_callback() can be called more than once, and also that way it can be observed when debugging. It's not a huge difference, but there is just no reason not to do so. Sorry, I should have mentioned it in my previous message.

jmishra01 commented 1 year ago

@erezsh Thanks. Understood the reason behind calling list(). I'm closing this PR.

erezsh commented 1 year ago

@jmishra01 You can re-open with just the rule-check. I'll be happy to merge that in.