else if (v->previous &&
v->previous->scope == PendingScope)
v->scope = PendingScope;
- else if (v->type == Tlabel)
- v->scope = PendingScope;
- else if (v->name->var == v)
- v->scope = OutScope;
+ else if (v->type == Tlabel) // UNTESTED
+ v->scope = PendingScope; // UNTESTED
+ else if (v->name->var == v) // UNTESTED
+ v->scope = OutScope; // UNTESTED
if (ct == CloseElse) {
/* All Pending variables with this name
* are now Conditional */
if (v2->type != Tlabel)
v2->scope = OutScope;
break;
- case OutScope: break;
+ case OutScope: break; // UNTESTED
}
break;
case CloseSequential:
t->prepare_type(c, t, 1); // NOTEST
if (c->global_size & (t->align - 1))
- c->global_size = (c->global_size + t->align) & ~(t->align-1);
+ c->global_size = (c->global_size + t->align) & ~(t->align-1); // UNTESTED
if (!v) {
v = &scratch;
v->type = t;
rvtype = ret.type = Tnone;
if (!e) {
- ret.lval = lrv;
- ret.rval = rv;
- return ret;
+ ret.lval = lrv; // UNTESTED
+ ret.rval = rv; // UNTESTED
+ return ret; // UNTESTED
}
switch(e->type) {
static int array_compat(struct type *require, struct type *have)
{
if (have->compat != require->compat)
- return 0;
+ return 0; // UNTESTED
/* Both are arrays, so we can look at details */
if (!type_compat(require->array.member, have->array.member, 0))
return 0;
if (have->array.unspec && require->array.unspec) {
if (have->array.vsize && require->array.vsize &&
- have->array.vsize != require->array.vsize)
+ have->array.vsize != require->array.vsize) // UNTESTED
/* sizes might not be the same */
- return 0;
+ return 0; // UNTESTED
return 1;
}
if (have->array.unspec || require->array.unspec)
- return 1;
+ return 1; // UNTESTED
if (require->array.vsize == NULL && have->array.vsize == NULL)
return require->array.size == have->array.size;
- return require->array.vsize == have->array.vsize;
+ return require->array.vsize == have->array.vsize; // UNTESTED
}
static void array_print_type(struct type *type, FILE *f)
struct type *st = propagate_types(f->left, c, ok, NULL, 0);
if (!st)
- type_err(c, "error: unknown type for field access", f->left,
+ type_err(c, "error: unknown type for field access", f->left, // UNTESTED
NULL, 0, NULL);
else if (st->init != structure_init)
type_err(c, "error: field reference attempted on %1, not a struct",
return;
free_fieldlist(f->prev);
if (f->f.init) {
- free_value(f->f.type, f->f.init);
- free(f->f.init);
+ free_value(f->f.type, f->f.init); // UNTESTED
+ free(f->f.init); // UNTESTED
}
free(f);
}
| ERROR ${ tok_err(c, "Syntax error in struct field", &$1); }$
Field -> IDENTIFIER : Type = Expression ${ {
- int ok;
+ int ok; // UNTESTED
$0 = calloc(1, sizeof(struct fieldlist));
$0->f.name = $1.txt;
propagate_types($<5, c, &ok, $3, 0);
} while (ok == 2);
if (!ok)
- c->parse_error = 1;
+ c->parse_error = 1; // UNTESTED
else {
struct value vl = interp_exec(c, $5, NULL);
$0->f.init = global_alloc(c, $0->f.type, NULL, &vl);
static void structure_print_type(struct type *t, FILE *f);
###### value functions
- static void structure_print_type(struct type *t, FILE *f)
- {
- int i;
+ static void structure_print_type(struct type *t, FILE *f) // UNTESTED
+ { // UNTESTED
+ int i; // UNTESTED
fprintf(f, "struct %.*s\n", t->name.len, t->name.txt);
if (fl->type->print && fl->init) {
fprintf(f, " = ");
if (fl->type == Tstr)
- fprintf(f, "\"");
+ fprintf(f, "\""); // UNTESTED
print_value(fl->type, fl->init);
if (fl->type == Tstr)
- fprintf(f, "\"");
+ fprintf(f, "\""); // UNTESTED
}
printf("\n");
}
}
###### print type decls
- {
- struct type *t;
+ { // UNTESTED
+ struct type *t; // UNTESTED
int target = -1;
while (target != 0) {
| Varlist ; ${ $0 = $<1; }$
| Varlist NEWLINE ${ $0 = $<1; }$
- Varlist -> Varlist ; ArgDecl ${
+ Varlist -> Varlist ; ArgDecl ${ // UNTESTED
$0 = new(binode);
$0->op = List;
$0->left = $<Vl;
{
char tail[3];
if (number_parse($0->val.num, tail, $1.txt) == 0)
- mpq_init($0->val.num);
+ mpq_init($0->val.num); // UNTESTED
if (tail[0])
tok_err(c, "error: unsupported number suffix",
&$1);
struct variable *v = var->var;
if (v->merged)
- v = v->merged;
+ v = v->merged; // UNTESTED
lrv = var_value(c, v);
rvtype = v->type;
break;
struct binode *b2 = cast(binode, b->right);
left = interp_exec(c, b->left, <ype);
if (left.bool)
- rv = interp_exec(c, b2->left, &rvtype);
+ rv = interp_exec(c, b2->left, &rvtype); // UNTESTED
else
rv = interp_exec(c, b2->right, &rvtype);
}
if (t)
propagate_types(b->right, c, ok, t, 0);
else {
- t = propagate_types(b->right, c, ok, NULL, Rnolabel);
- if (t)
- t = propagate_types(b->left, c, ok, t, 0);
+ t = propagate_types(b->right, c, ok, NULL, Rnolabel); // UNTESTED
+ if (t) // UNTESTED
+ t = propagate_types(b->left, c, ok, t, 0); // UNTESTED
}
if (!type_compat(type, Tbool, 0))
type_err(c, "error: Comparison returns %1 but %2 expected", prog,
/* op must be string, result is number */
propagate_types(b->left, c, ok, Tstr, 0);
if (!type_compat(type, Tnum, 0))
- type_err(c,
+ type_err(c, // UNTESTED
"error: Can only convert string to number, not %1",
prog, type, 0, NULL);
return Tnum;
char tail[3];
int neg = 0;
if (tx.txt[0] == '-') {
- neg = 1;
- tx.txt++;
- tx.len--;
+ neg = 1; // UNTESTED
+ tx.txt++; // UNTESTED
+ tx.len--; // UNTESTED
}
if (number_parse(rv.num, tail, tx) == 0)
- mpq_init(rv.num);
+ mpq_init(rv.num); // UNTESTED
else if (neg)
- mpq_neg(rv.num, rv.num);
+ mpq_neg(rv.num, rv.num); // UNTESTED
if (tail[0])
- printf("Unsupported suffix: %.*s\n", tx.len, tx.txt);
+ printf("Unsupported suffix: %.*s\n", tx.len, tx.txt); // UNTESTED
break;
case Block:
if (indent < 0) {
// simple statement
- if (b->left == NULL)
- printf("pass");
+ if (b->left == NULL) // UNTESTED
+ printf("pass"); // UNTESTED
else
- print_exec(b->left, indent, bracket);
- if (b->right) {
- printf("; ");
- print_exec(b->right, indent, bracket);
+ print_exec(b->left, indent, bracket); // UNTESTED
+ if (b->right) { // UNTESTED
+ printf("; "); // UNTESTED
+ print_exec(b->right, indent, bracket); // UNTESTED
}
} else {
// block, one per line
do_indent(indent, "if");
if (cs->condpart && cs->condpart->type == Xbinode &&
cast(binode, cs->condpart)->op == Block) {
- if (bracket)
- printf(" {\n");
+ if (bracket) // UNTESTED
+ printf(" {\n"); // UNTESTED
else
- printf(":\n");
- print_exec(cs->condpart, indent+1, bracket);
- if (bracket)
- do_indent(indent, "}\n");
- if (cs->thenpart) {
- do_indent(indent, "then:\n");
- print_exec(cs->thenpart, indent+1, bracket);
+ printf(":\n"); // UNTESTED
+ print_exec(cs->condpart, indent+1, bracket); // UNTESTED
+ if (bracket) // UNTESTED
+ do_indent(indent, "}\n"); // UNTESTED
+ if (cs->thenpart) { // UNTESTED
+ do_indent(indent, "then:\n"); // UNTESTED
+ print_exec(cs->thenpart, indent+1, bracket); // UNTESTED
}
} else {
printf(" ");
t = propagate_types(cs->forpart, c, ok, Tnone, 0);
if (!type_compat(Tnone, t, 0))
- *ok = 0;
+ *ok = 0; // UNTESTED
t = propagate_types(cs->dopart, c, ok, Tnone, 0);
if (!type_compat(Tnone, t, 0))
- *ok = 0;
+ *ok = 0; // UNTESTED
if (cs->dopart) {
t = propagate_types(cs->thenpart, c, ok, Tnone, 0);
if (!type_compat(Tnone, t, 0))
- *ok = 0;
+ *ok = 0; // UNTESTED
}
if (cs->casepart == NULL)
propagate_types(cs->condpart, c, ok, Tbool, 0);
cp && !t; cp = cp->next)
t = propagate_types(cp->value, c, ok, NULL, 0);
if (!t && cs->condpart)
- t = propagate_types(cs->condpart, c, ok, NULL, Rboolok);
+ t = propagate_types(cs->condpart, c, ok, NULL, Rboolok); // UNTESTED
// Now we have a type (I hope) push it down
if (t) {
for (cp = cs->casepart; cp; cp = cp->next)
type = propagate_types(cs->elsepart, c, ok, NULL, rules);
for (cp = cs->casepart;
cp && !type;
- cp = cp->next)
- type = propagate_types(cp->action, c, ok, NULL, rules);
+ cp = cp->next) // UNTESTED
+ type = propagate_types(cp->action, c, ok, NULL, rules); // UNTESTED
if (type) {
if (!cs->dopart)
propagate_types(cs->thenpart, c, ok, type, rules);
if (cs->condpart)
cnd = interp_exec(c, cs->condpart, &cndtype);
else
- cndtype = Tnone;
+ cndtype = Tnone; // UNTESTED
if (!(cndtype == Tnone ||
(cndtype == Tbool && cnd.bool != 0)))
break;
| DeclarationList Declaration
Declaration -> ERROR Newlines ${
- tok_err(c,
+ tok_err(c, // UNTESTED
"error: unhandled parse error", &$1);
}$
| DeclareConstant
/* Make sure everything is still consistent */
propagate_types(bp->right, c, &ok, Tnone, 0);
if (!ok)
- return 0;
+ return 0; // UNTESTED
scope_finalize(c);
return 1;
}