summaryrefslogtreecommitdiff
path: root/tools/dfagen/dfagen/command.py
diff options
context:
space:
mode:
authorNicolas Schodet2009-05-08 23:07:25 +0200
committerNicolas Schodet2009-05-08 23:07:25 +0200
commitb566e4bcd0c7cb3c90ad941b37db223134090ded (patch)
tree7d3f24a25860e17e7fa9cd017ad2d8bd8c0bd227 /tools/dfagen/dfagen/command.py
parent6b3d5061623a35c96e66e25fc14af6a9323f81b0 (diff)
* tools/dfagen:
- added state attributes. - added support for more than one initial state. - added table of transitions with only one default branch. - added state and event template parameter. - added --output-dir. - make template directory relative to config file. - more options checking. - added transition attributes and callback definition. - conserve input file order in output. - added --dump and more option checking. - fixed missing newline.
Diffstat (limited to 'tools/dfagen/dfagen/command.py')
-rw-r--r--tools/dfagen/dfagen/command.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/tools/dfagen/dfagen/command.py b/tools/dfagen/dfagen/command.py
index 8a976023..3325d6c1 100644
--- a/tools/dfagen/dfagen/command.py
+++ b/tools/dfagen/dfagen/command.py
@@ -17,13 +17,25 @@ def run ():
help='read output configuration from FILE', metavar='FILE')
opt.add_option ('-p', '--prefix', dest='prefix',
help='use PREFIX for generated output', metavar='PREFIX')
- # TODO add more error checking.
+ opt.add_option ('-O', '--output-dir', dest='output_dir', default='',
+ help='generate output in DIR', metavar='DIR')
+ opt.add_option ('--dump', action='store_true', default=False,
+ help='dump the read automaton')
(options, args) = opt.parse_args ()
+ if (options.dfa is None
+ or not options.dump and options.output is None
+ or len (args) != 0):
+ opt.error ('bad arguments')
# Read automaton.
f = open (options.dfa, 'r')
a = dfagen.parser.parse ('automaton', f.read ())
f.close ()
+ # Dump automaton.
+ if options.dump:
+ print a
# Read config.
cfg = dfagen.output.UserConfig (options.config)
# Produce output.
- dfagen.output.get_output (options.output).write (options.prefix, a, cfg)
+ if options.output is not None:
+ dfagen.output.get_output (options.output).write (options.prefix, a,
+ cfg, options.output_dir)