Skip to content

Commit efcd8ae

Browse files
Lena Olsonandysan
authored andcommitted
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 ([email protected]) Reviewed-on: https://gem5-review.googlesource.com/2168 Reviewed-by: Jason Lowe-Power <[email protected]> Reviewed-by: Joe Gross <[email protected]> Reviewed-by: Sooraj Puthoor <[email protected]> Maintainer: Jason Lowe-Power <[email protected]> [ Rebased onto master ] Signed-off-by: Andreas Sandberg <[email protected]>
1 parent 93e20c9 commit efcd8ae

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

COPYING

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ Copyright (c) 1994-1996 Carnegie-Mellon University.
4545
Copyright (c) 1993-1994 Christopher G. Demetriou
4646
Copyright (c) 1997-2002 Makoto Matsumoto and Takuji Nishimura
4747
Copyright (c) 1998,2001 Manuel Bouyer.
48-
Copyright (c) 2016 Google Inc.
48+
Copyright (c) 2016-2017 Google Inc.

src/mem/slicc/parser.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (c) 2009 The Hewlett-Packard Development Company
2+
# Copyright (c) 2017 Google Inc.
23
# All rights reserved.
34
#
45
# Redistribution and use in source and binary forms, with or without
@@ -25,6 +26,7 @@
2526
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2627
#
2728
# Authors: Nathan Binkert
29+
# Lena Olson
2830

2931
import os.path
3032
import re
@@ -158,7 +160,8 @@ def t_newline(self, t):
158160

159161
precedence = (
160162
('left', 'INCR', 'DECR'),
161-
('left', 'AND', 'OR'),
163+
('left', 'OR'),
164+
('left', 'AND'),
162165
('left', 'EQ', 'NE'),
163166
('left', 'LT', 'GT', 'LE', 'GE'),
164167
('left', 'RIGHTSHIFT', 'LEFTSHIFT'),

0 commit comments

Comments
 (0)