From 4ad36206285a84bfc3c9f7d41c55bba83bfdffef Mon Sep 17 00:00:00 2001 From: Dmitry Ivanov Date: Thu, 23 Feb 2017 18:02:23 -0500 Subject: 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 --- compiler/parser/Parser.y | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'compiler/parser') 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] } -- cgit v1.2.1