bydgoszczscript

simple, fast and efficient programming language
git clone git://git.kocotian.pl/bydgoszczscript.git
Log | Files | Refs | README | LICENSE

commit d9acb7d21641f8abda6e30502ae99db7b7181671
parent ffa017dd60adf76f11b37874b1bb7038525c38ae
Author: kocotian <kocotian@kocotian.pl>
Date:   Thu, 27 May 2021 15:38:08 +0200

dopoki (while)

Diffstat:
Mcompile.c | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/compile.c b/compile.c @@ -437,20 +437,22 @@ g_aglomeracja(File *f) dprintf(f->outfd, "return "); t = enextToken(f, TokenNULL); goto expr; - } else if (!Strccmp(t->c, "jesli")) { - dprintf(f->outfd, "if ("); + } else if (!Strccmp(t->c, "jesli") || !Strccmp(t->c, "dopoki")) { + int isif; isif = !Strccmp(t->c, "jesli"); + dprintf(f->outfd, isif ? "if (" : "while ("); while ((t = enextToken(f, TokenNULL))) { g_expression(f, &expr); t = enextToken(f, TokenIdentifier); dprintf(f->outfd, "(%.*s)", Strevalf(expr)); - if (!Strccmp(t->c, "wtedy")) + if ((isif && !Strccmp(t->c, "wtedy")) || (!isif && !Strccmp(t->c, "rob"))) break; else if (!Strccmp(t->c, "albo")) { dprintf(f->outfd, " || "); } else if (!Strccmp(t->c, "oraz")) { dprintf(f->outfd, " && "); } else { - errwarn(*f, 1, "unexpected identifier (expected albo, oraz or wtedy)"); + errwarn(*f, 1, "unexpected identifier (expected albo, oraz or %s)", + isif ? "wtedy" : "rob"); } } dprintf(f->outfd, ") {\n");