PageRenderTime 53ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/other/netcdf_write_matrix/src/ncgen/ncgentab.c

http://github.com/jbeezley/wrf-fire
C | 1350 lines | 1294 code | 30 blank | 26 comment | 164 complexity | 6cb5f3734c155a2ccbd9e89bb46f195b MD5 | raw file
Possible License(s): AGPL-1.0
  1. #ifndef lint
  2. static char const
  3. yyrcsid[] = "$FreeBSD: src/usr.bin/yacc/skeleton.c,v 1.28 2000/01/17 02:04:06 bde Exp $";
  4. #endif
  5. #include <stdlib.h>
  6. #define YYBYACC 1
  7. #define YYMAJOR 1
  8. #define YYMINOR 9
  9. #define YYLEX yylex()
  10. #define YYEMPTY -1
  11. #define yyclearin (yychar=(YYEMPTY))
  12. #define yyerrok (yyerrflag=0)
  13. #define YYRECOVERING() (yyerrflag!=0)
  14. static int yygrowstack();
  15. #define YYPREFIX "yy"
  16. #line 10 "ncgen.y"
  17. #ifndef lint
  18. static char SccsId[] = "$Id: ncgentab.c,v 1.15 2005/02/17 23:24:25 ed Exp $";
  19. #endif
  20. #include <string.h>
  21. #include <stdlib.h>
  22. #include <netcdf.h>
  23. #include "generic.h"
  24. #include "ncgen.h"
  25. #include "genlib.h" /* for grow_darray() et al */
  26. typedef struct Symbol { /* symbol table entry */
  27. char *name;
  28. struct Symbol *next;
  29. unsigned is_dim : 1; /* appears as netCDF dimension */
  30. unsigned is_var : 1; /* appears as netCDF variable */
  31. unsigned is_att : 1; /* appears as netCDF attribute */
  32. int dnum; /* handle as a dimension */
  33. int vnum; /* handle as a variable */
  34. } *YYSTYPE1;
  35. /* True if string a equals string b*/
  36. #define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
  37. #define NC_UNSPECIFIED ((nc_type)0) /* unspecified (as yet) type */
  38. #define YYSTYPE YYSTYPE1
  39. YYSTYPE symlist; /* symbol table: linked list */
  40. extern int derror_count; /* counts errors in netcdf definition */
  41. extern int lineno; /* line number for error messages */
  42. static int not_a_string; /* whether last constant read was a string */
  43. static char termstring[MAXTRST]; /* last terminal string read */
  44. static double double_val; /* last double value read */
  45. static float float_val; /* last float value read */
  46. static int int_val; /* last int value read */
  47. static short short_val; /* last short value read */
  48. static char char_val; /* last char value read */
  49. static signed char byte_val; /* last byte value read */
  50. static nc_type type_code; /* holds declared type for variables */
  51. static nc_type atype_code; /* holds derived type for attributes */
  52. static char *netcdfname; /* to construct netcdf file name */
  53. static void *att_space; /* pointer to block for attribute values */
  54. static nc_type valtype; /* type code for list of attribute values */
  55. static char *char_valp; /* pointers used to accumulate data values */
  56. static signed char *byte_valp;
  57. static short *short_valp;
  58. static int *int_valp;
  59. static float *float_valp;
  60. static double *double_valp;
  61. static void *rec_cur; /* pointer to where next data value goes */
  62. static void *rec_start; /* start of space for data */
  63. #line 71 "y.tab.c"
  64. #define YYERRCODE 256
  65. #define NC_UNLIMITED_K 257
  66. #define BYTE_K 258
  67. #define CHAR_K 259
  68. #define SHORT_K 260
  69. #define INT_K 261
  70. #define FLOAT_K 262
  71. #define DOUBLE_K 263
  72. #define IDENT 264
  73. #define TERMSTRING 265
  74. #define BYTE_CONST 266
  75. #define CHAR_CONST 267
  76. #define SHORT_CONST 268
  77. #define INT_CONST 269
  78. #define FLOAT_CONST 270
  79. #define DOUBLE_CONST 271
  80. #define DIMENSIONS 272
  81. #define VARIABLES 273
  82. #define NETCDF 274
  83. #define DATA 275
  84. #define FILLVALUE 276
  85. const short yylhs[] = { -1,
  86. 2, 5, 0, 1, 1, 6, 6, 7, 7, 8,
  87. 8, 8, 9, 10, 3, 3, 3, 11, 11, 13,
  88. 13, 12, 12, 16, 14, 17, 17, 17, 17, 17,
  89. 17, 18, 18, 22, 19, 20, 21, 21, 23, 23,
  90. 24, 26, 15, 25, 25, 28, 29, 27, 27, 30,
  91. 31, 31, 31, 31, 31, 31, 31, 4, 4, 4,
  92. 32, 32, 34, 33, 35, 35, 38, 36, 37, 37,
  93. 37, 37, 37, 37, 37, 37,
  94. };
  95. const short yylen[] = { 2,
  96. 0, 0, 8, 0, 2, 2, 3, 1, 3, 3,
  97. 3, 3, 1, 1, 0, 2, 1, 2, 3, 1,
  98. 1, 2, 3, 1, 2, 1, 1, 1, 1, 1,
  99. 1, 1, 3, 0, 3, 1, 0, 3, 1, 3,
  100. 1, 0, 4, 3, 2, 1, 1, 1, 3, 1,
  101. 1, 1, 1, 1, 1, 1, 1, 0, 2, 1,
  102. 2, 3, 0, 4, 1, 3, 0, 2, 1, 1,
  103. 1, 1, 1, 1, 1, 1,
  104. };
  105. const short yydefred[] = { 0,
  106. 0, 0, 1, 0, 0, 0, 14, 0, 0, 8,
  107. 0, 13, 36, 0, 0, 2, 0, 24, 0, 46,
  108. 42, 0, 0, 6, 0, 0, 26, 27, 28, 29,
  109. 30, 31, 0, 0, 20, 21, 0, 47, 45, 0,
  110. 0, 22, 0, 0, 7, 9, 12, 10, 11, 0,
  111. 18, 0, 32, 34, 0, 0, 23, 0, 44, 19,
  112. 0, 0, 63, 0, 0, 3, 52, 53, 51, 54,
  113. 55, 56, 57, 0, 48, 50, 33, 0, 35, 0,
  114. 0, 61, 0, 41, 0, 39, 67, 62, 49, 0,
  115. 38, 0, 65, 0, 40, 67, 70, 71, 69, 72,
  116. 73, 74, 75, 76, 68, 66,
  117. };
  118. const short yydgoto[] = { 2,
  119. 6, 4, 16, 56, 40, 8, 9, 10, 11, 12,
  120. 33, 17, 34, 35, 18, 19, 37, 52, 53, 20,
  121. 79, 62, 85, 86, 21, 43, 74, 22, 39, 75,
  122. 76, 64, 65, 80, 92, 93, 105, 94,
  123. };
  124. const short yysindex[] = { -261,
  125. -109, 0, 0, -253, -242, -54, 0, -242, -35, 0,
  126. -22, 0, 0, -38, -224, 0, -56, 0, -36, 0,
  127. 0, -17, -34, 0, -242, -241, 0, 0, 0, 0,
  128. 0, 0, -38, -8, 0, 0, -222, 0, 0, -223,
  129. -5, 0, -4, -224, 0, 0, 0, 0, 0, -3,
  130. 0, 9, 0, 0, -222, -70, 0, -221, 0, 0,
  131. -222, 18, 0, -222, 1, 0, 0, 0, 0, 0,
  132. 0, 0, 0, 15, 0, 0, 0, -242, 0, 2,
  133. 3, 0, -221, 0, -26, 0, 0, 0, 0, -242,
  134. 0, 17, 0, -233, 0, 0, 0, 0, 0, 0,
  135. 0, 0, 0, 0, 0, 0,
  136. };
  137. const short yyrindex[] = { 0,
  138. 0, 0, 0, -58, 0, -122, 0, -57, 0, 0,
  139. 0, 0, 0, 0, 0, 0, -120, 0, 0, 0,
  140. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  141. 0, 0, -119, 0, 0, 0, 0, 0, 0, -60,
  142. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  143. 0, 5, 0, 0, -59, 0, 0, 0, 0, 0,
  144. 0, -33, 0, -55, 0, 0, 0, 0, 0, 0,
  145. 0, 0, 0, 10, 0, 0, 0, 0, 0, 0,
  146. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  147. 0, 12, 0, 0, 0, 0, 0, 0, 0, 0,
  148. 0, 0, 0, 0, 0, 0,
  149. };
  150. const short yygindex[] = { 0,
  151. 0, 0, 0, 0, 0, 0, 64, 48, 0, -61,
  152. 0, 0, 41, 0, -6, 58, 0, 0, 16, -30,
  153. 0, 0, 0, -14, 0, 0, 0, -43, 34, -2,
  154. 0, 0, 19, 0, 0, -16, 0, 0,
  155. };
  156. #define YYTABLESIZE 226
  157. const short yytable[] = { 4,
  158. 5, 15, 15, 15, 17, 16, 54, 36, 25, 25,
  159. 37, 63, 1, 3, 91, 47, 84, 90, 5, 15,
  160. 63, 7, 42, 24, 45, 37, 36, 48, 84, 49,
  161. 54, 97, 98, 99, 100, 101, 102, 103, 26, 38,
  162. 44, 13, 104, 67, 68, 69, 70, 71, 72, 73,
  163. 51, 55, 61, 57, 66, 60, 58, 78, 83, 82,
  164. 96, 88, 87, 25, 58, 60, 4, 5, 43, 59,
  165. 64, 23, 46, 50, 41, 95, 77, 59, 0, 106,
  166. 89, 0, 81, 0, 0, 0, 0, 0, 0, 0,
  167. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  168. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  169. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  170. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  171. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  172. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  173. 0, 0, 15, 0, 17, 16, 0, 0, 0, 0,
  174. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  175. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  176. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  177. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  178. 0, 0, 0, 0, 0, 4, 0, 13, 0, 13,
  179. 0, 0, 0, 0, 4, 5, 4, 5, 14, 27,
  180. 28, 29, 30, 31, 32, 13,
  181. };
  182. const short yycheck[] = { 58,
  183. 58, 58, 125, 58, 125, 125, 37, 14, 44, 44,
  184. 44, 55, 274, 123, 41, 257, 78, 44, 272, 58,
  185. 64, 264, 59, 59, 59, 59, 33, 269, 90, 271,
  186. 61, 265, 266, 267, 268, 269, 270, 271, 61, 264,
  187. 58, 264, 276, 265, 266, 267, 268, 269, 270, 271,
  188. 59, 275, 44, 59, 125, 59, 61, 40, 44, 59,
  189. 44, 59, 61, 59, 125, 125, 125, 125, 59, 125,
  190. 59, 8, 25, 33, 17, 90, 61, 44, -1, 96,
  191. 83, -1, 64, -1, -1, -1, -1, -1, -1, -1,
  192. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  193. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  194. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  195. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  196. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  197. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  198. -1, -1, 275, -1, 275, 275, -1, -1, -1, -1,
  199. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  200. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  201. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  202. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  203. -1, -1, -1, -1, -1, 264, -1, 264, -1, 264,
  204. -1, -1, -1, -1, 273, 273, 275, 275, 273, 258,
  205. 259, 260, 261, 262, 263, 264,
  206. };
  207. #define YYFINAL 2
  208. #ifndef YYDEBUG
  209. #define YYDEBUG 0
  210. #endif
  211. #define YYMAXTOKEN 276
  212. #if YYDEBUG
  213. const char * const yyname[] = {
  214. "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,
  215. 0,0,0,0,0,0,"'('","')'",0,0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,"':'","';'",0,"'='",
  216. 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,
  217. 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,
  218. 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,
  219. 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,
  220. 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,
  221. "NC_UNLIMITED_K","BYTE_K","CHAR_K","SHORT_K","INT_K","FLOAT_K","DOUBLE_K",
  222. "IDENT","TERMSTRING","BYTE_CONST","CHAR_CONST","SHORT_CONST","INT_CONST",
  223. "FLOAT_CONST","DOUBLE_CONST","DIMENSIONS","VARIABLES","NETCDF","DATA",
  224. "FILLVALUE",
  225. };
  226. const char * const yyrule[] = {
  227. "$accept : ncdesc",
  228. "$$1 :",
  229. "$$2 :",
  230. "ncdesc : NETCDF '{' $$1 dimsection vasection $$2 datasection '}'",
  231. "dimsection :",
  232. "dimsection : DIMENSIONS dimdecls",
  233. "dimdecls : dimdecline ';'",
  234. "dimdecls : dimdecls dimdecline ';'",
  235. "dimdecline : dimdecl",
  236. "dimdecline : dimdecline ',' dimdecl",
  237. "dimdecl : dimd '=' INT_CONST",
  238. "dimdecl : dimd '=' DOUBLE_CONST",
  239. "dimdecl : dimd '=' NC_UNLIMITED_K",
  240. "dimd : dim",
  241. "dim : IDENT",
  242. "vasection :",
  243. "vasection : VARIABLES vadecls",
  244. "vasection : gattdecls",
  245. "vadecls : vadecl ';'",
  246. "vadecls : vadecls vadecl ';'",
  247. "vadecl : vardecl",
  248. "vadecl : attdecl",
  249. "gattdecls : gattdecl ';'",
  250. "gattdecls : gattdecls gattdecl ';'",
  251. "gattdecl : attdecl",
  252. "vardecl : type varlist",
  253. "type : BYTE_K",
  254. "type : CHAR_K",
  255. "type : SHORT_K",
  256. "type : INT_K",
  257. "type : FLOAT_K",
  258. "type : DOUBLE_K",
  259. "varlist : varspec",
  260. "varlist : varlist ',' varspec",
  261. "$$3 :",
  262. "varspec : var $$3 dimspec",
  263. "var : IDENT",
  264. "dimspec :",
  265. "dimspec : '(' dimlist ')'",
  266. "dimlist : vdim",
  267. "dimlist : dimlist ',' vdim",
  268. "vdim : dim",
  269. "$$4 :",
  270. "attdecl : att $$4 '=' attvallist",
  271. "att : avar ':' attr",
  272. "att : ':' attr",
  273. "avar : var",
  274. "attr : IDENT",
  275. "attvallist : aconst",
  276. "attvallist : attvallist ',' aconst",
  277. "aconst : attconst",
  278. "attconst : CHAR_CONST",
  279. "attconst : TERMSTRING",
  280. "attconst : BYTE_CONST",
  281. "attconst : SHORT_CONST",
  282. "attconst : INT_CONST",
  283. "attconst : FLOAT_CONST",
  284. "attconst : DOUBLE_CONST",
  285. "datasection :",
  286. "datasection : DATA datadecls",
  287. "datasection : DATA",
  288. "datadecls : datadecl ';'",
  289. "datadecls : datadecls datadecl ';'",
  290. "$$5 :",
  291. "datadecl : avar $$5 '=' constlist",
  292. "constlist : dconst",
  293. "constlist : constlist ',' dconst",
  294. "$$6 :",
  295. "dconst : $$6 const",
  296. "const : CHAR_CONST",
  297. "const : TERMSTRING",
  298. "const : BYTE_CONST",
  299. "const : SHORT_CONST",
  300. "const : INT_CONST",
  301. "const : FLOAT_CONST",
  302. "const : DOUBLE_CONST",
  303. "const : FILLVALUE",
  304. };
  305. #endif
  306. #ifndef YYSTYPE
  307. typedef int YYSTYPE;
  308. #endif
  309. #if YYDEBUG
  310. #include <stdio.h>
  311. #endif
  312. #ifdef YYSTACKSIZE
  313. #undef YYMAXDEPTH
  314. #define YYMAXDEPTH YYSTACKSIZE
  315. #else
  316. #ifdef YYMAXDEPTH
  317. #define YYSTACKSIZE YYMAXDEPTH
  318. #else
  319. #define YYSTACKSIZE 10000
  320. #define YYMAXDEPTH 10000
  321. #endif
  322. #endif
  323. #define YYINITSTACKSIZE 200
  324. int yydebug;
  325. int yynerrs;
  326. int yyerrflag;
  327. int yychar;
  328. short *yyssp;
  329. YYSTYPE *yyvsp;
  330. YYSTYPE yyval;
  331. YYSTYPE yylval;
  332. short *yyss;
  333. short *yysslim;
  334. YYSTYPE *yyvs;
  335. int yystacksize;
  336. #line 767 "ncgen.y"
  337. /* PROGRAMS */
  338. #ifdef vms
  339. void
  340. #else
  341. int
  342. #endif
  343. yyerror( /* called for yacc syntax error */
  344. char *s)
  345. {
  346. derror(s);
  347. #ifndef vms
  348. return -1;
  349. #endif
  350. }
  351. /* undefine yywrap macro, in case we are using bison instead of yacc */
  352. #ifdef yywrap
  353. #undef yywrap
  354. #endif
  355. int
  356. yywrap(void) /* returns 1 on EOF if no more input */
  357. {
  358. return 1;
  359. }
  360. /* Symbol table operations for ncgen tool */
  361. YYSTYPE lookup( /* find sname in symbol table (linear search) */
  362. const char *sname)
  363. {
  364. YYSTYPE sp;
  365. for (sp = symlist; sp != (YYSTYPE) 0; sp = sp -> next)
  366. if (STREQ(sp -> name, sname)) {
  367. return sp;
  368. }
  369. return 0; /* 0 ==> not found */
  370. }
  371. YYSTYPE install( /* install sname in symbol table */
  372. const char *sname)
  373. {
  374. YYSTYPE sp;
  375. sp = (YYSTYPE) emalloc (sizeof (struct Symbol));
  376. sp -> name = (char *) emalloc (strlen (sname) + 1);/* +1 for '\0' */
  377. (void) strcpy (sp -> name, sname);
  378. sp -> next = symlist; /* put at front of list */
  379. sp -> is_dim = 0;
  380. sp -> is_var = 0;
  381. sp -> is_att = 0;
  382. symlist = sp;
  383. return sp;
  384. }
  385. void
  386. clearout(void) /* reset symbol table to empty */
  387. {
  388. YYSTYPE sp, tp;
  389. for (sp = symlist; sp != (YYSTYPE) 0;) {
  390. tp = sp -> next;
  391. free (sp -> name);
  392. free ((char *) sp);
  393. sp = tp;
  394. }
  395. symlist = 0;
  396. }
  397. /* get lexical input routine generated by lex */
  398. #include "ncgenyy.c"
  399. #line 418 "y.tab.c"
  400. /* allocate initial stack or double stack size, up to YYMAXDEPTH */
  401. static int yygrowstack()
  402. {
  403. int newsize, i;
  404. short *newss;
  405. YYSTYPE *newvs;
  406. if ((newsize = yystacksize) == 0)
  407. newsize = YYINITSTACKSIZE;
  408. else if (newsize >= YYMAXDEPTH)
  409. return -1;
  410. else if ((newsize *= 2) > YYMAXDEPTH)
  411. newsize = YYMAXDEPTH;
  412. i = yyssp - yyss;
  413. newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) :
  414. (short *)malloc(newsize * sizeof *newss);
  415. if (newss == NULL)
  416. return -1;
  417. yyss = newss;
  418. yyssp = newss + i;
  419. newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) :
  420. (YYSTYPE *)malloc(newsize * sizeof *newvs);
  421. if (newvs == NULL)
  422. return -1;
  423. yyvs = newvs;
  424. yyvsp = newvs + i;
  425. yystacksize = newsize;
  426. yysslim = yyss + newsize - 1;
  427. return 0;
  428. }
  429. #define YYABORT goto yyabort
  430. #define YYREJECT goto yyabort
  431. #define YYACCEPT goto yyaccept
  432. #define YYERROR goto yyerrlab
  433. #ifndef YYPARSE_PARAM
  434. #if defined(__cplusplus) || __STDC__
  435. #define YYPARSE_PARAM_ARG void
  436. #define YYPARSE_PARAM_DECL
  437. #else /* ! ANSI-C/C++ */
  438. #define YYPARSE_PARAM_ARG
  439. #define YYPARSE_PARAM_DECL
  440. #endif /* ANSI-C/C++ */
  441. #else /* YYPARSE_PARAM */
  442. #ifndef YYPARSE_PARAM_TYPE
  443. #define YYPARSE_PARAM_TYPE void *
  444. #endif
  445. #if defined(__cplusplus) || __STDC__
  446. #define YYPARSE_PARAM_ARG YYPARSE_PARAM_TYPE YYPARSE_PARAM
  447. #define YYPARSE_PARAM_DECL
  448. #else /* ! ANSI-C/C++ */
  449. #define YYPARSE_PARAM_ARG YYPARSE_PARAM
  450. #define YYPARSE_PARAM_DECL YYPARSE_PARAM_TYPE YYPARSE_PARAM;
  451. #endif /* ANSI-C/C++ */
  452. #endif /* ! YYPARSE_PARAM */
  453. int
  454. yyparse (YYPARSE_PARAM_ARG)
  455. YYPARSE_PARAM_DECL
  456. {
  457. register int yym, yyn, yystate;
  458. #if YYDEBUG
  459. register const char *yys;
  460. if ((yys = getenv("YYDEBUG")))
  461. {
  462. yyn = *yys;
  463. if (yyn >= '0' && yyn <= '9')
  464. yydebug = yyn - '0';
  465. }
  466. #endif
  467. yynerrs = 0;
  468. yyerrflag = 0;
  469. yychar = (-1);
  470. if (yyss == NULL && yygrowstack()) goto yyoverflow;
  471. yyssp = yyss;
  472. yyvsp = yyvs;
  473. *yyssp = yystate = 0;
  474. yyloop:
  475. if ((yyn = yydefred[yystate])) goto yyreduce;
  476. if (yychar < 0)
  477. {
  478. if ((yychar = yylex()) < 0) yychar = 0;
  479. #if YYDEBUG
  480. if (yydebug)
  481. {
  482. yys = 0;
  483. if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
  484. if (!yys) yys = "illegal-symbol";
  485. printf("%sdebug: state %d, reading %d (%s)\n",
  486. YYPREFIX, yystate, yychar, yys);
  487. }
  488. #endif
  489. }
  490. if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
  491. yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
  492. {
  493. #if YYDEBUG
  494. if (yydebug)
  495. printf("%sdebug: state %d, shifting to state %d\n",
  496. YYPREFIX, yystate, yytable[yyn]);
  497. #endif
  498. if (yyssp >= yysslim && yygrowstack())
  499. {
  500. goto yyoverflow;
  501. }
  502. *++yyssp = yystate = yytable[yyn];
  503. *++yyvsp = yylval;
  504. yychar = (-1);
  505. if (yyerrflag > 0) --yyerrflag;
  506. goto yyloop;
  507. }
  508. if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
  509. yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
  510. {
  511. yyn = yytable[yyn];
  512. goto yyreduce;
  513. }
  514. if (yyerrflag) goto yyinrecovery;
  515. #if defined(lint) || defined(__GNUC__)
  516. goto yynewerror;
  517. #endif
  518. yynewerror:
  519. yyerror("syntax error");
  520. #if defined(lint) || defined(__GNUC__)
  521. goto yyerrlab;
  522. #endif
  523. yyerrlab:
  524. ++yynerrs;
  525. yyinrecovery:
  526. if (yyerrflag < 3)
  527. {
  528. yyerrflag = 3;
  529. for (;;)
  530. {
  531. if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
  532. yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
  533. {
  534. #if YYDEBUG
  535. if (yydebug)
  536. printf("%sdebug: state %d, error recovery shifting\
  537. to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
  538. #endif
  539. if (yyssp >= yysslim && yygrowstack())
  540. {
  541. goto yyoverflow;
  542. }
  543. *++yyssp = yystate = yytable[yyn];
  544. *++yyvsp = yylval;
  545. goto yyloop;
  546. }
  547. else
  548. {
  549. #if YYDEBUG
  550. if (yydebug)
  551. printf("%sdebug: error recovery discarding state %d\n",
  552. YYPREFIX, *yyssp);
  553. #endif
  554. if (yyssp <= yyss) goto yyabort;
  555. --yyssp;
  556. --yyvsp;
  557. }
  558. }
  559. }
  560. else
  561. {
  562. if (yychar == 0) goto yyabort;
  563. #if YYDEBUG
  564. if (yydebug)
  565. {
  566. yys = 0;
  567. if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
  568. if (!yys) yys = "illegal-symbol";
  569. printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
  570. YYPREFIX, yystate, yychar, yys);
  571. }
  572. #endif
  573. yychar = (-1);
  574. goto yyloop;
  575. }
  576. yyreduce:
  577. #if YYDEBUG
  578. if (yydebug)
  579. printf("%sdebug: state %d, reducing by rule %d (%s)\n",
  580. YYPREFIX, yystate, yyn, yyrule[yyn]);
  581. #endif
  582. yym = yylen[yyn];
  583. yyval = yyvsp[1-yym];
  584. switch (yyn)
  585. {
  586. case 1:
  587. #line 97 "ncgen.y"
  588. { init_netcdf(); }
  589. break;
  590. case 2:
  591. #line 100 "ncgen.y"
  592. {
  593. if (derror_count == 0)
  594. define_netcdf(netcdfname);
  595. if (derror_count > 0)
  596. exit(6);
  597. }
  598. break;
  599. case 3:
  600. #line 108 "ncgen.y"
  601. {
  602. if (derror_count == 0)
  603. close_netcdf();
  604. }
  605. break;
  606. case 10:
  607. #line 123 "ncgen.y"
  608. { if (int_val <= 0)
  609. derror("dimension length must be positive");
  610. dims[ndims].size = int_val;
  611. ndims++;
  612. }
  613. break;
  614. case 11:
  615. #line 129 "ncgen.y"
  616. { /* for rare case where 2^31 < dimsize < 2^32 */
  617. if (double_val <= 0)
  618. derror("dimension length must be positive");
  619. if (double_val > 4294967295.0)
  620. derror("dimension too large");
  621. if (double_val - (size_t) double_val > 0)
  622. derror("dimension length must be an integer");
  623. dims[ndims].size = (size_t) double_val;
  624. ndims++;
  625. }
  626. break;
  627. case 12:
  628. #line 140 "ncgen.y"
  629. { if (rec_dim != -1)
  630. derror("only one NC_UNLIMITED dimension allowed");
  631. rec_dim = ndims; /* the unlimited (record) dimension */
  632. dims[ndims].size = NC_UNLIMITED;
  633. ndims++;
  634. }
  635. break;
  636. case 13:
  637. #line 148 "ncgen.y"
  638. { if (yyvsp[0]->is_dim == 1) {
  639. derror( "duplicate dimension declaration for %s",
  640. yyvsp[0]->name);
  641. }
  642. yyvsp[0]->is_dim = 1;
  643. yyvsp[0]->dnum = ndims;
  644. /* make sure dims array will hold dimensions */
  645. grow_darray(ndims, /* must hold ndims+1 dims */
  646. &dims); /* grow as needed */
  647. dims[ndims].name = (char *) emalloc(strlen(yyvsp[0]->name)+1);
  648. (void) strcpy(dims[ndims].name, yyvsp[0]->name);
  649. /* name for use in generated Fortran and C variables */
  650. dims[ndims].lname = decodify(yyvsp[0]->name);
  651. }
  652. break;
  653. case 26:
  654. #line 181 "ncgen.y"
  655. { type_code = NC_BYTE; }
  656. break;
  657. case 27:
  658. #line 182 "ncgen.y"
  659. { type_code = NC_CHAR; }
  660. break;
  661. case 28:
  662. #line 183 "ncgen.y"
  663. { type_code = NC_SHORT; }
  664. break;
  665. case 29:
  666. #line 184 "ncgen.y"
  667. { type_code = NC_INT; }
  668. break;
  669. case 30:
  670. #line 185 "ncgen.y"
  671. { type_code = NC_FLOAT; }
  672. break;
  673. case 31:
  674. #line 186 "ncgen.y"
  675. { type_code = NC_DOUBLE; }
  676. break;
  677. case 34:
  678. #line 192 "ncgen.y"
  679. {
  680. static struct vars dummyvar;
  681. dummyvar.name = "dummy";
  682. dummyvar.type = NC_DOUBLE;
  683. dummyvar.ndims = 0;
  684. dummyvar.dims = 0;
  685. dummyvar.fill_value.doublev = NC_FILL_DOUBLE;
  686. dummyvar.has_data = 0;
  687. nvdims = 0;
  688. /* make sure variable not re-declared */
  689. if (yyvsp[0]->is_var == 1) {
  690. derror( "duplicate variable declaration for %s",
  691. yyvsp[0]->name);
  692. }
  693. yyvsp[0]->is_var = 1;
  694. yyvsp[0]->vnum = nvars;
  695. /* make sure vars array will hold variables */
  696. grow_varray(nvars, /* must hold nvars+1 vars */
  697. &vars); /* grow as needed */
  698. vars[nvars] = dummyvar; /* to make Purify happy */
  699. vars[nvars].name = (char *) emalloc(strlen(yyvsp[0]->name)+1);
  700. (void) strcpy(vars[nvars].name, yyvsp[0]->name);
  701. /* name for use in generated Fortran and C variables */
  702. vars[nvars].lname = decodify(yyvsp[0]->name);
  703. vars[nvars].type = type_code;
  704. /* set default fill value. You can override this with
  705. * the variable attribute "_FillValue". */
  706. nc_getfill(type_code, &vars[nvars].fill_value);
  707. vars[nvars].has_data = 0; /* has no data (yet) */
  708. }
  709. break;
  710. case 35:
  711. #line 225 "ncgen.y"
  712. {
  713. vars[nvars].ndims = nvdims;
  714. nvars++;
  715. }
  716. break;
  717. case 41:
  718. #line 239 "ncgen.y"
  719. {
  720. if (nvdims >= NC_MAX_VAR_DIMS) {
  721. derror("%s has too many dimensions",vars[nvars].name);
  722. }
  723. if (yyvsp[0]->is_dim == 1)
  724. dimnum = yyvsp[0]->dnum;
  725. else {
  726. derror( "%s is not declared as a dimension",
  727. yyvsp[0]->name);
  728. dimnum = ndims;
  729. }
  730. if (rec_dim != -1 && dimnum == rec_dim && nvdims != 0) {
  731. derror("unlimited dimension must be first");
  732. }
  733. grow_iarray(nvdims, /* must hold nvdims+1 ints */
  734. &vars[nvars].dims); /* grow as needed */
  735. vars[nvars].dims[nvdims] = dimnum;
  736. nvdims++;
  737. }
  738. break;
  739. case 42:
  740. #line 260 "ncgen.y"
  741. {
  742. valnum = 0;
  743. valtype = NC_UNSPECIFIED;
  744. /* get a large block for attributes, realloc later */
  745. att_space = emalloc(MAX_NC_ATTSIZE);
  746. /* make all kinds of pointers point to it */
  747. char_valp = (char *) att_space;
  748. byte_valp = (signed char *) att_space;
  749. short_valp = (short *) att_space;
  750. int_valp = (int *) att_space;
  751. float_valp = (float *) att_space;
  752. double_valp = (double *) att_space;
  753. }
  754. break;
  755. case 43:
  756. #line 274 "ncgen.y"
  757. {
  758. { /* check if duplicate attribute for this var */
  759. int i;
  760. for(i=0; i<natts; i++) { /* expensive */
  761. if(atts[i].var == varnum &&
  762. STREQ(atts[i].name,atts[natts].name)) {
  763. derror("duplicate attribute %s:%s",
  764. vars[varnum].name,atts[natts].name);
  765. }
  766. }
  767. }
  768. atts[natts].var = varnum ;
  769. atts[natts].type = valtype;
  770. atts[natts].len = valnum;
  771. /* shrink space down to what was really needed */
  772. att_space = erealloc(att_space, valnum*nctypesize(valtype));
  773. atts[natts].val = att_space;
  774. if (STREQ(atts[natts].name, _FillValue) &&
  775. atts[natts].var != NC_GLOBAL) {
  776. nc_putfill(atts[natts].type,
  777. atts[natts].val,
  778. &vars[atts[natts].var].fill_value);
  779. if(atts[natts].type != vars[atts[natts].var].type) {
  780. derror("variable %s: %s type mismatch",
  781. vars[atts[natts].var].name, _FillValue);
  782. }
  783. }
  784. natts++;
  785. }
  786. break;
  787. case 45:
  788. #line 306 "ncgen.y"
  789. {
  790. varnum = NC_GLOBAL; /* handle of "global" attribute */
  791. }
  792. break;
  793. case 46:
  794. #line 312 "ncgen.y"
  795. { if (yyvsp[0]->is_var == 1)
  796. varnum = yyvsp[0]->vnum;
  797. else {
  798. derror("%s not declared as a variable, fatal error",
  799. yyvsp[0]->name);
  800. YYABORT;
  801. }
  802. }
  803. break;
  804. case 47:
  805. #line 322 "ncgen.y"
  806. {
  807. /* make sure atts array will hold attributes */
  808. grow_aarray(natts, /* must hold natts+1 atts */
  809. &atts); /* grow as needed */
  810. atts[natts].name = (char *) emalloc(strlen(yyvsp[0]->name)+1);
  811. (void) strcpy(atts[natts].name,yyvsp[0]->name);
  812. /* name for use in generated Fortran and C variables */
  813. atts[natts].lname = decodify(yyvsp[0]->name);
  814. }
  815. break;
  816. case 50:
  817. #line 336 "ncgen.y"
  818. {
  819. if (valtype == NC_UNSPECIFIED)
  820. valtype = atype_code;
  821. if (valtype != atype_code)
  822. derror("values for attribute must be all of same type");
  823. }
  824. break;
  825. case 51:
  826. #line 345 "ncgen.y"
  827. {
  828. atype_code = NC_CHAR;
  829. *char_valp++ = char_val;
  830. valnum++;
  831. }
  832. break;
  833. case 52:
  834. #line 351 "ncgen.y"
  835. {
  836. atype_code = NC_CHAR;
  837. {
  838. /* don't null-terminate attribute strings */
  839. size_t len = strlen(termstring);
  840. if (len == 0) /* need null if that's only value */
  841. len = 1;
  842. (void)strncpy(char_valp,termstring,len);
  843. valnum += len;
  844. char_valp += len;
  845. }
  846. }
  847. break;
  848. case 53:
  849. #line 364 "ncgen.y"
  850. {
  851. atype_code = NC_BYTE;
  852. *byte_valp++ = byte_val;
  853. valnum++;
  854. }
  855. break;
  856. case 54:
  857. #line 370 "ncgen.y"
  858. {
  859. atype_code = NC_SHORT;
  860. *short_valp++ = short_val;
  861. valnum++;
  862. }
  863. break;
  864. case 55:
  865. #line 376 "ncgen.y"
  866. {
  867. atype_code = NC_INT;
  868. *int_valp++ = int_val;
  869. valnum++;
  870. }
  871. break;
  872. case 56:
  873. #line 382 "ncgen.y"
  874. {
  875. atype_code = NC_FLOAT;
  876. *float_valp++ = float_val;
  877. valnum++;
  878. }
  879. break;
  880. case 57:
  881. #line 388 "ncgen.y"
  882. {
  883. atype_code = NC_DOUBLE;
  884. *double_valp++ = double_val;
  885. valnum++;
  886. }
  887. break;
  888. case 63:
  889. #line 404 "ncgen.y"
  890. {
  891. valtype = vars[varnum].type; /* variable type */
  892. valnum = 0; /* values accumulated for variable */
  893. vars[varnum].has_data = 1;
  894. /* compute dimensions product */
  895. var_size = nctypesize(valtype);
  896. if (vars[varnum].ndims == 0) { /* scalar */
  897. var_len = 1;
  898. } else if (vars[varnum].dims[0] == rec_dim) {
  899. var_len = 1; /* one record for unlimited vars */
  900. } else {
  901. var_len = dims[vars[varnum].dims[0]].size;
  902. }
  903. for(dimnum = 1; dimnum < vars[varnum].ndims; dimnum++)
  904. var_len = var_len*dims[vars[varnum].dims[dimnum]].size;
  905. /* allocate memory for variable data */
  906. if (var_len*var_size != (size_t)(var_len*var_size)) {
  907. derror("variable %s too large for memory",
  908. vars[varnum].name);
  909. exit(9);
  910. }
  911. rec_len = var_len;
  912. rec_start = malloc ((size_t)(rec_len*var_size));
  913. if (rec_start == 0) {
  914. derror ("out of memory\n");
  915. exit(3);
  916. }
  917. rec_cur = rec_start;
  918. switch (valtype) {
  919. case NC_CHAR:
  920. char_valp = (char *) rec_start;
  921. break;
  922. case NC_BYTE:
  923. byte_valp = (signed char *) rec_start;
  924. break;
  925. case NC_SHORT:
  926. short_valp = (short *) rec_start;
  927. break;
  928. case NC_INT:
  929. int_valp = (int *) rec_start;
  930. break;
  931. case NC_FLOAT:
  932. float_valp = (float *) rec_start;
  933. break;
  934. case NC_DOUBLE:
  935. double_valp = (double *) rec_start;
  936. break;
  937. }
  938. }
  939. break;
  940. case 64:
  941. #line 454 "ncgen.y"
  942. {
  943. if (valnum < var_len) { /* leftovers */
  944. nc_fill(valtype,
  945. var_len - valnum,
  946. rec_cur,
  947. vars[varnum].fill_value);
  948. }
  949. /* put out var_len values */
  950. /* vars[varnum].nrecs = valnum / rec_len; */
  951. vars[varnum].nrecs = var_len / rec_len;
  952. if (derror_count == 0)
  953. put_variable(rec_start);
  954. free ((char *) rec_start);
  955. }
  956. break;
  957. case 67:
  958. #line 473 "ncgen.y"
  959. {
  960. if(valnum >= var_len) {
  961. if (vars[varnum].dims[0] != rec_dim) { /* not recvar */
  962. derror("too many values for this variable, %d >= %d",
  963. valnum, var_len);
  964. exit (4);
  965. } else { /* a record variable, so grow data
  966. container and increment var_len by
  967. multiple of record size */
  968. ptrdiff_t rec_inc = (char *)rec_cur
  969. - (char *)rec_start;
  970. var_len = rec_len * (1 + valnum / rec_len);
  971. rec_start = erealloc(rec_start, var_len*var_size);
  972. rec_cur = (char *)rec_start + rec_inc;
  973. char_valp = (char *) rec_cur;
  974. byte_valp = (signed char *) rec_cur;
  975. short_valp = (short *) rec_cur;
  976. int_valp = (int *) rec_cur;
  977. float_valp = (float *) rec_cur;
  978. double_valp = (double *) rec_cur;
  979. }
  980. }
  981. not_a_string = 1;
  982. }
  983. break;
  984. case 68:
  985. #line 498 "ncgen.y"
  986. {
  987. if (not_a_string) {
  988. switch (valtype) {
  989. case NC_CHAR:
  990. rec_cur = (void *) char_valp;
  991. break;
  992. case NC_BYTE:
  993. rec_cur = (void *) byte_valp;
  994. break;
  995. case NC_SHORT:
  996. rec_cur = (void *) short_valp;
  997. break;
  998. case NC_INT:
  999. rec_cur = (void *) int_valp;
  1000. break;
  1001. case NC_FLOAT:
  1002. rec_cur = (void *) float_valp;
  1003. break;
  1004. case NC_DOUBLE:
  1005. rec_cur = (void *) double_valp;
  1006. break;
  1007. }
  1008. }
  1009. }
  1010. break;
  1011. case 69:
  1012. #line 525 "ncgen.y"
  1013. {
  1014. atype_code = NC_CHAR;
  1015. switch (valtype) {
  1016. case NC_CHAR:
  1017. *char_valp++ = char_val;
  1018. break;
  1019. case NC_BYTE:
  1020. *byte_valp++ = char_val;
  1021. break;
  1022. case NC_SHORT:
  1023. *short_valp++ = char_val;
  1024. break;
  1025. case NC_INT:
  1026. *int_valp++ = char_val;
  1027. break;
  1028. case NC_FLOAT:
  1029. *float_valp++ = char_val;
  1030. break;
  1031. case NC_DOUBLE:
  1032. *double_valp++ = char_val;
  1033. break;
  1034. }
  1035. valnum++;
  1036. }
  1037. break;
  1038. case 70:
  1039. #line 550 "ncgen.y"
  1040. {
  1041. not_a_string = 0;
  1042. atype_code = NC_CHAR;
  1043. {
  1044. size_t len = strlen(termstring);
  1045. if(valnum + len > var_len) {
  1046. if (vars[varnum].dims[0] != rec_dim) {
  1047. derror("too many values for this variable, %d>%d",
  1048. valnum+len, var_len);
  1049. exit (5);
  1050. } else {/* a record variable so grow it */
  1051. ptrdiff_t rec_inc = (char *)rec_cur
  1052. - (char *)rec_start;
  1053. var_len += rec_len * (len + valnum - var_len)/rec_len;
  1054. rec_start = erealloc(rec_start, var_len*var_size);
  1055. rec_cur = (char *)rec_start + rec_inc;
  1056. char_valp = (char *) rec_cur;
  1057. }
  1058. }
  1059. switch (valtype) {
  1060. case NC_CHAR:
  1061. {
  1062. int ld;
  1063. size_t i, sl;
  1064. (void)strncpy(char_valp,termstring,len);
  1065. ld = vars[varnum].ndims-1;
  1066. if (ld > 0) {/* null-fill to size of last dim */
  1067. sl = dims[vars[varnum].dims[ld]].size;
  1068. for (i =len;i<sl;i++)
  1069. char_valp[i] = '\0';
  1070. if (sl < len)
  1071. sl = len;
  1072. valnum += sl;
  1073. char_valp += sl;
  1074. } else { /* scalar or 1D strings */
  1075. valnum += len;
  1076. char_valp += len;
  1077. }
  1078. rec_cur = (void *) char_valp;
  1079. }
  1080. break;
  1081. case NC_BYTE:
  1082. case NC_SHORT:
  1083. case NC_INT:
  1084. case NC_FLOAT:
  1085. case NC_DOUBLE:
  1086. derror("string value invalid for %s variable",
  1087. nctype(valtype));
  1088. break;
  1089. }
  1090. }
  1091. }
  1092. break;
  1093. case 71:
  1094. #line 604 "ncgen.y"
  1095. {
  1096. atype_code = NC_BYTE;
  1097. switch (valtype) {
  1098. case NC_CHAR:
  1099. *char_valp++ = byte_val;
  1100. break;
  1101. case NC_BYTE:
  1102. *byte_valp++ = byte_val;
  1103. break;
  1104. case NC_SHORT:
  1105. *short_valp++ = byte_val;
  1106. break;
  1107. case NC_INT:
  1108. *int_valp++ = byte_val;
  1109. break;
  1110. case NC_FLOAT:
  1111. *float_valp++ = byte_val;
  1112. break;
  1113. case NC_DOUBLE:
  1114. *double_valp++ = byte_val;
  1115. break;
  1116. }
  1117. valnum++;
  1118. }
  1119. break;
  1120. case 72:
  1121. #line 629 "ncgen.y"
  1122. {
  1123. atype_code = NC_SHORT;
  1124. switch (valtype) {
  1125. case NC_CHAR:
  1126. *char_valp++ = short_val;
  1127. break;
  1128. case NC_BYTE:
  1129. *byte_valp++ = short_val;
  1130. break;
  1131. case NC_SHORT:
  1132. *short_valp++ = short_val;
  1133. break;
  1134. case NC_INT:
  1135. *int_valp++ = short_val;
  1136. break;
  1137. case NC_FLOAT:
  1138. *float_valp++ = short_val;
  1139. break;
  1140. case NC_DOUBLE:
  1141. *double_valp++ = short_val;
  1142. break;
  1143. }
  1144. valnum++;
  1145. }
  1146. break;
  1147. case 73:
  1148. #line 654 "ncgen.y"
  1149. {
  1150. atype_code = NC_INT;
  1151. switch (valtype) {
  1152. case NC_CHAR:
  1153. *char_valp++ = int_val;
  1154. break;
  1155. case NC_BYTE:
  1156. *byte_valp++ = int_val;
  1157. break;
  1158. case NC_SHORT:
  1159. *short_valp++ = int_val;
  1160. break;
  1161. case NC_INT:
  1162. *int_valp++ = int_val;
  1163. break;
  1164. case NC_FLOAT:
  1165. *float_valp++ = int_val;
  1166. break;
  1167. case NC_DOUBLE:
  1168. *double_valp++ = int_val;
  1169. break;
  1170. }
  1171. valnum++;
  1172. }
  1173. break;
  1174. case 74:
  1175. #line 679 "ncgen.y"
  1176. {
  1177. atype_code = NC_FLOAT;
  1178. switch (valtype) {
  1179. case NC_CHAR:
  1180. *char_valp++ = float_val;
  1181. break;
  1182. case NC_BYTE:
  1183. *byte_valp++ = float_val;
  1184. break;
  1185. case NC_SHORT:
  1186. *short_valp++ = float_val;
  1187. break;
  1188. case NC_INT:
  1189. *int_valp++ = float_val;
  1190. break;
  1191. case NC_FLOAT:
  1192. *float_valp++ = float_val;
  1193. break;
  1194. case NC_DOUBLE:
  1195. *double_valp++ = float_val;
  1196. break;
  1197. }
  1198. valnum++;
  1199. }
  1200. break;
  1201. case 75:
  1202. #line 704 "ncgen.y"
  1203. {
  1204. atype_code = NC_DOUBLE;
  1205. switch (valtype) {
  1206. case NC_CHAR:
  1207. *char_valp++ = double_val;
  1208. break;
  1209. case NC_BYTE:
  1210. *byte_valp++ = double_val;
  1211. break;
  1212. case NC_SHORT:
  1213. *short_valp++ = double_val;
  1214. break;
  1215. case NC_INT:
  1216. *int_valp++ = double_val;
  1217. break;
  1218. case NC_FLOAT:
  1219. if (double_val == NC_FILL_DOUBLE)
  1220. *float_valp++ = NC_FILL_FLOAT;
  1221. else
  1222. *float_valp++ = double_val;
  1223. break;
  1224. case NC_DOUBLE:
  1225. *double_valp++ = double_val;
  1226. break;
  1227. }
  1228. valnum++;
  1229. }
  1230. break;
  1231. case 76:
  1232. #line 732 "ncgen.y"
  1233. {
  1234. /* store fill_value */
  1235. switch (valtype) {
  1236. case NC_CHAR:
  1237. nc_fill(valtype, 1, (void *)char_valp++,
  1238. vars[varnum].fill_value);
  1239. break;
  1240. case NC_BYTE:
  1241. nc_fill(valtype, 1, (void *)byte_valp++,
  1242. vars[varnum].fill_value);
  1243. break;
  1244. case NC_SHORT:
  1245. nc_fill(valtype, 1, (void *)short_valp++,
  1246. vars[varnum].fill_value);
  1247. break;
  1248. case NC_INT:
  1249. nc_fill(valtype, 1, (void *)int_valp++,
  1250. vars[varnum].fill_value);
  1251. break;
  1252. case NC_FLOAT:
  1253. nc_fill(valtype, 1, (void *)float_valp++,
  1254. vars[varnum].fill_value);
  1255. break;
  1256. case NC_DOUBLE:
  1257. nc_fill(valtype, 1, (void *)double_valp++,
  1258. vars[varnum].fill_value);
  1259. break;
  1260. }
  1261. valnum++;
  1262. }
  1263. break;
  1264. #line 1294 "y.tab.c"
  1265. }
  1266. yyssp -= yym;
  1267. yystate = *yyssp;
  1268. yyvsp -= yym;
  1269. yym = yylhs[yyn];
  1270. if (yystate == 0 && yym == 0)
  1271. {
  1272. #if YYDEBUG
  1273. if (yydebug)
  1274. printf("%sdebug: after reduction, shifting from state 0 to\
  1275. state %d\n", YYPREFIX, YYFINAL);
  1276. #endif
  1277. yystate = YYFINAL;
  1278. *++yyssp = YYFINAL;
  1279. *++yyvsp = yyval;
  1280. if (yychar < 0)
  1281. {
  1282. if ((yychar = yylex()) < 0) yychar = 0;
  1283. #if YYDEBUG
  1284. if (yydebug)
  1285. {
  1286. yys = 0;
  1287. if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
  1288. if (!yys) yys = "illegal-symbol";
  1289. printf("%sdebug: state %d, reading %d (%s)\n",
  1290. YYPREFIX, YYFINAL, yychar, yys);
  1291. }
  1292. #endif
  1293. }
  1294. if (yychar == 0) goto yyaccept;
  1295. goto yyloop;
  1296. }
  1297. if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
  1298. yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
  1299. yystate = yytable[yyn];
  1300. else
  1301. yystate = yydgoto[yym];
  1302. #if YYDEBUG
  1303. if (yydebug)
  1304. printf("%sdebug: after reduction, shifting from state %d \
  1305. to state %d\n", YYPREFIX, *yyssp, yystate);
  1306. #endif
  1307. if (yyssp >= yysslim && yygrowstack())
  1308. {
  1309. goto yyoverflow;
  1310. }
  1311. *++yyssp = yystate;
  1312. *++yyvsp = yyval;
  1313. goto yyloop;
  1314. yyoverflow:
  1315. yyerror("yacc stack overflow");
  1316. yyabort:
  1317. return (1);
  1318. yyaccept:
  1319. return (0);
  1320. }