From 164ac3a34cbac441e82b256c97cb8784ea9d482c Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Mon, 17 Mar 2008 22:53:01 +0100 Subject: * tools/dfagen: - added dfagen. --- tools/dfagen/dfagen/command.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tools/dfagen/dfagen/command.py (limited to 'tools/dfagen/dfagen/command.py') diff --git a/tools/dfagen/dfagen/command.py b/tools/dfagen/dfagen/command.py new file mode 100644 index 00000000..d384087e --- /dev/null +++ b/tools/dfagen/dfagen/command.py @@ -0,0 +1,23 @@ +import dfagen.parser, dfagen.output +from optparse import OptionParser + +def run (): + opt = OptionParser () + opt.add_option ('-d', '--dfa', dest='dfa', + help='read DFA description from FILE', metavar='FILE') + opt.add_option ('-o', '--output', dest='output', + help='choose output format', metavar='OUTPUT') + opt.add_option ('-c', '--config', dest='config', + 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. + (options, args) = opt.parse_args () + # Read automaton. + f = open (options.dfa, 'r') + a = dfagen.parser.parse ('automaton', f.read ()) + f.close () + # Read config. + cfg = dfagen.output.UserConfig (options.config) + # Produce output. + dfagen.output.get_output (options.output).write (options.prefix, a, cfg) -- cgit v1.2.3