bydgoszcz

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

commit cd62964efaa078dcadcb1ea2df028d24f84c3ee3
parent 842f1d29e7540bcef277e573fc1ce6688c114cbf
Author: kocotian <kocotian@kocotian.pl>
Date:   Tue,  8 Jun 2021 11:52:35 +0200

Initializing value of obywatel

Diffstat:
Mcompile.c | 11+++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/compile.c b/compile.c @@ -569,24 +569,31 @@ g_obywatel(File *f) { String name; TypeString type; + ExpressionString expr; Token *t; initType(&type, 0); t = enextToken(f, TokenIdentifier); name = t->c; + expr.len = strlen(strcpy(expr.data, "")); while ((t = enextToken(f, TokenNULL))) { if (t->type == TokenIdentifier) { if (!Strccmp(t->c, "przechowuje")) { g_type(f, &type); + } else if (!Strccmp(t->c, "rowne")) { + t = enextToken(f, TokenNULL); + g_expression(f, &expr); } else { errwarn(*f, 1, "unexpected identifier (expected przechowuje)"); } } else if (t->type == TokenSemicolon) { - dprintf(f->outfd, "%.*s %.*s%.*s;\n", + dprintf(f->outfd, "%.*s %.*s%.*s%s%.*s;\n", (int)(type.llen), type.ldata, Strevalf(name), - (int)(type.rlen), type.rdata); + (int)(type.rlen), type.rdata, + expr.len ? " = " : "", + (int)(expr.len), expr.data); return; } else { errwarn(*f, 1, "unexpected token (expected identifier or semicolon)");