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, verbose=False, traceback=False, **kwargs):
42 self.protocol = None
43 self.traceback = traceback
44 self.verbose = verbose
45 self.symtab = SymbolTable(self)
46
47 try:
48 self.decl_list = self.parse_file(filename, **kwargs)
49 except ParseError, e:
50 if not self.traceback:
51 sys.exit(str(e))
52 raise
53

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

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

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

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

--- 460 unchanged lines hidden ---