ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
Looks like the Natural Language Toolkit can pretty-print the AST that comes out of pygrun -t:
from nltk import Tree
tree = Tree.fromstring('...')
tree.pretty_print()
>>>
program
________|_________
| dec
| |
| predicate
| _________|________________
| | | | boolean_expressi
| | | | on
| | | | |
newLine Predicate hello := True
It would be trivial to add this to the existing pygrun python file (and I would happily do it), but is importing outside repos for tiny amounts of functionality like this frowned upon?
Hi,
since this is only useful during dev I would not want to include it in the runtime itself.
But I would be ok with a self documented auxiliary file.
Looks like the Natural Language Toolkit can pretty-print the AST that comes out of
pygrun -t
:It would be trivial to add this to the existing pygrun python file (and I would happily do it), but is importing outside repos for tiny amounts of functionality like this frowned upon?