summaryrefslogtreecommitdiff
path: root/src/mem/slicc/ast/FuncDeclAST.py
diff options
context:
space:
mode:
authorNilay Vaish <nilay@cs.wisc.edu>2014-09-01 16:55:44 -0500
committerNilay Vaish <nilay@cs.wisc.edu>2014-09-01 16:55:44 -0500
commitb1d3873ec52692b0442666718da4175379697bb2 (patch)
treecff299c0befcef4f843272e1e9f633060fa8c815 /src/mem/slicc/ast/FuncDeclAST.py
parent3202ec98e713d3f997e6b47f06451236c565f706 (diff)
downloadgem5-b1d3873ec52692b0442666718da4175379697bb2.tar.xz
ruby: slicc: improve the grammar
This patch changes the grammar for SLICC so as to remove some of the redundant / duplicate rules. In particular rules for object/variable declaration and class member declaration have been unified. Similarly, the rules for a general function and a class method have been unified. One more change is in the priority of two rules. The first rule is on declaring a function with all the params typed and named. The second rule is on declaring a function with all the params only typed. Earlier the second rule had a higher priority. Now the first rule has a higher priority.
Diffstat (limited to 'src/mem/slicc/ast/FuncDeclAST.py')
-rw-r--r--src/mem/slicc/ast/FuncDeclAST.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/mem/slicc/ast/FuncDeclAST.py b/src/mem/slicc/ast/FuncDeclAST.py
index 1d7e2c3ff..052d9f05e 100644
--- a/src/mem/slicc/ast/FuncDeclAST.py
+++ b/src/mem/slicc/ast/FuncDeclAST.py
@@ -57,9 +57,14 @@ class FuncDeclAST(DeclAST):
# Generate function header
for formal in self.formals:
# Lookup parameter types
- type, ident = formal.generate()
- types.append(type)
- params.append(ident)
+ try:
+ type, ident = formal.generate()
+ types.append(type)
+ params.append(ident)
+
+ except AttributeError:
+ types.append(formal.type)
+ params.append(None)
body = self.slicc.codeFormatter()
if self.statements is None: