From 9c651ace0bba90237bf55e4684d55e31c3015ac6 Mon Sep 17 00:00:00 2001 From: erg Date: Mon, 29 Jun 2009 16:41:28 +0000 Subject: [PATCH] Replace INT, CHAR, VOID token names since they are exported because expr.h includes exparse.h; extend types of user-supplied functions to include Exdisc_t*. --- lib/expr/exdata.c | 4 ++-- lib/expr/exeval.c | 4 ++-- lib/expr/exexpr.c | 2 +- lib/expr/exgram.h | 6 +++--- lib/expr/exparse.y | 5 ++--- lib/expr/expr.h | 6 +++--- lib/expr/extoken.c | 2 +- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/expr/exdata.c b/lib/expr/exdata.c index 18982558a..dc966772b 100644 --- a/lib/expr/exdata.c +++ b/lib/expr/exdata.c @@ -38,7 +38,7 @@ Exid_t exbuiltin[] = { EX_ID("break", BREAK, BREAK, 0, 0), EX_ID("case", CASE, CASE, 0, 0), - EX_ID("char", DECLARE, CHAR, CHAR, 0), + EX_ID("char", DECLARE, CHARACTER, CHARACTER, 0), EX_ID("continue", CONTINUE, CONTINUE, 0, 0), EX_ID("default", DEFAULT, DEFAULT, 0, 0), EX_ID("double", DECLARE, FLOATING, FLOATING, 0), @@ -63,7 +63,7 @@ Exid_t exbuiltin[] = { EX_ID("substr", SUBSTR, SUBSTR, STRING, 0), EX_ID("switch", SWITCH, SWITCH, 0, 0), EX_ID("unsigned", DECLARE, UNSIGNED, UNSIGNED, 0), - EX_ID("void", DECLARE, VOID, 0, 0), + EX_ID("void", DECLARE, VOIDTYPE, 0, 0), EX_ID("while", WHILE, WHILE, 0, 0), EX_ID({0}, 0, 0, 0, 0) diff --git a/lib/expr/exeval.c b/lib/expr/exeval.c index 5badc1c8b..307be7ae8 100644 --- a/lib/expr/exeval.c +++ b/lib/expr/exeval.c @@ -416,7 +416,7 @@ static int scformat(Sfio_t * sp, void *vp, Sffmt_t * dp) string, char, fmt->fmt.size, 0); break; case 'c': - if (node->type != CHAR) { + if (node->type != CHARACTER) { exerror("scanf: %s: char variable address argument expected", node->data.variable.symbol->name); return -1; @@ -740,7 +740,7 @@ xPrint(Expr_t * ex, Exnode_t * expr, Extype_t v, Exnode_t * tmp) { *tmp = *expr->data.operand.left; tmp->data.constant.value = v; - if ((*ex->disc->stringof) (ex, tmp, 0)) + if ((*ex->disc->stringof) (ex, tmp, 0, ex->disc)) exerror("%s: no string representation of %s value", expr->data.operand.left->data.variable.symbol->name, extypename(ex, expr->data.operand.left->type)); diff --git a/lib/expr/exexpr.c b/lib/expr/exexpr.c index 0c5108e9c..07689e614 100644 --- a/lib/expr/exexpr.c +++ b/lib/expr/exexpr.c @@ -33,7 +33,7 @@ Exnode_t *exexpr(Expr_t * ex, const char *name, Exid_t * sym, int type) if (!sym) sym = name ? (Exid_t *) dtmatch(ex->symbols, name) : &ex->main; if (sym && sym->lex == PROCEDURE && sym->value) { - if (type != DELETE) + if (type != DELETE_T) return excast(ex, sym->value->data.procedure.body, type, NiL, 0); exfreenode(ex, sym->value); diff --git a/lib/expr/exgram.h b/lib/expr/exgram.h index 829605720..fc590d1e1 100644 --- a/lib/expr/exgram.h +++ b/lib/expr/exgram.h @@ -248,7 +248,7 @@ extern "C" { exerror("cannot convert %s to STRING", extypename(p, type)); if (x->op != CONSTANT) { if (!BUILTIN(type)) { - if ((*p->disc->stringof) (p, x, 1) < 0) { + if ((*p->disc->stringof) (p, x, 1, p->disc) < 0) { exerror("cannot convert %s to STRING", extypename(p, type)); } @@ -264,7 +264,7 @@ extern "C" { } x = exnewnode(p, cvt, 0, STRING, x, 0); } else if (!BUILTIN(type)) { - if ((*p->disc->stringof) (p, x, 0) < 0) + if ((*p->disc->stringof) (p, x, 0, p->disc) < 0) exerror("cannot convert constant %s to STRING", extypename(p, x->type)); } else @@ -396,7 +396,7 @@ extern "C" { char *s; char *e; - if (x && x->type != type && type && type != VOID) { + if (x && x->type != type && type && type != VOIDTYPE) { if (!x->type) { x->type = type; return x; diff --git a/lib/expr/exparse.y b/lib/expr/exparse.y index e4ee3875e..ab4481001 100644 --- a/lib/expr/exparse.y +++ b/lib/expr/exparse.y @@ -58,13 +58,12 @@ %token MINTOKEN -%token INT %token INTEGER %token UNSIGNED -%token CHAR +%token CHARACTER %token FLOATING %token STRING -%token VOID +%token VOIDTYPE %token ADDRESS %token ARRAY diff --git a/lib/expr/expr.h b/lib/expr/expr.h index 5351e35c0..dddeb5dcd 100644 --- a/lib/expr/expr.h +++ b/lib/expr/expr.h @@ -76,9 +76,9 @@ extern "C" { /* previously known as EXID, but EXID is also defined by bison in y.tab.h */ #define EX_ID(n,l,i,t,f) {{0},(l),(i),(t),0,(f),0,{0},n} -#define DELETE BREAK /* exexpr() delete `type' */ +#define DELETE_T BREAK /* exexpr() delete `type' */ -#define INTEGRAL(t) ((t)>=INT&&(t)<=CHAR) +#define INTEGRAL(t) ((t)>=INTEGER&&(t)<=CHARACTER) #define BUILTIN(t) ((t) > MINTOKEN) /* function type mechanism @@ -222,7 +222,7 @@ extern "C" { /* binary operator function */ char *(*typename) (Expr_t *, int); /* application type names */ - int (*stringof) (Expr_t *, Exnode_t *, int); + int (*stringof) (Expr_t *, Exnode_t *, int, Exdisc_t *); /* value to string conversion */ Extype_t(*keyf) (Expr_t *, Extype_t, int, Exdisc_t *); /* dictionary key for external type objects */ diff --git a/lib/expr/extoken.c b/lib/expr/extoken.c index 366247640..ace4b640f 100644 --- a/lib/expr/extoken.c +++ b/lib/expr/extoken.c @@ -641,7 +641,7 @@ int extoken_fn(register Expr_t * ex) switch (exlval.id->lex) { case DECLARE: - if (exlval.id->index == CHAR) { + if (exlval.id->index == CHARACTER) { /* * `char*' === `string' * the * must immediately follow char -- 2.40.0