From cf86532857ba1e199db6ff16541e7242c6225ff0 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 10 Mar 2010 16:22:26 -0800 Subject: slicc: have a central mechanism for creating a code_formatter. This makes it easier to add global variables like protocol --- src/mem/slicc/parser.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/mem/slicc/parser.py') diff --git a/src/mem/slicc/parser.py b/src/mem/slicc/parser.py index 99b8fa5f4..ae8a9342f 100644 --- a/src/mem/slicc/parser.py +++ b/src/mem/slicc/parser.py @@ -30,6 +30,7 @@ import os.path import re import sys +from m5.util import code_formatter from m5.util.grammar import Grammar, TokenError, ParseError import slicc.ast as ast @@ -50,11 +51,17 @@ def read_slicc(sources): yield sm_file class SLICC(Grammar): - def __init__(self, **kwargs): + def __init__(self, protocol, **kwargs): super(SLICC, self).__init__(**kwargs) self.decl_list_vec = [] self.current_file = None - self.symtab = SymbolTable() + self.protocol = protocol + self.symtab = SymbolTable(self) + + def codeFormatter(self, *args, **kwargs): + code = code_formatter(*args, **kwargs) + code['protocol'] = self.protocol + return code def parse(self, filename): self.current_file = filename -- cgit v1.2.3