From c475b4fc62de3a6853d724b7294475bc1efb62a1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tiago=20M=C3=BCck?= Date: Fri, 13 Sep 2019 15:55:15 -0500 Subject: [PATCH] mem-ruby: added %(mod) operator to SLICC MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/mem/slicc/ast/OperatorExprAST.py | 2 +- src/mem/slicc/parser.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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 -- 2.30.2