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

Is a generated standalone parser really standalone? #1279

Closed laowantong closed 1 year ago

laowantong commented 1 year ago

When I open a generated stand-alone parser, VSCode marks quite a few identifiers as unknown, e.g., .lexer, InteractiveParser, _serialize, Enumerator, etc.

image

Are they somehow dynamically resolved during execution?

erezsh commented 1 year ago

These are parts of the code that never actually run. They are copied over from the Lark library along with chunks that do run.

Ideally we should produce a standalone without any unknown symbols, I guess no one cared enough so far to fix it.

(InteractiveParser should be available in standalone, I think?)

laowantong commented 1 year ago

Thanks for the explanation. Indeed, I have not encountered any case in which this dead code has caused problems.

One more nitpick though: I initially thought that the issue was solved (since you closed it as "completed", instead of "not planned"), but the file generated by Lark v1.1.7 still presents the same issue.

PS: I don't know about InteractiveParser, but I can confirm that PyLance doesn't know how to resolve it.

image