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): for name in slicc.load(files, verbose=True):
print " %s" % name print " %s" % name
hh,cc = slicc.files() target.extend(sorted(slicc.files()))
target.extend(sorted(hh))
target.extend(sorted(cc))
return target, source return target, source
def slicc_action(target, source, env): def slicc_action(target, source, env):

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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