17%define api.prefix {ex_}
131%binary <op>
'<' '>' LE GE
133%left <op>
'+' '-' IN_OP
134%left <op>
'*' '/' '%'
135%right <op>
'!' '~' '#' UNARY
142%type <expr> args variable
assign
144%type <expr> initialize switch_item constant
145%type <expr> formals formal_list formal_item
146%type <reference> members
205 exerror(
"no nested function definitions");
274 exwarn (
"assignment used as boolean in if statement");
279 $$ =
exnewnode(
expr.
program,
$1->index,
true,
INTEGER,
$3,
exnewnode(
expr.
program,
':',
true,
$5 ?
$5->type : 0,
$5, $6));
284 $$->data.generate.array =
$3;
285 if (!
$3->data.variable.index ||
$3->data.variable.index->op !=
DYNAMIC)
286 exerror(
"simple index variable expected");
287 $$->data.generate.index =
$3->data.variable.index->data.variable.symbol;
288 if (
$3->op ==
ID &&
$$->data.generate.index->type !=
INTEGER)
289 exerror(
"integer index variable expected");
291 $3->data.variable.index = 0;
292 $$->data.generate.statement =
$5;
299 $5->data.constant.value.integer = 1;
305 $$ =
exnewnode(
expr.
program,
$1->index,
true,
INTEGER,
$5,
exnewnode(
expr.
program,
';', 1, 0, $7, $9));
312 $$->data.generate.array =
$3;
313 if (!
$3->data.variable.index ||
$3->data.variable.index->op !=
DYNAMIC)
314 exerror(
"simple index variable expected");
315 $$->data.generate.index =
$3->data.variable.index->data.variable.symbol;
316 if (
$3->op ==
ID &&
$$->data.generate.index->type !=
INTEGER)
317 exerror(
"integer index variable expected");
319 $3->data.variable.index = 0;
320 $$->data.generate.statement =
$5;
325 exerror(
"cannot apply unset to non-array %s",
$3->name);
327 $$->data.variable.symbol =
$3;
328 $$->data.variable.index =
NULL;
333 exerror(
"cannot apply unset to non-array %s",
$3->name);
334 if ((
$3->index_type > 0) && (
$5->type !=
$3->index_type))
335 exerror(
"%s indices must have type %s, not %s",
338 $$->data.variable.symbol =
$3;
339 $$->data.variable.index =
$5;
344 exwarn (
"assignment used as boolean in while statement");
349 $$ =
exnewnode(
expr.
program,
$1->index,
true,
INTEGER,
$3,
exnewnode(
expr.
program,
';',
true, 0,
NULL,
$5));
355 $$ =
exnewnode(
expr.
program,
$1->index,
true,
INTEGER,
$3,
exnewnode(
expr.
program,
DEFAULT,
true, 0, sw->
defcase, sw->
firstcase));
368 $2->data.constant.value.integer = 1;
383 exerror(
"return in void function");
396 if (!(sw = calloc(1,
sizeof(
Switch_t))))
420 | switch_list switch_item
435 size_t n = (size_t)(sw->
cur - sw->
base);
438 memcpy(
$$->data.select.constant, sw->
base, n *
sizeof(
Extype_t*));
439 $$->data.select.constant[n] = 0;
442 $$->data.select.constant = 0;
447 exerror(
"duplicate default in switch");
455 | case_list case_item
458case_item :
CASE constant
':'
465 exerror(
"too many case labels for switch");
491dcl_item : dcl_name {checkName (
$1);
expr.
id=
$1;} array initialize
505 exerror(
"%s: a variable cannot be void typed",
$1->name);
519 exerror(
"%s: cannot initialize associative array",
$1->name);
524 if ($4->type !=
$1->type)
530 $4->data.operand.left->data.variable.symbol =
$1;
593 if (
$1->type !=
$3->type)
615 $$->data.constant.value.string =
729 if ($4->type != $7->type)
732 exerror(
"if statement string type mismatch");
740 if (
$1->data.constant.value.integer)
753 $$ =
exnewnode(
expr.
program,
'?',
true, $4->type,
$1,
exnewnode(
expr.
program,
':',
true, $4->type, $4, $7));
778 exerror(
"cannot apply '#' operator to non-array %s",
$2->name);
780 $$->data.variable.symbol =
$2;
794 |
'&' variable %prec
UNARY
849 $$->data.call.procedure =
$1;
860 $$->data.print.descriptor =
$3->data.operand.left;
861 $3 =
$3->data.operand.right;
868 $$->data.print.descriptor->data.constant.value.integer = 2;
872 $$->data.print.descriptor->data.constant.value.integer = 1;
875 $$->data.print.descriptor = 0;
878 $$->data.print.args = preprint(
$3);
887 $$->data.scan.descriptor =
$3->data.operand.left;
888 $3 =
$3->data.operand.right;
894 $$->data.scan.descriptor = 0;
897 if (
$3 &&
$3->data.operand.left->type ==
STRING)
899 $$->data.scan.descriptor =
$3->data.operand.left;
900 $3 =
$3->data.operand.right;
903 exerror(
"%s: string argument expected",
$1->name);
906 if (!
$3 || !
$3->data.operand.left ||
$3->data.operand.left->type !=
STRING)
907 exerror(
"%s: format argument expected",
$1->name);
908 $$->data.scan.format =
$3->data.operand.left;
912 exerror(
"%s: address argument expected",
$1->name);
921 exerror(
"%s: variable assignment not supported",
$1->data.variable.symbol->name);
926 else if (
$2->type !=
$1->type)
931 $2->data.operand.left =
$1;
940 exerror(
"++ and -- invalid for string variables");
948 exerror(
"++ and -- invalid for string variables");
955 exerror(
"cannot apply IN to non-array %s",
$3->name);
956 if ((
$3->index_type > 0) && (
$1->type !=
$3->index_type))
957 exerror(
"%s indices must have type %s, not %s",
960 $$->data.variable.symbol =
$3;
961 $$->data.variable.index =
$1;
981 exerror(
"%s: identifier references not supported",
$1->name);
988 $$->data.constant.value.floating =
$1;
993 $$->data.constant.value.integer =
$1;
998 $$->data.constant.value.string =
$1;
1003 $$->data.constant.value.integer =
$1;
1016variable :
ID members
1026 exerror(
"%s: is%s an array",
$1->name,
$1->local !=
NULL ?
"" :
" not");
1027 if (
$1->local !=
NULL && (
$1->index_type > 0)) {
1028 if (
$2->type !=
$1->index_type)
1029 exerror(
"%s: indices must have type %s, not %s",
1041 $$->data.variable.symbol =
$1;
1042 $$->data.variable.reference = 0;
1043 $$->data.variable.index = 0;
1044 $$->data.variable.dyna = 0;
1046 exerror(
"unknown identifier");
1087 $$ =
$1->data.operand.left;
1088 $1->data.operand.left =
$1->data.operand.right = 0;
1093arg_list :
expr %prec
','
1095 $$ =
exnewnode(
expr.
program,
',',
true, 0,
exnewnode(
expr.
program,
',',
true,
$1->type,
$1,
NULL),
NULL);
1096 $$->data.operand.right =
$$->data.operand.left;
1117formal_list : formal_item
1121 | formal_list
',' formal_item
1134 if (
$1->type == 0) {
1135 exerror(
"%s: parameters to functions cannot be void typed",
$3->name);
1138 $$->data.variable.symbol =
$3;
1140 $3->type =
$1->type;
1230 $$->data.operand.left =
$3;
1251 for (minid = 0;
yytname[minid] !=
NULL; ++minid) {
1252 if (strcmp(
yytname[minid],
"MINTOKEN") == 0) {
1258 &&
"failed to find MINTOKEN; incorrect token list in exparse.y?");
1268 for (k = 0;
yytname[i][k] !=
'\0'; ++k) {
1278 if (j ==
index + minid) {
1289void ex_error(
const char *message) {
CDT_API Dtmethod_t * Dtset
set with unique elements
CDT_API Dt_t * dtview(Dt_t *, Dt_t *)
CDT_API Dtmethod_t * Dtoset
ordered set (self-adjusting tree)
CDT_API Dt_t * dtopen(Dtdisc_t *, Dtmethod_t *)
static int binary(Exnode_t *l, Exnode_t *ex, Exnode_t *r, int arg)
static void scan(Excc_t *cc, Exnode_t *exnode)
static void print(Excc_t *cc, Exnode_t *exnode)
void exwarn(const char *format,...)
void exerror(const char *format,...)
Extype_t exeval(Expr_t *ex, Exnode_t *exnode, void *env)
const char * exop(size_t id)
static const char *const yytname[]
void ex_error(const char *message)
int exisAssign(Exnode_t *)
Exnode_t * excast(Expr_t *, Exnode_t *, long, Exnode_t *, int)
Exnode_t * exnewnode(Expr_t *, long, bool, long, Exnode_t *, Exnode_t *)
void exfreenode(Expr_t *, Exnode_t *)
char * extypename(Expr_t *p, long)
Extype_t exzero(long int)
replacements for ctype.h functions
static bool gv_isalnum(int c)
#define assign(h, i, j, index)
static int table[NTYPES][NTYPES]
static bool streq(const char *a, const char *b)
are a and b equal?
double(* floating)(char **)
long declare
current declaration type
long type
switch test type
struct Exdata_u::@87 variable
struct Exdata_u::@84 constant
struct Exdata_u::@85 operand
struct Exdata_u::@86 select
char * vmstrdup(Vmalloc_t *, const char *)