diff options
author | Dmitry Ivanov <ethercrow@gmail.com> | 2017-02-23 18:02:23 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-02-23 18:57:17 -0500 |
commit | 4ad36206285a84bfc3c9f7d41c55bba83bfdffef (patch) | |
tree | 745873b7427e017f63a7a27fd11d7d29e8f1b62a | |
parent | 8f8016a5cb006fe14e1058c01a215b90e8435cc8 (diff) | |
download | haskell-4ad36206285a84bfc3c9f7d41c55bba83bfdffef.tar.gz |
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
-rw-r--r-- | compiler/parser/Parser.y | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y index 175cfbbdfc..fcc3707e4f 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] } |