diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2015-03-20 14:56:02 +0100 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2015-03-20 14:56:02 +0100 |
commit | 375244b93979a4ea238d5dc31211209a60a459b1 (patch) | |
tree | e9a9bfe201d24d8af38d4405ee9fce00e552d647 | |
parent | 5a47ffbec20fb070383d0ff12981e8e50060136d (diff) | |
download | compcert-375244b93979a4ea238d5dc31211209a60a459b1.tar.gz compcert-375244b93979a4ea238d5dc31211209a60a459b1.zip |
"ecomma" smart constructor: reassociate to the left so that it prints more nicely.
-rw-r--r-- | cparser/Cutil.ml | 10 |
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. *) |