summaryrefslogtreecommitdiff
path: root/src/mem/slicc/main.py
diff options
context:
space:
mode:
authorJason Lowe-Power <jason@lowepower.com>2018-05-28 13:52:14 -0700
committerJason Lowe-Power <jason@lowepower.com>2018-06-14 22:15:21 +0000
commit74a8947fcb37ec4b3d43cf96740c474f0e3ffed8 (patch)
tree807000a621b8a27b8a4667ce3fe9b1bf8cd5464f /src/mem/slicc/main.py
parent96554eca9f7731f6f5e56f9f29c933e230e34bd8 (diff)
downloadgem5-74a8947fcb37ec4b3d43cf96740c474f0e3ffed8.tar.xz
ruby: Revamp standalone SLICC script
There was some bitrot in the standalone SLICC script (util/slicc and src/mem/slicc/main.py). Fix the changes to the SLICC interface and also add some better documentation. Change-Id: I91c0ec78d5072fba83edf32b661ae67967af7822 Signed-off-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-on: https://gem5-review.googlesource.com/10561 Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Diffstat (limited to 'src/mem/slicc/main.py')
-rw-r--r--src/mem/slicc/main.py29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/mem/slicc/main.py b/src/mem/slicc/main.py
index 05a5cdb97..f2a47510f 100644
--- a/src/mem/slicc/main.py
+++ b/src/mem/slicc/main.py
@@ -32,13 +32,19 @@ import sys
from slicc.parser import SLICC
-usage="%prog [options] <files> ... "
+usage="%prog [options] <slicc file> ... "
version="%prog v0.4"
brief_copyright='''
Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
Copyright (c) 2009 The Hewlett-Packard Development Company
All Rights Reserved.
'''
+help_details = '''This is intended to be used to process slicc files as a
+standalone script. This script assumes that it is running in a directory under
+gem5/ (e.g., gem5/temp). It takes a single argument: The path to a *.slicc
+file. By default it generates the C++ code in the directory generated/. This
+script can also generate the html SLICC output. See src/mem/slicc/main.py for
+more details.'''
def nprint(format, *args):
pass
@@ -53,6 +59,7 @@ def main(args=None):
import optparse
parser = optparse.OptionParser(usage=usage, version=version,
+ epilog=help_details,
description=brief_copyright)
parser.add_option("-d", "--debug", default=False, action="store_true",
help="Turn on PLY debugging")
@@ -60,7 +67,7 @@ def main(args=None):
help="Path where C++ code output code goes")
parser.add_option("-H", "--html-path",
help="Path where html output goes")
- parser.add_option("-F", "--print-files",
+ parser.add_option("-F", "--print-files", action='store_true',
help="Print files that SLICC will generate")
parser.add_option("--tb", "--traceback", action='store_true',
help="print traceback on error")
@@ -72,12 +79,21 @@ def main(args=None):
parser.print_help()
sys.exit(2)
+ slicc_file = files[0]
+ if not slicc_file.endswith('.slicc'):
+ print("Must specify a .slicc file with a list of state machine files")
+ parser.print_help()
+ sys.exit(2)
+
output = nprint if opts.quiet else eprint
output("SLICC v0.4")
output("Parsing...")
- slicc = SLICC(files[0], verbose=True, debug=opts.debug, traceback=opts.tb)
+ protocol_base = os.path.join(os.path.dirname(__file__), '..', 'protocol')
+ slicc = SLICC(slicc_file, protocol_base, verbose=True, debug=opts.debug,
+ traceback=opts.tb)
+
if opts.print_files:
for i in sorted(slicc.files()):
@@ -86,13 +102,14 @@ def main(args=None):
output("Processing AST...")
slicc.process()
- output("Writing C++ files...")
- slicc.writeCodeFiles(opts.code_path)
-
if opts.html_path:
output("Writing HTML files...")
slicc.writeHTMLFiles(opts.html_path)
+ output("Writing C++ files...")
+ slicc.writeCodeFiles(opts.code_path, [])
+
+
output("SLICC is Done.")
if __name__ == "__main__":