aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/Cutil.ml
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2015-03-20 14:56:02 +0100
committerXavier Leroy <xavier.leroy@inria.fr>2015-03-20 14:56:02 +0100
commit375244b93979a4ea238d5dc31211209a60a459b1 (patch)
treee9a9bfe201d24d8af38d4405ee9fce00e552d647 /cparser/Cutil.ml
parent5a47ffbec20fb070383d0ff12981e8e50060136d (diff)
downloadcompcert-kvx-375244b93979a4ea238d5dc31211209a60a459b1.tar.gz
compcert-kvx-375244b93979a4ea238d5dc31211209a60a459b1.zip
"ecomma" smart constructor: reassociate to the left so that it prints more nicely.
Diffstat (limited to 'cparser/Cutil.ml')
-rw-r--r--cparser/Cutil.ml10
1 files changed, 8 insertions, 2 deletions
diff --git a/cparser/Cutil.ml b/cparser/Cutil.ml
index 986c70a2..4d6d2137 100644
--- a/cparser/Cutil.ml
+++ b/cparser/Cutil.ml
@@ -834,9 +834,15 @@ let nullconst = ecast (TPtr(TVoid [], [])) (intconst 0L IInt)
let eassign e1 e2 = { edesc = EBinop(Oassign, e1, e2, e1.etyp); etyp = e1.etyp }
-(* Construct a "," expression *)
+(* Construct a "," expression. Reassociate to the left so that
+ it prints more nicely. *)
-let ecomma e1 e2 = { edesc = EBinop(Ocomma, e1, e2, e2.etyp); etyp = e2.etyp }
+let rec ecomma e1 e2 =
+ match e2.edesc with
+ | EBinop(Ocomma, e2', e2'', _) ->
+ ecomma (ecomma e1 e2') e2''
+ | _ ->
+ { edesc = EBinop(Ocomma, e1, e2, e2.etyp); etyp = e2.etyp }
(* Construct a cascade of "," expressions.
Associate to the left so that it prints more nicely. *)