Deleted Added
sdiff udiff text old ( 8452:3f2c329e9046 ) new ( 8453:82fc1267d3bb )
full compact
1# Copyright (c) 2009 The Hewlett-Packard Development Company
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 37 unchanged lines hidden (view full) ---

46 sm_file = sm_file.strip()
47 if not sm_file:
48 continue
49 if sm_file.startswith("#"):
50 continue
51 yield sm_file
52
53class SLICC(Grammar):
54 def __init__(self, protocol, verbose=False):
55 self.decl_list_vec = []
56 self.protocol = protocol
57 self.verbose = verbose
58 self.symtab = SymbolTable(self)
59
60 def currentLocation(self):
61 return util.Location(self.current_source, self.current_line,
62 no_warning=not self.verbose)
63
64 def codeFormatter(self, *args, **kwargs):
65 code = code_formatter(*args, **kwargs)
66 code['protocol'] = self.protocol
67 return code
68
69 def parse(self, filename):
70 try:
71 decl_list = self.parse_file(filename)
72 except ParseError, e:
73 sys.exit(str(e))
74 self.decl_list_vec.append(decl_list)
75
76 def load(self, filenames):
77 filenames = list(filenames)
78 while filenames:
79 f = filenames.pop(0)
80 if isinstance(f, (list, tuple)):
81 filenames[0:0] = list(f)
82 continue
83
84 if f.endswith(".slicc"):
85 dirname,basename = os.path.split(f)
86 filenames[0:0] = [ os.path.join(dirname, x) \
87 for x in read_slicc(f)]
88 else:
89 assert f.endswith(".sm")
90 self.parse(f)
91
92 def process(self):
93 for decl_list in self.decl_list_vec:
94 decl_list.findMachines()
95
96 for decl_list in self.decl_list_vec:
97 decl_list.generate()
98
99 def writeCodeFiles(self, code_path):
100 self.symtab.writeCodeFiles(code_path)
101
102 def writeHTMLFiles(self, html_path):
103 self.symtab.writeHTMLFiles(html_path)
104
105 def files(self):
106 f = set([
107 'MachineType.cc',
108 'MachineType.hh',
109 'Types.hh' ])
110
111 for decl_list in self.decl_list_vec:

--- 611 unchanged lines hidden ---