1 /* A Bison parser, made by GNU Bison 1.875a.  */
2 
3 /* Skeleton parser for Yacc-like parsing with Bison,
4    Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
5 
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2, or (at your option)
9    any later version.
10 
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15 
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place - Suite 330,
19    Boston, MA 02111-1307, USA.  */
20 
21 /* As a special exception, when this file is copied by Bison into a
22    Bison output file, you may use that output file without restriction.
23    This special exception was added by the Free Software Foundation
24    in version 1.24 of Bison.  */
25 
26 /* Written by Richard Stallman by simplifying the original so called
27    ``semantic'' parser.  */
28 
29 /* All symbols defined below should begin with yy or YY, to avoid
30    infringing on user name space.  This should be done even for local
31    variables, as they might otherwise be expanded by user macros.
32    There are some unavoidable exceptions within include files to
33    define necessary library symbols; they are noted "INFRINGES ON
34    USER NAME SPACE" below.  */
35 
36 /* Identify Bison output.  */
37 #define YYBISON 1
38 
39 /* Do not use alloca().  */
40 #define YYSTACK_USE_ALLOCA 0
41 
42 /* Use the default max depth.  */
43 #define YYMAXDEPTH 0
44 
45 /* Skeleton name.  */
46 #define YYSKELETON_NAME "yacc.c"
47 
48 /* Pure parsers.  */
49 #define YYPURE 0
50 
51 /* Using locations.  */
52 #define YYLSP_NEEDED 0
53 
54 /* If NAME_PREFIX is specified substitute the variables and functions
55    names.  */
56 #define yyparse dice_yyparse
57 #define yylex   dice_yylex
58 #define yyerror dice_yyerror
59 #define yylval  dice_yylval
60 #define yychar  dice_yychar
61 #define yydebug dice_yydebug
62 #define yynerrs dice_yynerrs
63 
64 
65 /* Tokens.  */
66 #ifndef YYTOKENTYPE
67 # define YYTOKENTYPE
68    /* Put the tokens into the symbol table, so that GDB and other debuggers
69       know about them.  */
70    enum yytokentype {
71      lFLOAT = 258,
72      tokINTEGER = 259,
73      tokARRAY = 260,
74      NAME = 261,
75      SIN = 262,
76      COS = 263,
77      TAN = 264,
78      ACOS = 265,
79      ASIN = 266,
80      ATAN = 267,
81      LOG = 268,
82      EXP = 269,
83      ABS_TOKEN = 270,
84      SQRT = 271,
85      WHERE = 272,
86      INDEX = 273,
87      EQEQ = 274,
88      LT = 275,
89      LE = 276,
90      GT = 277,
91      GE = 278,
92      NE = 279,
93      LTLT = 280,
94      GTGT = 281,
95      JOIN = 282
96    };
97 #endif
98 #define lFLOAT 258
99 #define tokINTEGER 259
100 #define tokARRAY 260
101 #define NAME 261
102 #define SIN 262
103 #define COS 263
104 #define TAN 264
105 #define ACOS 265
106 #define ASIN 266
107 #define ATAN 267
108 #define LOG 268
109 #define EXP 269
110 #define ABS_TOKEN 270
111 #define SQRT 271
112 #define WHERE 272
113 #define INDEX 273
114 #define EQEQ 274
115 #define LT 275
116 #define LE 276
117 #define GT 277
118 #define GE 278
119 #define NE 279
120 #define LTLT 280
121 #define GTGT 281
122 #define JOIN 282
123 
124 
125 
126 
127 /* Copy the first part of user declarations.  */
128 
129 /* Force the definition for Linux */
130 /* Possible bug in older Linux yacc */
131 
132 #ifndef NOBISON
133 extern int yylex();
134 extern "C" {
135         void yyerror( const char *);
136         int  yyparse( void );
137 }
138 #endif
139 #include <XdmfExpr.h>
140 #include <XdmfArray.h>
141 #include <XdmfHDF.h>
142 #include <math.h>
143 
144 static xdmf2::XdmfArray *XdmfExprReturnValue;
145 XdmfExprSymbol *XdmfExprItemsTable = NULL;
146 
147 
148 namespace xdmf2
149 {
150 
151 class XdmfInt64Array : public XdmfArray {
152 public :
XdmfInt64Array(XdmfInt64 Length)153         XdmfInt64Array( XdmfInt64 Length ) {
154                 this->SetNumberType( XDMF_INT64_TYPE );
155                 this->SetNumberOfElements( Length );
156                 }
XdmfInt64Array()157         XdmfInt64Array() {
158                 this->SetNumberType( XDMF_INT64_TYPE );
159                 this->SetNumberOfElements( 10 );
160                 };
161 };
162 
163 }
164 
165 #define ADD_XDMF_tokARRAY_TO_SYMBOL( a ) \
166         { \
167         char        name[80]; \
168         XdmfExprSymbol *sp; \
169         sprintf( name, "XdmfArray_%X", ( XdmfLength)(a) ); \
170         sp = XdmfExprSymbolLookup( name ); \
171         sp->ClientData = (a); \
172         }
173 
174 
175 
176 /* Enabling traces.  */
177 #ifndef YYDEBUG
178 # define YYDEBUG 0
179 #endif
180 
181 /* Enabling verbose error messages.  */
182 #ifdef YYERROR_VERBOSE
183 # undef YYERROR_VERBOSE
184 # define YYERROR_VERBOSE 1
185 #else
186 # define YYERROR_VERBOSE 0
187 #endif
188 
189 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
190 
191 typedef union YYSTYPE {
192         double                DoubleValue;
193         long                IntegerValue;
194         void                *ArrayPointer;
195         XdmfExprSymbol        *Symbol;
196 } YYSTYPE;
197 /* Line 191 of yacc.c.  */
198 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
199 # define YYSTYPE_IS_DECLARED 1
200 # define YYSTYPE_IS_TRIVIAL 1
201 #endif
202 
203 
204 
205 /* Copy the second part of user declarations.  */
206 
207 
208 /* Line 214 of yacc.c.  */
209 
210 
211 #if ! defined (yyoverflow) || YYERROR_VERBOSE
212 
213 /* The parser invokes alloca or malloc; define the necessary symbols.  */
214 
215 # if YYSTACK_USE_ALLOCA
216 #  define YYSTACK_ALLOC alloca
217 # else
218 #  ifndef YYSTACK_USE_ALLOCA
219 #   if defined (alloca) || defined (_ALLOCA_H)
220 #    define YYSTACK_ALLOC alloca
221 #   else
222 #    ifdef __GNUC__
223 #     define YYSTACK_ALLOC __builtin_alloca
224 #    endif
225 #   endif
226 #  endif
227 # endif
228 
229 # ifdef YYSTACK_ALLOC
230    /* Pacify GCC's `empty if-body' warning. */
231 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
232 # else
233 #  if defined (__STDC__) || defined (__cplusplus)
234 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
235 #   define YYSIZE_T size_t
236 #  endif
237 #  define YYSTACK_ALLOC malloc
238 #  define YYSTACK_FREE free
239 # endif
240 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
241 
242 
243 #if (! defined (yyoverflow) \
244      && (! defined (__cplusplus) \
245          || (YYSTYPE_IS_TRIVIAL)))
246 
247 /* A type that is properly aligned for any stack member.  */
248 union yyalloc
249 {
250   short yyss;
251   YYSTYPE yyvs;
252   };
253 
254 /* The size of the maximum gap between one aligned stack and the next.  */
255 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
256 
257 /* The size of an array large to enough to hold all stacks, each with
258    N elements.  */
259 # define YYSTACK_BYTES(N) \
260      ((N) * (sizeof (short) + sizeof (YYSTYPE))                                \
261       + YYSTACK_GAP_MAXIMUM)
262 
263 /* Copy COUNT objects from FROM to TO.  The source and destination do
264    not overlap.  */
265 # ifndef YYCOPY
266 #  if 1 < __GNUC__
267 #   define YYCOPY(To, From, Count) \
268       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
269 #  else
270 #   define YYCOPY(To, From, Count)                \
271       do                                        \
272         {                                        \
273           register YYSIZE_T yyi;                \
274           for (yyi = 0; yyi < (Count); yyi++)        \
275             (To)[yyi] = (From)[yyi];                \
276         }                                        \
277       while (0)
278 #  endif
279 # endif
280 
281 /* Relocate STACK from its old location to the new one.  The
282    local variables YYSIZE and YYSTACKSIZE give the old and new number of
283    elements in the stack, and YYPTR gives the new location of the
284    stack.  Advance YYPTR to a properly aligned location for the next
285    stack.  */
286 # define YYSTACK_RELOCATE(Stack)                                        \
287     do                                                                        \
288       {                                                                        \
289         YYSIZE_T yynewbytes;                                                \
290         YYCOPY (&yyptr->Stack, Stack, yysize);                                \
291         Stack = &yyptr->Stack;                                                \
292         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
293         yyptr += yynewbytes / sizeof (*yyptr);                                \
294       }                                                                        \
295     while (0)
296 
297 #endif
298 
299 #if defined (__STDC__) || defined (__cplusplus)
300    typedef signed char yysigned_char;
301 #else
302    typedef short yysigned_char;
303 #endif
304 
305 /* YYFINAL -- State number of the termination state. */
306 #define YYFINAL  22
307 /* YYLAST -- Last index in YYTABLE.  */
308 #define YYLAST   278
309 
310 /* YYNTOKENS -- Number of terminals. */
311 #define YYNTOKENS  40
312 /* YYNNTS -- Number of nonterminals. */
313 #define YYNNTS  5
314 /* YYNRULES -- Number of rules. */
315 #define YYNRULES  46
316 /* YYNRULES -- Number of states. */
317 #define YYNSTATES  119
318 
319 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
320 #define YYUNDEFTOK  2
321 #define YYMAXUTOK   282
322 
323 #define YYTRANSLATE(YYX)                                                 \
324   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
325 
326 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
327 static const unsigned char yytranslate[] =
328 {
329        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
330        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
331        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
332        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
333       38,    39,    30,    29,    32,    28,     2,    31,     2,     2,
334        2,     2,     2,     2,     2,     2,     2,     2,    37,    33,
335        2,    34,     2,     2,     2,     2,     2,     2,     2,     2,
336        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
337        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
338        2,    35,     2,    36,     2,     2,     2,     2,     2,     2,
339        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
340        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
341        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
342        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
343        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
344        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
345        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
346        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
347        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
348        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
349        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
350        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
351        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
352        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
353        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
354        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
355        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
356       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
357       25,    26,    27
358 };
359 
360 #if YYDEBUG
361 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
362    YYRHS.  */
363 static const unsigned char yyprhs[] =
364 {
365        0,     0,     3,     5,     9,    13,    20,    27,    36,    45,
366       47,    49,    53,    57,    61,    65,    69,    73,    77,    81,
367       85,    89,    93,    97,   101,   105,   110,   117,   124,   131,
368      138,   145,   152,   159,   166,   173,   178,   182,   187,   189,
369      193,   197,   201,   205,   210,   214,   216
370 };
371 
372 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
373 static const yysigned_char yyrhs[] =
374 {
375       41,     0,    -1,    42,    -1,     5,    34,    43,    -1,     5,
376       34,    44,    -1,     5,    35,    43,    36,    34,    44,    -1,
377        5,    35,    43,    36,    34,    43,    -1,     5,    35,     4,
378       37,     4,    36,    34,    44,    -1,     5,    35,     4,    37,
379        4,    36,    34,    43,    -1,    43,    -1,    44,    -1,    43,
380       29,    43,    -1,    43,    32,    43,    -1,    43,    33,    43,
381       -1,    43,    28,    43,    -1,    43,    30,    43,    -1,    43,
382       31,    43,    -1,    43,    29,    44,    -1,    43,    28,    44,
383       -1,    43,    30,    44,    -1,    43,    31,    44,    -1,    44,
384       29,    43,    -1,    44,    28,    43,    -1,    44,    30,    43,
385       -1,    44,    31,    43,    -1,     5,    35,    43,    36,    -1,
386        5,    35,     4,    37,     4,    36,    -1,    18,    38,    43,
387       19,    43,    39,    -1,    17,    38,    43,    19,    43,    39,
388       -1,    17,    38,    43,    19,    44,    39,    -1,    17,    38,
389       43,    20,    44,    39,    -1,    17,    38,    43,    21,    44,
390       39,    -1,    17,    38,    43,    22,    44,    39,    -1,    17,
391       38,    43,    23,    44,    39,    -1,    17,    38,    43,    24,
392       44,    39,    -1,     6,    38,    43,    39,    -1,    38,    43,
393       39,    -1,    27,    38,    43,    39,    -1,     5,    -1,    44,
394       29,    44,    -1,    44,    28,    44,    -1,    44,    30,    44,
395       -1,    44,    31,    44,    -1,     6,    38,    44,    39,    -1,
396       38,    44,    39,    -1,     4,    -1,     3,    -1
397 };
398 
399 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
400 static const unsigned short yyrline[] =
401 {
402        0,    68,    68,    76,    84,    89,   101,   117,   128,   141,
403      148,   153,   162,   239,   303,   312,   322,   331,   340,   349,
404      358,   367,   376,   385,   394,   403,   413,   424,   469,   502,
405      523,   544,   565,   586,   607,   628,   646,   650,   654,   671,
406      675,   679,   683,   687,   695,   699,   703
407 };
408 #endif
409 
410 #if YYDEBUG || YYERROR_VERBOSE
411 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
412    First, the terminals, then, starting at YYNTOKENS, nonterminals. */
413 static const char *const yytname[] =
414 {
415   "$end", "error", "$undefined", "lFLOAT", "tokINTEGER", "tokARRAY", "NAME",
416   "SIN", "COS", "TAN", "ACOS", "ASIN", "ATAN", "LOG", "EXP", "ABS_TOKEN",
417   "SQRT", "WHERE", "INDEX", "EQEQ", "LT", "LE", "GT", "GE", "NE", "LTLT",
418   "GTGT", "JOIN", "'-'", "'+'", "'*'", "'/'", "','", "';'", "'='", "'['",
419   "']'", "':'", "'('", "')'", "$accept", "statemant_list", "statement",
420   "ArrayExpression", "ScalarExpression", 0
421 };
422 #endif
423 
424 # ifdef YYPRINT
425 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
426    token YYLEX-NUM.  */
427 static const unsigned short yytoknum[] =
428 {
429        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
430      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
431      275,   276,   277,   278,   279,   280,   281,   282,    45,    43,
432       42,    47,    44,    59,    61,    91,    93,    58,    40,    41
433 };
434 # endif
435 
436 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
437 static const unsigned char yyr1[] =
438 {
439        0,    40,    41,    42,    42,    42,    42,    42,    42,    42,
440       42,    43,    43,    43,    43,    43,    43,    43,    43,    43,
441       43,    43,    43,    43,    43,    43,    43,    43,    43,    43,
442       43,    43,    43,    43,    43,    43,    43,    43,    43,    44,
443       44,    44,    44,    44,    44,    44,    44
444 };
445 
446 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
447 static const unsigned char yyr2[] =
448 {
449        0,     2,     1,     3,     3,     6,     6,     8,     8,     1,
450        1,     3,     3,     3,     3,     3,     3,     3,     3,     3,
451        3,     3,     3,     3,     3,     4,     6,     6,     6,     6,
452        6,     6,     6,     6,     6,     4,     3,     4,     1,     3,
453        3,     3,     3,     4,     3,     1,     1
454 };
455 
456 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
457    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
458    means the default is an error.  */
459 static const unsigned char yydefact[] =
460 {
461        0,    46,    45,    38,     0,     0,     0,     0,     0,     0,
462        2,     9,    10,     0,     0,     0,     0,     0,     0,    38,
463        0,     0,     1,     0,     0,     0,     0,     0,     0,     0,
464        0,     0,     0,     3,     4,    45,     0,     0,     0,     0,
465        0,     0,     0,     0,    36,    44,    14,    18,    11,    17,
466       15,    19,    16,    20,    12,    13,    22,    40,    21,    39,
467       23,    41,    24,    42,     0,    25,    35,    43,     0,     0,
468        0,     0,     0,     0,     0,    37,    45,     0,     0,     0,
469        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
470        0,    25,    26,     6,     5,    28,    29,     0,     0,     0,
471        0,     0,     0,    30,    31,    32,    33,    34,    27,     0,
472        0,     0,    40,    39,    41,    42,    26,     8,     7
473 };
474 
475 /* YYDEFGOTO[NTERM-NUM]. */
476 static const yysigned_char yydefgoto[] =
477 {
478       -1,     9,    10,    11,    37
479 };
480 
481 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
482    STATE-NUM.  */
483 #define YYPACT_NINF -36
484 static const short yypact[] =
485 {
486        1,   -36,   -36,   -33,   -35,   -27,   -24,   -16,    88,    27,
487      -36,   245,    26,    88,   113,    88,    88,    88,    88,     5,
488      143,     7,   -36,    88,    88,    88,    88,    88,    88,    88,
489       88,    88,    88,   245,    26,     4,   227,    26,   155,   108,
490      137,    56,   167,   117,   -36,   -36,   220,   -14,   220,   -14,
491      -12,   -36,   -12,   -36,   -36,   -36,   220,   -14,   220,   -14,
492      -12,   -36,   -12,   -36,    38,    11,   -36,   -36,    88,     6,
493        6,     6,     6,     6,    88,   -36,    10,   236,    40,    88,
494      179,   150,    36,     6,   162,   174,   186,   198,   203,   191,
495       73,   -36,    46,   245,    26,   -36,   -36,     6,   210,     6,
496        6,     6,     6,   -36,   -36,   -36,   -36,   -36,   -36,    45,
497       88,   215,     3,     3,   -36,   -36,   -36,   245,    26
498 };
499 
500 /* YYPGOTO[NTERM-NUM].  */
501 static const yysigned_char yypgoto[] =
502 {
503      -36,   -36,   -36,    35,     0
504 };
505 
506 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
507    positive, shift that token.  If negative, reduce the rule which
508    number is the opposite.  If zero, do what YYDEFACT says.
509    If YYTABLE_NINF, syntax error.  */
510 #define YYTABLE_NINF -1
511 static const unsigned char yytable[] =
512 {
513       12,    13,    14,    15,     1,     2,     3,     4,    21,     1,
514        2,    16,    82,    34,    17,    39,    31,    32,     5,     6,
515       27,    28,    18,    47,    49,    51,    53,    22,     7,    57,
516       59,    61,    63,   101,   102,    29,    30,    31,    32,     8,
517       43,    64,    78,    20,    83,    79,    45,    90,    33,    36,
518       38,    40,    41,    42,    29,    30,    31,    32,    46,    48,
519       50,    52,    54,    55,    56,    58,    60,    62,    81,    84,
520       85,    86,    87,    88,    97,    74,    92,   109,    77,    94,
521      110,   116,     0,    98,    23,    24,    25,    26,    27,    28,
522        0,     1,     2,    19,     4,     0,     0,   111,     0,   112,
523      113,   114,   115,    80,     0,     5,     6,     0,     0,    89,
524      118,     0,     0,     0,    93,     7,     1,    35,    19,     4,
525        1,    76,    19,     4,     0,     0,     8,     0,     0,     0,
526        5,     6,     0,     0,     5,     6,    29,    30,    31,    32,
527        7,     0,     0,     0,     7,   117,     0,    67,     0,     0,
528        0,     8,     0,     0,     0,     8,    68,    69,    70,    71,
529       72,    73,     0,     0,     0,    23,    24,    25,    26,    27,
530       28,    23,    24,    25,    26,    27,    28,     0,    29,    30,
531       31,    32,    44,    23,    24,    25,    26,    27,    28,    96,
532       99,   100,   101,   102,    66,    23,    24,    25,    26,    27,
533       28,   103,    99,   100,   101,   102,    75,    23,    24,    25,
534       26,    27,    28,   104,    99,   100,   101,   102,    95,    23,
535       24,    25,    26,    27,    28,   105,    99,   100,   101,   102,
536      108,    99,   100,   101,   102,     0,     0,   106,    99,   100,
537      101,   102,   107,    99,   100,   101,   102,     0,     0,    45,
538       25,    26,    27,    28,    67,    23,    24,    25,    26,    27,
539       28,     0,     0,    65,    23,    24,    25,    26,    27,    28,
540        0,     0,    91,    23,    24,    25,    26,    27,    28
541 };
542 
543 static const yysigned_char yycheck[] =
544 {
545        0,    34,    35,    38,     3,     4,     5,     6,     8,     3,
546        4,    38,     6,    13,    38,    15,    30,    31,    17,    18,
547       32,    33,    38,    23,    24,    25,    26,     0,    27,    29,
548       30,    31,    32,    30,    31,    28,    29,    30,    31,    38,
549       35,    37,     4,     8,    38,    34,    39,    37,    13,    14,
550       15,    16,    17,    18,    28,    29,    30,    31,    23,    24,
551       25,    26,    27,    28,    29,    30,    31,    32,    68,    69,
552       70,    71,    72,    73,    38,    19,    36,     4,    43,    79,
553       34,    36,    -1,    83,    28,    29,    30,    31,    32,    33,
554       -1,     3,     4,     5,     6,    -1,    -1,    97,    -1,    99,
555      100,   101,   102,    68,    -1,    17,    18,    -1,    -1,    74,
556      110,    -1,    -1,    -1,    79,    27,     3,     4,     5,     6,
557        3,     4,     5,     6,    -1,    -1,    38,    -1,    -1,    -1,
558       17,    18,    -1,    -1,    17,    18,    28,    29,    30,    31,
559       27,    -1,    -1,    -1,    27,   110,    -1,    39,    -1,    -1,
560       -1,    38,    -1,    -1,    -1,    38,    19,    20,    21,    22,
561       23,    24,    -1,    -1,    -1,    28,    29,    30,    31,    32,
562       33,    28,    29,    30,    31,    32,    33,    -1,    28,    29,
563       30,    31,    39,    28,    29,    30,    31,    32,    33,    39,
564       28,    29,    30,    31,    39,    28,    29,    30,    31,    32,
565       33,    39,    28,    29,    30,    31,    39,    28,    29,    30,
566       31,    32,    33,    39,    28,    29,    30,    31,    39,    28,
567       29,    30,    31,    32,    33,    39,    28,    29,    30,    31,
568       39,    28,    29,    30,    31,    -1,    -1,    39,    28,    29,
569       30,    31,    39,    28,    29,    30,    31,    -1,    -1,    39,
570       30,    31,    32,    33,    39,    28,    29,    30,    31,    32,
571       33,    -1,    -1,    36,    28,    29,    30,    31,    32,    33,
572       -1,    -1,    36,    28,    29,    30,    31,    32,    33
573 };
574 
575 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
576    symbol of state STATE-NUM.  */
577 static const unsigned char yystos[] =
578 {
579        0,     3,     4,     5,     6,    17,    18,    27,    38,    41,
580       42,    43,    44,    34,    35,    38,    38,    38,    38,     5,
581       43,    44,     0,    28,    29,    30,    31,    32,    33,    28,
582       29,    30,    31,    43,    44,     4,    43,    44,    43,    44,
583       43,    43,    43,    35,    39,    39,    43,    44,    43,    44,
584       43,    44,    43,    44,    43,    43,    43,    44,    43,    44,
585       43,    44,    43,    44,    37,    36,    39,    39,    19,    20,
586       21,    22,    23,    24,    19,    39,     4,    43,     4,    34,
587       43,    44,     6,    38,    44,    44,    44,    44,    44,    43,
588       37,    36,    36,    43,    44,    39,    39,    38,    44,    28,
589       29,    30,    31,    39,    39,    39,    39,    39,    39,     4,
590       34,    44,    44,    44,    44,    44,    36,    43,    44
591 };
592 
593 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
594 # define YYSIZE_T __SIZE_TYPE__
595 #endif
596 #if ! defined (YYSIZE_T) && defined (size_t)
597 # define YYSIZE_T size_t
598 #endif
599 #if ! defined (YYSIZE_T)
600 # if defined (__STDC__) || defined (__cplusplus)
601 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
602 #  define YYSIZE_T size_t
603 # endif
604 #endif
605 #if ! defined (YYSIZE_T)
606 # define YYSIZE_T unsigned int
607 #endif
608 
609 #define yyerrok                (yyerrstatus = 0)
610 #define yyclearin        (yychar = YYEMPTY)
611 #define YYEMPTY                (-2)
612 #define YYEOF                0
613 
614 #define YYACCEPT        goto yyacceptlab
615 #define YYABORT                goto yyabortlab
616 #define YYERROR                goto yyerrlab1
617 
618 
619 /* Like YYERROR except do call yyerror.  This remains here temporarily
620    to ease the transition to the new meaning of YYERROR, for GCC.
621    Once GCC version 2 has supplanted version 1, this can go.  */
622 
623 #define YYFAIL                goto yyerrlab
624 
625 #define YYRECOVERING()  (!!yyerrstatus)
626 
627 #define YYBACKUP(Token, Value)                                        \
628 do                                                                \
629   if (yychar == YYEMPTY && yylen == 1)                                \
630     {                                                                \
631       yychar = (Token);                                                \
632       yylval = (Value);                                                \
633       yytoken = YYTRANSLATE (yychar);                                \
634       YYPOPSTACK;                                                \
635       goto yybackup;                                                \
636     }                                                                \
637   else                                                                \
638     {                                                                 \
639       yyerror ("syntax error: cannot back up");\
640       YYERROR;                                                        \
641     }                                                                \
642 while (0)
643 
644 #define YYTERROR        1
645 #define YYERRCODE        256
646 
647 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
648    are run).  */
649 
650 #ifndef YYLLOC_DEFAULT
651 # define YYLLOC_DEFAULT(Current, Rhs, N)         \
652   Current.first_line   = Rhs[1].first_line;      \
653   Current.first_column = Rhs[1].first_column;    \
654   Current.last_line    = Rhs[N].last_line;       \
655   Current.last_column  = Rhs[N].last_column;
656 #endif
657 
658 /* YYLEX -- calling `yylex' with the right arguments.  */
659 
660 #ifdef YYLEX_PARAM
661 # define YYLEX yylex (YYLEX_PARAM)
662 #else
663 # define YYLEX yylex ()
664 #endif
665 
666 /* Enable debugging if requested.  */
667 #if YYDEBUG
668 
669 # ifndef YYFPRINTF
670 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
671 #  define YYFPRINTF fprintf
672 # endif
673 
674 # define YYDPRINTF(Args)                        \
675 do {                                                \
676   if (yydebug)                                        \
677     YYFPRINTF Args;                                \
678 } while (0)
679 
680 # define YYDSYMPRINT(Args)                        \
681 do {                                                \
682   if (yydebug)                                        \
683     yysymprint Args;                                \
684 } while (0)
685 
686 # define YYDSYMPRINTF(Title, Token, Value, Location)                \
687 do {                                                                \
688   if (yydebug)                                                        \
689     {                                                                \
690       YYFPRINTF (stderr, "%s ", Title);                                \
691       yysymprint (stderr,                                         \
692                   Token, Value);        \
693       YYFPRINTF (stderr, "\n");                                        \
694     }                                                                \
695 } while (0)
696 
697 /*------------------------------------------------------------------.
698 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
699 | TOP (cinluded).                                                   |
700 `------------------------------------------------------------------*/
701 
702 #if defined (__STDC__) || defined (__cplusplus)
703 static void
yy_stack_print(short * bottom,short * top)704 yy_stack_print (short *bottom, short *top)
705 #else
706 static void
707 yy_stack_print (bottom, top)
708     short *bottom;
709     short *top;
710 #endif
711 {
712   YYFPRINTF (stderr, "Stack now");
713   for (/* Nothing. */; bottom <= top; ++bottom)
714     YYFPRINTF (stderr, " %d", *bottom);
715   YYFPRINTF (stderr, "\n");
716 }
717 
718 # define YY_STACK_PRINT(Bottom, Top)                                \
719 do {                                                                \
720   if (yydebug)                                                        \
721     yy_stack_print ((Bottom), (Top));                                \
722 } while (0)
723 
724 
725 /*------------------------------------------------.
726 | Report that the YYRULE is going to be reduced.  |
727 `------------------------------------------------*/
728 
729 #if defined (__STDC__) || defined (__cplusplus)
730 static void
yy_reduce_print(int yyrule)731 yy_reduce_print (int yyrule)
732 #else
733 static void
734 yy_reduce_print (yyrule)
735     int yyrule;
736 #endif
737 {
738   int yyi;
739   unsigned int yylineno = yyrline[yyrule];
740   YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
741              yyrule - 1, yylineno);
742   /* Print the symbols being reduced, and their result.  */
743   for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
744     YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
745   YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
746 }
747 
748 # define YY_REDUCE_PRINT(Rule)                \
749 do {                                        \
750   if (yydebug)                                \
751     yy_reduce_print (Rule);                \
752 } while (0)
753 
754 /* Nonzero means print parse trace.  It is left uninitialized so that
755    multiple parsers can coexist.  */
756 int yydebug;
757 #else /* !YYDEBUG */
758 # define YYDPRINTF(Args)
759 # define YYDSYMPRINT(Args)
760 # define YYDSYMPRINTF(Title, Token, Value, Location)
761 # define YY_STACK_PRINT(Bottom, Top)
762 # define YY_REDUCE_PRINT(Rule)
763 #endif /* !YYDEBUG */
764 
765 
766 /* YYINITDEPTH -- initial size of the parser's stacks.  */
767 #ifndef        YYINITDEPTH
768 # define YYINITDEPTH 200
769 #endif
770 
771 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
772    if the built-in stack extension method is used).
773 
774    Do not make this value too large; the results are undefined if
775    SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
776    evaluated with infinite-precision integer arithmetic.  */
777 
778 #if YYMAXDEPTH == 0
779 # undef YYMAXDEPTH
780 #endif
781 
782 #ifndef YYMAXDEPTH
783 # define YYMAXDEPTH 10000
784 #endif
785 
786 
787 
788 #if YYERROR_VERBOSE
789 
790 # ifndef yystrlen
791 #  if defined (__GLIBC__) && defined (_STRING_H)
792 #   define yystrlen strlen
793 #  else
794 /* Return the length of YYSTR.  */
795 static YYSIZE_T
796 #   if defined (__STDC__) || defined (__cplusplus)
yystrlen(const char * yystr)797 yystrlen (const char *yystr)
798 #   else
799 yystrlen (yystr)
800      const char *yystr;
801 #   endif
802 {
803   register const char *yys = yystr;
804 
805   while (*yys++ != '\0')
806     continue;
807 
808   return yys - yystr - 1;
809 }
810 #  endif
811 # endif
812 
813 # ifndef yystpcpy
814 #  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
815 #   define yystpcpy stpcpy
816 #  else
817 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
818    YYDEST.  */
819 static char *
820 #   if defined (__STDC__) || defined (__cplusplus)
yystpcpy(char * yydest,const char * yysrc)821 yystpcpy (char *yydest, const char *yysrc)
822 #   else
823 yystpcpy (yydest, yysrc)
824      char *yydest;
825      const char *yysrc;
826 #   endif
827 {
828   register char *yyd = yydest;
829   register const char *yys = yysrc;
830 
831   while ((*yyd++ = *yys++) != '\0')
832     continue;
833 
834   return yyd - 1;
835 }
836 #  endif
837 # endif
838 
839 #endif /* !YYERROR_VERBOSE */
840 
841 
842 
843 #if YYDEBUG
844 /*--------------------------------.
845 | Print this symbol on YYOUTPUT.  |
846 `--------------------------------*/
847 
848 #if defined (__STDC__) || defined (__cplusplus)
849 static void
yysymprint(FILE * yyoutput,int yytype,YYSTYPE * yyvaluep)850 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
851 #else
852 static void
853 yysymprint (yyoutput, yytype, yyvaluep)
854     FILE *yyoutput;
855     int yytype;
856     YYSTYPE *yyvaluep;
857 #endif
858 {
859   /* Pacify ``unused variable'' warnings.  */
860   (void) yyvaluep;
861 
862   if (yytype < YYNTOKENS)
863     {
864       YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
865 # ifdef YYPRINT
866       YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
867 # endif
868     }
869   else
870     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
871 
872   YYFPRINTF (yyoutput, ")");
873 }
874 
875 #endif /* ! YYDEBUG */
876 /*-----------------------------------------------.
877 | Release the memory associated to this symbol.  |
878 `-----------------------------------------------*/
879 
880 #if defined (__STDC__) || defined (__cplusplus)
881 static void
yydestruct(int yytype,YYSTYPE * yyvaluep)882 yydestruct (int yytype, YYSTYPE *yyvaluep)
883 #else
884 static void
885 yydestruct (yytype, yyvaluep)
886     int yytype;
887     YYSTYPE *yyvaluep;
888 #endif
889 {
890   /* Pacify ``unused variable'' warnings.  */
891   (void) yyvaluep;
892   (void) yytype;
893 }
894 
895 
896 /* Prevent warnings from -Wmissing-prototypes.  */
897 
898 #ifdef YYPARSE_PARAM
899 # if defined (__STDC__) || defined (__cplusplus)
900 int yyparse (void *YYPARSE_PARAM);
901 # else
902 int yyparse ();
903 # endif
904 #else /* ! YYPARSE_PARAM */
905 #if defined (__STDC__) || defined (__cplusplus)
906 int yyparse (void);
907 #else
908 int yyparse ();
909 #endif
910 #endif /* ! YYPARSE_PARAM */
911 
912 
913 
914 /* The lookahead symbol.  */
915 int yychar;
916 
917 /* The semantic value of the lookahead symbol.  */
918 YYSTYPE yylval;
919 
920 /* Number of syntax errors so far.  */
921 int yynerrs;
922 
923 
924 
925 /*----------.
926 | yyparse.  |
927 `----------*/
928 
929 #ifdef YYPARSE_PARAM
930 # if defined (__STDC__) || defined (__cplusplus)
yyparse(void * YYPARSE_PARAM)931 int yyparse (void *YYPARSE_PARAM)
932 # else
933 int yyparse (YYPARSE_PARAM)
934   void *YYPARSE_PARAM;
935 # endif
936 #else /* ! YYPARSE_PARAM */
937 #if defined (__STDC__) || defined (__cplusplus)
938 int
939 yyparse (void)
940 #else
941 int
942 yyparse ()
943 
944 #endif
945 #endif
946 {
947 
948   register int yystate;
949   register int yyn;
950   int yyresult;
951   /* Number of tokens to shift before error messages enabled.  */
952   int yyerrstatus;
953   /* Lookahead token as an internal (translated) token number.  */
954   int yytoken = 0;
955 
956   /* Three stacks and their tools:
957      `yyss': related to states,
958      `yyvs': related to semantic values,
959      `yyls': related to locations.
960 
961      Refer to the stacks thru separate pointers, to allow yyoverflow
962      to reallocate them elsewhere.  */
963 
964   /* The state stack.  */
965   short        yyssa[YYINITDEPTH];
966   short *yyss = yyssa;
967   register short *yyssp;
968 
969   /* The semantic value stack.  */
970   YYSTYPE yyvsa[YYINITDEPTH];
971   YYSTYPE *yyvs = yyvsa;
972   register YYSTYPE *yyvsp;
973 
974 
975 
976 #define YYPOPSTACK   (yyvsp--, yyssp--)
977 
978   YYSIZE_T yystacksize = YYINITDEPTH;
979 
980   /* The variables used to return semantic value and location from the
981      action routines.  */
982   YYSTYPE yyval;
983 
984 
985   /* When reducing, the number of symbols on the RHS of the reduced
986      rule.  */
987   int yylen;
988 
989   YYDPRINTF ((stderr, "Starting parse\n"));
990 
991   yystate = 0;
992   yyerrstatus = 0;
993   yynerrs = 0;
994   yychar = YYEMPTY;                /* Cause a token to be read.  */
995 
996   /* Initialize stack pointers.
997      Waste one element of value and location stack
998      so that they stay on the same level as the state stack.
999      The wasted elements are never initialized.  */
1000 
1001   yyssp = yyss;
1002   yyvsp = yyvs;
1003 
1004   goto yysetstate;
1005 
1006 /*------------------------------------------------------------.
1007 | yynewstate -- Push a new state, which is found in yystate.  |
1008 `------------------------------------------------------------*/
1009  yynewstate:
1010   /* In all cases, when you get here, the value and location stacks
1011      have just been pushed. so pushing a state here evens the stacks.
1012      */
1013   yyssp++;
1014 
1015  yysetstate:
1016   *yyssp = yystate;
1017 
1018   if (yyss + yystacksize - 1 <= yyssp)
1019     {
1020       /* Get the current used size of the three stacks, in elements.  */
1021       YYSIZE_T yysize = yyssp - yyss + 1;
1022 
1023 #ifdef yyoverflow
1024       {
1025         /* Give user a chance to reallocate the stack. Use copies of
1026            these so that the &'s don't force the real ones into
1027            memory.  */
1028         YYSTYPE *yyvs1 = yyvs;
1029         short *yyss1 = yyss;
1030 
1031 
1032         /* Each stack pointer address is followed by the size of the
1033            data in use in that stack, in bytes.  This used to be a
1034            conditional around just the two extra args, but that might
1035            be undefined if yyoverflow is a macro.  */
1036         yyoverflow ("parser stack overflow",
1037                     &yyss1, yysize * sizeof (*yyssp),
1038                     &yyvs1, yysize * sizeof (*yyvsp),
1039 
1040                     &yystacksize);
1041 
1042         yyss = yyss1;
1043         yyvs = yyvs1;
1044       }
1045 #else /* no yyoverflow */
1046 # ifndef YYSTACK_RELOCATE
1047       goto yyoverflowlab;
1048 # else
1049       /* Extend the stack our own way.  */
1050       if (YYMAXDEPTH <= yystacksize)
1051         goto yyoverflowlab;
1052       yystacksize *= 2;
1053       if (YYMAXDEPTH < yystacksize)
1054         yystacksize = YYMAXDEPTH;
1055 
1056       {
1057         short *yyss1 = yyss;
1058         union yyalloc *yyptr =
1059           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1060         if (! yyptr)
1061           goto yyoverflowlab;
1062         YYSTACK_RELOCATE (yyss);
1063         YYSTACK_RELOCATE (yyvs);
1064 
1065 #  undef YYSTACK_RELOCATE
1066         if (yyss1 != yyssa)
1067           YYSTACK_FREE (yyss1);
1068       }
1069 # endif
1070 #endif /* no yyoverflow */
1071 
1072       yyssp = yyss + yysize - 1;
1073       yyvsp = yyvs + yysize - 1;
1074 
1075 
1076       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1077                   (unsigned long int) yystacksize));
1078 
1079       if (yyss + yystacksize - 1 <= yyssp)
1080         YYABORT;
1081     }
1082 
1083   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1084 
1085   goto yybackup;
1086 
1087 /*-----------.
1088 | yybackup.  |
1089 `-----------*/
1090 yybackup:
1091 
1092 /* Do appropriate processing given the current state.  */
1093 /* Read a lookahead token if we need one and don't already have one.  */
1094 /* yyresume: */
1095 
1096   /* First try to decide what to do without reference to lookahead token.  */
1097 
1098   yyn = yypact[yystate];
1099   if (yyn == YYPACT_NINF)
1100     goto yydefault;
1101 
1102   /* Not known => get a lookahead token if don't already have one.  */
1103 
1104   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1105   if (yychar == YYEMPTY)
1106     {
1107       YYDPRINTF ((stderr, "Reading a token: "));
1108       yychar = YYLEX;
1109     }
1110 
1111   if (yychar <= YYEOF)
1112     {
1113       yychar = yytoken = YYEOF;
1114       YYDPRINTF ((stderr, "Now at end of input.\n"));
1115     }
1116   else
1117     {
1118       yytoken = YYTRANSLATE (yychar);
1119       YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
1120     }
1121 
1122   /* If the proper action on seeing token YYTOKEN is to reduce or to
1123      detect an error, take that action.  */
1124   yyn += yytoken;
1125   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1126     goto yydefault;
1127   yyn = yytable[yyn];
1128   if (yyn <= 0)
1129     {
1130       if (yyn == 0 || yyn == YYTABLE_NINF)
1131         goto yyerrlab;
1132       yyn = -yyn;
1133       goto yyreduce;
1134     }
1135 
1136   if (yyn == YYFINAL)
1137     YYACCEPT;
1138 
1139   /* Shift the lookahead token.  */
1140   YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1141 
1142   /* Discard the token being shifted unless it is eof.  */
1143   if (yychar != YYEOF)
1144     yychar = YYEMPTY;
1145 
1146   *++yyvsp = yylval;
1147 
1148 
1149   /* Count tokens shifted since error; after three, turn off error
1150      status.  */
1151   if (yyerrstatus)
1152     yyerrstatus--;
1153 
1154   yystate = yyn;
1155   goto yynewstate;
1156 
1157 
1158 /*-----------------------------------------------------------.
1159 | yydefault -- do the default action for the current state.  |
1160 `-----------------------------------------------------------*/
1161 yydefault:
1162   yyn = yydefact[yystate];
1163   if (yyn == 0)
1164     goto yyerrlab;
1165   goto yyreduce;
1166 
1167 
1168 /*-----------------------------.
1169 | yyreduce -- Do a reduction.  |
1170 `-----------------------------*/
1171 yyreduce:
1172   /* yyn is the number of a rule to reduce with.  */
1173   yylen = yyr2[yyn];
1174 
1175   /* If YYLEN is nonzero, implement the default value of the action:
1176      `$$ = $1'.
1177 
1178      Otherwise, the following line sets YYVAL to garbage.
1179      This behavior is undocumented and Bison
1180      users should not rely upon it.  Assigning to YYVAL
1181      unconditionally makes the parser a bit smaller, and it avoids a
1182      GCC warning that YYVAL may be used uninitialized.  */
1183   yyval = yyvsp[1-yylen];
1184 
1185 
1186   YY_REDUCE_PRINT (yyn);
1187   switch (yyn)
1188     {
1189         case 2:
1190 
1191     {
1192                 /*
1193                 printf("Complete\n");
1194                 printf("XdmfExprReturnValue Nelms = %d\n", XdmfExprReturnValue->GetNumberOfElements());
1195                 */
1196                 }
1197     break;
1198 
1199   case 3:
1200 
1201     {
1202                 xdmf2::XdmfArray *TempArray = ( xdmf2::XdmfArray *)yyvsp[0].ArrayPointer;
1203 
1204                 /* printf("Setting %s from ArrayExpression\n", $1); */
1205                 XdmfExprReturnValue = (xdmf2::XdmfArray *)yyvsp[-2].ArrayPointer;
1206                 *XdmfExprReturnValue = *TempArray;
1207                 delete TempArray;
1208                 }
1209     break;
1210 
1211   case 4:
1212 
1213     {
1214                 /* printf("Setting %s from ScalarExpression\n", $1); */
1215                 XdmfExprReturnValue = (xdmf2::XdmfArray *)yyvsp[-2].ArrayPointer;
1216                 *XdmfExprReturnValue = yyvsp[0].DoubleValue;
1217                 }
1218     break;
1219 
1220   case 5:
1221 
1222     {
1223                         xdmf2::XdmfArray        *Array1 = ( xdmf2::XdmfArray *)yyvsp[-3].ArrayPointer;
1224                         xdmf2::XdmfArray        *Result = ( xdmf2::XdmfArray *)yyvsp[-5].ArrayPointer;
1225                         XdmfLength        i, index, Length = Array1->GetNumberOfElements();
1226 
1227                         for( i = 0 ; i < Length ; i++ ){
1228                                 index = (XdmfLength)Array1->GetValueAsFloat64( i );
1229                                 Result->SetValueFromFloat64( index, yyvsp[0].DoubleValue );
1230                                 }
1231                         delete Array1;
1232                         XdmfExprReturnValue = Result;
1233                 }
1234     break;
1235 
1236   case 6:
1237 
1238     {
1239                         xdmf2::XdmfArray        *Array1 = ( xdmf2::XdmfArray *)yyvsp[-3].ArrayPointer;
1240                         xdmf2::XdmfArray        *Array2 = ( xdmf2::XdmfArray *)yyvsp[0].ArrayPointer;
1241                         xdmf2::XdmfArray        *Result = ( xdmf2::XdmfArray *)yyvsp[-5].ArrayPointer;
1242                         XdmfFloat64        Value;
1243                         XdmfLength        i, index, Length = Array1->GetNumberOfElements();
1244 
1245                         for( i = 0 ; i < Length ; i++ ){
1246                                 index = (XdmfLength)Array1->GetValueAsFloat64( i );
1247                                 Value = Array2->GetValueAsFloat64( i );
1248                                 Result->SetValueFromFloat64( index, Value );
1249                                 }
1250                         delete Array1;
1251                         delete Array2;
1252                         XdmfExprReturnValue = Result;
1253                 }
1254     break;
1255 
1256   case 7:
1257 
1258     {
1259                         xdmf2::XdmfArray *Range;
1260 
1261                         /* printf("Array Range %d:%d = ScalarExpression \n", $3, $5);         */
1262                         Range = (xdmf2::XdmfArray *)yyvsp[-7].ArrayPointer;
1263                         XdmfExprReturnValue = Range->Reference( yyvsp[-5].IntegerValue, yyvsp[-3].IntegerValue ); /* This is a Reference */
1264                         *XdmfExprReturnValue = yyvsp[0].DoubleValue;
1265 
1266                         /* Now Point to the Entire Array */
1267                         XdmfExprReturnValue = (xdmf2::XdmfArray *)yyvsp[-7].ArrayPointer;
1268                         }
1269     break;
1270 
1271   case 8:
1272 
1273     {
1274                         xdmf2::XdmfArray *TempArray = ( xdmf2::XdmfArray *)yyvsp[0].ArrayPointer;
1275                         xdmf2::XdmfArray *Range;
1276 
1277                         /* printf("Array Range %d:%d = ArrayExpression \n", $3, $5);         */
1278                         Range = (xdmf2::XdmfArray *)yyvsp[-7].ArrayPointer;
1279                         XdmfExprReturnValue = Range->Reference( yyvsp[-5].IntegerValue, yyvsp[-3].IntegerValue ); /* This is a Reference */
1280                         *XdmfExprReturnValue = *TempArray;
1281 
1282                         /* Now Point to the Entire Array */
1283                         XdmfExprReturnValue = (xdmf2::XdmfArray *)yyvsp[-7].ArrayPointer;
1284                         delete TempArray;
1285                         }
1286     break;
1287 
1288   case 9:
1289 
1290     {
1291                 xdmf2::XdmfArray *TempArray = ( xdmf2::XdmfArray *)yyvsp[0].ArrayPointer;
1292 
1293                 /* printf("Clone from ArrayExpression\n"); */
1294                 XdmfExprReturnValue = TempArray;
1295                 /* printf("XdmfExprReturnValue Nelms = %d\n", XdmfExprReturnValue->GetNumberOfElements()); */
1296                 }
1297     break;
1298 
1299   case 10:
1300 
1301     {
1302                 printf("Pointless !! Scalar = %g\n", yyvsp[0].DoubleValue);
1303                 }
1304     break;
1305 
1306   case 11:
1307 
1308     {
1309                         xdmf2::XdmfArray *Array1 = ( xdmf2::XdmfArray *)yyvsp[-2].ArrayPointer;
1310                         xdmf2::XdmfArray *Array2 = ( xdmf2::XdmfArray *)yyvsp[0].ArrayPointer;
1311 
1312                         /* printf("Array 0x%X + 0x%X\n", Array1, Array2); */
1313                         *Array1 += *Array2;
1314                         yyval.ArrayPointer = Array1;
1315                         delete Array2;
1316                         }
1317     break;
1318 
1319   case 12:
1320 
1321     {
1322                         /* Interlace */
1323                         xdmf2::XdmfArray *Array1 = ( xdmf2::XdmfArray *)yyvsp[-2].ArrayPointer;
1324                         xdmf2::XdmfArray *Array2 = ( xdmf2::XdmfArray *)yyvsp[0].ArrayPointer;
1325                         xdmf2::XdmfArray *NewArray = new xdmf2::XdmfArray();
1326                         XdmfInt32 i, Rank1, Rank2;
1327                         XdmfInt64 NewLength, Length1, Length2, IFactor, Lcd;
1328                         XdmfInt64 Dimension1[ XDMF_MAX_DIMENSION ];
1329                         XdmfInt64 Dimension2[ XDMF_MAX_DIMENSION ];
1330                         XdmfInt64 Start[ XDMF_MAX_DIMENSION ];
1331                         XdmfInt64 Stride[ XDMF_MAX_DIMENSION ];
1332                         XdmfInt64 Count[ XDMF_MAX_DIMENSION ];
1333                         XdmfInt64 NewDimension[ XDMF_MAX_DIMENSION ];
1334 
1335                         /* printf("Array 0x%X , 0x%X\n", Array1, Array2); */
1336 
1337                         Rank1 = Array1->GetShape( Dimension1 );
1338                         Rank2 = Array2->GetShape( Dimension2 );
1339                         if( Rank1 != Rank2 ){
1340                                 printf(" Interlace : Rank Mismatch !!\n");
1341                                 }
1342                         NewArray->CopyType( Array1 );
1343 
1344                         Length1 = Array1->GetNumberOfElements();
1345                         Length2 = Array2->GetNumberOfElements();
1346                         NewLength = Length1 + Length2;
1347                         IFactor = Length1 / Length2;
1348                         Lcd = Length1;
1349                         if( Length2 < Length1 ){
1350                                 Lcd = Length2;
1351                                 }
1352                         NewDimension[0] = Lcd;
1353                         NewDimension[1] = NewLength / Lcd;
1354                         NewArray->SetShape( 2, NewDimension );
1355                         /*
1356                         printf("Rank1 = %d Rank2 = %d\n", Rank1, Rank2 );
1357                         printf("Array1 Size = %d\n", Array1->GetNumberOfElements() );
1358                         printf("Array2 Size = %d\n", Array2->GetNumberOfElements() );
1359                         printf("NewLength = %d\n", NewLength );
1360                         printf("Lcd = %d\n", Lcd );
1361                         printf("IFactor = %d\n", IFactor );
1362                         printf("New Dims = %s\n", NewArray->GetShapeAsString() );
1363                         */
1364                         /* NewArray->Generate( -55.0,  -55.0 ); */
1365                         /* Copy in Array 1 */
1366                         Start[0] = 0; Start[1] = 0;
1367                         Stride[0] = 1; Stride[1] = 1;
1368                         Count[0] = Lcd; Count[1] = Length1 / Lcd;
1369                         NewArray->SelectHyperSlab( Start, Stride, Count );
1370                         Array1->SelectAll();
1371                         /*
1372                         printf("Copy in Array1 = %s\n", NewArray->GetHyperSlabAsString() );
1373                         */
1374                         CopyArray( Array1, NewArray );
1375                         /* Copy in Array 2 */
1376                         Start[0] = 0; Start[1] = Length1 / Lcd;
1377                         Stride[0] = 1; Stride[1] = 1;
1378                         Count[0] = Lcd; Count[1] = Length2 / Lcd;
1379                         NewArray->SelectHyperSlab( Start, Stride, Count );
1380                         Array2->SelectAll();
1381                         /*
1382                         printf("Copy in Array2 = %s\n", NewArray->GetHyperSlabAsString() );
1383                         */
1384                         CopyArray( Array2, NewArray );
1385                         NewDimension[0] = Dimension1[0] + Dimension2[0];
1386                         for( i = 1 ; i < Rank1 ; i++ ){
1387                                 NewDimension[i] = Dimension1[i];
1388                                 }
1389                         NewArray->Reform( Rank1, NewDimension );
1390                         /*
1391                         printf("Result(%s) = %s\n", NewArray->GetShapeAsString(), NewArray->GetValues() );
1392                         */
1393                         yyval.ArrayPointer = NewArray;
1394                         delete Array1;
1395                         delete Array2;
1396                         }
1397     break;
1398 
1399   case 13:
1400 
1401     {
1402                         /* Interlace */
1403                         xdmf2::XdmfArray *Array1 = ( xdmf2::XdmfArray *)yyvsp[-2].ArrayPointer;
1404                         xdmf2::XdmfArray *Array2 = ( xdmf2::XdmfArray *)yyvsp[0].ArrayPointer;
1405                         xdmf2::XdmfArray *NewArray = new xdmf2::XdmfArray();
1406                         XdmfInt32 i, Rank1, Rank2;
1407                         XdmfInt64 Dimension1[ XDMF_MAX_DIMENSION ];
1408                         XdmfInt64 Dimension2[ XDMF_MAX_DIMENSION ];
1409                         XdmfInt64 Start[ XDMF_MAX_DIMENSION ];
1410                         XdmfInt64 Stride[ XDMF_MAX_DIMENSION ];
1411                         XdmfInt64 Count[ XDMF_MAX_DIMENSION ];
1412                         XdmfInt64 NewDimension[ XDMF_MAX_DIMENSION ];
1413 
1414                          /* printf("Array 0x%X  << 0x%X\n", Array1, Array2); */
1415 
1416                         Rank1 = Array1->GetShape( Dimension1 );
1417                         Rank2 = Array2->GetShape( Dimension2 );
1418                         if( Rank1 != Rank2 ){
1419                                 printf(" Cat : Rank Mismatch !!\n");
1420                                 }
1421                         NewDimension[0] = Dimension1[0] + Dimension2[0];
1422                         for( i = 1 ; i < Rank1 ; i++ ){
1423                                 NewDimension[i] = Dimension1[i];
1424                                 }
1425                         NewArray->CopyType( Array1 );
1426                         NewArray->SetShape( Rank1, NewDimension );
1427 
1428                         /*
1429                         NewArray->Generate( -55.0,  -55.0 );
1430                         */
1431                         /* Copy in Array 1 */
1432                         for( i = 0 ; i < Rank1 ; i++ ){
1433                                 Start[i] = 0;
1434                                 Stride[i] = 1;
1435                                 Count[i] = Dimension1[i];
1436                                 }
1437                         NewArray->SelectHyperSlab( Start, Stride, Count );
1438                         Array1->SelectAll();
1439                         /*
1440                         printf("Copy in Array1 = %s\n", NewArray->GetHyperSlabAsString() );
1441                         */
1442                         CopyArray( Array1, NewArray );
1443                         /* Copy in Array 2 */
1444                         Start[0] = Dimension1[0];
1445                         Stride[0] = 1;
1446                         Count[0] = Dimension2[0];
1447                         for( i = 1 ; i < Rank1 ; i++ ){
1448                                 Start[i] = 0;
1449                                 Stride[i] = 1;
1450                                 Count[i] = Dimension1[i];
1451                                 }
1452                         NewArray->SelectHyperSlab( Start, Stride, Count );
1453                         Array2->SelectAll();
1454                         /*
1455                         printf("Copy in Array2 = %s\n", NewArray->GetHyperSlabAsString() );
1456                         */
1457                         CopyArray( Array2, NewArray );
1458                         /*
1459                         printf("Result(%s) = %s\n", NewArray->GetShapeAsString(), NewArray->GetValues() );
1460                         */
1461                         yyval.ArrayPointer = NewArray;
1462                         delete Array1;
1463                         delete Array2;
1464                         }
1465     break;
1466 
1467   case 14:
1468 
1469     {
1470                         xdmf2::XdmfArray *Array1 = ( xdmf2::XdmfArray *)yyvsp[-2].ArrayPointer;
1471                         xdmf2::XdmfArray *Array2 = ( xdmf2::XdmfArray *)yyvsp[0].ArrayPointer;
1472 
1473                         /* printf("Array 0x%X + 0x%X\n", Array1, Array2); */
1474                         *Array1 -= *Array2;
1475                         yyval.ArrayPointer = Array1;
1476                         delete Array2;
1477                         }
1478     break;
1479 
1480   case 15:
1481 
1482     {
1483                         xdmf2::XdmfArray *Array1 = ( xdmf2::XdmfArray *)yyvsp[-2].ArrayPointer;
1484                         xdmf2::XdmfArray *Array2 = ( xdmf2::XdmfArray *)yyvsp[0].ArrayPointer;
1485 
1486                         /* printf("Array 0x%X * 0x%X\n", Array1, Array2); */
1487                         *Array1 *= *Array2;
1488                         yyval.ArrayPointer = Array1;
1489                         delete Array2;
1490                         /* printf("Array1 Nelms = %d\n", Array1->GetNumberOfElements()); */
1491                         }
1492     break;
1493 
1494   case 16:
1495 
1496     {
1497                         xdmf2::XdmfArray *Array1 = ( xdmf2::XdmfArray *)yyvsp[-2].ArrayPointer;
1498                         xdmf2::XdmfArray *Array2 = ( xdmf2::XdmfArray *)yyvsp[0].ArrayPointer;
1499 
1500                         /* printf("Array 0x%X + 0x%X\n", Array1, Array2); */
1501                         *Array1 /= *Array2;
1502                         yyval.ArrayPointer = Array1;
1503                         delete Array2;
1504                         }
1505     break;
1506 
1507   case 17:
1508 
1509     {
1510                         xdmf2::XdmfArray *Array1 = ( xdmf2::XdmfArray *)yyvsp[-2].ArrayPointer;
1511                         xdmf2::XdmfArray *Result;
1512 
1513                         /* printf("Array + %g\n", $3); */
1514                         Result  = Array1;
1515                         *Result += yyvsp[0].DoubleValue;
1516                         yyval.ArrayPointer = Result;
1517                         }
1518     break;
1519 
1520   case 18:
1521 
1522     {
1523                         xdmf2::XdmfArray *Array1 = ( xdmf2::XdmfArray *)yyvsp[-2].ArrayPointer;
1524                         xdmf2::XdmfArray *Result;
1525 
1526                         /* printf("Array - %g\n", $3); */
1527                         Result  = Array1;
1528                         *Result -= yyvsp[0].DoubleValue;
1529                         yyval.ArrayPointer = Result;
1530                         }
1531     break;
1532 
1533   case 19:
1534 
1535     {
1536                         xdmf2::XdmfArray *Array1 = ( xdmf2::XdmfArray *)yyvsp[-2].ArrayPointer;
1537                         xdmf2::XdmfArray *Result;
1538 
1539                         /* printf("Array * %g\n", $3); */
1540                         Result  = Array1;
1541                         *Result *= yyvsp[0].DoubleValue;
1542                         yyval.ArrayPointer = Result;
1543                         }
1544     break;
1545 
1546   case 20:
1547 
1548     {
1549                         xdmf2::XdmfArray *Array1 = ( xdmf2::XdmfArray *)yyvsp[-2].ArrayPointer;
1550                         xdmf2::XdmfArray *Result;
1551 
1552                         /* printf("Array / %g\n", $3); */
1553                         Result  = Array1;
1554                         *Result /= yyvsp[0].DoubleValue;
1555                         yyval.ArrayPointer = Result;
1556                         }
1557     break;
1558 
1559   case 21:
1560 
1561     {
1562                         xdmf2::XdmfArray *Array1 = ( xdmf2::XdmfArray *)yyvsp[0].ArrayPointer;
1563                         xdmf2::XdmfArray *Result;
1564 
1565                         /* printf("Array + %g\n", $1); */
1566                         Result  = Array1;
1567                         *Result += yyvsp[-2].DoubleValue;
1568                         yyval.ArrayPointer = Result;
1569                         }
1570     break;
1571 
1572   case 22:
1573 
1574     {
1575                         xdmf2::XdmfArray *Array1 = ( xdmf2::XdmfArray *)yyvsp[0].ArrayPointer;
1576                         xdmf2::XdmfArray *Result;
1577 
1578                         /* printf("Array - %g\n", $1); */
1579                         Result  = Array1;
1580                         *Result -= yyvsp[-2].DoubleValue;
1581                         yyval.ArrayPointer = Result;
1582                         }
1583     break;
1584 
1585   case 23:
1586 
1587     {
1588                         xdmf2::XdmfArray *Array1 = ( xdmf2::XdmfArray *)yyvsp[0].ArrayPointer;
1589                         xdmf2::XdmfArray *Result;
1590 
1591                         /* printf("Array * %g\n", $1); */
1592                         Result  = Array1;
1593                         *Result *= yyvsp[-2].DoubleValue;
1594                         yyval.ArrayPointer = Result;
1595                         }
1596     break;
1597 
1598   case 24:
1599 
1600     {
1601                         xdmf2::XdmfArray *Array1 = ( xdmf2::XdmfArray *)yyvsp[0].ArrayPointer;
1602                         xdmf2::XdmfArray *Result;
1603 
1604                         /* printf("Array / %g\n", $1); */
1605                         Result  = Array1;
1606                         *Result /= yyvsp[-2].DoubleValue;
1607                         yyval.ArrayPointer = Result;
1608                         }
1609     break;
1610 
1611   case 25:
1612 
1613     {
1614                         xdmf2::XdmfArray        *Array1 = ( xdmf2::XdmfArray *)yyvsp[-3].ArrayPointer;
1615                         xdmf2::XdmfArray        *Array2 = ( xdmf2::XdmfArray *)yyvsp[-1].ArrayPointer;
1616                         xdmf2::XdmfArray        *Result;
1617 
1618                         /* printf("ArrayExpression From Indexes\n"); */
1619                         Result = Array1->Clone( Array2 );
1620                         delete Array2;
1621                         yyval.ArrayPointer = Result;
1622                 }
1623     break;
1624 
1625   case 26:
1626 
1627     {
1628                         xdmf2::XdmfArray *Array1 = ( xdmf2::XdmfArray *)yyvsp[-5].ArrayPointer;
1629                         xdmf2::XdmfArray *Range, *Result;
1630 
1631                         /* printf("ArrayExpression From Array Range %d:%d\n", $3, $5);         */
1632                         Range = Array1->Reference( yyvsp[-3].IntegerValue, yyvsp[-1].IntegerValue ); /* This not a copy  */
1633 
1634                         Result  = Range->Clone(); /* So Copy It */
1635                         delete Array1;
1636                         yyval.ArrayPointer = Result;
1637                         }
1638     break;
1639 
1640   case 27:
1641 
1642     {
1643                         xdmf2::XdmfArray        *Array1 = ( xdmf2::XdmfArray *)yyvsp[-3].ArrayPointer;
1644                         xdmf2::XdmfArray        *Array2 = ( xdmf2::XdmfArray *)yyvsp[-1].ArrayPointer;
1645                         XdmfLength        i, howmany = 0, cntr = 0;
1646                         XdmfLength        Length1 = Array1->GetNumberOfElements(), Length2;
1647                         xdmf2::XdmfInt64Array        *Index = new xdmf2::XdmfInt64Array( Length1 );
1648                         XdmfInt64        A1Value, A2Value;
1649                         XdmfInt64        *A1Values, *A2Values;
1650                         float                Percent;
1651 
1652                         if(Array1->GetNumberType() != XDMF_INT64_TYPE){
1653                                 yyerror("INDEX operator only uses XdmfInt64 Arrays");
1654                                 return( 0 );
1655                                 }
1656                         if(Array2->GetNumberType() != XDMF_INT64_TYPE){
1657                                 yyerror("INDEX operator only uses XdmfInt64 Arrays");
1658                                 return( 0 );
1659                                 }
1660                         Length2 = Array2->GetNumberOfElements();
1661                         A1Values = (XdmfInt64 *)Array1->GetDataPointer();
1662                         A2Values = (XdmfInt64 *)Array2->GetDataPointer();
1663                         for( i = 0 ; i < Length1 ; i++ ){
1664                                 /* A1Value = Array1->GetValueAsFloat64( i ); */
1665                                 A1Value = *A1Values++;
1666                                 cntr = 0;
1667                                 A2Value = A1Value + 1;
1668                                 while((cntr < Length2) && (A2Value != A1Value)) {
1669                                         /* A2Value = Array2->GetValueAsFloat64(cntr); */
1670                                         A2Value = A2Values[cntr];
1671                                         cntr++;
1672                                         }
1673                                 howmany++;
1674                                 if(howmany > 5000){
1675                                         Percent = 100.0 * i / Length1;
1676                                         printf("%5.2f %% Done\n", Percent);
1677                                         howmany = 0;
1678                                         }
1679                                 if( A1Value == A2Value ) {
1680                                         Index->SetValue( i, cntr - 1 );
1681                                 }else{
1682                                         Index->SetValue( i, -1);
1683                                         }
1684                                 }
1685                         yyval.ArrayPointer = ( xdmf2::XdmfArray *)Index;
1686                         }
1687     break;
1688 
1689   case 28:
1690 
1691     {
1692                         xdmf2::XdmfArray        *Array1 = ( xdmf2::XdmfArray *)yyvsp[-3].ArrayPointer;
1693                         /* XdmfLength        howmany = 0; */
1694                         XdmfLength        i, cntr = 0;
1695                         XdmfLength        Length1 = Array1->GetNumberOfElements(), Length2;
1696                         xdmf2::XdmfInt64Array        *Index = new xdmf2::XdmfInt64Array( Length1 );
1697                         xdmf2::XdmfArray        *Array2 = ( xdmf2::XdmfArray *)yyvsp[-1].ArrayPointer;
1698                         XdmfFloat64        A1Value, A2Value;
1699 
1700                         Length2 = Array2->GetNumberOfElements();
1701                         for( i = 0 ; i < Length1 ; i++ ){
1702                                 A1Value = Array1->GetValueAsFloat64( i );
1703                                 cntr = 0;
1704                                 A2Value = A1Value + 1;
1705                                 while((cntr < Length2) && (A2Value != A1Value)) {
1706                                         A2Value = Array2->GetValueAsFloat64(cntr);
1707                                         cntr++;
1708                                         }
1709 /*
1710                                 howmany++;
1711                                 if(howmany > 1000){
1712                                         cout << "Checked " << i << " of " << Length1 << endl;
1713                                         howmany = 0;
1714                                         }
1715 */
1716                                 if( A1Value == A2Value ) {
1717                                         Index->SetValue( i, cntr - 1 );
1718                                 }else{
1719                                         Index->SetValue( i, -1);
1720                                         }
1721                                 }
1722                         yyval.ArrayPointer = ( xdmf2::XdmfArray *)Index;
1723                         }
1724     break;
1725 
1726   case 29:
1727 
1728     {
1729                         xdmf2::XdmfArray        *Array1 = ( xdmf2::XdmfArray *)yyvsp[-3].ArrayPointer;
1730                         XdmfLength        i, cntr = 0;
1731                         XdmfLength        Length = Array1->GetNumberOfElements();
1732                         xdmf2::XdmfInt64Array        *Index = new xdmf2::XdmfInt64Array( Length );
1733                         XdmfFloat64        Value, SValue = yyvsp[-1].DoubleValue;
1734 
1735                         for( i = 0 ; i < Length ; i++ ){
1736                                 Value = Array1->GetValueAsFloat64( i );
1737                                 if( Value == SValue ) {
1738                                         Index->SetValue( cntr++, i );
1739                                         }
1740                                 }
1741                         /* printf("Found %d Wheres\n", cntr ); */
1742                         if( cntr == 0 ){
1743                                 yyerror("WHERE Function Length == 0");
1744                                 return( 0 );
1745                                 }
1746                         Index->SetNumberOfElements( cntr );
1747                         yyval.ArrayPointer = ( xdmf2::XdmfArray *)Index;
1748                         }
1749     break;
1750 
1751   case 30:
1752 
1753     {
1754                         xdmf2::XdmfArray        *Array1 = ( xdmf2::XdmfArray *)yyvsp[-3].ArrayPointer;
1755                         XdmfLength        i, cntr = 0;
1756                         XdmfLength        Length = Array1->GetNumberOfElements();
1757                         xdmf2::XdmfInt64Array        *Index = new xdmf2::XdmfInt64Array( Length );
1758                         XdmfFloat64        Value, SValue = yyvsp[-1].DoubleValue;
1759 
1760                         for( i = 0 ; i < Length ; i++ ){
1761                                 Value = Array1->GetValueAsFloat64( i );
1762                                 if( Value < SValue ) {
1763                                         Index->SetValue( cntr++, i );
1764                                         }
1765                                 }
1766                         /* printf("Found %d Wheres\n", cntr ); */
1767                         if( cntr == 0 ){
1768                                 yyerror("WHERE Function Length == 0");
1769                                 return( 0 );
1770                                 }
1771                         Index->SetNumberOfElements( cntr );
1772                         yyval.ArrayPointer = ( xdmf2::XdmfArray *)Index;
1773                         }
1774     break;
1775 
1776   case 31:
1777 
1778     {
1779                         xdmf2::XdmfArray        *Array1 = ( xdmf2::XdmfArray *)yyvsp[-3].ArrayPointer;
1780                         XdmfLength        i, cntr = 0;
1781                         XdmfLength        Length = Array1->GetNumberOfElements();
1782                         xdmf2::XdmfInt64Array        *Index = new xdmf2::XdmfInt64Array( Length );
1783                         XdmfFloat64        Value, SValue = yyvsp[-1].DoubleValue;
1784 
1785                         for( i = 0 ; i < Length ; i++ ){
1786                                 Value = Array1->GetValueAsFloat64( i );
1787                                 if( Value <= SValue ) {
1788                                         Index->SetValue( cntr++, i );
1789                                         }
1790                                 }
1791                         /* printf("Found %d Wheres\n", cntr ); */
1792                         if( cntr == 0 ){
1793                                 yyerror("WHERE Function Length == 0");
1794                                 return( 0 );
1795                                 }
1796                         Index->SetNumberOfElements( cntr );
1797                         yyval.ArrayPointer = ( xdmf2::XdmfArray *)Index;
1798                         }
1799     break;
1800 
1801   case 32:
1802 
1803     {
1804                         xdmf2::XdmfArray        *Array1 = ( xdmf2::XdmfArray *)yyvsp[-3].ArrayPointer;
1805                         XdmfLength        i, cntr = 0;
1806                         XdmfLength        Length = Array1->GetNumberOfElements();
1807                         xdmf2::XdmfInt64Array        *Index = new xdmf2::XdmfInt64Array( Length );
1808                         XdmfFloat64        Value, SValue = yyvsp[-1].DoubleValue;
1809 
1810                         for( i = 0 ; i < Length ; i++ ){
1811                                 Value = Array1->GetValueAsFloat64( i );
1812                                 if( Value > SValue ) {
1813                                         Index->SetValue( cntr++, i );
1814                                         }
1815                                 }
1816                         /* printf("Found %d Wheres\n", cntr ); */
1817                         if( cntr == 0 ){
1818                                 yyerror("WHERE Function Length == 0");
1819                                 return( 0 );
1820                                 }
1821                         Index->SetNumberOfElements( cntr );
1822                         yyval.ArrayPointer = ( xdmf2::XdmfArray *)Index;
1823                         }
1824     break;
1825 
1826   case 33:
1827 
1828     {
1829                         xdmf2::XdmfArray        *Array1 = ( xdmf2::XdmfArray *)yyvsp[-3].ArrayPointer;
1830                         XdmfLength        i, cntr = 0;
1831                         XdmfLength        Length = Array1->GetNumberOfElements();
1832                         xdmf2::XdmfInt64Array        *Index = new xdmf2::XdmfInt64Array( Length );
1833                         XdmfFloat64        Value, SValue = yyvsp[-1].DoubleValue;
1834 
1835                         for( i = 0 ; i < Length ; i++ ){
1836                                 Value = Array1->GetValueAsFloat64( i );
1837                                 if( Value >= SValue ) {
1838                                         Index->SetValue( cntr++, i );
1839                                         }
1840                                 }
1841                         /* printf("Found %d Wheres\n", cntr ); */
1842                         if( cntr == 0 ){
1843                                 yyerror("WHERE Function Length == 0");
1844                                 return( 0 );
1845                                 }
1846                         Index->SetNumberOfElements( cntr );
1847                         yyval.ArrayPointer = ( xdmf2::XdmfArray *)Index;
1848                         }
1849     break;
1850 
1851   case 34:
1852 
1853     {
1854                         xdmf2::XdmfArray        *Array1 = ( xdmf2::XdmfArray *)yyvsp[-3].ArrayPointer;
1855                         XdmfLength        i, cntr = 0;
1856                         XdmfLength        Length = Array1->GetNumberOfElements();
1857                         xdmf2::XdmfInt64Array        *Index = new xdmf2::XdmfInt64Array( Length );
1858                         XdmfFloat64        Value, SValue = yyvsp[-1].DoubleValue;
1859 
1860                         for( i = 0 ; i < Length ; i++ ){
1861                                 Value = Array1->GetValueAsFloat64( i );
1862                                 if( Value != SValue ) {
1863                                         Index->SetValue( cntr++, i );
1864                                         }
1865                                 }
1866                         /* printf("Found %d Wheres\n", cntr ); */
1867                         if( cntr == 0 ){
1868                                 yyerror("WHERE Function Length == 0");
1869                                 return( 0 );
1870                                 }
1871                         Index->SetNumberOfElements( cntr );
1872                         yyval.ArrayPointer = ( xdmf2::XdmfArray *)Index;
1873                         }
1874     break;
1875 
1876   case 35:
1877 
1878     {
1879 
1880                         if( yyvsp[-3].Symbol->DoubleFunctionPtr == NULL ){
1881                                 /* printf("Bad Function Ptr for %s\n", $1->Name ); */
1882                                 yyval.ArrayPointer = yyvsp[-1].ArrayPointer;
1883                         } else {
1884                                 xdmf2::XdmfArray *Array1 = ( xdmf2::XdmfArray *)yyvsp[-1].ArrayPointer;
1885                                 XdmfFloat64        Value;
1886                                 XdmfLength        i, Length = Array1->GetNumberOfElements();
1887 
1888                                 /* printf("Function Call %s\n", $1->Name ); */
1889                                 for( i = 0 ; i < Length ; i++ ){
1890                                         Value = Array1->GetValueAsFloat64( i );
1891                                         Array1->SetValueFromFloat64( i, (yyvsp[-3].Symbol->DoubleFunctionPtr)( Value ) );
1892                                         }
1893                                 yyval.ArrayPointer = Array1;
1894                         }
1895                         }
1896     break;
1897 
1898   case 36:
1899 
1900     {
1901                         /* printf("( ArrayExpression )\n"); */
1902                         yyval.ArrayPointer = yyvsp[-1].ArrayPointer;
1903                         }
1904     break;
1905 
1906   case 37:
1907 
1908     {
1909                         /* printf("( ArrayExpression )\n"); */
1910                         yyval.ArrayPointer = yyvsp[-1].ArrayPointer;
1911                         }
1912     break;
1913 
1914   case 38:
1915 
1916     {
1917                         xdmf2::XdmfArray *Array1 = ( xdmf2::XdmfArray *)yyvsp[0].ArrayPointer;
1918                         xdmf2::XdmfArray *Result;
1919 
1920                         /* printf("ArrayExpression From Array\n"); */
1921 
1922                         if ( Array1 == NULL ){
1923                                 /* Bomb */
1924                                 yyerror("NULL Array Pointer");
1925                                 return( 0 );
1926                         } else {
1927                                 Result  = Array1->Clone();
1928                                 yyval.ArrayPointer = Result;
1929                                 }
1930                         }
1931     break;
1932 
1933   case 39:
1934 
1935     {
1936                         /* printf("Scalar +\n"); */
1937                         yyval.DoubleValue = yyvsp[-2].DoubleValue + yyvsp[0].DoubleValue;
1938                         }
1939     break;
1940 
1941   case 40:
1942 
1943     {
1944                         /* printf("Scalar -\n"); */
1945                         yyval.DoubleValue = yyvsp[-2].DoubleValue - yyvsp[0].DoubleValue;
1946                         }
1947     break;
1948 
1949   case 41:
1950 
1951     {
1952                         /* printf("Scalar *\n"); */
1953                         yyval.DoubleValue = yyvsp[-2].DoubleValue * yyvsp[0].DoubleValue;
1954                         }
1955     break;
1956 
1957   case 42:
1958 
1959     {
1960                         /* printf("Scalar /\n"); */
1961                         yyval.DoubleValue = yyvsp[-2].DoubleValue / yyvsp[0].DoubleValue;
1962                         }
1963     break;
1964 
1965   case 43:
1966 
1967     {
1968                         if( yyvsp[-3].Symbol->DoubleFunctionPtr == NULL ){
1969                                 /* printf("Bad Function Ptr for %s\n", $1->Name ); */
1970                                 yyval.DoubleValue = 0.0;
1971                         } else {
1972                                 yyval.DoubleValue = (yyvsp[-3].Symbol->DoubleFunctionPtr)( yyvsp[-1].DoubleValue );
1973                         }
1974                         }
1975     break;
1976 
1977   case 44:
1978 
1979     {
1980                         /* printf ("( ScalarExpression )\n"); */
1981                         yyval.DoubleValue = yyvsp[-1].DoubleValue;
1982                         }
1983     break;
1984 
1985   case 45:
1986 
1987     {
1988                         /* printf ("ScalarExpression from tokINTEGER\n"); */
1989                         yyval.DoubleValue = yyvsp[0].IntegerValue;
1990                         }
1991     break;
1992 
1993   case 46:
1994 
1995     {
1996                         /* printf ("ScalarExpression from FLOAT\n"); */
1997                         yyval.DoubleValue = yyvsp[0].DoubleValue;
1998                         }
1999     break;
2000 
2001 
2002     }
2003 
2004 /* Line 999 of yacc.c.  */
2005 
2006 
2007   yyvsp -= yylen;
2008   yyssp -= yylen;
2009 
2010 
2011   YY_STACK_PRINT (yyss, yyssp);
2012 
2013   *++yyvsp = yyval;
2014 
2015 
2016   /* Now `shift' the result of the reduction.  Determine what state
2017      that goes to, based on the state we popped back to and the rule
2018      number reduced by.  */
2019 
2020   yyn = yyr1[yyn];
2021 
2022   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2023   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2024     yystate = yytable[yystate];
2025   else
2026     yystate = yydefgoto[yyn - YYNTOKENS];
2027 
2028   goto yynewstate;
2029 
2030 
2031 /*------------------------------------.
2032 | yyerrlab -- here on detecting error |
2033 `------------------------------------*/
2034 yyerrlab:
2035   /* If not already recovering from an error, report this error.  */
2036   if (!yyerrstatus)
2037     {
2038       ++yynerrs;
2039 #if YYERROR_VERBOSE
2040       yyn = yypact[yystate];
2041 
2042       if (YYPACT_NINF < yyn && yyn < YYLAST)
2043         {
2044           YYSIZE_T yysize = 0;
2045           int yytype = YYTRANSLATE (yychar);
2046           char *yymsg;
2047           int yyx, yycount;
2048 
2049           yycount = 0;
2050           /* Start YYX at -YYN if negative to avoid negative indexes in
2051              YYCHECK.  */
2052           for (yyx = yyn < 0 ? -yyn : 0;
2053                yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
2054             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
2055               yysize += yystrlen (yytname[yyx]) + 15, yycount++;
2056           yysize += yystrlen ("syntax error, unexpected ") + 1;
2057           yysize += yystrlen (yytname[yytype]);
2058           yymsg = (char *) YYSTACK_ALLOC (yysize);
2059           if (yymsg != 0)
2060             {
2061               char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
2062               yyp = yystpcpy (yyp, yytname[yytype]);
2063 
2064               if (yycount < 5)
2065                 {
2066                   yycount = 0;
2067                   for (yyx = yyn < 0 ? -yyn : 0;
2068                        yyx < (int) (sizeof (yytname) / sizeof (char *));
2069                        yyx++)
2070                     if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
2071                       {
2072                         const char *yyq = ! yycount ? ", expecting " : " or ";
2073                         yyp = yystpcpy (yyp, yyq);
2074                         yyp = yystpcpy (yyp, yytname[yyx]);
2075                         yycount++;
2076                       }
2077                 }
2078               yyerror (yymsg);
2079               YYSTACK_FREE (yymsg);
2080             }
2081           else
2082             yyerror ("syntax error; also virtual memory exhausted");
2083         }
2084       else
2085 #endif /* YYERROR_VERBOSE */
2086         yyerror ("syntax error");
2087     }
2088 
2089 
2090 
2091   if (yyerrstatus == 3)
2092     {
2093       /* If just tried and failed to reuse lookahead token after an
2094          error, discard it.  */
2095 
2096       /* Return failure if at end of input.  */
2097       if (yychar == YYEOF)
2098         {
2099           /* Pop the error token.  */
2100           YYPOPSTACK;
2101           /* Pop the rest of the stack.  */
2102           while (yyss < yyssp)
2103             {
2104               YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
2105               yydestruct (yystos[*yyssp], yyvsp);
2106               YYPOPSTACK;
2107             }
2108           YYABORT;
2109         }
2110 
2111       YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
2112       yydestruct (yytoken, &yylval);
2113       yychar = YYEMPTY;
2114 
2115     }
2116 
2117   /* Else will try to reuse lookahead token after shifting the error
2118      token.  */
2119   goto yyerrlab1;
2120 
2121 
2122 /*----------------------------------------------------.
2123 | yyerrlab1 -- error raised explicitly by an action.  |
2124 `----------------------------------------------------*/
2125 yyerrlab1:
2126   yyerrstatus = 3;        /* Each real token shifted decrements this.  */
2127 
2128   for (;;)
2129     {
2130       yyn = yypact[yystate];
2131       if (yyn != YYPACT_NINF)
2132         {
2133           yyn += YYTERROR;
2134           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2135             {
2136               yyn = yytable[yyn];
2137               if (0 < yyn)
2138                 break;
2139             }
2140         }
2141 
2142       /* Pop the current state because it cannot handle the error token.  */
2143       if (yyssp == yyss)
2144         YYABORT;
2145 
2146       YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
2147       yydestruct (yystos[yystate], yyvsp);
2148       yyvsp--;
2149       yystate = *--yyssp;
2150 
2151       YY_STACK_PRINT (yyss, yyssp);
2152     }
2153 
2154   if (yyn == YYFINAL)
2155     YYACCEPT;
2156 
2157   YYDPRINTF ((stderr, "Shifting error token, "));
2158 
2159   *++yyvsp = yylval;
2160 
2161 
2162   yystate = yyn;
2163   goto yynewstate;
2164 
2165 
2166 /*-------------------------------------.
2167 | yyacceptlab -- YYACCEPT comes here.  |
2168 `-------------------------------------*/
2169 yyacceptlab:
2170   yyresult = 0;
2171   goto yyreturn;
2172 
2173 /*-----------------------------------.
2174 | yyabortlab -- YYABORT comes here.  |
2175 `-----------------------------------*/
2176 yyabortlab:
2177   yyresult = 1;
2178   goto yyreturn;
2179 
2180 #ifndef yyoverflow
2181 /*----------------------------------------------.
2182 | yyoverflowlab -- parser overflow comes here.  |
2183 `----------------------------------------------*/
2184 yyoverflowlab:
2185   yyerror ("parser stack overflow");
2186   yyresult = 2;
2187   /* Fall through.  */
2188 #endif
2189 
2190 yyreturn:
2191 #ifndef yyoverflow
2192   if (yyss != yyssa)
2193     YYSTACK_FREE (yyss);
2194 #endif
2195   return yyresult;
2196 }
2197 
2198 
2199 
2200 
2201 
2202 /* extern        FILE        *yyin, *yyout; */
2203 
2204 #ifdef __cplusplus
2205 /**/
2206 extern "C" {
2207 /**/
2208 #endif
2209 
2210 char        InputBuffer[ 512 ];
2211 int         InputBufferPtr = 0, InputBufferEnd = 0;
2212 char        OutputBuffer[ 512 ];
2213 int         OutputBufferPtr = 0;
2214 /* static int OutputBufferEnd = 511; */
2215 
2216 int
dice_yywrap(void)2217 dice_yywrap( void ) {
2218 
2219 return 1;
2220 }
2221 
2222 void
dice_yyerror(const char * string)2223 dice_yyerror( const char *string ) {
2224 fprintf(stderr, "XdmfExpr : %s \n", string);
2225 }
2226 
2227 int
XdmfExprFlexInput(char * buf,int maxlen)2228 XdmfExprFlexInput( char *buf, int maxlen ) {
2229 (void)maxlen;
2230 if ( InputBufferPtr < InputBufferEnd ){
2231         buf[0] = InputBuffer[ InputBufferPtr++ ];
2232         return(1);
2233 } else {
2234         buf[0] = '\n';
2235         return( 0 );
2236         }
2237 }
2238 
2239 int
XdmfExprInput(void)2240 XdmfExprInput( void ){
2241 
2242 if ( InputBufferPtr < InputBufferEnd ){
2243         return( InputBuffer[ InputBufferPtr++ ] );
2244 } else {
2245         return '\n';
2246         }
2247 }
2248 
2249 void
XdmfExprUnput(int c)2250 XdmfExprUnput( int c ) {
2251 if( InputBufferPtr > 0 ){
2252         InputBufferPtr--;
2253         InputBuffer[ InputBufferPtr ] = c;
2254         }
2255 }
2256 
2257 void
XdmfExprOutput(int c)2258 XdmfExprOutput( int c ) {
2259         /* printf("XdmfExprOutput Called\n"); */
2260         OutputBuffer[ OutputBufferPtr++ ] = c;
2261         OutputBuffer[ OutputBufferPtr ] = '\0';
2262         }
2263 
2264 XdmfExprSymbol
XdmfExprSymbolLookup(const char * Name)2265 *XdmfExprSymbolLookup( const char *Name ){
2266 
2267 XdmfExprSymbol        *Last = NULL, *Item = XdmfExprItemsTable;
2268 
2269 if( Name == NULL ) {
2270         /* Table Check  */
2271         return( XdmfExprItemsTable );
2272         }
2273 
2274 while( Item != NULL ) {
2275         if( strcmp( Item->Name, Name ) == 0 ) {
2276                 /* printf("Found Symbol %s\n", Name ); */
2277                 return( Item );
2278                 }
2279         Last = Item;
2280         Item = Item->Next;
2281 }
2282 /* Not Found : Create New One */
2283 Item = ( XdmfExprSymbol *)calloc( 1, sizeof( XdmfExprSymbol ));
2284 Item->Next = NULL;
2285 Item->Name = strdup( Name );
2286 Item->ClientData = NULL;
2287 Item->DoubleValue = 0;
2288 Item->DoubleFunctionPtr = NULL;
2289 if( XdmfExprItemsTable == NULL ) {
2290         XdmfExprItemsTable = Item;
2291         }
2292 if( Last != NULL ){
2293         Last->Next = Item;
2294         }
2295 /* printf("New Symbol for %s\n", Name ); */
2296 return( Item );
2297 }
2298 
2299 #ifdef __cplusplus
2300 /**/
2301 }
2302 /**/
2303 #endif
2304 
2305 xdmf2::XdmfArray *
XdmfExprParse(char * string)2306 XdmfExprParse( char *string ){
2307 
2308 XdmfExprSymbol        *Item;
2309 XdmfLength        CurrentTime;
2310 XdmfLength        TimeOfCreation;
2311 xdmf2::XdmfArray        *ap;
2312 
2313 /* Build the Symbol Table if Necessary */
2314 Item = XdmfExprSymbolLookup( NULL );
2315 if( Item == NULL ){
2316         /* printf("Creating Symbol Table\n"); */
2317         Item = XdmfExprSymbolLookup( "cos" );
2318         Item->DoubleFunctionPtr = cos;
2319         Item = XdmfExprSymbolLookup( "sin" );
2320         Item->DoubleFunctionPtr = sin;
2321         Item = XdmfExprSymbolLookup( "exp" );
2322         Item->DoubleFunctionPtr = exp;
2323         Item = XdmfExprSymbolLookup( "tan" );
2324         Item->DoubleFunctionPtr = tan;
2325         Item = XdmfExprSymbolLookup( "acos" );
2326         Item->DoubleFunctionPtr = acos;
2327         Item = XdmfExprSymbolLookup( "asin" );
2328         Item->DoubleFunctionPtr = asin;
2329         Item = XdmfExprSymbolLookup( "atan" );
2330         Item->DoubleFunctionPtr = atan;
2331         Item = XdmfExprSymbolLookup( "log" );
2332         Item->DoubleFunctionPtr = log;
2333         Item = XdmfExprSymbolLookup( "sqrt" );
2334         Item->DoubleFunctionPtr = sqrt;
2335         }
2336 /* Print Symbol Table */
2337 Item = XdmfExprSymbolLookup( NULL );
2338 while( Item != NULL ) {
2339         if( Item->ClientData != NULL ){
2340                 /* printf("Found Symbol %s\n", Item->Name ); */
2341                 }
2342         Item = Item->Next;
2343         }
2344 strcpy( InputBuffer, string );
2345 InputBufferEnd = strlen( InputBuffer );
2346 InputBufferPtr = OutputBufferPtr = 0;
2347 XdmfExprReturnValue = NULL;
2348 /* printf("XdmfExprParse Scanning <%s>\n", InputBuffer); */
2349  CurrentTime = xdmf2::GetCurrentArrayTime();
2350 if ( yyparse() != 0 ){
2351         /* Error */
2352         XdmfExprReturnValue = NULL;
2353         }
2354 Item = XdmfExprSymbolLookup( NULL );
2355 while( Item != NULL ) {
2356   XdmfExprSymbol *next = Item->Next;
2357   if ( Item->Name )
2358     {
2359     free(Item->Name);
2360     }
2361   free(Item);
2362         Item = next;
2363         }
2364 
2365 XdmfExprItemsTable = NULL;
2366 
2367 /* Remove All Arrays Older than when we started */
2368 /* printf("Cleaning up Temparary Arrays\n"); */
2369  while( ( ap = xdmf2::GetNextOlderArray( CurrentTime, &TimeOfCreation ) ) != NULL ){
2370         /* Don't remove the return value */
2371         if( ap != XdmfExprReturnValue ){
2372                 /* printf("Removing Temporary Array\n"); */
2373                 delete ap;
2374                 }
2375         CurrentTime = TimeOfCreation;
2376         }
2377 return( XdmfExprReturnValue );
2378 }
2379 
2380 
2381