From b566e4bcd0c7cb3c90ad941b37db223134090ded Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Fri, 8 May 2009 23:07:25 +0200 Subject: * 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. --- tools/dfagen/dfagen/command.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'tools/dfagen/dfagen/command.py') 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) -- cgit v1.2.3