[commit: ghc] master: Fix parsing of And chains in BoolFormula (4ad3620)
git at git.haskell.org
git at git.haskell.org
Thu Feb 23 23:57:43 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/4ad36206285a84bfc3c9f7d41c55bba83bfdffef/ghc
>---------------------------------------------------------------
commit 4ad36206285a84bfc3c9f7d41c55bba83bfdffef
Author: Dmitry Ivanov <ethercrow at gmail.com>
Date: Thu Feb 23 18:02:23 2017 -0500
Fix parsing of And chains in BoolFormula
Parse `foo, bar, baz` into `And [foo, bar, baz]`
instead of `And [foo, And [bar, baz]]`.
Fixes #11024.
Test Plan: read and think
Reviewers: austin, bgamari, mpickering
Reviewed By: bgamari, mpickering
Subscribers: ezyang, thomie, alanz
Differential Revision: https://phabricator.haskell.org/D3139
>---------------------------------------------------------------
4ad36206285a84bfc3c9f7d41c55bba83bfdffef
compiler/parser/Parser.y | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y
index 175cfbb..fcc3707 100644
--- a/compiler/parser/Parser.y
+++ b/compiler/parser/Parser.y
@@ -2959,9 +2959,13 @@ name_boolformula :: { LBooleanFormula (Located RdrName) }
>> return (sLL $1 $> (Or [$1,$3])) }
name_boolformula_and :: { LBooleanFormula (Located RdrName) }
- : name_boolformula_atom { $1 }
- | name_boolformula_atom ',' name_boolformula_and
- {% aa $1 (AnnComma,$2) >> return (sLL $1 $> (And [$1,$3])) }
+ : name_boolformula_and_list
+ { sLL (head $1) (last $1) (And ($1)) }
+
+name_boolformula_and_list :: { [LBooleanFormula (Located RdrName)] }
+ : name_boolformula_atom { [$1] }
+ | name_boolformula_atom ',' name_boolformula_and_list
+ {% aa $1 (AnnComma, $2) >> return ($1 : $3) }
name_boolformula_atom :: { LBooleanFormula (Located RdrName) }
: '(' name_boolformula ')' {% ams (sLL $1 $> (Parens $2)) [mop $1,mcp $3] }
More information about the ghc-commits
mailing list