slicc: tweak file enumeration for scons

Right now .cc and .hh files are handled separately, but then
they're just munged together at the end by scons, so it
doesn't buy us anything.  Might as well munge from the start
since we'll eventually be adding generated Python files
to the list too.
This commit is contained in:
Steve Reinhardt 2009-11-05 11:11:06 -08:00
parent 058ccfc7fe
commit 9098010e3f
9 changed files with 31 additions and 42 deletions

View file

@ -69,9 +69,7 @@ def slicc_emitter(target, source, env):
for name in slicc.load(files, verbose=True):
print " %s" % name
hh,cc = slicc.files()
target.extend(sorted(hh))
target.extend(sorted(cc))
target.extend(sorted(slicc.files()))
return target, source
def slicc_action(target, source, env):

View file

@ -31,8 +31,8 @@ class DeclAST(AST):
def __init__(self, slicc, pairs):
super(DeclAST, self).__init__(slicc, pairs)
def files(self, hh, cc, parent=None):
pass
def files(self, parent=None):
return set()
def findMachines(self):
return

View file

@ -38,9 +38,11 @@ class DeclListAST(AST):
def __repr__(self):
return "[DeclListAST: %s]" % (', '.join(repr(d) for d in self.decls))
def files(self, hh, cc, parent=None):
def files(self, parent=None):
s = set()
for decl in self.decls:
decl.files(hh, cc, parent)
s |= decl.files(parent)
return s
def generate(self):
for decl in self.decls:

View file

@ -38,16 +38,16 @@ class EnumDeclAST(DeclAST):
def __repr__(self):
return "[EnumDecl: %s]" % (self.type_ast)
def files(self, hh, cc, parent=None):
def files(self, parent=None):
if "external" in self:
return
return set()
if parent:
ident = "%s_%s" % (parent, self.type_ast.ident)
else:
ident = self.type_ast.ident
hh.add("%s.hh" % ident)
cc.add("%s.cc" % ident)
s = set(("%s.hh" % ident, "%s.cc" % ident))
return s
def generate(self):
ident = str(self.type_ast)

View file

@ -42,15 +42,15 @@ class FuncDeclAST(DeclAST):
def __repr__(self):
return "[FuncDecl: %s]" % self.ident
def files(self, hh, cc, parent=None):
def files(self, parent=None):
if "external" in self or self.statements is None:
return
return set()
if parent:
ident = "%s_%s" % (parent, self.ident)
else:
ident = self.ident
cc.add("%s.cc" % ident)
return set(("%s.cc" % ident,))
def generate(self):
types = []

View file

@ -40,16 +40,16 @@ class MachineAST(DeclAST):
def __repr__(self):
return "[Machine: %r]" % self.ident
def files(self, hh, cc, parent=None):
hh.add('%s_Controller.hh' % self.ident)
hh.add('%s_Profiler.hh' % self.ident)
def files(self, parent=None):
s = set(('%s_Controller.cc' % self.ident,
'%s_Controller.hh' % self.ident,
'%s_Profiler.cc' % self.ident,
'%s_Profiler.hh' % self.ident,
'%s_Transitions.cc' % self.ident,
'%s_Wakeup.cc' % self.ident))
cc.add('%s_Controller.cc' % self.ident)
cc.add('%s_Profiler.cc' % self.ident)
cc.add('%s_Transitions.cc' % self.ident)
cc.add('%s_Wakeup.cc' % self.ident)
self.decls.files(hh, cc, self.ident)
s |= self.decls.files(self.ident)
return s
def generate(self):
# Make a new frame

View file

@ -38,16 +38,15 @@ class TypeDeclAST(DeclAST):
def __repr__(self):
return "[TypeDecl: %r]" % (self.type_ast)
def files(self, hh, cc, parent=None):
def files(self, parent=None):
if "external" in self:
return
return set()
if parent:
ident = "%s_%s" % (parent, self.type_ast.ident)
else:
ident = self.type_ast.ident
hh.add("%s.hh" % ident)
cc.add("%s.cc" % ident)
return set(("%s.hh" % ident, "%s.cc" % ident))
def generate(self):
ident = str(self.type_ast)

View file

@ -78,15 +78,7 @@ def main(args=None):
output(" %s", filename)
if opts.print_files:
hh, cc = slicc.files()
hh = sorted(hh)
cc = sorted(cc)
print 'Headers:'
for i in hh:
print ' %s' % i
print 'Sources:'
for i in cc:
for i in sorted(slicc.files()):
print ' %s' % i
else:
output("Generator pass 1...")

View file

@ -114,19 +114,17 @@ class SLICC(Grammar):
self.symtab.writeHTMLFiles(code_path)
def files(self):
cc = set([
f = set([
'ControllerFactory.cc',
'MachineType.cc'])
hh = set([
'ControllerFactory.hh',
'MachineType.cc',
'MachineType.hh',
'Types.hh' ])
for decl_list in self.decl_list_vec:
decl_list.files(hh, cc)
f |= decl_list.files()
return hh, cc
return f
t_ignore = '\t '