aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/Cutil.ml
diff options
context:
space:
mode:
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. *)