4 This is a tool for exploring abstract syntax trees generated by
5 ``parser.suite()`` from test data in
6 docutils/test/test_readers/test_python/test_parser or stdin.
10 showparse <key> <index>
12 showparse < <module.py>
14 Where ``<key>`` is the key to the ``totest`` dictionary, and ``<index>`` is
15 the index of the list ``totest[key]``. If no arguments are given, stdin is
26 names
= token
.tok_name
.copy()
27 names
.update(symbol
.sym_name
)
29 def name_elements(ast
):
32 ast
[0] = '%s (%s)' % (name
, ast
[0])
34 if type(node
) is list:
38 key
, caseno
= sys
.argv
[1:]
39 print 'totest["%s"][%s][0]:\n' % (key
, caseno
)
40 input_text
= test_parser
.totest
[key
][int(caseno
)][0]
42 input_text
= sys
.stdin
.read()
44 module
= parser
.suite(input_text
)
45 ast
= parser
.ast2list(module
, line_info
=1)