From 59e663021a6e251927b359460ff651839f66046e Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Mon, 17 Jul 2017 00:29:18 +0200 Subject: [PATCH] mescc: Tinycc support: comma operator. * module/language/c99/compiler.mes (expr->accu): Handle comma operator. * scaffold/tests/74-multi-line-string.c (test): Test it. --- module/language/c99/compiler.mes | 7 +++++++ scaffold/tests/74-multi-line-string.c | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/module/language/c99/compiler.mes b/module/language/c99/compiler.mes index e779d200..e750e7b3 100644 --- a/module/language/c99/compiler.mes +++ b/module/language/c99/compiler.mes @@ -449,6 +449,13 @@ locals)) (pmatch o ((expr) info) + + ((comma-expr) info) + + ((comma-expr ,a . ,rest) + (let ((info ((expr->accu info) a))) + ((expr->accu info) `(comma-expr ,@rest)))) + ((p-expr (string ,string)) (let* ((globals ((globals:add-string globals) string)) (info (clone info #:globals globals))) diff --git a/scaffold/tests/74-multi-line-string.c b/scaffold/tests/74-multi-line-string.c index e3d1c875..f90b214f 100644 --- a/scaffold/tests/74-multi-line-string.c +++ b/scaffold/tests/74-multi-line-string.c @@ -31,7 +31,7 @@ char const* help = int test () { - if (strcmp (help, "All your base are")) return 1; + if (printf ("belong to us"), strcmp (help, "All your base are")) return 1; - return 0; + return 2,1,0; }