by Tim Henderson (tim.tadh@gmail.com)
Computes statistics about the structure of a grammar based on a set of operational inputs.
usage: stat.py [Options] [FILE]+
Explanation
Generates statistics on parse trees. "[FILE]+" is a list of files containing
serialized parse trees. The format for the parse tree is a pre-order
enumeration.
grammar
nodes := nodes node
nodes := node
node := NUM COLON STRING NEWLINE
COLON = r':'
NUM = r'[0-9]+'
STRING = r'.+$'
NEWLINE = "\\n"
NB: Whitespace is signficant, but STRING matches whitespace (except for
newline).
eg.
2:root
2:left side
0:x
1:y
0:z
3:right side
0:a
0:b
0:c
corresponds to
root
/ \
/ \
left side right side
/ \ / | \
x y a b c
|
z
Options
-h, help print this message
-v, version print the version
-g, grammar=<file> supply a known grammar to annotate
-o, outdir=<directory> supply a path to a non-existant
directory
[default: ./gramstats]
-i, imgs=<bool> generate images
[default: true]
-t, tables=<bool> generate statistic tables (as csv files)
[default: true]
-a, artifacts list what artifacts `stat.py` can
generate
-A, artifact=<artspec> generate a specific artifact only.
Multiple '-A' flags allowed.
[overrides -o,-i, and -t]
-T, usetables=<directory> look for pre-existing statistic tables
in this directory. With this option
no other files are required, however
if more examples are given the tables
are updated. The new tables will only
overwrite the old tables if
"-o <dirname>" == "-T <dirname>"
-s, stdin accept ASTs on standard in. With blank
lines seperating trees. If files are
supplied with this flag it will be an
error.
Specs
<file> the path to a file
<directory> the path to a directory.
<bool> either "true" or "false"
<artspec> <artifact>:<file>
<artifact> an artifact in the list generated by
--artifacts