From b1d3873ec52692b0442666718da4175379697bb2 Mon Sep 17 00:00:00 2001 From: Nilay Vaish Date: Mon, 1 Sep 2014 16:55:44 -0500 Subject: 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. --- src/mem/slicc/ast/FuncDeclAST.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/mem/slicc/ast/FuncDeclAST.py') 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: -- cgit v1.2.3