From efcd8ae0244ec2791b58c749815c2f7a835eb78f Mon Sep 17 00:00:00 2001 From: Lena Olson Date: Sun, 5 Feb 2017 14:47:37 -0600 Subject: ruby: fix and/or precedence in slicc The slicc compiler currently treats && and || with the same precedence. This is highly non-intuitive to people used to C, and was probably an error. This patch makes && bind tighter than ||. For example, previously: if (A || B && C) compiled to: if ((A || B) && C) With this patch, it compiles to: if (A || (B && C)) Change-Id: Idbbd5b50cc86a8d6601045adc14a253284d7b791 Signed-off-by: Lena Olson (leolson@google.com) Reviewed-on: https://gem5-review.googlesource.com/2168 Reviewed-by: Jason Lowe-Power Reviewed-by: Joe Gross Reviewed-by: Sooraj Puthoor Maintainer: Jason Lowe-Power [ Rebased onto master ] Signed-off-by: Andreas Sandberg --- src/mem/slicc/parser.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/mem/slicc') diff --git a/src/mem/slicc/parser.py b/src/mem/slicc/parser.py index 4afe0d367..5c2b212a2 100644 --- a/src/mem/slicc/parser.py +++ b/src/mem/slicc/parser.py @@ -1,4 +1,5 @@ # Copyright (c) 2009 The Hewlett-Packard Development Company +# Copyright (c) 2017 Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -25,6 +26,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # Authors: Nathan Binkert +# Lena Olson import os.path import re @@ -158,7 +160,8 @@ class SLICC(Grammar): precedence = ( ('left', 'INCR', 'DECR'), - ('left', 'AND', 'OR'), + ('left', 'OR'), + ('left', 'AND'), ('left', 'EQ', 'NE'), ('left', 'LT', 'GT', 'LE', 'GE'), ('left', 'RIGHTSHIFT', 'LEFTSHIFT'), -- cgit v1.2.3