summaryrefslogtreecommitdiff
path: root/src/mem/slicc/parser.py
diff options
context:
space:
mode:
authorJason Power <power.jg@gmail.com>2012-09-12 14:52:04 -0500
committerJason Power <power.jg@gmail.com>2012-09-12 14:52:04 -0500
commitaa8bcd15ec1ba916f3e750f41697a65e06b3c2ac (patch)
treeef66477d4b1904699ab751a841ff465768ab158e /src/mem/slicc/parser.py
parentc6927ed13868c096a60df6a217f92857799b5be6 (diff)
downloadgem5-aa8bcd15ec1ba916f3e750f41697a65e06b3c2ac.tar.xz
Ruby: Modify Scons so that we can put .sm files in extras
Also allows for header files which are required in slicc generated code to be in a directory other than src/mem/ruby/slicc_interface.
Diffstat (limited to 'src/mem/slicc/parser.py')
-rw-r--r--src/mem/slicc/parser.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/mem/slicc/parser.py b/src/mem/slicc/parser.py
index e4f3ba952..77ac4de56 100644
--- a/src/mem/slicc/parser.py
+++ b/src/mem/slicc/parser.py
@@ -38,11 +38,12 @@ import slicc.util as util
from slicc.symbols import SymbolTable
class SLICC(Grammar):
- def __init__(self, filename, verbose=False, traceback=False, **kwargs):
+ def __init__(self, filename, base_dir, verbose=False, traceback=False, **kwargs):
self.protocol = None
self.traceback = traceback
self.verbose = verbose
self.symtab = SymbolTable(self)
+ self.base_dir = base_dir
try:
self.decl_list = self.parse_file(filename, **kwargs)
@@ -64,8 +65,8 @@ class SLICC(Grammar):
self.decl_list.findMachines()
self.decl_list.generate()
- def writeCodeFiles(self, code_path):
- self.symtab.writeCodeFiles(code_path)
+ def writeCodeFiles(self, code_path, includes):
+ self.symtab.writeCodeFiles(code_path, includes)
def writeHTMLFiles(self, html_path):
self.symtab.writeHTMLFiles(html_path)
@@ -249,7 +250,10 @@ class SLICC(Grammar):
def p_decl__include(self, p):
"decl : INCLUDE STRING SEMI"
dirname = os.path.dirname(self.current_source)
- filename = os.path.join(dirname, p[2])
+ if os.path.exists(os.path.join(dirname, p[2])):
+ filename = os.path.join(dirname, p[2])
+ else:
+ filename = os.path.join(self.base_dir, p[2])
p[0] = self.parse_file(filename)
def p_decl__machine(self, p):