Feature or enhancement
As a companion to the proposed token browser (#152941), visualizing the abstract syntax tree helps in learning how Python parses code and in understanding the structure that the compiler works from.
I propose an AST Browser added as an extension on the Tools menu (Shell and editor). It shows ast.parse of the current window as a hierarchical, fully expanded ttk.Treeview, each node labeled with its type and inline simple fields.
Interaction:
- Selecting a node highlights the corresponding source in the editor.
- The browser follows the editor: the editor selection (or cursor) selects the single smallest enclosing node.
- Scope is the editor selection if it parses, else the Shell's current input, else the whole window (a context-dependent fragment that does not parse reports the syntax error).
It shares the window skeleton and editor-sync mechanism with the token browser, so the two are best reviewed and landed together.
A PR will follow.
Linked PRs
Feature or enhancement
As a companion to the proposed token browser (#152941), visualizing the abstract syntax tree helps in learning how Python parses code and in understanding the structure that the compiler works from.
I propose an AST Browser added as an extension on the Tools menu (Shell and editor). It shows
ast.parseof the current window as a hierarchical, fully expandedttk.Treeview, each node labeled with its type and inline simple fields.Interaction:
It shares the window skeleton and editor-sync mechanism with the token browser, so the two are best reviewed and landed together.
A PR will follow.
Linked PRs