#include #ifndef lint #if 0 static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; #else __IDSTRING(yyrcsid, "$NetBSD: skeleton.c,v 1.14 1997/10/20 03:41:16 lukem Exp $"); #endif #endif #include #define YYBYACC 1 #define YYMAJOR 1 #define YYMINOR 9 #define YYLEX yylex() #define YYEMPTY -1 #define yyclearin (yychar=(YYEMPTY)) #define yyerrok (yyerrflag=0) #define YYRECOVERING (yyerrflag!=0) #define YYPREFIX "yy" #line 36 "ddl.y" #include #include #include #include #include #include #include "ddlp.h" #include "ddlpsym.h" #include "ddlpglob.h" /*--------------------------- Function prototypes --------------------------*/ static void add_keymember PRM( (sym_struct *, char *, int); ) /*---------------------------- Global variables ----------------------------*/ static unsigned type; /* Holds FT_.. flags of current field */ static sym_member *control_field; /* Field that controls current union */ #line 57 "ddl.y" typedef union { int val; char is_union; char s[IDENT_LEN+1]; } YYSTYPE; #line 46 "y.tab.c" #define T_DATABASE 257 #define T_KEY 258 #define T_DATA 259 #define T_FILE 260 #define T_CONTAINS 261 #define T_RECORD 262 #define T_UNIQUE 263 #define T_DEFINE 264 #define T_CONTROLLED 265 #define T_MAP 266 #define T_ARROW 267 #define T_PRIMARY 268 #define T_ALTERNATE 269 #define T_FOREIGN 270 #define T_ON 271 #define T_DELETE 272 #define T_RESTRICT 273 #define T_REFERENCES 274 #define T_UPDATE 275 #define T_CASCADE 276 #define T_NULL 277 #define T_SEQUENCE 278 #define T_CHAR 279 #define T_SHORT 280 #define T_INT 281 #define T_LONG 282 #define T_SIGNED 283 #define T_UNSIGNED 284 #define T_FLOAT 285 #define T_DOUBLE 286 #define T_UCHAR 287 #define T_USHORT 288 #define T_ULONG 289 #define T_STRUCT 290 #define T_UNION 291 #define T_COMPOUND 292 #define T_ASC 293 #define T_DESC 294 #define T_VARIABLE 295 #define T_BY 296 #define T_IDENT 297 #define T_STRING 298 #define T_NUMBER 299 #define T_CHARCONST 300 #define YYERRCODE 256 short yylhs[] = { -1, 0, 5, 5, 11, 11, 12, 12, 12, 12, 12, 12, 13, 10, 10, 14, 14, 18, 18, 20, 20, 22, 22, 24, 23, 23, 15, 25, 25, 26, 26, 29, 29, 30, 27, 27, 31, 31, 32, 6, 6, 4, 4, 28, 28, 33, 34, 34, 35, 3, 3, 2, 2, 2, 19, 19, 19, 19, 19, 19, 36, 36, 36, 36, 37, 37, 38, 38, 39, 39, 39, 1, 1, 1, 1, 1, 1, 21, 21, 40, 8, 8, 9, 9, 16, 17, 17, 41, 7, 7, }; short yylen[] = { 2, 5, 0, 3, 1, 2, 7, 9, 5, 3, 1, 4, 2, 1, 1, 1, 2, 4, 2, 0, 2, 1, 2, 3, 0, 3, 3, 0, 3, 0, 1, 1, 2, 5, 0, 1, 1, 2, 12, 1, 1, 0, 3, 3, 2, 3, 1, 3, 2, 0, 1, 0, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 1, 6, 4, 2, 1, 4, 0, 1, 7, 1, 2, 4, 1, 1, }; short yydefred[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 10, 0, 0, 12, 0, 0, 0, 1, 5, 0, 0, 0, 0, 76, 0, 0, 89, 88, 0, 0, 85, 0, 60, 61, 62, 0, 64, 65, 66, 67, 68, 69, 70, 80, 0, 0, 0, 15, 0, 0, 54, 0, 57, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 86, 52, 53, 0, 59, 0, 0, 79, 0, 0, 16, 0, 0, 18, 63, 56, 0, 3, 0, 0, 75, 0, 0, 73, 74, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 31, 0, 0, 0, 21, 0, 0, 0, 87, 0, 81, 78, 0, 28, 0, 0, 46, 50, 0, 0, 26, 0, 36, 32, 0, 17, 0, 20, 22, 0, 0, 6, 84, 45, 48, 43, 0, 0, 0, 37, 23, 0, 0, 14, 13, 0, 47, 0, 0, 0, 25, 77, 7, 0, 33, 0, 42, 0, 0, 39, 40, 0, 0, 0, 0, 0, 38, }; short yydgoto[] = { 2, 29, 72, 123, 153, 25, 166, 32, 49, 76, 150, 11, 12, 13, 50, 78, 14, 33, 51, 52, 107, 53, 108, 132, 109, 80, 103, 125, 99, 104, 105, 126, 127, 100, 120, 121, 54, 55, 56, 57, 58, 34, }; short yysindex[] = { -234, -272, 0, -94, -219, -229, -225, -260, -245, -52, -224, -81, 0, -46, 0, -7, -7, 0, -40, -230, -216, 0, 0, -166, -40, -213, -211, 0, -40, -9, 0, 0, -177, -120, 0, -218, 0, 0, 0, -206, 0, 0, 0, 0, 0, 0, 0, 0, -174, -209, -179, 0, -205, 35, 0, -231, 0, 0, -27, -21, -164, -135, 19, -40, -40, -40, -40, -230, 0, 0, 0, 0, -169, 0, -168, -167, 0, -129, 6, 0, -137, 42, 0, 0, 0, -166, 0, -163, -162, 0, -1, -1, 0, 0, 77, -161, -160, 42, -158, 81, -156, 0, -121, -127, -137, 0, -40, 85, -90, 0, -118, 99, 87, 0, 88, 0, 0, 25, 0, -218, -32, 0, 0, -129, -129, 0, -127, 0, 0, -15, 0, -147, 0, 0, -146, -255, 0, 0, 0, 0, 0, -156, -119, -124, 0, 0, -141, 42, 0, 0, 98, 0, -136, 100, -123, 0, 0, 0, -122, 0, -95, 0, -93, -208, 0, 0, -87, -84, -208, -119, 130, 0, }; short yyrindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -107, -107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -72, 0, 0, 0, 0, 0, -103, 0, 0, 0, -102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 73, -117, 0, 0, 0, 0, -99, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 76, 0, 0, 0, 0, -116, 141, 0, 0, 0, 0, 0, 0, 0, 0, -39, -30, 0, 0, 0, 0, 0, 141, 0, 0, 0, 0, -57, 78, -115, 0, 0, 0, 143, 0, 0, 0, 0, 0, 0, 0, 0, -56, 0, -26, 0, 0, 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 148, 0, 0, 0, 0, 141, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 148, 0, 0, }; short yygindex[] = { 0, -8, 89, 0, 40, 194, 43, 145, 0, 0, 0, 0, 202, 0, 129, 0, 0, 0, -36, 0, -80, 0, 0, 0, 107, 0, 0, 0, -42, 0, 112, 0, 91, 0, 0, 83, 167, 0, 187, 0, 0, 197, }; #define YYTABLESIZE 259 short yytable[] = { 28, 106, 71, 44, 71, 68, 71, 134, 27, 29, 30, 72, 141, 72, 79, 72, 59, 116, 51, 148, 62, 65, 63, 1, 64, 3, 66, 65, 63, 4, 64, 15, 66, 65, 63, 16, 64, 17, 66, 5, 6, 65, 149, 7, 21, 8, 66, 9, 36, 37, 38, 83, 18, 9, 71, 90, 91, 92, 93, 10, 89, 65, 63, 72, 64, 164, 66, 156, 165, 30, 31, 19, 86, 20, 79, 70, 71, 23, 145, 42, 43, 142, 143, 35, 24, 60, 71, 61, 75, 77, 67, 74, 81, 140, 82, 72, 85, 87, 129, 51, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 88, 95, 96, 98, 97, 101, 102, 106, 111, 112, 113, 115, 114, 117, 118, 119, 122, 124, 130, 135, 136, 137, 138, 146, 154, 147, 27, 27, 29, 30, 155, 157, 152, 159, 158, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 160, 161, 162, 5, 6, 30, 31, 7, 163, 8, 167, 9, 9, 9, 168, 171, 9, 2, 9, 51, 9, 63, 82, 10, 55, 83, 19, 49, 24, 34, 35, 131, 9, 41, 139, 170, 26, 169, 94, 22, 110, 133, 128, 144, 44, 71, 71, 44, 84, 71, 151, 71, 73, 71, 72, 72, 69, 0, 72, 0, 72, 0, 72, 0, 0, 71, 0, 0, 0, 0, 0, 0, 0, 0, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, }; short yycheck[] = { 40, 91, 41, 59, 43, 125, 45, 125, 125, 125, 125, 41, 44, 43, 50, 45, 24, 97, 44, 274, 28, 42, 43, 257, 45, 297, 47, 42, 43, 123, 45, 260, 47, 42, 43, 260, 45, 297, 47, 258, 259, 42, 297, 262, 125, 264, 47, 266, 279, 280, 281, 282, 297, 125, 93, 63, 64, 65, 66, 278, 41, 42, 43, 93, 45, 273, 47, 147, 276, 299, 300, 123, 93, 297, 110, 293, 294, 123, 93, 285, 286, 123, 124, 299, 91, 298, 125, 298, 297, 268, 267, 265, 297, 125, 59, 125, 123, 261, 106, 125, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 261, 296, 296, 258, 297, 125, 269, 91, 297, 297, 59, 297, 299, 297, 59, 297, 263, 270, 59, 46, 59, 59, 123, 296, 274, 297, 269, 270, 270, 270, 297, 59, 277, 59, 296, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 297, 297, 271, 258, 259, 299, 300, 262, 275, 264, 271, 266, 258, 259, 272, 59, 262, 298, 264, 296, 266, 297, 123, 278, 297, 123, 59, 258, 59, 125, 125, 295, 278, 59, 119, 169, 16, 168, 67, 11, 85, 108, 104, 126, 274, 258, 259, 277, 55, 262, 141, 264, 39, 266, 258, 259, 33, -1, 262, -1, 264, -1, 266, -1, -1, 278, -1, -1, -1, -1, -1, -1, -1, -1, 278, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 299, }; #define YYFINAL 2 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 300 #if YYDEBUG char *yyname[] = { "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0,0,0,0,0,0,0,0,0, 0,"';'",0,0,"'>'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'['", 0,"']'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'", 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,"T_DATABASE","T_KEY","T_DATA","T_FILE","T_CONTAINS", "T_RECORD","T_UNIQUE","T_DEFINE","T_CONTROLLED","T_MAP","T_ARROW","T_PRIMARY", "T_ALTERNATE","T_FOREIGN","T_ON","T_DELETE","T_RESTRICT","T_REFERENCES", "T_UPDATE","T_CASCADE","T_NULL","T_SEQUENCE","T_CHAR","T_SHORT","T_INT", "T_LONG","T_SIGNED","T_UNSIGNED","T_FLOAT","T_DOUBLE","T_UCHAR","T_USHORT", "T_ULONG","T_STRUCT","T_UNION","T_COMPOUND","T_ASC","T_DESC","T_VARIABLE", "T_BY","T_IDENT","T_STRING","T_NUMBER","T_CHARCONST", }; char *yyrule[] = { "$accept : database", "database : T_DATABASE T_IDENT '{' decl_list '}'", "pagesize :", "pagesize : '[' expr ']'", "decl_list : decl", "decl_list : decl_list decl", "decl : T_DATA T_FILE pagesize T_STRING T_CONTAINS T_IDENT ';'", "decl : T_KEY T_FILE pagesize T_STRING T_CONTAINS T_IDENT '.' key_type ';'", "decl : record_head '{' member_list opt_key_list '}'", "decl : T_DEFINE T_IDENT expr", "decl : sequence", "decl : T_MAP '{' map_list '}'", "record_head : T_RECORD T_IDENT", "key_type : T_IDENT", "key_type : T_REFERENCES", "member_list : member", "member_list : member_list member", "member : membertype T_IDENT opt_dimen ';'", "member : struct_specifier ';'", "opt_dimen :", "opt_dimen : dimension opt_varlen_decl", "dimension : array", "dimension : dimension array", "array : '[' expr ']'", "opt_varlen_decl :", "opt_varlen_decl : T_VARIABLE T_BY T_IDENT", "opt_key_list : opt_primary_key_decl opt_alternate_key_decl_list opt_foreign_key_decl_list", "opt_primary_key_decl :", "opt_primary_key_decl : T_PRIMARY key_decl ';'", "opt_alternate_key_decl_list :", "opt_alternate_key_decl_list : alternate_key_decl_list", "alternate_key_decl_list : alternate_key_decl", "alternate_key_decl_list : alternate_key_decl_list alternate_key_decl", "alternate_key_decl : T_ALTERNATE opt_unique key_decl opt_null ';'", "opt_foreign_key_decl_list :", "opt_foreign_key_decl_list : foreign_key_decl_list", "foreign_key_decl_list : foreign_key_decl", "foreign_key_decl_list : foreign_key_decl_list foreign_key_decl", "foreign_key_decl : T_FOREIGN key_decl T_REFERENCES T_IDENT T_ON T_UPDATE action T_ON T_DELETE action opt_null ';'", "action : T_RESTRICT", "action : T_CASCADE", "opt_null :", "opt_null : T_NULL T_BY T_IDENT", "key_decl : key_decl_head comkey_member_list '}'", "key_decl : T_KEY T_IDENT", "key_decl_head : T_KEY T_IDENT '{'", "comkey_member_list : comkey_member", "comkey_member_list : comkey_member_list ',' comkey_member", "comkey_member : T_IDENT opt_sortorder", "opt_unique :", "opt_unique : T_UNIQUE", "opt_sortorder :", "opt_sortorder : T_ASC", "opt_sortorder : T_DESC", "membertype : int_type", "membertype : int_sign", "membertype : int_sign int_type", "membertype : float_type", "membertype : u_type", "membertype : T_LONG float_type", "int_type : T_CHAR", "int_type : T_SHORT", "int_type : T_INT", "int_type : T_LONG", "int_sign : T_SIGNED", "int_sign : T_UNSIGNED", "float_type : T_FLOAT", "float_type : T_DOUBLE", "u_type : T_UCHAR", "u_type : T_USHORT", "u_type : T_ULONG", "expr : expr '+' expr", "expr : expr '-' expr", "expr : expr '*' expr", "expr : expr '/' expr", "expr : '(' expr ')'", "expr : T_NUMBER", "struct_specifier : struct_or_union_opt_ident '{' member_list '}' T_IDENT opt_dimen", "struct_specifier : struct_or_union T_IDENT T_IDENT opt_dimen", "struct_or_union_opt_ident : struct_or_union opt_ident", "struct_or_union : T_STRUCT", "struct_or_union : T_UNION T_CONTROLLED T_BY T_IDENT", "opt_ident :", "opt_ident : T_IDENT", "sequence : T_SEQUENCE T_IDENT T_NUMBER opt_sortorder T_BY T_NUMBER ';'", "map_list : map", "map_list : map_list map", "map : map_id T_ARROW map_id ';'", "map_id : T_CHARCONST", "map_id : T_NUMBER", }; #endif #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #define YYINITSTACKSIZE 200 int yydebug; int yynerrs; int yyerrflag; int yychar; short *yyssp; YYSTYPE *yyvsp; YYSTYPE yyval; YYSTYPE yylval; short *yyss; short *yysslim; YYSTYPE *yyvs; int yystacksize; #line 513 "ddl.y" #include static void add_keymember(str, name, sortorder) sym_struct *str; char *name; int sortorder; { sym_member *mem; if( mem = sym_findmember(str, name) ) { dims = mem->dims; memcpy(dim, mem->dim, sizeof(*dim) * dims); sym_addmember(name, mem->type, mem->struc); add_keyfield(mem->id, sortorder); } else yyerror("unknown struct member '%s'", name); } extern errors; yyerror(char *fmt ELLIPSIS) { va_list ap; printf("%s %d: ", ddlname, lex_lineno); va_start(ap, fmt); vprintf(fmt, ap); puts(""); va_end(ap); errors++; return 0; } /* end-of-file */ #line 427 "y.tab.c" /* allocate initial stack or double stack size, up to YYMAXDEPTH */ int yyparse __P((void)); static int yygrowstack __P((void)); static int yygrowstack() { int newsize, i; short *newss; YYSTYPE *newvs; if ((newsize = yystacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return -1; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = yyssp - yyss; if ((newss = (short *)realloc(yyss, newsize * sizeof *newss)) == NULL) return -1; yyss = newss; yyssp = newss + i; if ((newvs = (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs)) == NULL) return -1; yyvs = newvs; yyvsp = newvs + i; yystacksize = newsize; yysslim = yyss + newsize - 1; return 0; } #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab int yyparse() { int yym, yyn, yystate; #if YYDEBUG char *yys; if ((yys = getenv("YYDEBUG")) != NULL) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } #endif yynerrs = 0; yyerrflag = 0; yychar = (-1); if (yyss == NULL && yygrowstack()) goto yyoverflow; yyssp = yyss; yyvsp = yyvs; *yyssp = yystate = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { if ((yychar = yylex()) < 0) yychar = 0; #if YYDEBUG if (yydebug) { yys = 0; if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (!yys) yys = "illegal-symbol"; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } #endif } if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { #if YYDEBUG if (yydebug) printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif if (yyssp >= yysslim && yygrowstack()) { goto yyoverflow; } *++yyssp = yystate = yytable[yyn]; *++yyvsp = yylval; yychar = (-1); if (yyerrflag > 0) --yyerrflag; goto yyloop; } if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag) goto yyinrecovery; goto yynewerror; yynewerror: yyerror("syntax error"); goto yyerrlab; yyerrlab: ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) { #if YYDEBUG if (yydebug) printf("%sdebug: state %d, error recovery shifting\ to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); #endif if (yyssp >= yysslim && yygrowstack()) { goto yyoverflow; } *++yyssp = yystate = yytable[yyn]; *++yyvsp = yylval; goto yyloop; } else { #if YYDEBUG if (yydebug) printf("%sdebug: error recovery discarding state %d\n", YYPREFIX, *yyssp); #endif if (yyssp <= yyss) goto yyabort; --yyssp; --yyvsp; } } } else { if (yychar == 0) goto yyabort; #if YYDEBUG if (yydebug) { yys = 0; if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (!yys) yys = "illegal-symbol"; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } #endif yychar = (-1); goto yyloop; } yyreduce: #if YYDEBUG if (yydebug) printf("%sdebug: state %d, reducing by rule %d (%s)\n", YYPREFIX, yystate, yyn, yyrule[yyn]); #endif yym = yylen[yyn]; yyval = yyvsp[1-yym]; switch (yyn) { case 1: #line 88 "ddl.y" { strcpy(dbname, yyvsp[-3].s); } break; case 2: #line 92 "ddl.y" { yyval.val = 512; } break; case 3: #line 94 "ddl.y" { if( yyvsp[-1].val < 512 ) { printf("Page size too small\n"); yyval.val = 512; } else yyval.val = yyvsp[-1].val; } break; case 6: #line 110 "ddl.y" { add_contains('d', yyvsp[-1].s, ""); add_file('d', yyvsp[-3].s, yyvsp[-4].val); } break; case 7: #line 115 "ddl.y" { char type = strcmp(yyvsp[-1].s, "") ? 'k' : 'r'; add_contains(type, yyvsp[-3].s, yyvsp[-1].s); add_file(type, yyvsp[-5].s, yyvsp[-6].val); } break; case 8: #line 122 "ddl.y" { sym_endstruct(); record[records-1].size = structnest[curnest+1]->size; structdef[record[records-1].structid].size = record[records-1].size; } break; case 9: #line 127 "ddl.y" { add_define(yyvsp[-1].s, yyvsp[0].val); } break; case 12: #line 132 "ddl.y" { add_record(yyvsp[0].s); add_structdef(yyvsp[0].s, 0, 0); sym_addstruct(yyvsp[0].s, 0); } break; case 13: #line 137 "ddl.y" { strcpy(yyval.s, yyvsp[0].s); } break; case 14: #line 138 "ddl.y" { strcpy(yyval.s, ""); } break; case 17: #line 146 "ddl.y" { sym_addmember(yyvsp[-2].s, type, NULL); cur_str->last_member->id = fields; if( type != FT_STRUCT ) add_field(yyvsp[-2].s, type); /* Increase the number of level-0 fields of the record */ if( curnest == 0 ) structdef[record[records-1].structid].members++; type = 0; } break; case 23: #line 170 "ddl.y" { dim[dims++] = yyvsp[-1].val; } break; case 25: #line 177 "ddl.y" { /* if( curnest != 1 ) yyerror("variable size fields cannot be nested");*/ if( !(size_field = sym_findmember(structnest[0], yyvsp[0].s)) ) yyerror("unknown struct member '%s'", yyvsp[0].s); } break; case 28: #line 203 "ddl.y" { key[keys-1].type = KT_PRIMARY|KT_UNIQUE; } break; case 33: #line 225 "ddl.y" { key[keys-1].type = KT_ALTERNATE | yyvsp[-3].val | yyvsp[-1].val; } break; case 38: #line 250 "ddl.y" { /* Set the record's first_foreign field */ if( record[records-1].first_foreign == -1 ) record[records-1].first_foreign = keys-1; key[keys-1].type = KT_FOREIGN | yyvsp[-5].val | yyvsp[-2].val | yyvsp[-1].val; check_foreign_key(yyvsp[-8].s, &key[keys-1]); } break; case 39: #line 260 "ddl.y" { yyval.val = KT_RESTRICT; } break; case 40: #line 261 "ddl.y" { yyval.val = KT_CASCADE; yyerror("'cascade' not supported"); } break; case 41: #line 272 "ddl.y" { yyval.val = 0; } break; case 42: #line 276 "ddl.y" { sym_member *mem; int type; if( !(mem = sym_findmember(cur_str, yyvsp[0].s)) ) yyerror("'%s' is not a member the record", yyvsp[0].s); else { key[keys-1].null_indicator = mem->id; type = FT_GETBASIC(field[mem->id].type); if( type != FT_CHAR && type != FT_CHARSTR ) yyerror("field determiner must be char or string"); } yyval.val = KT_OPTIONAL; } break; case 43: #line 297 "ddl.y" { sym_endstruct(); /* Set the size of the compound key. * Foreign keys have special size. */ if( KT_GETBASIC(key[keys-1].type) == KT_FOREIGN ) key[keys-1].size = sizeof(REF_ENTRY); else key[keys-1].size = last_str->size; } break; case 44: #line 309 "ddl.y" { sym_member *mem; if( !(mem = sym_findmember(cur_str, yyvsp[0].s)) ) yyerror("unknown field '%s'", yyvsp[0].s); add_key(yyvsp[0].s); add_keyfield(mem->id, 1); key[keys-1].size = mem->size; field[mem->id].type |= FT_KEY; field[mem->id].keyid = keys-1; } break; case 45: #line 326 "ddl.y" { /* Ensure that the key name is not also a field name */ if( sym_findmember(cur_str, yyvsp[-1].s) ) yyerror("the key '%s' is already a field name", yyvsp[-1].s); sym_addstruct(yyvsp[-1].s, 0); add_key(yyvsp[-1].s); } break; case 48: #line 348 "ddl.y" { add_keymember(structnest[curnest-1], yyvsp[-1].s, yyvsp[0].val); } break; case 49: #line 353 "ddl.y" { yyval.val = 0; /* Not unique */} break; case 50: #line 354 "ddl.y" { yyval.val = KT_UNIQUE; /* Unique */ } break; case 51: #line 358 "ddl.y" { yyval.val = 1; /* Ascending */ } break; case 52: #line 359 "ddl.y" { yyval.val = 1; /* Ascending */ } break; case 53: #line 360 "ddl.y" { yyval.val = 0; /* Descending */ } break; case 55: #line 368 "ddl.y" { if( type == FT_UNSIGNED ) type |= FT_INT; } break; case 59: #line 373 "ddl.y" { type |= FT_LONG; } break; case 60: #line 376 "ddl.y" { type |= FT_CHAR; } break; case 61: #line 377 "ddl.y" { type |= FT_SHORT; } break; case 62: #line 378 "ddl.y" { type |= FT_INT; } break; case 63: #line 379 "ddl.y" { type |= FT_LONG; } break; case 65: #line 383 "ddl.y" { type |= FT_UNSIGNED; } break; case 66: #line 386 "ddl.y" { type |= FT_FLOAT; } break; case 67: #line 387 "ddl.y" { type |= FT_DOUBLE; } break; case 68: #line 390 "ddl.y" { type |= FT_UNSIGNED|FT_CHAR; } break; case 69: #line 391 "ddl.y" { type |= FT_UNSIGNED|FT_SHORT; } break; case 70: #line 392 "ddl.y" { type |= FT_UNSIGNED|FT_LONG; } break; case 71: #line 395 "ddl.y" { yyval.val = yyvsp[-2].val + yyvsp[0].val; } break; case 72: #line 396 "ddl.y" { yyval.val = yyvsp[-2].val - yyvsp[0].val; } break; case 73: #line 397 "ddl.y" { yyval.val = yyvsp[-2].val * yyvsp[0].val; } break; case 74: #line 398 "ddl.y" { yyval.val = yyvsp[-2].val / yyvsp[0].val; } break; case 75: #line 399 "ddl.y" { yyval.val = yyvsp[-1].val; } break; case 77: #line 409 "ddl.y" { sym_struct *str; Field *fld; Structdef *strdef; sym_endstruct(); str = structnest[curnest + 1]; fld = &field[str->fieldid]; strdef = &structdef[ fld->structid ]; strcpy(fld->name, yyvsp[-1].s); strdef->size = str->size; strdef->members = str->members; sym_addmember(yyvsp[-1].s, FT_STRUCT, structnest[curnest+1]); fld->size = cur_str->last_member->size; fld->elemsize = cur_str->last_member->elemsize; fld->offset = cur_str->last_member->offset; if( size_field ) { fld->type |= FT_VARIABLE; fld->keyid = size_field->id; size_field = NULL; } } break; case 78: #line 438 "ddl.y" { sym_struct *str = sym_findstruct(yyvsp[-2].s, yyvsp[-3].is_union); if( str ) { sym_addmember(yyvsp[-1].s, FT_STRUCT, str); /* add_field($3, FT_STRUCT);*/ } /* else error message */ } break; case 79: #line 452 "ddl.y" { add_field("", FT_STRUCT); sym_addstruct(yyvsp[0].s, yyvsp[-1].is_union); cur_str->fieldid = fields-1; field[fields-1].structid = structdefs; add_structdef(yyvsp[0].s, yyvsp[-1].is_union, yyvsp[-1].is_union ? control_field->id : 0); /* Increase the number of level-0 field of the record. * Actually, at this point the grammar we have moved to * level 1. */ if( curnest == 1 ) structdef[record[records-1].structid].members++; } break; case 80: #line 471 "ddl.y" { yyval.is_union = 0; } break; case 81: #line 475 "ddl.y" { yyval.is_union = 1; if( !(control_field = sym_findmember(cur_str, yyvsp[0].s)) ) yyerror("'%s' is not a member of the union/struct '%s'", yyvsp[0].s, cur_str->name); } break; case 82: #line 483 "ddl.y" { *yyval.s = 0; } break; case 83: #line 484 "ddl.y" { strcpy(yyval.s, yyvsp[0].s); } break; case 84: #line 493 "ddl.y" { add_sequence(yyvsp[-5].s,yyvsp[-4].val,yyvsp[-3].val,yyvsp[-1].val); } break; case 87: #line 504 "ddl.y" { header.sorttable[yyvsp[-3].val] = yyvsp[-1].val; } break; case 88: #line 507 "ddl.y" { yyval.val = yyvsp[0].val; } break; case 89: #line 508 "ddl.y" { yyval.val = yyvsp[0].val; } break; #line 981 "y.tab.c" } yyssp -= yym; yystate = *yyssp; yyvsp -= yym; yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) printf("%sdebug: after reduction, shifting from state 0 to\ state %d\n", YYPREFIX, YYFINAL); #endif yystate = YYFINAL; *++yyssp = YYFINAL; *++yyvsp = yyval; if (yychar < 0) { if ((yychar = yylex()) < 0) yychar = 0; #if YYDEBUG if (yydebug) { yys = 0; if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (!yys) yys = "illegal-symbol"; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } if (yychar == 0) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) printf("%sdebug: after reduction, shifting from state %d \ to state %d\n", YYPREFIX, *yyssp, yystate); #endif if (yyssp >= yysslim && yygrowstack()) { goto yyoverflow; } *++yyssp = yystate; *++yyvsp = yyval; goto yyloop; yyoverflow: yyerror("yacc stack overflow"); yyabort: return (1); yyaccept: return (0); }