From: Tiago Mück Date: Fri, 13 Sep 2019 20:55:15 +0000 (-0500) Subject: mem-ruby: added %(mod) operator to SLICC X-Git-Tag: develop-gem5-snapshot~650 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c475b4fc62de3a6853d724b7294475bc1efb62a1;p=gem5.git mem-ruby: added %(mod) operator to SLICC Change-Id: I9d1a10824ced3723d13e2843ad739ced72e476ce Signed-off-by: Tiago Mück Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/31260 Reviewed-by: Jason Lowe-Power Reviewed-by: John Alsop Maintainer: Jason Lowe-Power Tested-by: kokoro --- diff --git a/src/mem/slicc/ast/OperatorExprAST.py b/src/mem/slicc/ast/OperatorExprAST.py index 7752e9c07..cab13692c 100644 --- a/src/mem/slicc/ast/OperatorExprAST.py +++ b/src/mem/slicc/ast/OperatorExprAST.py @@ -64,7 +64,7 @@ class InfixOperatorExprAST(ExprAST): elif self.op in ("<<", ">>"): expected_types = [("int", "int", "int"), ("Cycles", "int", "Cycles")] - elif self.op in ("+", "-", "*", "/"): + elif self.op in ("+", "-", "*", "/", "%"): expected_types = [("int", "int", "int"), ("Cycles", "Cycles", "Cycles"), ("Tick", "Tick", "Tick"), diff --git a/src/mem/slicc/parser.py b/src/mem/slicc/parser.py index 643eec65d..13dde9ab4 100644 --- a/src/mem/slicc/parser.py +++ b/src/mem/slicc/parser.py @@ -128,7 +128,7 @@ class SLICC(Grammar): tokens = [ 'EQ', 'NE', 'LT', 'GT', 'LE', 'GE', 'LEFTSHIFT', 'RIGHTSHIFT', 'NOT', 'AND', 'OR', - 'PLUS', 'DASH', 'STAR', 'SLASH', + 'PLUS', 'DASH', 'STAR', 'SLASH', 'MOD', 'INCR', 'DECR', 'DOUBLE_COLON', 'SEMI', 'ASSIGN', 'DOT', @@ -150,6 +150,7 @@ class SLICC(Grammar): t_DASH = r'-' t_STAR = r'\*' t_SLASH = r'/' + t_MOD = r'%' t_DOUBLE_COLON = r'::' t_SEMI = r';' t_ASSIGN = r':=' @@ -165,7 +166,7 @@ class SLICC(Grammar): ('left', 'LT', 'GT', 'LE', 'GE'), ('left', 'RIGHTSHIFT', 'LEFTSHIFT'), ('left', 'PLUS', 'DASH'), - ('left', 'STAR', 'SLASH'), + ('left', 'STAR', 'SLASH', 'MOD'), ('right', 'NOT', 'UMINUS'), ) @@ -695,6 +696,7 @@ class SLICC(Grammar): def p_expr__binary_op(self, p): """expr : expr STAR expr | expr SLASH expr + | expr MOD expr | expr PLUS expr | expr DASH expr | expr LT expr