bydgoszczscript

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

commit ffa017dd60adf76f11b37874b1bb7038525c38ae
parent c2674e21d9847f3774dd94d939c5d9946e6edd64
Author: kocotian <kocotian@kocotian.pl>
Date:   Thu, 27 May 2021 15:33:56 +0200

oddaj (returning), jesli (if)

Diffstat:
Mcompile.c | 23+++++++++++++++++++++++
1 file changed, 23 insertions(+), 0 deletions(-)

diff --git a/compile.c b/compile.c @@ -433,6 +433,29 @@ g_aglomeracja(File *f) } else if (!Strccmp(t->c, "typ")) { dprintf(f->outfd, "typedef "); g_obywatel(f); + } else if (!Strccmp(t->c, "oddaj")) { + dprintf(f->outfd, "return "); + t = enextToken(f, TokenNULL); + goto expr; + } else if (!Strccmp(t->c, "jesli")) { + dprintf(f->outfd, "if ("); + while ((t = enextToken(f, TokenNULL))) { + g_expression(f, &expr); + t = enextToken(f, TokenIdentifier); + dprintf(f->outfd, "(%.*s)", Strevalf(expr)); + if (!Strccmp(t->c, "wtedy")) + 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)"); + } + } + dprintf(f->outfd, ") {\n"); + t = enextToken(f, TokenColon); + g_aglomeracja(f); } else { goto expr; }