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 <jason@lowepower.com>
Reviewed-by: Joe Gross <criusx@gmail.com>
Reviewed-by: Sooraj Puthoor <puthoorsooraj@gmail.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
[ Rebased onto master ]
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
This commit is contained in:
Lena Olson 2017-02-05 14:47:37 -06:00 committed by Andreas Sandberg
parent 93e20c9a73
commit efcd8ae024
2 changed files with 5 additions and 2 deletions

View file

@ -45,4 +45,4 @@ Copyright (c) 1994-1996 Carnegie-Mellon University.
Copyright (c) 1993-1994 Christopher G. Demetriou Copyright (c) 1993-1994 Christopher G. Demetriou
Copyright (c) 1997-2002 Makoto Matsumoto and Takuji Nishimura Copyright (c) 1997-2002 Makoto Matsumoto and Takuji Nishimura
Copyright (c) 1998,2001 Manuel Bouyer. Copyright (c) 1998,2001 Manuel Bouyer.
Copyright (c) 2016 Google Inc. Copyright (c) 2016-2017 Google Inc.

View file

@ -1,4 +1,5 @@
# Copyright (c) 2009 The Hewlett-Packard Development Company # Copyright (c) 2009 The Hewlett-Packard Development Company
# Copyright (c) 2017 Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # 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. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# #
# Authors: Nathan Binkert # Authors: Nathan Binkert
# Lena Olson
import os.path import os.path
import re import re
@ -158,7 +160,8 @@ class SLICC(Grammar):
precedence = ( precedence = (
('left', 'INCR', 'DECR'), ('left', 'INCR', 'DECR'),
('left', 'AND', 'OR'), ('left', 'OR'),
('left', 'AND'),
('left', 'EQ', 'NE'), ('left', 'EQ', 'NE'),
('left', 'LT', 'GT', 'LE', 'GE'), ('left', 'LT', 'GT', 'LE', 'GE'),
('left', 'RIGHTSHIFT', 'LEFTSHIFT'), ('left', 'RIGHTSHIFT', 'LEFTSHIFT'),