Deleted Added
sdiff udiff text old ( 9104:27d56b644e78 ) new ( 9219:258753d3bc47 )
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

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

33from m5.util import code_formatter
34from m5.util.grammar import Grammar, ParseError
35
36import slicc.ast as ast
37import slicc.util as util
38from slicc.symbols import SymbolTable
39
40class SLICC(Grammar):
41 def __init__(self, filename, base_dir, verbose=False, traceback=False, **kwargs):
42 self.protocol = None
43 self.traceback = traceback
44 self.verbose = verbose
45 self.symtab = SymbolTable(self)
46 self.base_dir = base_dir
47
48 try:
49 self.decl_list = self.parse_file(filename, **kwargs)
50 except ParseError, e:
51 if not self.traceback:
52 sys.exit(str(e))
53 raise
54

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

60 code = code_formatter(*args, **kwargs)
61 code['protocol'] = self.protocol
62 return code
63
64 def process(self):
65 self.decl_list.findMachines()
66 self.decl_list.generate()
67
68 def writeCodeFiles(self, code_path, includes):
69 self.symtab.writeCodeFiles(code_path, includes)
70
71 def writeHTMLFiles(self, html_path):
72 self.symtab.writeHTMLFiles(html_path)
73
74 def files(self):
75 f = set([
76 'MachineType.cc',
77 'MachineType.hh',

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

245 (self.current_source, self.current_line)
246 raise ParseError(msg)
247 self.protocol = p[2]
248 p[0] = None
249
250 def p_decl__include(self, p):
251 "decl : INCLUDE STRING SEMI"
252 dirname = os.path.dirname(self.current_source)
253 if os.path.exists(os.path.join(dirname, p[2])):
254 filename = os.path.join(dirname, p[2])
255 else:
256 filename = os.path.join(self.base_dir, p[2])
257 p[0] = self.parse_file(filename)
258
259 def p_decl__machine(self, p):
260 "decl : MACHINE '(' ident pairs ')' ':' params '{' decls '}'"
261 p[0] = ast.MachineAST(self, p[3], p[4], p[7], p[9])
262
263 def p_decl__action(self, p):
264 "decl : ACTION '(' ident pairs ')' statements"

--- 460 unchanged lines hidden ---