- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# /home/coin/SVN-release/OS-2.3.5/OS/src/OSParsers/OSParseosil.tab.cpp

Go to the documentation of this file.

    00001
    00002 /* A Bison parser, made by GNU Bison 2.4.1.  */
    00003
    00004 /* Skeleton implementation for Bison's Yacc-like parsers in C
    00005
    00006       Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
    00007    Free Software Foundation, Inc.
    00008
    00009    This program is free software: you can redistribute it and/or modify
    00010    it under the terms of the GNU General Public License as published by
    00011    the Free Software Foundation, either version 3 of the License, or
    00012    (at your option) any later version.
    00013
    00014    This program is distributed in the hope that it will be useful,
    00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00017    GNU General Public License for more details.
    00018
    00019    You should have received a copy of the GNU General Public License
    00020    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
    00021
    00022 /* As a special exception, you may create a larger work that contains
    00023    part or all of the Bison parser skeleton and distribute that work
    00024    under terms of your choice, so long as that work isn't itself a
    00025    parser generator using the skeleton or a modified version thereof
    00026    as a parser skeleton.  Alternatively, if you modify or redistribute
    00027    the parser skeleton itself, you may (at your option) remove this
    00028    special exception, which will cause the skeleton and the resulting
    00029    Bison output files to be licensed under the GNU General Public
    00030    License without this special exception.
    00031
    00032    This special exception was added by the Free Software Foundation in
    00033    version 2.2 of Bison.  */
    00034
    00035 /* C LALR(1) parser skeleton written by Richard Stallman, by
    00036    simplifying the original so-called "semantic" parser.  */
    00037
    00038 /* All symbols defined below should begin with yy or YY, to avoid
    00039    infringing on user name space.  This should be done even for local
    00040    variables, as they might otherwise be expanded by user macros.
    00041    There are some unavoidable exceptions within include files to
    00042    define necessary library symbols; they are noted "INFRINGES ON
    00043    USER NAME SPACE" below.  */
    00044
    00045 /* Identify Bison output.  */
    00046 #define YYBISON 1
    00047
    00048 /* Bison version.  */
    00049 #define YYBISON_VERSION "2.4.1"
    00050
    00051 /* Skeleton name.  */
    00052 #define YYSKELETON_NAME "yacc.c"
    00053
    00054 /* Pure parsers.  */
    00055 #define YYPURE 1
    00056
    00057 /* Push parsers.  */
    00058 #define YYPUSH 0
    00059
    00060 /* Pull parsers.  */
    00061 #define YYPULL 1
    00062
    00063 /* Using locations.  */
    00064 #define YYLSP_NEEDED 1
    00065
    00066 /* Substitute the variable and function names.  */
    00067 #define yyparse         osilparse
    00068 #define yylex           osillex
    00069 #define yyerror         osilerror
    00070 #define yylval          osillval
    00071 #define yychar          osilchar
    00072 #define yydebug         osildebug
    00073 #define yynerrs         osilnerrs
    00074 #define yylloc          osillloc
    00075
    00076 /* Copy the first part of user declarations.  */
    00077
    00078
    00079
    00080 #include <string>
    00081 #include <iostream>
    00082 #include <sstream>
    00083
    00084 #include "OSInstance.h"
    00085 #include "OSnLNode.h"
    00086 #include "OSErrorClass.h"
    00087 #include "OSParameters.h"
    00088 #include "OSiLParserData.h"
    00089 #include "OSBase64.h"
    00090 #include "OSMathUtil.h"
    00091 #include "OSConfig.h"
    00092
    00093 //#define CHECK_PARSE_TIME
    00094
    00095
    00096 #ifdef HAVE_CTIME
    00097 # include <ctime>
    00098 #else
    00099 # ifdef HAVE_TIME_H
    00100 #  include <time.h>
    00101 # else
    00102 #  error "don't have header file for time"
    00103 # endif
    00104 #endif
    00105
    00106 #ifdef HAVE_CSTRING
    00107 # include <cstring>
    00108 #else
    00109 # ifdef HAVE_STRING_H
    00110 #  include <string.h>
    00111 # else
    00112 #  error "don't have header file for string"
    00113 # endif
    00114 #endif
    00115
    00116 #ifdef HAVE_CSTDIO
    00117 # include <cstdio>
    00118 #else
    00119 # ifdef HAVE_STDIO_H
    00120 #  include <stdio.h>
    00121 # else
    00122 #  error "don't have header file for stdio"
    00123 # endif
    00124 #endif
    00125
    00126 using std::cout;
    00127 using std::endl;
    00128 using std::ostringstream;
    00129
    00130
    00131 typedef struct yy_buffer_state *YY_BUFFER_STATE;
    00132 YY_BUFFER_STATE osil_scan_string (const char *yy_str , void* yyscanner  );
    00133 int osillex_init(void** ptr_yy_globals);
    00134 int osillex_destroy (void* yyscanner );
    00135 void osilset_extra (OSiLParserData* parserData , void* yyscanner );
    00136 int osilget_lineno( void* yyscanner);
    00137 char *osilget_text (void* yyscanner );
    00138 void osilset_lineno (int line_number , void* yyscanner );
    00139 void yygetOSInstance(const char *osil, OSInstance* osinstance, OSiLParserData *parserData) throw(ErrorClass);
    00140 //
    00141
    00142 double atofmod1(int* osillineno, const char *ch1, const char *ch2 );
    00143 int atoimod1(int* osillineno, const char *ch1, const char *ch2);
    00144 // we distinguish a newline from other whitespace
    00145 // since we need to know when we hit a new line
    00146 void osilerror_wrapper( const char* ch, int* osillineno, const char* errormsg);
    00147 bool isnewline(char c, int* osillineno);
    00148 bool parseVariables(const char **pchar, OSInstance *osinstance ,int* osillineno);
    00149 bool parseObjectives(const char **pchar, OSInstance *osinstance ,int* osillineno);
    00150 bool parseObjCoef(const char **pchar, int objcount, OSInstance *osinstance ,int* osillineno);
    00151 bool parseConstraints(const char **pchar, OSInstance *osinstance ,int* osillineno);
    00152 bool parseLinearConstraintCoefficients(const char **pchar, OSInstance *osinstance ,int* osillineno);
    00153 bool parseStart(const char **pchar, OSInstance *osinstance ,int* osillineno);
    00154 bool parseRowIdx(const char **pchar, OSInstance *osinstance ,int* osillineno);
    00155 bool parseColIdx(const char **pchar, OSInstance *osinstance ,int* osillineno);
    00156 bool parseValue(const char **pchar, OSInstance *osinstance ,int* osillineno);
    00157 bool parseInstanceHeader(const char **pchar, OSInstance *osinstance ,int* osillineno);
    00158 bool parseInstanceData( const char **pchar, OSInstance *osinstance, int* osillineno);
    00159 char *parseBase64( const char **p, int *dataSize ,int* osillineno);
    00160
    00161 #define ISWHITESPACE( char_) ((char_) == ' ' || \
    00162                      (char_) == '\t' ||  (char_) == '\r')
    00163
    00164 #define ISDIGIT(_c) ((_c) >= '0' && (_c) <= '9')
    00165
    00166 #define GETATTRIBUTETEXT        \
    00167         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ; \
    00168         if( *ch != '=') {  osilerror_wrapper( ch, osillineno, "found an attribute not defined"); return false;}  \
    00169         ch++; \
    00170         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;       \
    00171         if(*ch == '\"'){ \
    00172                 ch++; \
    00173             for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ; \
    00174             *p = ch; \
    00175             for( ; *ch != '\"'; ch++); \
    00176         }\
    00177         else{\
    00178             if(*ch == '\'') { \
    00179                 ch++; \
    00180                 for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ; \
    00181                 *p = ch; \
    00182                 for( ; *ch != '\''; ch++); \
    00183             } \
    00184             else {  osilerror_wrapper( ch, osillineno,"missing quote on attribute"); return false;} \
    00185         }\
    00186         numChar = ch - *p; \
    00187         attText = new char[numChar + 1]; \
    00188         for(ki = 0; ki < numChar; ki++) attText[ki] = *((*p)++); \
    00189         attText[ki] = '\0'; \
    00190         attTextEnd = &attText[ki];
    00191
    00192 #define GAIL printf("GAIL ANN HONDA\n")
    00193
    00194
    00195
    00196 #define ECHOCHECK \
    00197         GAIL; \
    00198         printf("%c", ch[-2]); \
    00199         printf("%c", ch[-1]); \
    00200         printf("%c", ch[0]); \
    00201         printf("%c", ch[1]); \
    00202         printf("%c", ch[2]); \
    00203         printf("%c", ch[3]); \
    00204         printf("%c", ch[4]); \
    00205         printf("%c", ch[5]); \
    00206         printf("%c \n", ch[6]); \
    00207         GAIL;
    00208
    00209
    00210
    00211 /* Enabling traces.  */
    00212 #ifndef YYDEBUG
    00213 # define YYDEBUG 0
    00214 #endif
    00215
    00216 /* Enabling verbose error messages.  */
    00217 #ifdef YYERROR_VERBOSE
    00218 # undef YYERROR_VERBOSE
    00219 # define YYERROR_VERBOSE 1
    00220 #else
    00221 # define YYERROR_VERBOSE 1
    00222 #endif
    00223
    00224 /* Enabling the token table.  */
    00225 #ifndef YYTOKEN_TABLE
    00226 # define YYTOKEN_TABLE 0
    00227 #endif
    00228
    00229
    00230 /* Tokens.  */
    00231 #ifndef YYTOKENTYPE
    00232 # define YYTOKENTYPE
    00233    /* Put the tokens into the symbol table, so that GDB and other debuggers
    00234       know about them.  */
    00235    enum yytokentype {
    00236      QUOTE = 258,
    00237      ATTRIBUTETEXT = 259,
    00238      INTEGER = 260,
    00239      DOUBLE = 261,
    00240      OSILEND = 262,
    00241      INSTANCEDATAEND = 263,
    00242      INSTANCEDATASTARTEND = 264,
    00243      VALUEATT = 265,
    00244      NUMBEROFNONLINEAREXPRESSIONS = 266,
    00245      IDXONEATT = 267,
    00246      IDXTWOATT = 268,
    00247      COEFATT = 269,
    00248      IDATT = 270,
    00249      TIMESSTART = 271,
    00250      TIMESEND = 272,
    00251      NUMBERSTART = 273,
    00252      NUMBEREND = 274,
    00253      NUMBEROFQTERMSATT = 275,
    00254      IDXATT = 276,
    00255      TYPEATT = 277,
    00256      QTERMSTART = 278,
    00257      QTERMEND = 279,
    00258      QUADRATICCOEFFICIENTSSTART = 280,
    00259      QUADRATICCOEFFICIENTSEND = 281,
    00260      NONLINEAREXPRESSIONSSTART = 282,
    00261      NONLINEAREXPRESSIONSEND = 283,
    00262      NLSTART = 284,
    00263      NLEND = 285,
    00264      POWERSTART = 286,
    00265      POWEREND = 287,
    00266      PLUSSTART = 288,
    00267      PLUSEND = 289,
    00268      MINUSSTART = 290,
    00269      MINUSEND = 291,
    00270      DIVIDESTART = 292,
    00271      DIVIDEEND = 293,
    00272      LNSTART = 294,
    00273      LNEND = 295,
    00274      SQRTSTART = 296,
    00275      SQRTEND = 297,
    00276      SUMSTART = 298,
    00277      SUMEND = 299,
    00278      PRODUCTSTART = 300,
    00279      PRODUCTEND = 301,
    00280      ENDOFELEMENT = 302,
    00281      EXPSTART = 303,
    00282      EXPEND = 304,
    00283      NEGATESTART = 305,
    00284      NEGATEEND = 306,
    00285      IFSTART = 307,
    00286      IFEND = 308,
    00287      SQUARESTART = 309,
    00288      SQUAREEND = 310,
    00289      COSSTART = 311,
    00290      COSEND = 312,
    00291      SINSTART = 313,
    00292      SINEND = 314,
    00293      GREATERTHAN = 315,
    00294      VARIABLESTART = 316,
    00295      VARIABLEEND = 317,
    00296      ABSSTART = 318,
    00297      ABSEND = 319,
    00298      ERFSTART = 320,
    00299      ERFEND = 321,
    00300      MAXSTART = 322,
    00301      MAXEND = 323,
    00302      ALLDIFFSTART = 324,
    00303      ALLDIFFEND = 325,
    00304      MINSTART = 326,
    00305      MINEND = 327,
    00306      ESTART = 328,
    00307      EEND = 329,
    00308      PISTART = 330,
    00309      PIEND = 331,
    00310      TIMEDOMAINSTART = 332,
    00311      TIMEDOMAINEND = 333,
    00312      STAGESSTART = 334,
    00313      STAGESEND = 335,
    00314      STAGESTART = 336,
    00315      STAGEEND = 337,
    00316      NAMEATT = 338,
    00317      NUMBEROFSTAGESATT = 339,
    00318      HORIZONATT = 340,
    00319      STARTATT = 341,
    00320      VARIABLESSTART = 342,
    00321      CONSTRAINTSSTART = 343,
    00322      OBJECTIVESSTART = 344,
    00323      VARIABLESEND = 345,
    00324      CONSTRAINTSEND = 346,
    00325      OBJECTIVESEND = 347,
    00326      NUMBEROFVARIABLESATT = 348,
    00327      NUMBEROFCONSTRAINTSATT = 349,
    00328      NUMBEROFOBJECTIVESATT = 350,
    00329      STARTIDXATT = 351,
    00330      VARSTART = 352,
    00331      VAREND = 353,
    00332      CONSTART = 354,
    00333      CONEND = 355,
    00334      OBJSTART = 356,
    00335      OBJEND = 357,
    00336      INTERVALSTART = 358,
    00337      INTERVALEND = 359
    00338    };
    00339 #endif
    00340 /* Tokens.  */
    00341 #define QUOTE 258
    00342 #define ATTRIBUTETEXT 259
    00343 #define INTEGER 260
    00344 #define DOUBLE 261
    00345 #define OSILEND 262
    00346 #define INSTANCEDATAEND 263
    00347 #define INSTANCEDATASTARTEND 264
    00348 #define VALUEATT 265
    00349 #define NUMBEROFNONLINEAREXPRESSIONS 266
    00350 #define IDXONEATT 267
    00351 #define IDXTWOATT 268
    00352 #define COEFATT 269
    00353 #define IDATT 270
    00354 #define TIMESSTART 271
    00355 #define TIMESEND 272
    00356 #define NUMBERSTART 273
    00357 #define NUMBEREND 274
    00358 #define NUMBEROFQTERMSATT 275
    00359 #define IDXATT 276
    00360 #define TYPEATT 277
    00361 #define QTERMSTART 278
    00362 #define QTERMEND 279
    00363 #define QUADRATICCOEFFICIENTSSTART 280
    00364 #define QUADRATICCOEFFICIENTSEND 281
    00365 #define NONLINEAREXPRESSIONSSTART 282
    00366 #define NONLINEAREXPRESSIONSEND 283
    00367 #define NLSTART 284
    00368 #define NLEND 285
    00369 #define POWERSTART 286
    00370 #define POWEREND 287
    00371 #define PLUSSTART 288
    00372 #define PLUSEND 289
    00373 #define MINUSSTART 290
    00374 #define MINUSEND 291
    00375 #define DIVIDESTART 292
    00376 #define DIVIDEEND 293
    00377 #define LNSTART 294
    00378 #define LNEND 295
    00379 #define SQRTSTART 296
    00380 #define SQRTEND 297
    00381 #define SUMSTART 298
    00382 #define SUMEND 299
    00383 #define PRODUCTSTART 300
    00384 #define PRODUCTEND 301
    00385 #define ENDOFELEMENT 302
    00386 #define EXPSTART 303
    00387 #define EXPEND 304
    00388 #define NEGATESTART 305
    00389 #define NEGATEEND 306
    00390 #define IFSTART 307
    00391 #define IFEND 308
    00392 #define SQUARESTART 309
    00393 #define SQUAREEND 310
    00394 #define COSSTART 311
    00395 #define COSEND 312
    00396 #define SINSTART 313
    00397 #define SINEND 314
    00398 #define GREATERTHAN 315
    00399 #define VARIABLESTART 316
    00400 #define VARIABLEEND 317
    00401 #define ABSSTART 318
    00402 #define ABSEND 319
    00403 #define ERFSTART 320
    00404 #define ERFEND 321
    00405 #define MAXSTART 322
    00406 #define MAXEND 323
    00407 #define ALLDIFFSTART 324
    00408 #define ALLDIFFEND 325
    00409 #define MINSTART 326
    00410 #define MINEND 327
    00411 #define ESTART 328
    00412 #define EEND 329
    00413 #define PISTART 330
    00414 #define PIEND 331
    00415 #define TIMEDOMAINSTART 332
    00416 #define TIMEDOMAINEND 333
    00417 #define STAGESSTART 334
    00418 #define STAGESEND 335
    00419 #define STAGESTART 336
    00420 #define STAGEEND 337
    00421 #define NAMEATT 338
    00422 #define NUMBEROFSTAGESATT 339
    00423 #define HORIZONATT 340
    00424 #define STARTATT 341
    00425 #define VARIABLESSTART 342
    00426 #define CONSTRAINTSSTART 343
    00427 #define OBJECTIVESSTART 344
    00428 #define VARIABLESEND 345
    00429 #define CONSTRAINTSEND 346
    00430 #define OBJECTIVESEND 347
    00431 #define NUMBEROFVARIABLESATT 348
    00432 #define NUMBEROFCONSTRAINTSATT 349
    00433 #define NUMBEROFOBJECTIVESATT 350
    00434 #define STARTIDXATT 351
    00435 #define VARSTART 352
    00436 #define VAREND 353
    00437 #define CONSTART 354
    00438 #define CONEND 355
    00439 #define OBJSTART 356
    00440 #define OBJEND 357
    00441 #define INTERVALSTART 358
    00442 #define INTERVALEND 359
    00443
    00444
    00445
    00446
    00447 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
    00448 typedef union YYSTYPE
    00449 {
    00450
    00451
    00452         double dval;
    00453         int ival;
    00454         char* sval;
    00455
    00456
    00457
    00458
    00459 } YYSTYPE;
    00460 # define YYSTYPE_IS_TRIVIAL 1
    00461 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
    00462 # define YYSTYPE_IS_DECLARED 1
    00463 #endif
    00464
    00465 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
    00466 typedef struct YYLTYPE
    00467 {
    00468   int first_line;
    00469   int first_column;
    00470   int last_line;
    00471   int last_column;
    00472 } YYLTYPE;
    00473 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
    00474 # define YYLTYPE_IS_DECLARED 1
    00475 # define YYLTYPE_IS_TRIVIAL 1
    00476 #endif
    00477
    00478
    00479 /* Copy the second part of user declarations.  */
    00480
    00481
    00482 int osillex(YYSTYPE* lvalp,  YYLTYPE* llocp, void* scanner );
    00483 void osilerror(YYLTYPE* type, OSInstance *osintance,  OSiLParserData *parserData ,const char* errormsg );
    00484
    00485
    00486 #define scanner parserData->scanner
    00487
    00488
    00489
    00490 #ifdef short
    00491 # undef short
    00492 #endif
    00493
    00494 #ifdef YYTYPE_UINT8
    00495 typedef YYTYPE_UINT8 yytype_uint8;
    00496 #else
    00497 typedef unsigned char yytype_uint8;
    00498 #endif
    00499
    00500 #ifdef YYTYPE_INT8
    00501 typedef YYTYPE_INT8 yytype_int8;
    00502 #elif (defined __STDC__ || defined __C99__FUNC__ \
    00503      || defined __cplusplus || defined _MSC_VER)
    00504 typedef signed char yytype_int8;
    00505 #else
    00506 typedef short int yytype_int8;
    00507 #endif
    00508
    00509 #ifdef YYTYPE_UINT16
    00510 typedef YYTYPE_UINT16 yytype_uint16;
    00511 #else
    00512 typedef unsigned short int yytype_uint16;
    00513 #endif
    00514
    00515 #ifdef YYTYPE_INT16
    00516 typedef YYTYPE_INT16 yytype_int16;
    00517 #else
    00518 typedef short int yytype_int16;
    00519 #endif
    00520
    00521 #ifndef YYSIZE_T
    00522 # ifdef __SIZE_TYPE__
    00523 #  define YYSIZE_T __SIZE_TYPE__
    00524 # elif defined size_t
    00525 #  define YYSIZE_T size_t
    00526 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
    00527      || defined __cplusplus || defined _MSC_VER)
    00528 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
    00529 #  define YYSIZE_T size_t
    00530 # else
    00531 #  define YYSIZE_T unsigned int
    00532 # endif
    00533 #endif
    00534
    00535 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
    00536
    00537 #ifndef YY_
    00538 # if YYENABLE_NLS
    00539 #  if ENABLE_NLS
    00540 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
    00541 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
    00542 #  endif
    00543 # endif
    00544 # ifndef YY_
    00545 #  define YY_(msgid) msgid
    00546 # endif
    00547 #endif
    00548
    00549 /* Suppress unused-variable warnings by "using" E.  */
    00550 #if ! defined lint || defined __GNUC__
    00551 # define YYUSE(e) ((void) (e))
    00552 #else
    00553 # define YYUSE(e) /* empty */
    00554 #endif
    00555
    00556 /* Identity function, used to suppress warnings about constant conditions.  */
    00557 #ifndef lint
    00558 # define YYID(n) (n)
    00559 #else
    00560 #if (defined __STDC__ || defined __C99__FUNC__ \
    00561      || defined __cplusplus || defined _MSC_VER)
    00562 static int
    00563 YYID (int yyi)
    00564 #else
    00565 static int
    00566 YYID (yyi)
    00567     int yyi;
    00568 #endif
    00569 {
    00570   return yyi;
    00571 }
    00572 #endif
    00573
    00574 #if ! defined yyoverflow || YYERROR_VERBOSE
    00575
    00576 /* The parser invokes alloca or malloc; define the necessary symbols.  */
    00577
    00578 # ifdef YYSTACK_USE_ALLOCA
    00579 #  if YYSTACK_USE_ALLOCA
    00580 #   ifdef __GNUC__
    00581 #    define YYSTACK_ALLOC __builtin_alloca
    00582 #   elif defined __BUILTIN_VA_ARG_INCR
    00583 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
    00584 #   elif defined _AIX
    00585 #    define YYSTACK_ALLOC __alloca
    00586 #   elif defined _MSC_VER
    00587 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
    00588 #    define alloca _alloca
    00589 #   else
    00590 #    define YYSTACK_ALLOC alloca
    00591 #    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
    00592      || defined __cplusplus || defined _MSC_VER)
    00593 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
    00594 #     ifndef _STDLIB_H
    00595 #      define _STDLIB_H 1
    00596 #     endif
    00597 #    endif
    00598 #   endif
    00599 #  endif
    00600 # endif
    00601
    00602 # ifdef YYSTACK_ALLOC
    00603    /* Pacify GCC's `empty if-body' warning.  */
    00604 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
    00605 #  ifndef YYSTACK_ALLOC_MAXIMUM
    00606     /* The OS might guarantee only one guard page at the bottom of the stack,
    00607        and a page size can be as small as 4096 bytes.  So we cannot safely
    00608        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
    00609        to allow for a few compiler-allocated temporary stack slots.  */
    00610 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
    00611 #  endif
    00612 # else
    00613 #  define YYSTACK_ALLOC YYMALLOC
    00614 #  define YYSTACK_FREE YYFREE
    00615 #  ifndef YYSTACK_ALLOC_MAXIMUM
    00616 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
    00617 #  endif
    00618 #  if (defined __cplusplus && ! defined _STDLIB_H \
    00619        && ! ((defined YYMALLOC || defined malloc) \
    00620              && (defined YYFREE || defined free)))
    00621 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
    00622 #   ifndef _STDLIB_H
    00623 #    define _STDLIB_H 1
    00624 #   endif
    00625 #  endif
    00626 #  ifndef YYMALLOC
    00627 #   define YYMALLOC malloc
    00628 #   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
    00629      || defined __cplusplus || defined _MSC_VER)
    00630 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
    00631 #   endif
    00632 #  endif
    00633 #  ifndef YYFREE
    00634 #   define YYFREE free
    00635 #   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
    00636      || defined __cplusplus || defined _MSC_VER)
    00637 void free (void *); /* INFRINGES ON USER NAME SPACE */
    00638 #   endif
    00639 #  endif
    00640 # endif
    00641 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
    00642
    00643
    00644 #if (! defined yyoverflow \
    00645      && (! defined __cplusplus \
    00646          || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
    00647              && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
    00648
    00649 /* A type that is properly aligned for any stack member.  */
    00650 union yyalloc
    00651 {
    00652   yytype_int16 yyss_alloc;
    00653   YYSTYPE yyvs_alloc;
    00654   YYLTYPE yyls_alloc;
    00655 };
    00656
    00657 /* The size of the maximum gap between one aligned stack and the next.  */
    00658 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
    00659
    00660 /* The size of an array large to enough to hold all stacks, each with
    00661    N elements.  */
    00662 # define YYSTACK_BYTES(N) \
    00663      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
    00664       + 2 * YYSTACK_GAP_MAXIMUM)
    00665
    00666 /* Copy COUNT objects from FROM to TO.  The source and destination do
    00667    not overlap.  */
    00668 # ifndef YYCOPY
    00669 #  if defined __GNUC__ && 1 < __GNUC__
    00670 #   define YYCOPY(To, From, Count) \
    00671       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
    00672 #  else
    00673 #   define YYCOPY(To, From, Count)              \
    00674       do                                        \
    00675         {                                       \
    00676           YYSIZE_T yyi;                         \
    00677           for (yyi = 0; yyi < (Count); yyi++)   \
    00678             (To)[yyi] = (From)[yyi];            \
    00679         }                                       \
    00680       while (YYID (0))
    00681 #  endif
    00682 # endif
    00683
    00684 /* Relocate STACK from its old location to the new one.  The
    00685    local variables YYSIZE and YYSTACKSIZE give the old and new number of
    00686    elements in the stack, and YYPTR gives the new location of the
    00687    stack.  Advance YYPTR to a properly aligned location for the next
    00688    stack.  */
    00689 # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
    00690     do                                                                  \
    00691       {                                                                 \
    00692         YYSIZE_T yynewbytes;                                            \
    00693         YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
    00694         Stack = &yyptr->Stack_alloc;                                    \
    00695         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
    00696         yyptr += yynewbytes / sizeof (*yyptr);                          \
    00697       }                                                                 \
    00698     while (YYID (0))
    00699
    00700 #endif
    00701
    00702 /* YYFINAL -- State number of the termination state.  */
    00703 #define YYFINAL  6
    00704 /* YYLAST -- Last index in YYTABLE.  */
    00705 #define YYLAST   403
    00706
    00707 /* YYNTOKENS -- Number of terminals.  */
    00708 #define YYNTOKENS  105
    00709 /* YYNNTS -- Number of nonterminals.  */
    00710 #define YYNNTS  148
    00711 /* YYNRULES -- Number of rules.  */
    00712 #define YYNRULES  232
    00713 /* YYNRULES -- Number of states.  */
    00714 #define YYNSTATES  407
    00715
    00716 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
    00717 #define YYUNDEFTOK  2
    00718 #define YYMAXUTOK   359
    00719
    00720 #define YYTRANSLATE(YYX)                                                \
    00721   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
    00722
    00723 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
    00724 static const yytype_uint8 yytranslate[] =
    00725 {
    00726        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00727        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00728        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00729        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00730        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00731        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00732        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00733        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00734        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00735        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00736        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00737        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00738        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00739        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00740        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00741        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00742        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00743        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00744        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00745        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00746        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00747        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00748        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00749        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00750        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    00751        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
    00752        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
    00753       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
    00754       25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
    00755       35,    36,    37,    38,    39,    40,    41,    42,    43,    44,
    00756       45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
    00757       55,    56,    57,    58,    59,    60,    61,    62,    63,    64,
    00758       65,    66,    67,    68,    69,    70,    71,    72,    73,    74,
    00759       75,    76,    77,    78,    79,    80,    81,    82,    83,    84,
    00760       85,    86,    87,    88,    89,    90,    91,    92,    93,    94,
    00761       95,    96,    97,    98,    99,   100,   101,   102,   103,   104
    00762 };
    00763
    00764 #if YYDEBUG
    00765 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
    00766    YYRHS.  */
    00767 static const yytype_uint16 yyprhs[] =
    00768 {
    00769        0,     0,     3,     9,    11,    13,    15,    16,    17,    22,
    00770       28,    30,    33,    37,    39,    41,    44,    45,    48,    50,
    00771       52,    54,    56,    61,    66,    71,    76,    81,    82,    87,
    00772       93,    94,    95,   103,   105,   110,   112,   114,   116,   118,
    00773      120,   122,   124,   126,   128,   130,   132,   134,   136,   138,
    00774      140,   142,   144,   146,   148,   150,   152,   154,   156,   158,
    00775      159,   165,   166,   172,   173,   179,   180,   185,   186,   192,
    00776      193,   199,   200,   205,   207,   210,   211,   216,   218,   221,
    00777      222,   227,   229,   232,   233,   238,   240,   243,   244,   249,
    00778      251,   254,   255,   260,   261,   266,   267,   272,   273,   278,
    00779      279,   284,   285,   290,   291,   296,   297,   302,   303,   310,
    00780      311,   315,   317,   320,   321,   325,   327,   330,   331,   336,
    00781      338,   341,   342,   345,   347,   349,   351,   352,   357,   358,
    00782      363,   368,   373,   374,   379,   381,   382,   387,   390,   391,
    00783      394,   396,   398,   403,   408,   413,   414,   417,   419,   420,
    00784      422,   426,   430,   432,   435,   440,   442,   448,   450,   453,
    00785      454,   459,   460,   464,   466,   470,   474,   475,   479,   480,
    00786      483,   485,   487,   492,   497,   499,   503,   505,   508,   510,
    00787      513,   514,   519,   524,   526,   529,   530,   534,   535,   538,
    00788      540,   542,   547,   552,   554,   558,   560,   563,   565,   568,
    00789      569,   574,   579,   581,   584,   585,   589,   590,   593,   595,
    00790      597,   602,   607,   609,   613,   615,   618,   620,   623,   624,
    00791      629,   634,   636,   639,   640,   645,   647,   650,   651,   654,
    00792      656,   658,   663
    00793 };
    00794
    00795 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
    00796 static const yytype_int16 yyrhs[] =
    00797 {
    00798      106,     0,    -1,   109,   121,   197,   107,   108,    -1,     9,
    00799       -1,     8,    -1,     7,    -1,    -1,    -1,    25,   110,   111,
    00800       26,    -1,    20,     3,     5,     3,    60,    -1,   112,    -1,
    00801      111,   112,    -1,   113,   115,   114,    -1,    23,    -1,    47,
    00802       -1,    60,    24,    -1,    -1,   115,   116,    -1,   117,    -1,
    00803      118,    -1,   119,    -1,   120,    -1,    12,     3,     5,     3,
    00804       -1,    13,     3,     5,     3,    -1,    14,     3,     6,     3,
    00805       -1,    14,     3,     5,     3,    -1,    21,     3,     5,     3,
    00806       -1,    -1,    27,   122,   123,    28,    -1,    11,     3,     5,
    00807        3,    60,    -1,    -1,    -1,   123,   125,   126,    60,   127,
    00808      124,    30,    -1,    29,    -1,    21,     3,     5,     3,    -1,
    00809      179,    -1,   189,    -1,   128,    -1,   130,    -1,   140,    -1,
    00810      132,    -1,   134,    -1,   136,    -1,   138,    -1,   152,    -1,
    00811      155,    -1,   157,    -1,   159,    -1,   163,    -1,   161,    -1,
    00812      165,    -1,   171,    -1,   167,    -1,   169,    -1,   146,    -1,
    00813      149,    -1,   173,    -1,   176,    -1,   143,    -1,    -1,    16,
    00814      129,   127,   127,    17,    -1,    -1,    33,   131,   127,   127,
    00815       34,    -1,    -1,    35,   133,   127,   127,    36,    -1,    -1,
    00816       50,   135,   127,    51,    -1,    -1,    37,   137,   127,   127,
    00817       38,    -1,    -1,    31,   139,   127,   127,    32,    -1,    -1,
    00818       43,   141,   142,    44,    -1,   127,    -1,   142,   127,    -1,
    00819       -1,    69,   144,   145,    70,    -1,   127,    -1,   145,   127,
    00820       -1,    -1,    67,   147,   148,    68,    -1,   127,    -1,   148,
    00821      127,    -1,    -1,    71,   150,   151,    72,    -1,   127,    -1,
    00822      151,   127,    -1,    -1,    45,   153,   154,    46,    -1,   127,
    00823       -1,   154,   127,    -1,    -1,    39,   156,   127,    40,    -1,
    00824       -1,    41,   158,   127,    42,    -1,    -1,    54,   160,   127,
    00825       55,    -1,    -1,    56,   162,   127,    57,    -1,    -1,    58,
    00826      164,   127,    59,    -1,    -1,    48,   166,   127,    49,    -1,
    00827       -1,    63,   168,   127,    64,    -1,    -1,    65,   170,   127,
    00828       66,    -1,    -1,    52,   172,   127,   127,   127,    53,    -1,
    00829       -1,    73,   174,   175,    -1,    47,    -1,    60,    74,    -1,
    00830       -1,    75,   177,   178,    -1,    47,    -1,    60,    76,    -1,
    00831       -1,    18,   180,   182,   181,    -1,    47,    -1,    60,    19,
    00832       -1,    -1,   182,   183,    -1,   184,    -1,   188,    -1,   186,
    00833       -1,    -1,    22,     4,   185,     3,    -1,    -1,    15,     4,
    00834      187,     3,    -1,    10,     3,     6,     3,    -1,    10,     3,
    00835        5,     3,    -1,    -1,    61,   190,   193,   191,    -1,    47,
    00836       -1,    -1,    60,   127,   192,    62,    -1,    60,    62,    -1,
    00837       -1,   193,   194,    -1,   195,    -1,   196,    -1,    14,     3,
    00838        6,     3,    -1,    14,     3,     5,     3,    -1,    21,     3,
    00839        5,     3,    -1,    -1,   198,   199,    -1,    77,    -1,    -1,
    00840      200,    -1,    60,   201,    78,    -1,    60,   246,    78,    -1,
    00841       47,    -1,    60,    78,    -1,   202,   203,   204,    80,    -1,
    00842       79,    -1,    84,     3,     5,     3,    60,    -1,   205,    -1,
    00843      204,   205,    -1,    -1,   206,    81,   207,   208,    -1,    -1,
    00844       83,     4,     3,    -1,    47,    -1,    60,   209,    82,    -1,
    00845      210,   222,   234,    -1,    -1,    87,   211,   215,    -1,    -1,
    00846      211,   212,    -1,   213,    -1,   214,    -1,    93,     3,     5,
    00847        3,    -1,    96,     3,     5,     3,    -1,   216,    -1,    60,
    00848      217,    90,    -1,    47,    -1,    60,    90,    -1,   218,    -1,
    00849      217,   218,    -1,    -1,   219,    97,   220,   221,    -1,    21,
    00850        3,     5,     3,    -1,    47,    -1,    60,    98,    -1,    -1,
    00851       88,   223,   227,    -1,    -1,   223,   224,    -1,   225,    -1,
    00852      226,    -1,    94,     3,     5,     3,    -1,    96,     3,     5,
    00853        3,    -1,   228,    -1,    60,   229,    91,    -1,    47,    -1,
    00854       60,    91,    -1,   230,    -1,   229,   230,    -1,    -1,   231,
    00855       99,   232,   233,    -1,    21,     3,     5,     3,    -1,    47,
    00856       -1,    60,   100,    -1,    -1,    89,   235,   239,    -1,    -1,
    00857      235,   236,    -1,   237,    -1,   238,    -1,    95,     3,     5,
    00858        3,    -1,    96,     3,     5,     3,    -1,   240,    -1,    60,
    00859      241,    92,    -1,    47,    -1,    60,    92,    -1,   242,    -1,
    00860      241,   242,    -1,    -1,   243,   101,   244,   245,    -1,    21,
    00861        3,     5,     3,    -1,    47,    -1,    60,   102,    -1,    -1,
    00862      247,   103,   249,   248,    -1,    47,    -1,    60,   104,    -1,
    00863       -1,   249,   250,    -1,   251,    -1,   252,    -1,    85,     3,
    00864        6,     3,    -1,    86,     3,     6,     3,    -1
    00865 };
    00866
    00867 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
    00868 static const yytype_uint16 yyrline[] =
    00869 {
    00870        0,   225,   225,   228,   229,   231,   232,   235,   236,   241,
    00871      248,   249,   251,   264,   271,   272,   275,   276,   280,   283,
    00872      286,   289,   295,   302,   309,   311,   315,   318,   319,   323,
    00873      332,   334,   333,   341,   346,   360,   361,   362,   363,   364,
    00874      365,   366,   367,   368,   369,   370,   371,   372,   373,   374,
    00875      375,   376,   377,   378,   379,   380,   381,   382,   383,   386,
    00876      386,   391,   391,   396,   396,   401,   401,   406,   406,   411,
    00877      411,   416,   416,   426,   427,   432,   432,   444,   445,   448,
    00878      448,   459,   460,   462,   462,   473,   474,   477,   477,   487,
    00879      488,   491,   491,   496,   496,   501,   501,   506,   506,   511,
    00880      511,   518,   518,   523,   523,   531,   531,   539,   539,   546,
    00881      546,   549,   550,   552,   552,   555,   556,   558,   558,   563,
    00882      564,   566,   567,   569,   571,   573,   577,   577,   581,   581,
    00883      585,   588,   592,   592,   597,   598,   598,   602,   604,   605,
    00884      607,   609,   613,   616,   620,   628,   628,   630,   632,   633,
    00885      634,   635,   637,   638,   640,   691,   693,   707,   708,   710,
    00886      710,   734,   735,   738,   739,   741,   743,   744,   748,   749,
    00887      751,   752,   754,   770,   778,   785,   790,   791,   793,   794,
    00888      796,   796,   799,   808,   809,   811,   812,   816,   817,   819,
    00889      820,   822,   838,   846,   853,   858,   859,   861,   862,   864,
    00890      864,   867,   876,   877,   879,   889,   893,   894,   896,   897,
    00891      899,   915,   923,   930,   935,   936,   938,   939,   941,   941,
    00892      944,   953,   954,   959,   959,   967,   968,   970,   971,   973,
    00893      977,   982,   986
    00894 };
    00895 #endif
    00896
    00897 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
    00898 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
    00899    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
    00900 static const char *const yytname[] =
    00901 {
    00902   "$end", "error", "$undefined", "QUOTE", "ATTRIBUTETEXT", "INTEGER",
    00903   "DOUBLE", "OSILEND", "INSTANCEDATAEND", "INSTANCEDATASTARTEND",
    00904   "VALUEATT", "NUMBEROFNONLINEAREXPRESSIONS", "IDXONEATT", "IDXTWOATT",
    00905   "COEFATT", "IDATT", "TIMESSTART", "TIMESEND", "NUMBERSTART", "NUMBEREND",
    00906   "NUMBEROFQTERMSATT", "IDXATT", "TYPEATT", "QTERMSTART", "QTERMEND",
    00907   "QUADRATICCOEFFICIENTSSTART", "QUADRATICCOEFFICIENTSEND",
    00908   "NONLINEAREXPRESSIONSSTART", "NONLINEAREXPRESSIONSEND", "NLSTART",
    00909   "NLEND", "POWERSTART", "POWEREND", "PLUSSTART", "PLUSEND", "MINUSSTART",
    00910   "MINUSEND", "DIVIDESTART", "DIVIDEEND", "LNSTART", "LNEND", "SQRTSTART",
    00911   "SQRTEND", "SUMSTART", "SUMEND", "PRODUCTSTART", "PRODUCTEND",
    00912   "ENDOFELEMENT", "EXPSTART", "EXPEND", "NEGATESTART", "NEGATEEND",
    00913   "IFSTART", "IFEND", "SQUARESTART", "SQUAREEND", "COSSTART", "COSEND",
    00914   "SINSTART", "SINEND", "GREATERTHAN", "VARIABLESTART", "VARIABLEEND",
    00915   "ABSSTART", "ABSEND", "ERFSTART", "ERFEND", "MAXSTART", "MAXEND",
    00916   "ALLDIFFSTART", "ALLDIFFEND", "MINSTART", "MINEND", "ESTART", "EEND",
    00917   "PISTART", "PIEND", "TIMEDOMAINSTART", "TIMEDOMAINEND", "STAGESSTART",
    00918   "STAGESEND", "STAGESTART", "STAGEEND", "NAMEATT", "NUMBEROFSTAGESATT",
    00919   "HORIZONATT", "STARTATT", "VARIABLESSTART", "CONSTRAINTSSTART",
    00920   "OBJECTIVESSTART", "VARIABLESEND", "CONSTRAINTSEND", "OBJECTIVESEND",
    00921   "NUMBEROFVARIABLESATT", "NUMBEROFCONSTRAINTSATT",
    00922   "NUMBEROFOBJECTIVESATT", "STARTIDXATT", "VARSTART", "VAREND", "CONSTART",
    00923   "CONEND", "OBJSTART", "OBJEND", "INTERVALSTART", "INTERVALEND",
    00924   "$accept", "osildoc", "theInstanceEnd", "osilEnd",
    00925   "quadraticCoefficients", "quadnumberatt", "qTermlist", "qterm",
    00926   "qtermStart", "qtermend", "anotherqTermATT", "qtermatt",
    00927   "qtermidxOneatt", "qtermidxTwoatt", "qtermcoefatt", "qtermidxatt",
    00928   "nonlinearExpressions", "nlnumberatt", "nlnodes", "$@1", "nlstart",
    00929   "nlIdxATT", "nlnode", "times", "$@2", "plus", "$@3", "minus", "$@4",
    00930   "negate", "$@5", "divide", "$@6", "power", "$@7", "sum", "$@8",
    00931   "anothersumnlnode", "allDiff", "$@9", "anotherallDiffnlnode", "max",
    00932   "$@10", "anothermaxnlnode", "min", "$@11", "anotherminnlnode", "product",
    00933   "$@12", "anotherproductnlnode", "ln", "$@13", "sqrt", "$@14", "square",
    00934   "$@15", "cos", "$@16", "sin", "$@17", "exp", "$@18", "abs", "$@19",
    00935   "erf", "$@20", "if", "$@21", "E", "$@22", "eend", "PI", "$@23", "piend",
    00936   "number", "$@24", "numberend", "anotherNumberATT", "numberATT",
    00937   "numbertypeATT", "$@25", "numberidATT", "$@26", "numbervalueATT",
    00938   "variable", "$@27", "variableend", "$@28", "anotherVariableATT",
    00939   "variableATT", "variablecoefATT", "variableidxATT", "timeDomain",
    00940   "timedomainstart", "timedomain", "timedomainend", "stages",
    00941   "stagesstart", "numberofstagesatt", "stagelist", "stage", "$@29",
    00942   "stagenameATT", "stageend", "stagecontent", "stagevariables",
    00943   "anotherstagevarATT", "stagevaratt", "numberofstagevariablesatt",
    00944   "stagevarstartidxATT", "restofstagevariables", "emptyvarlist",
    00945   "stagevarlist", "stagevar", "$@30", "stagevaridxATT", "stagevarend",
    00946   "stageconstraints", "anotherstageconATT", "stageconatt",
    00947   "numberofstageconstraintsatt", "stageconstartidxATT",
    00948   "restofstageconstraints", "emptyconlist", "stageconlist", "stagecon",
    00949   "$@31", "stageconidxATT", "stageconend", "stageobjectives",
    00950   "anotherstageobjATT", "stageobjatt", "numberofstageobjectivesatt",
    00951   "stageobjstartidxATT", "restofstageobjectives", "emptyobjlist",
    00952   "stageobjlist", "stageobj", "$@32", "stageobjidxATT", "stageobjend",
    00953   "interval", "$@33", "intervalend", "anotherIntervalATT", "intervalatt",
    00954   "intervalhorizonatt", "intervalstartatt", 0
    00955 };
    00956 #endif
    00957
    00958 # ifdef YYPRINT
    00959 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
    00960    token YYLEX-NUM.  */
    00961 static const yytype_uint16 yytoknum[] =
    00962 {
    00963        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
    00964      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
    00965      275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
    00966      285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
    00967      295,   296,   297,   298,   299,   300,   301,   302,   303,   304,
    00968      305,   306,   307,   308,   309,   310,   311,   312,   313,   314,
    00969      315,   316,   317,   318,   319,   320,   321,   322,   323,   324,
    00970      325,   326,   327,   328,   329,   330,   331,   332,   333,   334,
    00971      335,   336,   337,   338,   339,   340,   341,   342,   343,   344,
    00972      345,   346,   347,   348,   349,   350,   351,   352,   353,   354,
    00973      355,   356,   357,   358,   359
    00974 };
    00975 # endif
    00976
    00977 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
    00978 static const yytype_uint8 yyr1[] =
    00979 {
    00980        0,   105,   106,   107,   107,   108,   108,   109,   109,   110,
    00981      111,   111,   112,   113,   114,   114,   115,   115,   116,   116,
    00982      116,   116,   117,   118,   119,   119,   120,   121,   121,   122,
    00983      123,   124,   123,   125,   126,   127,   127,   127,   127,   127,
    00984      127,   127,   127,   127,   127,   127,   127,   127,   127,   127,
    00985      127,   127,   127,   127,   127,   127,   127,   127,   127,   129,
    00986      128,   131,   130,   133,   132,   135,   134,   137,   136,   139,
    00987      138,   141,   140,   142,   142,   144,   143,   145,   145,   147,
    00988      146,   148,   148,   150,   149,   151,   151,   153,   152,   154,
    00989      154,   156,   155,   158,   157,   160,   159,   162,   161,   164,
    00990      163,   166,   165,   168,   167,   170,   169,   172,   171,   174,
    00991      173,   175,   175,   177,   176,   178,   178,   180,   179,   181,
    00992      181,   182,   182,   183,   183,   183,   185,   184,   187,   186,
    00993      188,   188,   190,   189,   191,   192,   191,   191,   193,   193,
    00994      194,   194,   195,   195,   196,   197,   197,   198,   199,   199,
    00995      199,   199,   200,   200,   201,   202,   203,   204,   204,   206,
    00996      205,   207,   207,   208,   208,   209,   210,   210,   211,   211,
    00997      212,   212,   213,   214,   215,   215,   216,   216,   217,   217,
    00998      219,   218,   220,   221,   221,   222,   222,   223,   223,   224,
    00999      224,   225,   226,   227,   227,   228,   228,   229,   229,   231,
    01000      230,   232,   233,   233,   234,   234,   235,   235,   236,   236,
    01001      237,   238,   239,   239,   240,   240,   241,   241,   243,   242,
    01002      244,   245,   245,   247,   246,   248,   248,   249,   249,   250,
    01003      250,   251,   252
    01004 };
    01005
    01006 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
    01007 static const yytype_uint8 yyr2[] =
    01008 {
    01009        0,     2,     5,     1,     1,     1,     0,     0,     4,     5,
    01010        1,     2,     3,     1,     1,     2,     0,     2,     1,     1,
    01011        1,     1,     4,     4,     4,     4,     4,     0,     4,     5,
    01012        0,     0,     7,     1,     4,     1,     1,     1,     1,     1,
    01013        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
    01014        1,     1,     1,     1,     1,     1,     1,     1,     1,     0,
    01015        5,     0,     5,     0,     5,     0,     4,     0,     5,     0,
    01016        5,     0,     4,     1,     2,     0,     4,     1,     2,     0,
    01017        4,     1,     2,     0,     4,     1,     2,     0,     4,     1,
    01018        2,     0,     4,     0,     4,     0,     4,     0,     4,     0,
    01019        4,     0,     4,     0,     4,     0,     4,     0,     6,     0,
    01020        3,     1,     2,     0,     3,     1,     2,     0,     4,     1,
    01021        2,     0,     2,     1,     1,     1,     0,     4,     0,     4,
    01022        4,     4,     0,     4,     1,     0,     4,     2,     0,     2,
    01023        1,     1,     4,     4,     4,     0,     2,     1,     0,     1,
    01024        3,     3,     1,     2,     4,     1,     5,     1,     2,     0,
    01025        4,     0,     3,     1,     3,     3,     0,     3,     0,     2,
    01026        1,     1,     4,     4,     1,     3,     1,     2,     1,     2,
    01027        0,     4,     4,     1,     2,     0,     3,     0,     2,     1,
    01028        1,     4,     4,     1,     3,     1,     2,     1,     2,     0,
    01029        4,     4,     1,     2,     0,     3,     0,     2,     1,     1,
    01030        4,     4,     1,     3,     1,     2,     1,     2,     0,     4,
    01031        4,     1,     2,     0,     4,     1,     2,     0,     2,     1,
    01032        1,     4,     4
    01033 };
    01034
    01035 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
    01036    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
    01037    means the default is an error.  */
    01038 static const yytype_uint8 yydefact[] =
    01039 {
    01040        7,     0,     0,    27,     0,     0,     1,     0,   145,     0,
    01041       13,     0,    10,    16,     0,    30,   147,     0,   148,     0,
    01042        8,    11,     0,     0,     0,     4,     3,     6,   152,   223,
    01043      146,   149,     0,     0,     0,     0,     0,    14,     0,    12,
    01044       17,    18,    19,    20,    21,     0,    28,    33,     0,     5,
    01045        2,   153,   155,     0,     0,     0,     0,     9,     0,     0,
    01046        0,     0,    15,     0,     0,     0,   150,     0,   159,   151,
    01047      227,     0,     0,     0,     0,     0,    29,     0,     0,     0,
    01048      159,   157,     0,     0,    22,    23,    25,    24,    26,     0,
    01049       59,   117,    69,    61,    63,    67,    91,    93,    71,    87,
    01050      101,    65,   107,    95,    97,    99,   132,   103,   105,    79,
    01051       75,    83,   109,   113,    31,    37,    38,    40,    41,    42,
    01052       43,    39,    58,    54,    55,    44,    45,    46,    47,    49,
    01053       48,    50,    52,    53,    51,    56,    57,    35,    36,     0,
    01054      154,   158,   161,   225,     0,     0,     0,   224,   228,   229,
    01055      230,    34,     0,   121,     0,     0,     0,     0,     0,     0,
    01056        0,     0,     0,     0,     0,     0,     0,     0,   138,     0,
    01057        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
    01058      226,     0,     0,     0,     0,     0,     0,     0,     0,     0,
    01059        0,    73,     0,    89,     0,     0,     0,     0,     0,     0,
    01060        0,     0,     0,     0,    81,     0,    77,     0,    85,     0,
    01061      111,     0,   110,   115,     0,   114,    32,   156,     0,   163,
    01062      166,   160,     0,     0,     0,     0,     0,     0,   119,     0,
    01063      118,   122,   123,   125,   124,     0,     0,     0,     0,    92,
    01064       94,    72,    74,    88,    90,   102,    66,     0,    96,    98,
    01065      100,     0,     0,   134,     0,   133,   139,   140,   141,   104,
    01066      106,    80,    82,    76,    78,    84,    86,   112,   116,   162,
    01067      168,     0,   185,   231,   232,    60,     0,   128,   126,   120,
    01068       70,    62,    64,    68,     0,     0,     0,   137,   135,     0,
    01069      164,   187,   204,     0,     0,     0,     0,   108,     0,     0,
    01070        0,     0,   176,   180,     0,     0,   169,   170,   171,   167,
    01071      174,     0,   206,   165,   131,   130,   129,   127,   143,   142,
    01072      144,   136,   177,   180,   178,     0,     0,     0,   195,   199,
    01073        0,     0,   188,   189,   190,   186,   193,     0,   175,   179,
    01074        0,     0,     0,   196,   199,   197,     0,     0,     0,   214,
    01075      218,     0,     0,   207,   208,   209,   205,   212,     0,     0,
    01076      172,   173,   194,   198,     0,     0,     0,   215,   218,   216,
    01077        0,     0,     0,     0,   183,     0,   181,     0,     0,   191,
    01078      192,   213,   217,     0,     0,     0,     0,   184,     0,   202,
    01079        0,   200,     0,     0,   210,   211,   182,     0,   203,     0,
    01080      221,     0,   219,   201,     0,   222,   220
    01081 };
    01082
    01083 /* YYDEFGOTO[NTERM-NUM].  */
    01084 static const yytype_int16 yydefgoto[] =
    01085 {
    01086       -1,     2,    27,    50,     3,     5,    11,    12,    13,    39,
    01087       22,    40,    41,    42,    43,    44,     8,    15,    24,   176,
    01088       48,    65,   114,   115,   152,   116,   155,   117,   156,   118,
    01089      163,   119,   157,   120,   154,   121,   160,   192,   122,   172,
    01090      207,   123,   171,   205,   124,   173,   209,   125,   161,   194,
    01091      126,   158,   127,   159,   128,   165,   129,   166,   130,   167,
    01092      131,   162,   132,   169,   133,   170,   134,   164,   135,   174,
    01093      212,   136,   175,   215,   137,   153,   230,   184,   231,   232,
    01094      296,   233,   295,   234,   138,   168,   255,   301,   201,   256,
    01095      257,   258,    17,    18,    30,    31,    53,    54,    68,    80,
    01096       81,    82,   179,   221,   271,   272,   289,   306,   307,   308,
    01097      309,   310,   323,   324,   325,   359,   376,   292,   311,   332,
    01098      333,   334,   335,   336,   344,   345,   346,   378,   391,   313,
    01099      337,   353,   354,   355,   356,   357,   368,   369,   370,   393,
    01100      402,    55,    56,   147,    83,   148,   149,   150
    01101 };
    01102
    01103 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
    01104    STATE-NUM.  */
    01105 #define YYPACT_NINF -153
    01106 static const yytype_int16 yypact[] =
    01107 {
    01108      -24,     2,    24,     5,    41,     4,  -153,    36,   -28,    46,
    01109     -153,     0,  -153,  -153,    65,  -153,  -153,    92,   -31,    78,
    01110     -153,  -153,   329,    71,   122,  -153,  -153,    80,  -153,    54,
    01111     -153,  -153,    33,    94,   100,   102,   106,  -153,    83,  -153,
    01112     -153,  -153,  -153,  -153,  -153,   110,  -153,  -153,   105,  -153,
    01113     -153,  -153,  -153,    37,    44,    75,    52,  -153,   152,   159,
    01114      238,   163,  -153,   121,   167,   123,  -153,   182,  -153,  -153,
    01115     -153,   186,   187,   191,   193,   195,  -153,   198,   263,   202,
    01116      107,  -153,   128,   145,  -153,  -153,  -153,  -153,  -153,   208,
    01117     -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,
    01118     -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,
    01119     -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,
    01120     -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,
    01121     -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,   217,
    01122     -153,  -153,   139,  -153,   120,   223,   225,  -153,  -153,  -153,
    01123     -153,  -153,   263,  -153,   263,   263,   263,   263,   263,   263,
    01124      263,   263,   263,   263,   263,   263,   263,   263,  -153,   263,
    01125      263,   263,   263,   263,   -19,   -17,   203,   175,   233,    -1,
    01126     -153,   235,   244,   263,   325,   263,   263,   263,   263,   199,
    01127      210,  -153,    21,  -153,    73,   205,   207,   263,   209,   211,
    01128      201,    64,   206,   196,  -153,   104,  -153,   143,  -153,   184,
    01129     -153,   192,  -153,  -153,   231,  -153,  -153,  -153,   269,  -153,
    01130      200,  -153,   280,   282,   257,   306,   308,   310,  -153,   291,
    01131     -153,  -153,  -153,  -153,  -153,   286,   288,   287,   278,  -153,
    01132     -153,  -153,  -153,  -153,  -153,  -153,  -153,   263,  -153,  -153,
    01133     -153,   317,   322,  -153,   230,  -153,  -153,  -153,  -153,  -153,
    01134     -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,
    01135     -153,   245,   241,  -153,  -153,  -153,   271,  -153,  -153,  -153,
    01136     -153,  -153,  -153,  -153,   292,   284,   326,  -153,  -153,    70,
    01137     -153,  -153,   248,   330,   336,   341,   343,  -153,   345,   346,
    01138      348,   290,  -153,   264,   350,   352,  -153,  -153,  -153,  -153,
    01139     -153,   -22,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,
    01140     -153,  -153,  -153,   266,  -153,   260,   353,   354,  -153,   270,
    01141      357,   359,  -153,  -153,  -153,  -153,  -153,     3,  -153,  -153,
    01142      342,   361,   362,  -153,   275,  -153,   268,   363,   364,  -153,
    01143      279,   367,   370,  -153,  -153,  -153,  -153,  -153,   371,     1,
    01144     -153,  -153,  -153,  -153,   356,   372,   375,  -153,   289,  -153,
    01145      281,   374,   378,   379,  -153,   293,  -153,   377,    20,  -153,
    01146     -153,  -153,  -153,   365,   384,   385,   387,  -153,   388,  -153,
    01147      294,  -153,   389,    23,  -153,  -153,  -153,   392,  -153,   391,
    01148     -153,   295,  -153,  -153,   395,  -153,  -153
    01149 };
    01150
    01151 /* YYPGOTO[NTERM-NUM].  */
    01152 static const yytype_int16 yypgoto[] =
    01153 {
    01154     -153,  -153,  -153,  -153,  -153,  -153,  -153,   390,  -153,  -153,
    01155     -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,
    01156     -153,  -153,  -152,  -153,  -153,  -153,  -153,  -153,  -153,  -153,
    01157     -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,
    01158     -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,
    01159     -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,
    01160     -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,
    01161     -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,
    01162     -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,
    01163     -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,
    01164      319,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153,
    01165     -153,  -153,  -153,    77,  -153,  -153,  -153,  -153,  -153,  -153,
    01166     -153,  -153,  -153,  -153,  -153,    58,  -153,  -153,  -153,  -153,
    01167     -153,  -153,  -153,  -153,  -153,  -153,  -153,    35,  -153,  -153,
    01168     -153,  -153,  -153,  -153,  -153,  -153,  -153,  -153
    01169 };
    01170
    01171 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
    01172    positive, shift that token.  If negative, reduce the rule which
    01173    number is the opposite.  If zero, do what YYDEFACT says.
    01174    If YYTABLE_NINF, syntax error.  */
    01175 #define YYTABLE_NINF -1
    01176 static const yytype_uint16 yytable[] =
    01177 {
    01178      183,     1,   185,   186,   187,   188,   189,   190,   191,   193,
    01179      195,   196,   197,   198,   199,   200,    28,   202,   203,   204,
    01180      206,   208,     4,    10,     6,   328,    20,    10,   210,    29,
    01181      213,   224,     7,   235,   236,   237,   238,    90,   329,    91,
    01182      242,   211,   244,   214,     9,   247,   219,    14,   374,    16,
    01183      349,    19,    92,   262,    93,   264,    94,   266,    95,   220,
    01184       96,   375,    97,   350,    98,   241,    99,   389,    23,   100,
    01185      400,   101,   330,   102,   331,   103,    45,   104,   251,   105,
    01186      390,    32,   106,   401,   107,   252,   108,    49,   109,    90,
    01187      110,    91,   111,    57,   112,   284,   113,    58,   351,   352,
    01188       25,    26,   288,    59,    92,    60,    93,    62,    94,    61,
    01189       95,   253,    96,    63,    97,    66,    98,   302,    99,   243,
    01190       90,   100,    91,   101,   254,   102,    64,   103,    67,   104,
    01191      303,   105,    51,    52,   106,    92,   107,    93,   108,    94,
    01192      109,    95,   110,    96,   111,    97,   112,    98,   113,    99,
    01193       46,    47,   100,    69,   101,    70,   102,    71,   103,    90,
    01194      104,    91,   105,   304,    72,   106,   305,   107,    75,   108,
    01195       77,   109,   261,   110,    92,   111,    93,   112,    94,   113,
    01196       95,    76,    96,    78,    97,    79,    98,   140,    99,    84,
    01197       85,   100,   143,   101,    86,   102,    87,   103,    88,   104,
    01198       90,   105,    91,    89,   106,   144,   107,   139,   108,   142,
    01199      109,   151,   110,   263,   111,    92,   112,    93,   113,    94,
    01200      177,    95,   178,    96,   180,    97,   181,    98,   182,    99,
    01201      145,   146,   100,   216,   101,   217,   102,   218,   103,   239,
    01202      104,   222,   105,    73,    74,   106,    90,   107,    91,   108,
    01203      223,   109,   240,   110,   245,   111,   265,   112,   246,   113,
    01204      250,    92,   260,    93,   248,    94,   267,    95,   249,    96,
    01205      259,    97,   269,    98,   275,    99,   293,   294,   100,    90,
    01206      101,    91,   102,   273,   103,   274,   104,   270,   105,   298,
    01207      299,   106,   287,   107,    92,   108,    93,   109,    94,   110,
    01208       95,   111,    96,   112,    97,   113,    98,   268,    99,   276,
    01209      279,   100,   277,   101,   278,   102,   283,   103,   280,   104,
    01210      285,   105,   281,   282,   106,   286,   107,   290,   108,   291,
    01211      109,   300,   110,   314,   111,   225,   112,   312,   113,   315,
    01212      226,    33,    34,    35,   316,   297,   317,   227,   318,   319,
    01213       36,   320,   321,   326,   322,   327,   338,   340,   341,   342,
    01214      347,   343,   348,   358,   360,   361,   362,   364,   365,   366,
    01215      371,   367,   228,   372,   373,   379,    37,   377,   380,   384,
    01216      388,   381,   383,   385,   386,   229,   392,   394,   395,    38,
    01217      396,   387,   399,   397,   398,   403,   404,   405,   406,   141,
    01218      339,    21,   363,   382
    01219 };
    01220
    01221 static const yytype_uint16 yycheck[] =
    01222 {
    01223      152,    25,   154,   155,   156,   157,   158,   159,   160,   161,
    01224      162,   163,   164,   165,   166,   167,    47,   169,   170,   171,
    01225      172,   173,    20,    23,     0,    47,    26,    23,    47,    60,
    01226       47,   183,    27,   185,   186,   187,   188,    16,    60,    18,
    01227      192,    60,   194,    60,     3,   197,    47,    11,    47,    77,
    01228       47,     5,    31,   205,    33,   207,    35,   209,    37,    60,
    01229       39,    60,    41,    60,    43,    44,    45,    47,     3,    48,
    01230       47,    50,    94,    52,    96,    54,     5,    56,    14,    58,
    01231       60,     3,    61,    60,    63,    21,    65,     7,    67,    16,
    01232       69,    18,    71,    60,    73,   247,    75,     3,    95,    96,
    01233        8,     9,   254,     3,    31,     3,    33,    24,    35,     3,
    01234       37,    47,    39,     3,    41,    78,    43,    47,    45,    46,
    01235       16,    48,    18,    50,    60,    52,    21,    54,    84,    56,
    01236       60,    58,    78,    79,    61,    31,    63,    33,    65,    35,
    01237       67,    37,    69,    39,    71,    41,    73,    43,    75,    45,
    01238       28,    29,    48,    78,    50,   103,    52,     5,    54,    16,
    01239       56,    18,    58,    93,     5,    61,    96,    63,     5,    65,
    01240        3,    67,    68,    69,    31,    71,    33,    73,    35,    75,
    01241       37,    60,    39,    60,    41,     3,    43,    80,    45,     3,
    01242        3,    48,    47,    50,     3,    52,     3,    54,     3,    56,
    01243       16,    58,    18,     5,    61,    60,    63,     5,    65,    81,
    01244       67,     3,    69,    70,    71,    31,    73,    33,    75,    35,
    01245        3,    37,    83,    39,   104,    41,     3,    43,     3,    45,
    01246       85,    86,    48,    30,    50,    60,    52,     4,    54,    40,
    01247       56,     6,    58,     5,     6,    61,    16,    63,    18,    65,
    01248        6,    67,    42,    69,    49,    71,    72,    73,    51,    75,
    01249       59,    31,    66,    33,    55,    35,    74,    37,    57,    39,
    01250       64,    41,     3,    43,    17,    45,     5,     6,    48,    16,
    01251       50,    18,    52,     3,    54,     3,    56,    87,    58,     5,
    01252        6,    61,    62,    63,    31,    65,    33,    67,    35,    69,
    01253       37,    71,    39,    73,    41,    75,    43,    76,    45,     3,
    01254       19,    48,     4,    50,     4,    52,    38,    54,    32,    56,
    01255        3,    58,    34,    36,    61,     3,    63,    82,    65,    88,
    01256       67,     5,    69,     3,    71,    10,    73,    89,    75,     3,
    01257       15,    12,    13,    14,     3,    53,     3,    22,     3,     3,
    01258       21,     3,    62,     3,    90,     3,    90,    97,     5,     5,
    01259        3,    91,     3,    21,     3,     3,    91,    99,     5,     5,
    01260        3,    92,    47,     3,     3,     3,    47,    21,     3,     5,
    01261        3,    92,   101,     5,     5,    60,    21,     3,     3,    60,
    01262        3,    98,     3,     5,   100,     3,     5,   102,     3,    80,
    01263      323,    11,   344,   368
    01264 };
    01265
    01266 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
    01267    symbol of state STATE-NUM.  */
    01268 static const yytype_uint8 yystos[] =
    01269 {
    01270        0,    25,   106,   109,    20,   110,     0,    27,   121,     3,
    01271       23,   111,   112,   113,    11,   122,    77,   197,   198,     5,
    01272       26,   112,   115,     3,   123,     8,     9,   107,    47,    60,
    01273      199,   200,     3,    12,    13,    14,    21,    47,    60,   114,
    01274      116,   117,   118,   119,   120,     5,    28,    29,   125,     7,
    01275      108,    78,    79,   201,   202,   246,   247,    60,     3,     3,
    01276        3,     3,    24,     3,    21,   126,    78,    84,   203,    78,
    01277      103,     5,     5,     5,     6,     5,    60,     3,    60,     3,
    01278      204,   205,   206,   249,     3,     3,     3,     3,     3,     5,
    01279       16,    18,    31,    33,    35,    37,    39,    41,    43,    45,
    01280       48,    50,    52,    54,    56,    58,    61,    63,    65,    67,
    01281       69,    71,    73,    75,   127,   128,   130,   132,   134,   136,
    01282      138,   140,   143,   146,   149,   152,   155,   157,   159,   161,
    01283      163,   165,   167,   169,   171,   173,   176,   179,   189,     5,
    01284       80,   205,    81,    47,    60,    85,    86,   248,   250,   251,
    01285      252,     3,   129,   180,   139,   131,   133,   137,   156,   158,
    01286      141,   153,   166,   135,   172,   160,   162,   164,   190,   168,
    01287      170,   147,   144,   150,   174,   177,   124,     3,    83,   207,
    01288      104,     3,     3,   127,   182,   127,   127,   127,   127,   127,
    01289      127,   127,   142,   127,   154,   127,   127,   127,   127,   127,
    01290      127,   193,   127,   127,   127,   148,   127,   145,   127,   151,
    01291       47,    60,   175,    47,    60,   178,    30,    60,     4,    47,
    01292       60,   208,     6,     6,   127,    10,    15,    22,    47,    60,
    01293      181,   183,   184,   186,   188,   127,   127,   127,   127,    40,
    01294       42,    44,   127,    46,   127,    49,    51,   127,    55,    57,
    01295       59,    14,    21,    47,    60,   191,   194,   195,   196,    64,
    01296       66,    68,   127,    70,   127,    72,   127,    74,    76,     3,
    01297       87,   209,   210,     3,     3,    17,     3,     4,     4,    19,
    01298       32,    34,    36,    38,   127,     3,     3,    62,   127,   211,
    01299       82,    88,   222,     5,     6,   187,   185,    53,     5,     6,
    01300        5,   192,    47,    60,    93,    96,   212,   213,   214,   215,
    01301      216,   223,    89,   234,     3,     3,     3,     3,     3,     3,
    01302        3,    62,    90,   217,   218,   219,     3,     3,    47,    60,
    01303       94,    96,   224,   225,   226,   227,   228,   235,    90,   218,
    01304       97,     5,     5,    91,   229,   230,   231,     3,     3,    47,
    01305       60,    95,    96,   236,   237,   238,   239,   240,    21,   220,
    01306        3,     3,    91,   230,    99,     5,     5,    92,   241,   242,
    01307      243,     3,     3,     3,    47,    60,   221,    21,   232,     3,
    01308        3,    92,   242,   101,     5,     5,     5,    98,     3,    47,
    01309       60,   233,    21,   244,     3,     3,     3,     5,   100,     3,
    01310       47,    60,   245,     3,     5,   102,     3
    01311 };
    01312
    01313 #define yyerrok         (yyerrstatus = 0)
    01314 #define yyclearin       (yychar = YYEMPTY)
    01315 #define YYEMPTY         (-2)
    01316 #define YYEOF           0
    01317
    01318 #define YYACCEPT        goto yyacceptlab
    01319 #define YYABORT         goto yyabortlab
    01320 #define YYERROR         goto yyerrorlab
    01321
    01322
    01323 /* Like YYERROR except do call yyerror.  This remains here temporarily
    01324    to ease the transition to the new meaning of YYERROR, for GCC.
    01325    Once GCC version 2 has supplanted version 1, this can go.  */
    01326
    01327 #define YYFAIL          goto yyerrlab
    01328
    01329 #define YYRECOVERING()  (!!yyerrstatus)
    01330
    01331 #define YYBACKUP(Token, Value)                                  \
    01332 do                                                              \
    01333   if (yychar == YYEMPTY && yylen == 1)                          \
    01334     {                                                           \
    01335       yychar = (Token);                                         \
    01336       yylval = (Value);                                         \
    01337       yytoken = YYTRANSLATE (yychar);                           \
    01338       YYPOPSTACK (1);                                           \
    01339       goto yybackup;                                            \
    01340     }                                                           \
    01341   else                                                          \
    01342     {                                                           \
    01343       yyerror (&yylloc, osinstance, parserData, YY_("syntax error: cannot back up")); \
    01344       YYERROR;                                                  \
    01345     }                                                           \
    01346 while (YYID (0))
    01347
    01348
    01349 #define YYTERROR        1
    01350 #define YYERRCODE       256
    01351
    01352
    01353 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
    01354    If N is 0, then set CURRENT to the empty location which ends
    01355    the previous symbol: RHS[0] (always defined).  */
    01356
    01357 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
    01358 #ifndef YYLLOC_DEFAULT
    01359 # define YYLLOC_DEFAULT(Current, Rhs, N)                                \
    01360     do                                                                  \
    01361       if (YYID (N))                                                    \
    01362         {                                                               \
    01363           (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
    01364           (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
    01365           (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
    01366           (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
    01367         }                                                               \
    01368       else                                                              \
    01369         {                                                               \
    01370           (Current).first_line   = (Current).last_line   =              \
    01371             YYRHSLOC (Rhs, 0).last_line;                                \
    01372           (Current).first_column = (Current).last_column =              \
    01373             YYRHSLOC (Rhs, 0).last_column;                              \
    01374         }                                                               \
    01375     while (YYID (0))
    01376 #endif
    01377
    01378
    01379 /* YY_LOCATION_PRINT -- Print the location on the stream.
    01380    This macro was not mandated originally: define only if we know
    01381    we won't break user code: when these are the locations we know.  */
    01382
    01383 #ifndef YY_LOCATION_PRINT
    01384 # if YYLTYPE_IS_TRIVIAL
    01385 #  define YY_LOCATION_PRINT(File, Loc)                  \
    01386      fprintf (File, "%d.%d-%d.%d",                      \
    01387               (Loc).first_line, (Loc).first_column,     \
    01388               (Loc).last_line,  (Loc).last_column)
    01389 # else
    01390 #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
    01391 # endif
    01392 #endif
    01393
    01394
    01395 /* YYLEX -- calling `yylex' with the right arguments.  */
    01396
    01397 #ifdef YYLEX_PARAM
    01398 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
    01399 #else
    01400 # define YYLEX yylex (&yylval, &yylloc, scanner)
    01401 #endif
    01402
    01403 /* Enable debugging if requested.  */
    01404 #if YYDEBUG
    01405
    01406 # ifndef YYFPRINTF
    01407 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
    01408 #  define YYFPRINTF fprintf
    01409 # endif
    01410
    01411 # define YYDPRINTF(Args)                        \
    01412 do {                                            \
    01413   if (yydebug)                                  \
    01414     YYFPRINTF Args;                             \
    01415 } while (YYID (0))
    01416
    01417 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
    01418 do {                                                                      \
    01419   if (yydebug)                                                            \
    01420     {                                                                     \
    01421       YYFPRINTF (stderr, "%s ", Title);                                   \
    01422       yy_symbol_print (stderr,                                            \
    01423                   Type, Value, Location, osinstance, parserData); \
    01424       YYFPRINTF (stderr, "\n");                                           \
    01425     }                                                                     \
    01426 } while (YYID (0))
    01427
    01428
    01429 /*--------------------------------.
    01430 | Print this symbol on YYOUTPUT.  |
    01431 `--------------------------------*/
    01432
    01433 /*ARGSUSED*/
    01434 #if (defined __STDC__ || defined __C99__FUNC__ \
    01435      || defined __cplusplus || defined _MSC_VER)
    01436 static void
    01437 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, OSInstance *osinstance, OSiLParserData *parserData)
    01438 #else
    01439 static void
    01440 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, osinstance, parserData)
    01441     FILE *yyoutput;
    01442     int yytype;
    01443     YYSTYPE const * const yyvaluep;
    01444     YYLTYPE const * const yylocationp;
    01445     OSInstance *osinstance;
    01446     OSiLParserData *parserData;
    01447 #endif
    01448 {
    01449   if (!yyvaluep)
    01450     return;
    01451   YYUSE (yylocationp);
    01452   YYUSE (osinstance);
    01453   YYUSE (parserData);
    01454 # ifdef YYPRINT
    01455   if (yytype < YYNTOKENS)
    01456     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
    01457 # else
    01458   YYUSE (yyoutput);
    01459 # endif
    01460   switch (yytype)
    01461     {
    01462       default:
    01463         break;
    01464     }
    01465 }
    01466
    01467
    01468 /*--------------------------------.
    01469 | Print this symbol on YYOUTPUT.  |
    01470 `--------------------------------*/
    01471
    01472 #if (defined __STDC__ || defined __C99__FUNC__ \
    01473      || defined __cplusplus || defined _MSC_VER)
    01474 static void
    01475 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, OSInstance *osinstance, OSiLParserData *parserData)
    01476 #else
    01477 static void
    01478 yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, osinstance, parserData)
    01479     FILE *yyoutput;
    01480     int yytype;
    01481     YYSTYPE const * const yyvaluep;
    01482     YYLTYPE const * const yylocationp;
    01483     OSInstance *osinstance;
    01484     OSiLParserData *parserData;
    01485 #endif
    01486 {
    01487   if (yytype < YYNTOKENS)
    01488     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
    01489   else
    01490     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
    01491
    01492   YY_LOCATION_PRINT (yyoutput, *yylocationp);
    01493   YYFPRINTF (yyoutput, ": ");
    01494   yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, osinstance, parserData);
    01495   YYFPRINTF (yyoutput, ")");
    01496 }
    01497
    01498 /*------------------------------------------------------------------.
    01499 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
    01500 | TOP (included).                                                   |
    01501 `------------------------------------------------------------------*/
    01502
    01503 #if (defined __STDC__ || defined __C99__FUNC__ \
    01504      || defined __cplusplus || defined _MSC_VER)
    01505 static void
    01506 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
    01507 #else
    01508 static void
    01509 yy_stack_print (yybottom, yytop)
    01510     yytype_int16 *yybottom;
    01511     yytype_int16 *yytop;
    01512 #endif
    01513 {
    01514   YYFPRINTF (stderr, "Stack now");
    01515   for (; yybottom <= yytop; yybottom++)
    01516     {
    01517       int yybot = *yybottom;
    01518       YYFPRINTF (stderr, " %d", yybot);
    01519     }
    01520   YYFPRINTF (stderr, "\n");
    01521 }
    01522
    01523 # define YY_STACK_PRINT(Bottom, Top)                            \
    01524 do {                                                            \
    01525   if (yydebug)                                                  \
    01526     yy_stack_print ((Bottom), (Top));                           \
    01527 } while (YYID (0))
    01528
    01529
    01530 /*------------------------------------------------.
    01531 | Report that the YYRULE is going to be reduced.  |
    01532 `------------------------------------------------*/
    01533
    01534 #if (defined __STDC__ || defined __C99__FUNC__ \
    01535      || defined __cplusplus || defined _MSC_VER)
    01536 static void
    01537 yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, OSInstance *osinstance, OSiLParserData *parserData)
    01538 #else
    01539 static void
    01540 yy_reduce_print (yyvsp, yylsp, yyrule, osinstance, parserData)
    01541     YYSTYPE *yyvsp;
    01542     YYLTYPE *yylsp;
    01543     int yyrule;
    01544     OSInstance *osinstance;
    01545     OSiLParserData *parserData;
    01546 #endif
    01547 {
    01548   int yynrhs = yyr2[yyrule];
    01549   int yyi;
    01550   unsigned long int yylno = yyrline[yyrule];
    01551   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
    01552              yyrule - 1, yylno);
    01553   /* The symbols being reduced.  */
    01554   for (yyi = 0; yyi < yynrhs; yyi++)
    01555     {
    01556       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
    01557       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
    01558                        &(yyvsp[(yyi + 1) - (yynrhs)])
    01559                        , &(yylsp[(yyi + 1) - (yynrhs)])                , osinstance, parserData);
    01560       YYFPRINTF (stderr, "\n");
    01561     }
    01562 }
    01563
    01564 # define YY_REDUCE_PRINT(Rule)          \
    01565 do {                                    \
    01566   if (yydebug)                          \
    01567     yy_reduce_print (yyvsp, yylsp, Rule, osinstance, parserData); \
    01568 } while (YYID (0))
    01569
    01570 /* Nonzero means print parse trace.  It is left uninitialized so that
    01571    multiple parsers can coexist.  */
    01572 int yydebug;
    01573 #else /* !YYDEBUG */
    01574 # define YYDPRINTF(Args)
    01575 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
    01576 # define YY_STACK_PRINT(Bottom, Top)
    01577 # define YY_REDUCE_PRINT(Rule)
    01578 #endif /* !YYDEBUG */
    01579
    01580
    01581 /* YYINITDEPTH -- initial size of the parser's stacks.  */
    01582 #ifndef YYINITDEPTH
    01583 # define YYINITDEPTH 200
    01584 #endif
    01585
    01586 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
    01587    if the built-in stack extension method is used).
    01588
    01589    Do not make this value too large; the results are undefined if
    01590    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
    01591    evaluated with infinite-precision integer arithmetic.  */
    01592
    01593 #ifndef YYMAXDEPTH
    01594 # define YYMAXDEPTH 10000
    01595 #endif
    01596
    01597
    01598
    01599 #if YYERROR_VERBOSE
    01600
    01601 # ifndef yystrlen
    01602 #  if defined __GLIBC__ && defined _STRING_H
    01603 #   define yystrlen strlen
    01604 #  else
    01605 /* Return the length of YYSTR.  */
    01606 #if (defined __STDC__ || defined __C99__FUNC__ \
    01607      || defined __cplusplus || defined _MSC_VER)
    01608 static YYSIZE_T
    01609 yystrlen (const char *yystr)
    01610 #else
    01611 static YYSIZE_T
    01612 yystrlen (yystr)
    01613     const char *yystr;
    01614 #endif
    01615 {
    01616   YYSIZE_T yylen;
    01617   for (yylen = 0; yystr[yylen]; yylen++)
    01618     continue;
    01619   return yylen;
    01620 }
    01621 #  endif
    01622 # endif
    01623
    01624 # ifndef yystpcpy
    01625 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
    01626 #   define yystpcpy stpcpy
    01627 #  else
    01628 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
    01629    YYDEST.  */
    01630 #if (defined __STDC__ || defined __C99__FUNC__ \
    01631      || defined __cplusplus || defined _MSC_VER)
    01632 static char *
    01633 yystpcpy (char *yydest, const char *yysrc)
    01634 #else
    01635 static char *
    01636 yystpcpy (yydest, yysrc)
    01637     char *yydest;
    01638     const char *yysrc;
    01639 #endif
    01640 {
    01641   char *yyd = yydest;
    01642   const char *yys = yysrc;
    01643
    01644   while ((*yyd++ = *yys++) != '\0')
    01645     continue;
    01646
    01647   return yyd - 1;
    01648 }
    01649 #  endif
    01650 # endif
    01651
    01652 # ifndef yytnamerr
    01653 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
    01654    quotes and backslashes, so that it's suitable for yyerror.  The
    01655    heuristic is that double-quoting is unnecessary unless the string
    01656    contains an apostrophe, a comma, or backslash (other than
    01657    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
    01658    null, do not copy; instead, return the length of what the result
    01659    would have been.  */
    01660 static YYSIZE_T
    01661 yytnamerr (char *yyres, const char *yystr)
    01662 {
    01663   if (*yystr == '"')
    01664     {
    01665       YYSIZE_T yyn = 0;
    01666       char const *yyp = yystr;
    01667
    01668       for (;;)
    01669         switch (*++yyp)
    01670           {
    01671           case '\'':
    01672           case ',':
    01673             goto do_not_strip_quotes;
    01674
    01675           case '\\':
    01676             if (*++yyp != '\\')
    01677               goto do_not_strip_quotes;
    01678             /* Fall through.  */
    01679           default:
    01680             if (yyres)
    01681               yyres[yyn] = *yyp;
    01682             yyn++;
    01683             break;
    01684
    01685           case '"':
    01686             if (yyres)
    01687               yyres[yyn] = '\0';
    01688             return yyn;
    01689           }
    01690     do_not_strip_quotes: ;
    01691     }
    01692
    01693   if (! yyres)
    01694     return yystrlen (yystr);
    01695
    01696   return yystpcpy (yyres, yystr) - yyres;
    01697 }
    01698 # endif
    01699
    01700 /* Copy into YYRESULT an error message about the unexpected token
    01701    YYCHAR while in state YYSTATE.  Return the number of bytes copied,
    01702    including the terminating null byte.  If YYRESULT is null, do not
    01703    copy anything; just return the number of bytes that would be
    01704    copied.  As a special case, return 0 if an ordinary "syntax error"
    01705    message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
    01706    size calculation.  */
    01707 static YYSIZE_T
    01708 yysyntax_error (char *yyresult, int yystate, int yychar)
    01709 {
    01710   int yyn = yypact[yystate];
    01711
    01712   if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
    01713     return 0;
    01714   else
    01715     {
    01716       int yytype = YYTRANSLATE (yychar);
    01717       YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
    01718       YYSIZE_T yysize = yysize0;
    01719       YYSIZE_T yysize1;
    01720       int yysize_overflow = 0;
    01721       enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
    01722       char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
    01723       int yyx;
    01724
    01725 # if 0
    01726       /* This is so xgettext sees the translatable formats that are
    01727          constructed on the fly.  */
    01728       YY_("syntax error, unexpected %s");
    01729       YY_("syntax error, unexpected %s, expecting %s");
    01730       YY_("syntax error, unexpected %s, expecting %s or %s");
    01731       YY_("syntax error, unexpected %s, expecting %s or %s or %s");
    01732       YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
    01733 # endif
    01734       char *yyfmt;
    01735       char const *yyf;
    01736       static char const yyunexpected[] = "syntax error, unexpected %s";
    01737       static char const yyexpecting[] = ", expecting %s";
    01738       static char const yyor[] = " or %s";
    01739       char yyformat[sizeof yyunexpected
    01740                     + sizeof yyexpecting - 1
    01741                     + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
    01742                        * (sizeof yyor - 1))];
    01743       char const *yyprefix = yyexpecting;
    01744
    01745       /* Start YYX at -YYN if negative to avoid negative indexes in
    01746          YYCHECK.  */
    01747       int yyxbegin = yyn < 0 ? -yyn : 0;
    01748
    01749       /* Stay within bounds of both yycheck and yytname.  */
    01750       int yychecklim = YYLAST - yyn + 1;
    01751       int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
    01752       int yycount = 1;
    01753
    01754       yyarg[0] = yytname[yytype];
    01755       yyfmt = yystpcpy (yyformat, yyunexpected);
    01756
    01757       for (yyx = yyxbegin; yyx < yyxend; ++yyx)
    01758         if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
    01759           {
    01760             if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
    01761               {
    01762                 yycount = 1;
    01763                 yysize = yysize0;
    01764                 yyformat[sizeof yyunexpected - 1] = '\0';
    01765                 break;
    01766               }
    01767             yyarg[yycount++] = yytname[yyx];
    01768             yysize1 = yysize + yytnamerr (0, yytname[yyx]);
    01769             yysize_overflow |= (yysize1 < yysize);
    01770             yysize = yysize1;
    01771             yyfmt = yystpcpy (yyfmt, yyprefix);
    01772             yyprefix = yyor;
    01773           }
    01774
    01775       yyf = YY_(yyformat);
    01776       yysize1 = yysize + yystrlen (yyf);
    01777       yysize_overflow |= (yysize1 < yysize);
    01778       yysize = yysize1;
    01779
    01780       if (yysize_overflow)
    01781         return YYSIZE_MAXIMUM;
    01782
    01783       if (yyresult)
    01784         {
    01785           /* Avoid sprintf, as that infringes on the user's name space.
    01786              Don't have undefined behavior even if the translation
    01787              produced a string with the wrong number of "%s"s.  */
    01788           char *yyp = yyresult;
    01789           int yyi = 0;
    01790           while ((*yyp = *yyf) != '\0')
    01791             {
    01792               if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
    01793                 {
    01794                   yyp += yytnamerr (yyp, yyarg[yyi++]);
    01795                   yyf += 2;
    01796                 }
    01797               else
    01798                 {
    01799                   yyp++;
    01800                   yyf++;
    01801                 }
    01802             }
    01803         }
    01804       return yysize;
    01805     }
    01806 }
    01807 #endif /* YYERROR_VERBOSE */
    01808
    01809
    01810 /*-----------------------------------------------.
    01811 | Release the memory associated to this symbol.  |
    01812 `-----------------------------------------------*/
    01813
    01814 /*ARGSUSED*/
    01815 #if (defined __STDC__ || defined __C99__FUNC__ \
    01816      || defined __cplusplus || defined _MSC_VER)
    01817 static void
    01818 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, OSInstance *osinstance, OSiLParserData *parserData)
    01819 #else
    01820 static void
    01821 yydestruct (yymsg, yytype, yyvaluep, yylocationp, osinstance, parserData)
    01822     const char *yymsg;
    01823     int yytype;
    01824     YYSTYPE *yyvaluep;
    01825     YYLTYPE *yylocationp;
    01826     OSInstance *osinstance;
    01827     OSiLParserData *parserData;
    01828 #endif
    01829 {
    01830   YYUSE (yyvaluep);
    01831   YYUSE (yylocationp);
    01832   YYUSE (osinstance);
    01833   YYUSE (parserData);
    01834
    01835   if (!yymsg)
    01836     yymsg = "Deleting";
    01837   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
    01838
    01839   switch (yytype)
    01840     {
    01841
    01842       default:
    01843         break;
    01844     }
    01845 }
    01846
    01847 /* Prevent warnings from -Wmissing-prototypes.  */
    01848 #ifdef YYPARSE_PARAM
    01849 #if defined __STDC__ || defined __cplusplus
    01850 int yyparse (void *YYPARSE_PARAM);
    01851 #else
    01852 int yyparse ();
    01853 #endif
    01854 #else /* ! YYPARSE_PARAM */
    01855 #if defined __STDC__ || defined __cplusplus
    01856 int yyparse (OSInstance *osinstance, OSiLParserData *parserData);
    01857 #else
    01858 int yyparse ();
    01859 #endif
    01860 #endif /* ! YYPARSE_PARAM */
    01861
    01862
    01863
    01864
    01865
    01866 /*-------------------------.
    01867 | yyparse or yypush_parse.  |
    01868 `-------------------------*/
    01869
    01870 #ifdef YYPARSE_PARAM
    01871 #if (defined __STDC__ || defined __C99__FUNC__ \
    01872      || defined __cplusplus || defined _MSC_VER)
    01873 int
    01874 yyparse (void *YYPARSE_PARAM)
    01875 #else
    01876 int
    01877 yyparse (YYPARSE_PARAM)
    01878     void *YYPARSE_PARAM;
    01879 #endif
    01880 #else /* ! YYPARSE_PARAM */
    01881 #if (defined __STDC__ || defined __C99__FUNC__ \
    01882      || defined __cplusplus || defined _MSC_VER)
    01883 int
    01884 yyparse (OSInstance *osinstance, OSiLParserData *parserData)
    01885 #else
    01886 int
    01887 yyparse (osinstance, parserData)
    01888     OSInstance *osinstance;
    01889     OSiLParserData *parserData;
    01890 #endif
    01891 #endif
    01892 {
    01893 /* The lookahead symbol.  */
    01894 int yychar;
    01895
    01896 /* The semantic value of the lookahead symbol.  */
    01897 YYSTYPE yylval;
    01898
    01899 /* Location data for the lookahead symbol.  */
    01900 YYLTYPE yylloc;
    01901
    01902     /* Number of syntax errors so far.  */
    01903     int yynerrs;
    01904
    01905     int yystate;
    01906     /* Number of tokens to shift before error messages enabled.  */
    01907     int yyerrstatus;
    01908
    01909     /* The stacks and their tools:
    01910        `yyss': related to states.
    01911        `yyvs': related to semantic values.
    01912        `yyls': related to locations.
    01913
    01914        Refer to the stacks thru separate pointers, to allow yyoverflow
    01915        to reallocate them elsewhere.  */
    01916
    01917     /* The state stack.  */
    01918     yytype_int16 yyssa[YYINITDEPTH];
    01919     yytype_int16 *yyss;
    01920     yytype_int16 *yyssp;
    01921
    01922     /* The semantic value stack.  */
    01923     YYSTYPE yyvsa[YYINITDEPTH];
    01924     YYSTYPE *yyvs;
    01925     YYSTYPE *yyvsp;
    01926
    01927     /* The location stack.  */
    01928     YYLTYPE yylsa[YYINITDEPTH];
    01929     YYLTYPE *yyls;
    01930     YYLTYPE *yylsp;
    01931
    01932     /* The locations where the error started and ended.  */
    01933     YYLTYPE yyerror_range[2];
    01934
    01935     YYSIZE_T yystacksize;
    01936
    01937   int yyn;
    01938   int yyresult;
    01939   /* Lookahead token as an internal (translated) token number.  */
    01940   int yytoken;
    01941   /* The variables used to return semantic value and location from the
    01942      action routines.  */
    01943   YYSTYPE yyval;
    01944   YYLTYPE yyloc;
    01945
    01946 #if YYERROR_VERBOSE
    01947   /* Buffer for error messages, and its allocated size.  */
    01948   char yymsgbuf[128];
    01949   char *yymsg = yymsgbuf;
    01950   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
    01951 #endif
    01952
    01953 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
    01954
    01955   /* The number of symbols on the RHS of the reduced rule.
    01956      Keep to zero when no symbol should be popped.  */
    01957   int yylen = 0;
    01958
    01959   yytoken = 0;
    01960   yyss = yyssa;
    01961   yyvs = yyvsa;
    01962   yyls = yylsa;
    01963   yystacksize = YYINITDEPTH;
    01964
    01965   YYDPRINTF ((stderr, "Starting parse\n"));
    01966
    01967   yystate = 0;
    01968   yyerrstatus = 0;
    01969   yynerrs = 0;
    01970   yychar = YYEMPTY; /* Cause a token to be read.  */
    01971
    01972   /* Initialize stack pointers.
    01973      Waste one element of value and location stack
    01974      so that they stay on the same level as the state stack.
    01975      The wasted elements are never initialized.  */
    01976   yyssp = yyss;
    01977   yyvsp = yyvs;
    01978   yylsp = yyls;
    01979
    01980 #if YYLTYPE_IS_TRIVIAL
    01981   /* Initialize the default location before parsing starts.  */
    01982   yylloc.first_line   = yylloc.last_line   = 1;
    01983   yylloc.first_column = yylloc.last_column = 1;
    01984 #endif
    01985
    01986   goto yysetstate;
    01987
    01988 /*------------------------------------------------------------.
    01989 | yynewstate -- Push a new state, which is found in yystate.  |
    01990 `------------------------------------------------------------*/
    01991  yynewstate:
    01992   /* In all cases, when you get here, the value and location stacks
    01993      have just been pushed.  So pushing a state here evens the stacks.  */
    01994   yyssp++;
    01995
    01996  yysetstate:
    01997   *yyssp = yystate;
    01998
    01999   if (yyss + yystacksize - 1 <= yyssp)
    02000     {
    02001       /* Get the current used size of the three stacks, in elements.  */
    02002       YYSIZE_T yysize = yyssp - yyss + 1;
    02003
    02004 #ifdef yyoverflow
    02005       {
    02006         /* Give user a chance to reallocate the stack.  Use copies of
    02007            these so that the &'s don't force the real ones into
    02008            memory.  */
    02009         YYSTYPE *yyvs1 = yyvs;
    02010         yytype_int16 *yyss1 = yyss;
    02011         YYLTYPE *yyls1 = yyls;
    02012
    02013         /* Each stack pointer address is followed by the size of the
    02014            data in use in that stack, in bytes.  This used to be a
    02015            conditional around just the two extra args, but that might
    02016            be undefined if yyoverflow is a macro.  */
    02017         yyoverflow (YY_("memory exhausted"),
    02018                     &yyss1, yysize * sizeof (*yyssp),
    02019                     &yyvs1, yysize * sizeof (*yyvsp),
    02020                     &yyls1, yysize * sizeof (*yylsp),
    02021                     &yystacksize);
    02022
    02023         yyls = yyls1;
    02024         yyss = yyss1;
    02025         yyvs = yyvs1;
    02026       }
    02027 #else /* no yyoverflow */
    02028 # ifndef YYSTACK_RELOCATE
    02029       goto yyexhaustedlab;
    02030 # else
    02031       /* Extend the stack our own way.  */
    02032       if (YYMAXDEPTH <= yystacksize)
    02033         goto yyexhaustedlab;
    02034       yystacksize *= 2;
    02035       if (YYMAXDEPTH < yystacksize)
    02036         yystacksize = YYMAXDEPTH;
    02037
    02038       {
    02039         yytype_int16 *yyss1 = yyss;
    02040         union yyalloc *yyptr =
    02041           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
    02042         if (! yyptr)
    02043           goto yyexhaustedlab;
    02044         YYSTACK_RELOCATE (yyss_alloc, yyss);
    02045         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
    02046         YYSTACK_RELOCATE (yyls_alloc, yyls);
    02047 #  undef YYSTACK_RELOCATE
    02048         if (yyss1 != yyssa)
    02049           YYSTACK_FREE (yyss1);
    02050       }
    02051 # endif
    02052 #endif /* no yyoverflow */
    02053
    02054       yyssp = yyss + yysize - 1;
    02055       yyvsp = yyvs + yysize - 1;
    02056       yylsp = yyls + yysize - 1;
    02057
    02058       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
    02059                   (unsigned long int) yystacksize));
    02060
    02061       if (yyss + yystacksize - 1 <= yyssp)
    02062         YYABORT;
    02063     }
    02064
    02065   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
    02066
    02067   if (yystate == YYFINAL)
    02068     YYACCEPT;
    02069
    02070   goto yybackup;
    02071
    02072 /*-----------.
    02073 | yybackup.  |
    02074 `-----------*/
    02075 yybackup:
    02076
    02077   /* Do appropriate processing given the current state.  Read a
    02078      lookahead token if we need one and don't already have one.  */
    02079
    02080   /* First try to decide what to do without reference to lookahead token.  */
    02081   yyn = yypact[yystate];
    02082   if (yyn == YYPACT_NINF)
    02083     goto yydefault;
    02084
    02085   /* Not known => get a lookahead token if don't already have one.  */
    02086
    02087   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
    02088   if (yychar == YYEMPTY)
    02089     {
    02090       YYDPRINTF ((stderr, "Reading a token: "));
    02091       yychar = YYLEX;
    02092     }
    02093
    02094   if (yychar <= YYEOF)
    02095     {
    02096       yychar = yytoken = YYEOF;
    02097       YYDPRINTF ((stderr, "Now at end of input.\n"));
    02098     }
    02099   else
    02100     {
    02101       yytoken = YYTRANSLATE (yychar);
    02102       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
    02103     }
    02104
    02105   /* If the proper action on seeing token YYTOKEN is to reduce or to
    02106      detect an error, take that action.  */
    02107   yyn += yytoken;
    02108   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
    02109     goto yydefault;
    02110   yyn = yytable[yyn];
    02111   if (yyn <= 0)
    02112     {
    02113       if (yyn == 0 || yyn == YYTABLE_NINF)
    02114         goto yyerrlab;
    02115       yyn = -yyn;
    02116       goto yyreduce;
    02117     }
    02118
    02119   /* Count tokens shifted since error; after three, turn off error
    02120      status.  */
    02121   if (yyerrstatus)
    02122     yyerrstatus--;
    02123
    02124   /* Shift the lookahead token.  */
    02125   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
    02126
    02127   /* Discard the shifted token.  */
    02128   yychar = YYEMPTY;
    02129
    02130   yystate = yyn;
    02131   *++yyvsp = yylval;
    02132   *++yylsp = yylloc;
    02133   goto yynewstate;
    02134
    02135
    02136 /*-----------------------------------------------------------.
    02137 | yydefault -- do the default action for the current state.  |
    02138 `-----------------------------------------------------------*/
    02139 yydefault:
    02140   yyn = yydefact[yystate];
    02141   if (yyn == 0)
    02142     goto yyerrlab;
    02143   goto yyreduce;
    02144
    02145
    02146 /*-----------------------------.
    02147 | yyreduce -- Do a reduction.  |
    02148 `-----------------------------*/
    02149 yyreduce:
    02150   /* yyn is the number of a rule to reduce with.  */
    02151   yylen = yyr2[yyn];
    02152
    02153   /* If YYLEN is nonzero, implement the default value of the action:
    02154      `$$ = $1'.
    02155
    02156      Otherwise, the following line sets YYVAL to garbage.
    02157      This behavior is undocumented and Bison
    02158      users should not rely upon it.  Assigning to YYVAL
    02159      unconditionally makes the parser a bit smaller, and it avoids a
    02160      GCC warning that YYVAL may be used uninitialized.  */
    02161   yyval = yyvsp[1-yylen];
    02162
    02163   /* Default location.  */
    02164   YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
    02165   YY_REDUCE_PRINT (yyn);
    02166   switch (yyn)
    02167     {
    02168         case 6:
    02169
    02170     {   osilerror( NULL, osinstance, parserData, "unexpected end of file, expecting </osil>");}
    02171     break;
    02172
    02173   case 8:
    02174
    02175     {if(osinstance->instanceData->quadraticCoefficients->numberOfQuadraticTerms > parserData->qtermcount )
    02176         osilerror( NULL, osinstance, parserData, "actual number of qterms less than numberOfQuadraticTerms");}
    02177     break;
    02178
    02179   case 9:
    02180
    02181     {
    02182 if ( *(yyvsp[(2) - (5)].sval) != *(yyvsp[(4) - (5)].sval) ) osilerror( NULL, osinstance, parserData, "start and end quotes are not the same");
    02183 osinstance->instanceData->quadraticCoefficients->numberOfQuadraticTerms = (yyvsp[(3) - (5)].ival);
    02184 if(osinstance->instanceData->quadraticCoefficients->numberOfQuadraticTerms > 0 )
    02185 osinstance->instanceData->quadraticCoefficients->qTerm = new QuadraticTerm*[ (yyvsp[(3) - (5)].ival) ];
    02186 for(int i = 0; i < (yyvsp[(3) - (5)].ival); i++) osinstance->instanceData->quadraticCoefficients->qTerm[i] = new QuadraticTerm();}
    02187     break;
    02188
    02189   case 12:
    02190
    02191     {
    02192         parserData->qtermcount++;
    02193         if(!parserData->qtermidxattON)  osilerror( NULL, osinstance, parserData, "the qTerm attribute idx is required");
    02194         if(!parserData->qtermidxOneattON)  osilerror( NULL, osinstance, parserData, "the qTerm attribute idxOne is required");
    02195         if(!parserData->qtermidxTwoattON)  osilerror( NULL, osinstance, parserData, "the qTerm attribute idxTwo is required");
    02196         parserData->qtermidattON = false;
    02197         parserData->qtermidxattON = false;
    02198         parserData->qtermidxOneattON = false;
    02199         parserData->qtermidxTwoattON = false;
    02200         parserData->qtermcoefattON = false;
    02201 }
    02202     break;
    02203
    02204   case 13:
    02205
    02206     {
    02207         if(osinstance->instanceData->quadraticCoefficients->numberOfQuadraticTerms <= parserData->qtermcount )
    02208         osilerror( NULL, osinstance, parserData, "too many QuadraticTerms");
    02209 }
    02210     break;
    02211
    02212   case 18:
    02213
    02214     { if(parserData->qtermidxOneattON) osilerror( NULL, osinstance, parserData, "too many qTerm idxOne attributes");
    02215                         parserData->qtermidxOneattON = true;  }
    02216     break;
    02217
    02218   case 19:
    02219
    02220     { if(parserData->qtermidxTwoattON) osilerror( NULL, osinstance, parserData, "too many qTerm idxTwo attributes");
    02221                         parserData->qtermidxTwoattON = true;  }
    02222     break;
    02223
    02224   case 20:
    02225
    02226     { if(parserData->qtermcoefattON) osilerror( NULL, osinstance, parserData, "too many qTerm coef attributes");
    02227                         parserData->qtermcoefattON = true;  }
    02228     break;
    02229
    02230   case 21:
    02231
    02232     { if(parserData->qtermidxattON) osilerror( NULL, osinstance, parserData, "too many qTerm idx attributes");
    02233                         parserData->qtermidxattON = true;  }
    02234     break;
    02235
    02236   case 22:
    02237
    02238     {  if ( *(yyvsp[(2) - (4)].sval) != *(yyvsp[(4) - (4)].sval) ) osilerror( NULL, osinstance, parserData, "start and end quotes are not the same");
    02239 osinstance->instanceData->quadraticCoefficients->qTerm[parserData->qtermcount]->idxOne = (yyvsp[(3) - (4)].ival);
    02240         if( (yyvsp[(3) - (4)].ival) >= osinstance->instanceData->variables->numberOfVariables){
    02241                 osilerror( NULL, osinstance, parserData, "variable index exceeds number of variables");
    02242          }
    02243 }
    02244     break;
    02245
    02246   case 23:
    02247
    02248     { if ( *(yyvsp[(2) - (4)].sval) != *(yyvsp[(4) - (4)].sval) ) osilerror( NULL, osinstance, parserData, "start and end quotes are not the same");
    02249 osinstance->instanceData->quadraticCoefficients->qTerm[parserData->qtermcount]->idxTwo = (yyvsp[(3) - (4)].ival);
    02250         if( (yyvsp[(3) - (4)].ival) >= osinstance->instanceData->variables->numberOfVariables){
    02251                 osilerror( NULL, osinstance, parserData, "variable index exceeds number of variables");
    02252          }
    02253 }
    02254     break;
    02255
    02256   case 24:
    02257
    02258     {if ( *(yyvsp[(2) - (4)].sval) != *(yyvsp[(4) - (4)].sval) ) osilerror( NULL, osinstance, parserData, "start and end quotes are not the same");
    02259 osinstance->instanceData->quadraticCoefficients->qTerm[parserData->qtermcount]->coef = (yyvsp[(3) - (4)].dval);}
    02260     break;
    02261
    02262   case 25:
    02263
    02264     {
    02265 osinstance->instanceData->quadraticCoefficients->qTerm[parserData->qtermcount]->coef = (yyvsp[(3) - (4)].ival);}
    02266     break;
    02267
    02268   case 26:
    02269
    02270     {  if ( *(yyvsp[(2) - (4)].sval) != *(yyvsp[(4) - (4)].sval) ) osilerror( NULL, osinstance, parserData, "start and end quotes are not the same");
    02271 osinstance->instanceData->quadraticCoefficients->qTerm[parserData->qtermcount]->idx = (yyvsp[(3) - (4)].ival);}
    02272     break;
    02273
    02274   case 28:
    02275
    02276     {  if(parserData->nlnodecount <  parserData->tmpnlcount)  osilerror( NULL, osinstance, parserData, "actual number of nl terms less than number attribute");   }
    02277     break;
    02278
    02279   case 29:
    02280
    02281     { if ( *(yyvsp[(2) - (5)].sval) != *(yyvsp[(4) - (5)].sval) ) osilerror( NULL, osinstance, parserData, "start and end quotes are not the same");
    02282 parserData->tmpnlcount = (yyvsp[(3) - (5)].ival);
    02283 osinstance->instanceData->nonlinearExpressions->numberOfNonlinearExpressions = (yyvsp[(3) - (5)].ival);
    02284 if(osinstance->instanceData->nonlinearExpressions->numberOfNonlinearExpressions > 0 ) osinstance->instanceData->nonlinearExpressions->nl = new Nl*[ (yyvsp[(3) - (5)].ival) ];
    02285 for(int i = 0; i < osinstance->instanceData->nonlinearExpressions->numberOfNonlinearExpressions; i++){
    02286         osinstance->instanceData->nonlinearExpressions->nl[ i] = new Nl();
    02287 }
    02288 }
    02289     break;
    02290
    02291   case 31:
    02292
    02293     {
    02294         // IMPORTANT -- HERE IS WHERE WE CREATE THE EXPRESSION TREE
    02295         osinstance->instanceData->nonlinearExpressions->nl[ parserData->nlnodecount]->osExpressionTree->m_treeRoot =
    02296         parserData->nlNodeVec[ 0]->createExpressionTreeFromPrefix( parserData->nlNodeVec);
    02297         parserData->nlnodecount++;
    02298 }
    02299     break;
    02300
    02301   case 33:
    02302
    02303     {
    02304         if(parserData->nlnodecount >= parserData->tmpnlcount) osilerror( NULL, osinstance, parserData, "actual number of nl terms greater than number attribute");
    02305 }
    02306     break;
    02307
    02308   case 34:
    02309
    02310     { if ( *(yyvsp[(2) - (4)].sval) != *(yyvsp[(4) - (4)].sval) ) osilerror( NULL, osinstance, parserData, "start and end quotes are not the same");
    02311 //osinstance->instanceData->nonlinearExpressions->nl[ parserData->nlnodecount] = new Nl();
    02312 osinstance->instanceData->nonlinearExpressions->nl[ parserData->nlnodecount]->idx = (yyvsp[(3) - (4)].ival);
    02313 osinstance->instanceData->nonlinearExpressions->nl[ parserData->nlnodecount]->osExpressionTree = new OSExpressionTree();
    02314 // clear the vectors of pointers
    02315 parserData->nlNodeVec.clear();
    02316 parserData->sumVec.clear();
    02317 //parserData->allDiffVec.clear();
    02318 parserData->maxVec.clear();
    02319 parserData->minVec.clear();
    02320 parserData->productVec.clear();
    02321 }
    02322     break;
    02323
    02324   case 59:
    02325
    02326     {
    02327         parserData->nlNodePoint = new OSnLNodeTimes();
    02328         parserData->nlNodeVec.push_back( parserData->nlNodePoint);
    02329 }
    02330     break;
    02331
    02332   case 61:
    02333
    02334     {
    02335         parserData->nlNodePoint = new OSnLNodePlus();
    02336         parserData->nlNodeVec.push_back( parserData->nlNodePoint);
    02337 }
    02338     break;
    02339
    02340   case 63:
    02341
    02342     {
    02343         parserData->nlNodePoint = new OSnLNodeMinus();
    02344         parserData->nlNodeVec.push_back( parserData->nlNodePoint);
    02345 }
    02346     break;
    02347
    02348   case 65:
    02349
    02350     {
    02351         parserData->nlNodePoint = new OSnLNodeNegate();
    02352         parserData->nlNodeVec.push_back( parserData->nlNodePoint);
    02353 }
    02354     break;
    02355
    02356   case 67:
    02357
    02358     {
    02359         parserData->nlNodePoint = new OSnLNodeDivide();
    02360         parserData->nlNodeVec.push_back( parserData->nlNodePoint);
    02361 }
    02362     break;
    02363
    02364   case 69:
    02365
    02366     {
    02367         parserData->nlNodePoint = new OSnLNodePower();
    02368         parserData->nlNodeVec.push_back( parserData->nlNodePoint);
    02369 }
    02370     break;
    02371
    02372   case 71:
    02373
    02374     {
    02375         parserData->nlNodePoint = new OSnLNodeSum();
    02376         parserData->nlNodeVec.push_back( parserData->nlNodePoint);
    02377         parserData->sumVec.push_back( parserData->nlNodePoint);
    02378 }
    02379     break;
    02380
    02381   case 72:
    02382
    02383     {
    02384         parserData->sumVec.back()->m_mChildren = new OSnLNode*[ parserData->sumVec.back()->inumberOfChildren];
    02385         parserData->sumVec.pop_back();
    02386 }
    02387     break;
    02388
    02389   case 73:
    02390
    02391     {   parserData->sumVec.back()->inumberOfChildren++; }
    02392     break;
    02393
    02394   case 74:
    02395
    02396     {   parserData->sumVec.back()->inumberOfChildren++; }
    02397     break;
    02398
    02399   case 75:
    02400
    02401     {
    02402
    02403         parserData->nlNodePoint =   new OSnLNodeAllDiff ();
    02404         parserData->nlNodeVec.push_back( parserData->nlNodePoint);
    02405         parserData->allDiffVec.push_back( parserData->nlNodePoint);
    02406 }
    02407     break;
    02408
    02409   case 76:
    02410
    02411     {
    02412         parserData->allDiffVec.back()->m_mChildren = new OSnLNode*[ parserData->allDiffVec.back()->inumberOfChildren];
    02413         parserData->allDiffVec.pop_back();
    02414         osinstance->instanceData->nonlinearExpressions->nl[ parserData->nlnodecount]->osExpressionTree->bADMustReTape = true;
    02415 }
    02416     break;
    02417
    02418   case 77:
    02419
    02420     {   parserData->allDiffVec.back()->inumberOfChildren++; }
    02421     break;
    02422
    02423   case 78:
    02424
    02425     {   parserData->allDiffVec.back()->inumberOfChildren++; }
    02426     break;
    02427
    02428   case 79:
    02429
    02430     {
    02431         parserData->nlNodePoint = new OSnLNodeMax();
    02432         parserData->nlNodeVec.push_back( parserData->nlNodePoint);
    02433         parserData->maxVec.push_back( parserData->nlNodePoint);
    02434 }
    02435     break;
    02436
    02437   case 80:
    02438
    02439     {
    02440         parserData->maxVec.back()->m_mChildren = new OSnLNode*[ parserData->maxVec.back()->inumberOfChildren];
    02441         parserData->maxVec.pop_back();
    02442         osinstance->instanceData->nonlinearExpressions->nl[ parserData->nlnodecount]->osExpressionTree->bADMustReTape = true;
    02443 }
    02444     break;
    02445
    02446   case 81:
    02447
    02448     {   parserData->maxVec.back()->inumberOfChildren++; }
    02449     break;
    02450
    02451   case 82:
    02452
    02453     {   parserData->maxVec.back()->inumberOfChildren++; }
    02454     break;
    02455
    02456   case 83:
    02457
    02458     {
    02459         parserData->nlNodePoint = new OSnLNodeMin();
    02460         parserData->nlNodeVec.push_back( parserData->nlNodePoint);
    02461         parserData->minVec.push_back( parserData->nlNodePoint);
    02462 }
    02463     break;
    02464
    02465   case 84:
    02466
    02467     {
    02468         parserData->minVec.back()->m_mChildren = new OSnLNode*[ parserData->minVec.back()->inumberOfChildren];
    02469         parserData->minVec.pop_back();
    02470         osinstance->instanceData->nonlinearExpressions->nl[ parserData->nlnodecount]->osExpressionTree->bADMustReTape = true;
    02471 }
    02472     break;
    02473
    02474   case 85:
    02475
    02476     {   parserData->minVec.back()->inumberOfChildren++; }
    02477     break;
    02478
    02479   case 86:
    02480
    02481     {   parserData->minVec.back()->inumberOfChildren++; }
    02482     break;
    02483
    02484   case 87:
    02485
    02486     {
    02487         parserData->nlNodePoint = new OSnLNodeProduct();
    02488         parserData->nlNodeVec.push_back( parserData->nlNodePoint);
    02489         parserData->productVec.push_back( parserData->nlNodePoint);
    02490 }
    02491     break;
    02492
    02493   case 88:
    02494
    02495     {
    02496         parserData->productVec.back()->m_mChildren = new OSnLNode*[ parserData->productVec.back()->inumberOfChildren];
    02497         parserData->productVec.pop_back();
    02498 }
    02499     break;
    02500
    02501   case 89:
    02502
    02503     {   parserData->productVec.back()->inumberOfChildren++; }
    02504     break;
    02505
    02506   case 90:
    02507
    02508     {   parserData->productVec.back()->inumberOfChildren++; }
    02509     break;
    02510
    02511   case 91:
    02512
    02513     {
    02514         parserData->nlNodePoint = new OSnLNodeLn();
    02515         parserData->nlNodeVec.push_back( parserData->nlNodePoint);
    02516 }
    02517     break;
    02518
    02519   case 93:
    02520
    02521     {
    02522         parserData->nlNodePoint = new OSnLNodeSqrt();
    02523         parserData->nlNodeVec.push_back( parserData->nlNodePoint);
    02524 }
    02525     break;
    02526
    02527   case 95:
    02528
    02529     {
    02530         parserData->nlNodePoint = new OSnLNodeSquare();
    02531         parserData->nlNodeVec.push_back( parserData->nlNodePoint);
    02532 }
    02533     break;
    02534
    02535   case 97:
    02536
    02537     {
    02538         parserData->nlNodePoint = new OSnLNodeCos();
    02539         parserData->nlNodeVec.push_back( parserData->nlNodePoint);
    02540 }
    02541     break;
    02542
    02543   case 99:
    02544
    02545     {
    02546         parserData->nlNodePoint = new OSnLNodeSin();
    02547         parserData->nlNodeVec.push_back( parserData->nlNodePoint);
    02548 }
    02549     break;
    02550
    02551   case 101:
    02552
    02553     {
    02554         parserData->nlNodePoint = new OSnLNodeExp();
    02555         parserData->nlNodeVec.push_back( parserData->nlNodePoint);
    02556 }
    02557     break;
    02558
    02559   case 103:
    02560
    02561     {
    02562         parserData->nlNodePoint = new OSnLNodeAbs();
    02563         parserData->nlNodeVec.push_back( parserData->nlNodePoint);
    02564 }
    02565     break;
    02566
    02567   case 104:
    02568
    02569     {
    02570 osinstance->instanceData->nonlinearExpressions->nl[ parserData->nlnodecount]->osExpressionTree->bADMustReTape = true;
    02571 }
    02572     break;
    02573
    02574   case 105:
    02575
    02576     {
    02577         parserData->nlNodePoint = new OSnLNodeErf();
    02578         parserData->nlNodeVec.push_back( parserData->nlNodePoint);
    02579 }
    02580     break;
    02581
    02582   case 106:
    02583
    02584     {
    02585 //osinstance->instanceData->nonlinearExpressions->nl[ parserData->nlnodecount]->osExpressionTree->bADMustReTape = true;
    02586 }
    02587     break;
    02588
    02589   case 107:
    02590
    02591     {
    02592         parserData->nlNodePoint = new OSnLNodeIf();
    02593         parserData->nlNodeVec.push_back( parserData->nlNodePoint);
    02594 }
    02595     break;
    02596
    02597   case 108:
    02598
    02599     {
    02600 osinstance->instanceData->nonlinearExpressions->nl[ parserData->nlnodecount]->osExpressionTree->bADMustReTape = true;
    02601 }
    02602     break;
    02603
    02604   case 109:
    02605
    02606     {   parserData->nlNodePoint = new OSnLNodeE();
    02607         parserData->nlNodeVec.push_back( parserData->nlNodePoint);}
    02608     break;
    02609
    02610   case 113:
    02611
    02612     {   parserData->nlNodePoint = new OSnLNodePI();
    02613         parserData->nlNodeVec.push_back( parserData->nlNodePoint);}
    02614     break;
    02615
    02616   case 117:
    02617
    02618     {
    02619         parserData->nlNodeNumberPoint = new OSnLNodeNumber();
    02620         parserData->nlNodeVec.push_back( parserData->nlNodeNumberPoint);
    02621 }
    02622     break;
    02623
    02624   case 118:
    02625
    02626     {parserData->numbervalueattON = false; parserData->numbertypeattON = false; parserData->numberidattON = false;}
    02627     break;
    02628
    02629   case 123:
    02630
    02631     {if(parserData->numbertypeattON) osilerror( NULL, osinstance, parserData, "too many number type attributes");
    02632                         parserData->numbertypeattON = true; }
    02633     break;
    02634
    02635   case 124:
    02636
    02637     {if(parserData->numbervalueattON) osilerror( NULL, osinstance, parserData, "too many number value attributes");
    02638                         parserData->numbervalueattON = true; }
    02639     break;
    02640
    02641   case 125:
    02642
    02643     {if(parserData->numberidattON) osilerror( NULL, osinstance, parserData,"too many number id attributes");
    02644                         parserData->numberidattON = true; }
    02645     break;
    02646
    02647   case 126:
    02648
    02649     {
    02650         parserData->nlNodeNumberPoint->type = (yyvsp[(2) - (2)].sval);
    02651 }
    02652     break;
    02653
    02654   case 128:
    02655
    02656     {
    02657         parserData->nlNodeNumberPoint->id = (yyvsp[(2) - (2)].sval);
    02658 }
    02659     break;
    02660
    02661   case 130:
    02662
    02663     {if ( *(yyvsp[(2) - (4)].sval) != *(yyvsp[(4) - (4)].sval) ) osilerror( NULL, osinstance, parserData, "start and end quotes are not the same");
    02664         parserData->nlNodeNumberPoint->value = (yyvsp[(3) - (4)].dval);
    02665 }
    02666     break;
    02667
    02668   case 131:
    02669
    02670     {if ( *(yyvsp[(2) - (4)].sval) != *(yyvsp[(4) - (4)].sval) ) osilerror( NULL, osinstance, parserData, "start and end quotes are not the same");
    02671         parserData->nlNodeNumberPoint->value = (yyvsp[(3) - (4)].ival);
    02672 }
    02673     break;
    02674
    02675   case 132:
    02676
    02677     {
    02678         parserData->nlNodeVariablePoint = new OSnLNodeVariable();
    02679         parserData->nlNodeVec.push_back( parserData->nlNodeVariablePoint);
    02680 }
    02681     break;
    02682
    02683   case 133:
    02684
    02685     {parserData->variablecoefattON = false; parserData->variableidxattON = false;}
    02686     break;
    02687
    02688   case 135:
    02689
    02690     {
    02691         parserData->nlNodeVariablePoint->inumberOfChildren = 1;
    02692         parserData->nlNodeVariablePoint->m_mChildren = new OSnLNode*[ 1];
    02693 }
    02694     break;
    02695
    02696   case 140:
    02697
    02698     {if(parserData->variablecoefattON) osilerror( NULL, osinstance, parserData, "too many variable coef attributes");
    02699                         parserData->variablecoefattON = true; }
    02700     break;
    02701
    02702   case 141:
    02703
    02704     {if(parserData->variableidxattON) osilerror( NULL, osinstance, parserData, "too many variable idx attributes");
    02705                         parserData->variableidxattON = true;
    02706                         }
    02707     break;
    02708
    02709   case 142:
    02710
    02711     { if ( *(yyvsp[(2) - (4)].sval) != *(yyvsp[(4) - (4)].sval) ) osilerror( NULL, osinstance, parserData, "start and end quotes are not the same");
    02712         parserData->nlNodeVariablePoint->coef = (yyvsp[(3) - (4)].dval);
    02713 }
    02714     break;
    02715
    02716   case 143:
    02717
    02718     { if ( *(yyvsp[(2) - (4)].sval) != *(yyvsp[(4) - (4)].sval) ) osilerror( NULL, osinstance, parserData, "start and end quotes are not the same");
    02719         parserData->nlNodeVariablePoint->coef = (yyvsp[(3) - (4)].ival);
    02720 }
    02721     break;
    02722
    02723   case 144:
    02724
    02725     { if ( *(yyvsp[(2) - (4)].sval) != *(yyvsp[(4) - (4)].sval) ) osilerror( NULL, osinstance, parserData, "start and end quotes are not the same");
    02726         parserData->nlNodeVariablePoint->idx = (yyvsp[(3) - (4)].ival);
    02727         if( (yyvsp[(3) - (4)].ival) >= osinstance->instanceData->variables->numberOfVariables){
    02728                 osilerror( NULL, osinstance, parserData, "variable index exceeds number of variables");
    02729          }
    02730 }
    02731     break;
    02732
    02733   case 147:
    02734
    02735     {osinstance->instanceData->timeDomain = new TimeDomain();}
    02736     break;
    02737
    02738   case 154:
    02739
    02740     {
    02741         if( osinstance->instanceData->timeDomain->stages->numberOfStages > parserData->stagecount )
    02742                 osilerror( NULL, osinstance, parserData, "actual number of stages less than numberOfStages");
    02743  /* After stages have been processed, make sure that all variables and constraints have been assigned
    02744   * to a stage (uniquely) and all objectives have been assigned as well (possibly more than once).
    02745   * For future reference also record the stage to which each variable and constraint belongs.
    02746   */
    02747         parserData->m_miVarStageInfo = new int [ osinstance->instanceData->variables->numberOfVariables ];
    02748         parserData->m_miObjStageInfo = new int [ osinstance->instanceData->objectives->numberOfObjectives ];
    02749         parserData->m_miConStageInfo = new int [ osinstance->instanceData->constraints->numberOfConstraints ];
    02750         parserData->nvarcovered = 0;
    02751         for (int i = 0; i < osinstance->instanceData->variables->numberOfVariables; i++)
    02752                  parserData->m_miVarStageInfo[i] = -1;
    02753         for (int i = 0; i < osinstance->instanceData->objectives->numberOfObjectives; i++)
    02754                  parserData->m_miObjStageInfo[i] = -1;
    02755         for (int i = 0; i < osinstance->instanceData->constraints->numberOfConstraints; i++)
    02756                  parserData->m_miConStageInfo[i] = -1;
    02757         for (int k = 0; k < osinstance->instanceData->timeDomain->stages->numberOfStages; k++)
    02758                 {for (int i = 0; i < osinstance->instanceData->timeDomain->stages->stage[k]->variables->numberOfVariables; i++)
    02759                         {
    02760                         if (parserData->m_miVarStageInfo[ osinstance->instanceData->timeDomain->stages->stage[k]->variables->var[i]->idx ] != -1)
    02761                                         osilerror (NULL, osinstance, parserData, "variable belongs to two stages");
    02762                                 parserData->m_miVarStageInfo[ osinstance->instanceData->timeDomain->stages->stage[k]->variables->var[i]->idx ] = k;
    02763                         };
    02764                  parserData->nvarcovered += osinstance->instanceData->timeDomain->stages->stage[k]->variables->numberOfVariables;
    02765                 };
    02766         if (parserData->nvarcovered != osinstance->instanceData->variables->numberOfVariables)
    02767                 osilerror (NULL, osinstance, parserData, "some variables not assigned to any stage");
    02768         parserData->nconcovered = 0;
    02769         for (int k = 0; k < osinstance->instanceData->timeDomain->stages->numberOfStages; k++)
    02770                 {for (int i = 0; i < osinstance->instanceData->timeDomain->stages->stage[k]->constraints->numberOfConstraints; i++)
    02771                         {if (parserData->m_miConStageInfo[ osinstance->instanceData->timeDomain->stages->stage[k]->constraints->con[i]->idx ] != -1)
    02772                                 osilerror (NULL, osinstance, parserData, "constraint belongs to two stages");
    02773                                  parserData->m_miConStageInfo[ osinstance->instanceData->timeDomain->stages->stage[k]->constraints->con[i]->idx ] = k;
    02774                         };
    02775                  parserData->nconcovered += osinstance->instanceData->timeDomain->stages->stage[k]->constraints->numberOfConstraints;
    02776                 };
    02777         if (parserData->nconcovered != osinstance->instanceData->constraints->numberOfConstraints)
    02778                 osilerror (NULL, osinstance, parserData, "some constraints not assigned to any stage");
    02779         for (int k = 0; k < osinstance->instanceData->timeDomain->stages->numberOfStages; k++)
    02780                 { for (int i = 0; i < osinstance->instanceData->timeDomain->stages->stage[k]->objectives->numberOfObjectives; i++)
    02781                         { if (parserData->m_miObjStageInfo[ -osinstance->instanceData->timeDomain->stages->stage[k]->objectives->obj[i]->idx-1 ] == -1)
    02782                                   parserData->m_miObjStageInfo[ -osinstance->instanceData->timeDomain->stages->stage[k]->objectives->obj[i]->idx-1 ] = k;
    02783                         };
    02784                 };
    02785         for (int i = 0; i < osinstance->instanceData->objectives->numberOfObjectives; i++)
    02786                 if (parserData->m_miObjStageInfo[i] == -1)
    02787                         osilerror (NULL, osinstance, parserData, "some objectives not assigned to any stage");
    02788 }
    02789     break;
    02790
    02791   case 155:
    02792
    02793     {osinstance->instanceData->timeDomain->stages = new TimeDomainStages();}
    02794     break;
    02795
    02796   case 156:
    02797
    02798     {
    02799         if ( *(yyvsp[(2) - (5)].sval) != *(yyvsp[(4) - (5)].sval) ) osilerror( NULL, osinstance, parserData, "start and end quotes are not the same");
    02800         if ((yyvsp[(3) - (5)].ival) < 1) osilerror (NULL, osinstance, parserData, "number of stages must be positive");
    02801         osinstance->instanceData->timeDomain->stages->numberOfStages = (yyvsp[(3) - (5)].ival);
    02802         if (osinstance->instanceData->timeDomain->stages->numberOfStages > 0 )
    02803                 osinstance->instanceData->timeDomain->stages->stage = new TimeDomainStage*[ (yyvsp[(3) - (5)].ival) ];
    02804         for(int i = 0; i < (yyvsp[(3) - (5)].ival); i++)
    02805         {       osinstance->instanceData->timeDomain->stages->stage[i] = new TimeDomainStage();
    02806                 osinstance->instanceData->timeDomain->stages->stage[i]->variables   = new TimeDomainStageVariables();
    02807                 osinstance->instanceData->timeDomain->stages->stage[i]->constraints = new TimeDomainStageConstraints();
    02808                 osinstance->instanceData->timeDomain->stages->stage[i]->objectives  = new TimeDomainStageObjectives();
    02809         }
    02810 }
    02811     break;
    02812
    02813   case 159:
    02814
    02815     {
    02816         if( osinstance->instanceData->timeDomain->stages->numberOfStages <= parserData->stagecount)
    02817                 osilerror( NULL, osinstance, parserData, "too many stages");
    02818         osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->variables->numberOfVariables = 0;
    02819         osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->constraints->numberOfConstraints = 0;
    02820         osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->objectives->numberOfObjectives = 0;
    02821 }
    02822     break;
    02823
    02824   case 160:
    02825
    02826     { /* set defaults for next stage */
    02827         parserData->stagenameON = false;
    02828         parserData->stageVariablesON = false;
    02829         parserData->stageObjectivesON = false;
    02830         parserData->stageConstraintsON = false;
    02831         parserData->stageVariablesOrdered = false;
    02832         parserData->stageObjectivesOrdered = false;
    02833         parserData->stageConstraintsOrdered = false;
    02834         parserData->stageVariableStartIdx = 0;
    02835         parserData->stageObjectiveStartIdx = 0;
    02836         parserData->stageConstraintStartIdx = 0;
    02837         parserData->stagevarcount = 0;
    02838         parserData->stageconcount = 0;
    02839         parserData->stageobjcount = 0;
    02840         parserData->stagecount++;
    02841 }
    02842     break;
    02843
    02844   case 162:
    02845
    02846     {
    02847                   osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->name = (yyvsp[(2) - (3)].sval);}
    02848     break;
    02849
    02850   case 167:
    02851
    02852     {
    02853         parserData->stageVariablesON = true;
    02854         }
    02855     break;
    02856
    02857   case 172:
    02858
    02859     {
    02860         if ((yyvsp[(3) - (4)].ival) < 0) osilerror (NULL, osinstance, parserData, "number of variables cannot be negative");
    02861         if ((yyvsp[(3) - (4)].ival) > osinstance->instanceData->variables->numberOfVariables)
    02862                 osilerror (NULL, osinstance, parserData, "too many variables in this stage");
    02863         if ((yyvsp[(3) - (4)].ival) > 0) {
    02864                 if (osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->variables->numberOfVariables > 0)
    02865                         osilerror( NULL, osinstance, parserData, "duplicate attribute numberOfVariables");
    02866                 osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->variables->numberOfVariables = (yyvsp[(3) - (4)].ival);
    02867                 osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->variables->var = new TimeDomainStageVar*[ (yyvsp[(3) - (4)].ival) ];
    02868                 for (int i = 0; i < (yyvsp[(3) - (4)].ival); i++)
    02869                 {       osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->variables->var[i] = new TimeDomainStageVar;
    02870                         osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->variables->var[i]->idx = 0;
    02871                 }
    02872         };
    02873 }
    02874     break;
    02875
    02876   case 173:
    02877
    02878     {
    02879         if (parserData->stageVariablesOrdered == true) osilerror (NULL, osinstance, parserData, "duplicate attribute");
    02880         if ((yyvsp[(3) - (4)].ival) < 0 && (yyvsp[(3) - (4)].ival) >= osinstance->instanceData->variables->numberOfVariables)
    02881                 osilerror (NULL, osinstance, parserData, "variable index out of range");
    02882         parserData->stageVariablesOrdered = true;
    02883         parserData->stageVariableStartIdx = (yyvsp[(3) - (4)].ival);
    02884 }
    02885     break;
    02886
    02887   case 174:
    02888
    02889     {
    02890         if ((parserData->stageVariablesOrdered != true) &&
    02891                  (osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->variables->numberOfVariables > 0) )
    02892                   osilerror (NULL, osinstance, parserData, "varlist missing");
    02893         for (int i = 0; i < osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->variables->numberOfVariables; i++)
    02894                 osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->variables->var[i]->idx = parserData->stageVariableStartIdx + i;
    02895         }
    02896     break;
    02897
    02898   case 175:
    02899
    02900     {
    02901           if (parserData->stagevarcount < osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->variables->numberOfVariables)
    02902               osilerror (NULL, osinstance, parserData, "too few variables supplied");
    02903           }
    02904     break;
    02905
    02906   case 180:
    02907
    02908     {if (parserData->stageVariablesOrdered == true) osilerror (NULL, osinstance, parserData, "no varlist expected");}
    02909     break;
    02910
    02911   case 182:
    02912
    02913     {
    02914         if ((yyvsp[(3) - (4)].ival) < 0 && (yyvsp[(3) - (4)].ival) >= osinstance->instanceData->variables->numberOfVariables)
    02915                 osilerror (NULL, osinstance, parserData, "variable index out of range");
    02916         if (parserData->stagevarcount >= osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->variables->numberOfVariables)
    02917             osilerror (NULL, osinstance, parserData, "too many variables in this stage");
    02918         osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->variables->var[parserData->stagevarcount]->idx = (yyvsp[(3) - (4)].ival);
    02919         parserData->stagevarcount++;
    02920 }
    02921     break;
    02922
    02923   case 186:
    02924
    02925     {
    02926         parserData->stageConstraintsON = true;
    02927         }
    02928     break;
    02929
    02930   case 191:
    02931
    02932     {
    02933         if ((yyvsp[(3) - (4)].ival) < 0) osilerror (NULL, osinstance, parserData, "number of constraints cannot be negative");
    02934         if ((yyvsp[(3) - (4)].ival) > osinstance->instanceData->constraints->numberOfConstraints)
    02935                 osilerror (NULL, osinstance, parserData, "too many constraints in this stage");
    02936         if ((yyvsp[(3) - (4)].ival) > 0) {
    02937                 if (osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->constraints->numberOfConstraints > 0)
    02938                         osilerror( NULL, osinstance, parserData, "duplicate attribute numberOfConstraints");
    02939                 osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->constraints->numberOfConstraints = (yyvsp[(3) - (4)].ival);
    02940                 osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->constraints->con = new TimeDomainStageCon*[ (yyvsp[(3) - (4)].ival) ];
    02941                 for (int i = 0; i < (yyvsp[(3) - (4)].ival); i++)
    02942                 {       osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->constraints->con[i] = new TimeDomainStageCon;
    02943                         osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->constraints->con[i]->idx = 0;
    02944                 }
    02945         };
    02946 }
    02947     break;
    02948
    02949   case 192:
    02950
    02951     {
    02952         if (parserData->stageConstraintsOrdered == true) osilerror (NULL, osinstance, parserData, "duplicate attribute");
    02953         if ((yyvsp[(3) - (4)].ival) < 0 && (yyvsp[(3) - (4)].ival) >= osinstance->instanceData->constraints->numberOfConstraints)
    02954                 osilerror (NULL, osinstance, parserData, "constraint index out of range");
    02955         parserData->stageConstraintsOrdered = true;
    02956         parserData->stageConstraintStartIdx = (yyvsp[(3) - (4)].ival);
    02957 }
    02958     break;
    02959
    02960   case 193:
    02961
    02962     {
    02963         if ((parserData->stageConstraintsOrdered != true) &&
    02964                  (osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->constraints->numberOfConstraints > 0) )
    02965                   osilerror (NULL, osinstance, parserData, "conlist missing");
    02966         for (int i = 0; i < osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->constraints->numberOfConstraints; i++)
    02967                 osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->constraints->con[i]->idx = parserData->stageConstraintStartIdx + i;
    02968         }
    02969     break;
    02970
    02971   case 194:
    02972
    02973     {
    02974           if (parserData->stageconcount < osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->constraints->numberOfConstraints)
    02975               osilerror (NULL, osinstance, parserData, "too few constraints supplied");
    02976           }
    02977     break;
    02978
    02979   case 199:
    02980
    02981     {if (parserData->stageConstraintsOrdered == true) osilerror (NULL, osinstance, parserData, "no conlist expected");}
    02982     break;
    02983
    02984   case 201:
    02985
    02986     {
    02987         if ((yyvsp[(3) - (4)].ival) < 0 && (yyvsp[(3) - (4)].ival) >= osinstance->instanceData->constraints->numberOfConstraints)
    02988                 osilerror (NULL, osinstance, parserData, "constraint index out of range");
    02989         if (parserData->stageconcount >= osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->constraints->numberOfConstraints)
    02990             osilerror (NULL, osinstance, parserData, "too many constraints in this stage");
    02991         osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->constraints->con[parserData->stageconcount]->idx = (yyvsp[(3) - (4)].ival);
    02992         parserData->stageconcount++;
    02993 }
    02994     break;
    02995
    02996   case 204:
    02997
    02998     { /* By default, an objective belongs to every stage */
    02999                         osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->objectives->numberOfObjectives =
    03000                                 osinstance->instanceData->objectives->numberOfObjectives;
    03001                         osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->objectives->obj =
    03002                                 new TimeDomainStageObj*[ osinstance->instanceData->objectives->numberOfObjectives ];
    03003                         for (int i = 0; i < osinstance->instanceData->objectives->numberOfObjectives; i++)
    03004                         {       osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->objectives->obj[i] = new TimeDomainStageObj;
    03005                                 osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->objectives->obj[i]->idx = -(i+1);
    03006                         }
    03007         }
    03008     break;
    03009
    03010   case 205:
    03011
    03012     {
    03013           parserData->stageObjectivesON = true;
    03014         }
    03015     break;
    03016
    03017   case 210:
    03018
    03019     {
    03020         if ((yyvsp[(3) - (4)].ival) < 0) osilerror (NULL, osinstance, parserData, "number of objectives cannot be negative");
    03021         if ((yyvsp[(3) - (4)].ival) > osinstance->instanceData->objectives->numberOfObjectives)
    03022                 osilerror (NULL, osinstance, parserData, "too many objectives in this stage");
    03023         if ((yyvsp[(3) - (4)].ival) > 0) {
    03024                 if (osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->objectives->numberOfObjectives > 0)
    03025                         osilerror( NULL, osinstance, parserData, "duplicate attribute numberOfObjectives");
    03026                 osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->objectives->numberOfObjectives = (yyvsp[(3) - (4)].ival);
    03027                 osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->objectives->obj = new TimeDomainStageObj*[ (yyvsp[(3) - (4)].ival) ];
    03028                 for (int i = 0; i < (yyvsp[(3) - (4)].ival); i++)
    03029                 {       osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->objectives->obj[i] = new TimeDomainStageObj;
    03030                         osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->objectives->obj[i]->idx = 0;
    03031                 }
    03032         };
    03033 }
    03034     break;
    03035
    03036   case 211:
    03037
    03038     {
    03039         if (parserData->stageObjectivesOrdered == true) osilerror (NULL, osinstance, parserData, "duplicate attribute");
    03040         if ((yyvsp[(3) - (4)].ival) >= 0 && (yyvsp[(3) - (4)].ival) <= -osinstance->instanceData->objectives->numberOfObjectives - 1)
    03041                 osilerror (NULL, osinstance, parserData, "objective index out of range");
    03042         parserData->stageObjectivesOrdered = true;
    03043         parserData->stageObjectiveStartIdx = (yyvsp[(3) - (4)].ival);
    03044 }
    03045     break;
    03046
    03047   case 212:
    03048
    03049     {
    03050         if ((parserData->stageObjectivesOrdered != true) &&
    03051                  (osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->objectives->numberOfObjectives > 0) )
    03052                   osilerror (NULL, osinstance, parserData, "objlist missing");
    03053         for (int i = 0; i < osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->objectives->numberOfObjectives; i++)
    03054                 osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->objectives->obj[i]->idx = parserData->stageObjectiveStartIdx - i;
    03055         }
    03056     break;
    03057
    03058   case 213:
    03059
    03060     {
    03061           if (parserData->stageobjcount < osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->objectives->numberOfObjectives)
    03062               osilerror (NULL, osinstance, parserData, "too few objectives supplied");
    03063         }
    03064     break;
    03065
    03066   case 218:
    03067
    03068     {if (parserData->stageObjectivesOrdered == true) osilerror (NULL, osinstance, parserData, "no objlist expected");}
    03069     break;
    03070
    03071   case 220:
    03072
    03073     {
    03074         if ((yyvsp[(3) - (4)].ival) >= 0 && (yyvsp[(3) - (4)].ival) >= -osinstance->instanceData->objectives->numberOfObjectives - 1)
    03075                 osilerror (NULL, osinstance, parserData, "objective index out of range");
    03076         if (parserData->stageobjcount >= osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->objectives->numberOfObjectives)
    03077             osilerror (NULL, osinstance, parserData, "too many objectives in this stage");
    03078         osinstance->instanceData->timeDomain->stages->stage[parserData->stagecount]->objectives->obj[parserData->stageobjcount]->idx = (yyvsp[(3) - (4)].ival);
    03079         parserData->stageobjcount++;
    03080 }
    03081     break;
    03082
    03083   case 223:
    03084
    03085     {osinstance->instanceData->timeDomain->interval = new TimeDomainInterval();
    03086         }
    03087     break;
    03088
    03089   case 224:
    03090
    03091     {
    03092                 parserData->intervalhorizonON = false;
    03093                 parserData->intervalstartON = false;
    03094                 printf("Interval not yet supported.\n\n");
    03095 }
    03096     break;
    03097
    03098   case 229:
    03099
    03100     { if(parserData->intervalhorizonON)
    03101        osilerror( NULL, osinstance, parserData, "too many interval horizon attributes");
    03102                 parserData->intervalhorizonON = true; }
    03103     break;
    03104
    03105   case 230:
    03106
    03107     { if(parserData->intervalstartON)
    03108        osilerror( NULL, osinstance, parserData, "too many interval start attributes");
    03109                 parserData->intervalstartON = true; }
    03110     break;
    03111
    03112   case 231:
    03113
    03114     {
    03115                 if ( *(yyvsp[(2) - (4)].sval) != *(yyvsp[(4) - (4)].sval) ) osilerror( NULL, osinstance, parserData, "start and end quotes are not the same");
    03116                 parserData->intervalhorizon = (yyvsp[(3) - (4)].dval);}
    03117     break;
    03118
    03119   case 232:
    03120
    03121     {
    03122                 if ( *(yyvsp[(2) - (4)].sval) != *(yyvsp[(4) - (4)].sval) ) osilerror( NULL, osinstance, parserData, "start and end quotes are not the same");
    03123                 parserData->intervalstart = (yyvsp[(3) - (4)].dval);}
    03124     break;
    03125
    03126
    03127
    03128       default: break;
    03129     }
    03130   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
    03131
    03132   YYPOPSTACK (yylen);
    03133   yylen = 0;
    03134   YY_STACK_PRINT (yyss, yyssp);
    03135
    03136   *++yyvsp = yyval;
    03137   *++yylsp = yyloc;
    03138
    03139   /* Now `shift' the result of the reduction.  Determine what state
    03140      that goes to, based on the state we popped back to and the rule
    03141      number reduced by.  */
    03142
    03143   yyn = yyr1[yyn];
    03144
    03145   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
    03146   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
    03147     yystate = yytable[yystate];
    03148   else
    03149     yystate = yydefgoto[yyn - YYNTOKENS];
    03150
    03151   goto yynewstate;
    03152
    03153
    03154 /*------------------------------------.
    03155 | yyerrlab -- here on detecting error |
    03156 `------------------------------------*/
    03157 yyerrlab:
    03158   /* If not already recovering from an error, report this error.  */
    03159   if (!yyerrstatus)
    03160     {
    03161       ++yynerrs;
    03162 #if ! YYERROR_VERBOSE
    03163       yyerror (&yylloc, osinstance, parserData, YY_("syntax error"));
    03164 #else
    03165       {
    03166         YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
    03167         if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
    03168           {
    03169             YYSIZE_T yyalloc = 2 * yysize;
    03170             if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
    03171               yyalloc = YYSTACK_ALLOC_MAXIMUM;
    03172             if (yymsg != yymsgbuf)
    03173               YYSTACK_FREE (yymsg);
    03174             yymsg = (char *) YYSTACK_ALLOC (yyalloc);
    03175             if (yymsg)
    03176               yymsg_alloc = yyalloc;
    03177             else
    03178               {
    03179                 yymsg = yymsgbuf;
    03180                 yymsg_alloc = sizeof yymsgbuf;
    03181               }
    03182           }
    03183
    03184         if (0 < yysize && yysize <= yymsg_alloc)
    03185           {
    03186             (void) yysyntax_error (yymsg, yystate, yychar);
    03187             yyerror (&yylloc, osinstance, parserData, yymsg);
    03188           }
    03189         else
    03190           {
    03191             yyerror (&yylloc, osinstance, parserData, YY_("syntax error"));
    03192             if (yysize != 0)
    03193               goto yyexhaustedlab;
    03194           }
    03195       }
    03196 #endif
    03197     }
    03198
    03199   yyerror_range[0] = yylloc;
    03200
    03201   if (yyerrstatus == 3)
    03202     {
    03203       /* If just tried and failed to reuse lookahead token after an
    03204          error, discard it.  */
    03205
    03206       if (yychar <= YYEOF)
    03207         {
    03208           /* Return failure if at end of input.  */
    03209           if (yychar == YYEOF)
    03210             YYABORT;
    03211         }
    03212       else
    03213         {
    03214           yydestruct ("Error: discarding",
    03215                       yytoken, &yylval, &yylloc, osinstance, parserData);
    03216           yychar = YYEMPTY;
    03217         }
    03218     }
    03219
    03220   /* Else will try to reuse lookahead token after shifting the error
    03221      token.  */
    03222   goto yyerrlab1;
    03223
    03224
    03225 /*---------------------------------------------------.
    03226 | yyerrorlab -- error raised explicitly by YYERROR.  |
    03227 `---------------------------------------------------*/
    03228 yyerrorlab:
    03229
    03230   /* Pacify compilers like GCC when the user code never invokes
    03231      YYERROR and the label yyerrorlab therefore never appears in user
    03232      code.  */
    03233   if (/*CONSTCOND*/ 0)
    03234      goto yyerrorlab;
    03235
    03236   yyerror_range[0] = yylsp[1-yylen];
    03237   /* Do not reclaim the symbols of the rule which action triggered
    03238      this YYERROR.  */
    03239   YYPOPSTACK (yylen);
    03240   yylen = 0;
    03241   YY_STACK_PRINT (yyss, yyssp);
    03242   yystate = *yyssp;
    03243   goto yyerrlab1;
    03244
    03245
    03246 /*-------------------------------------------------------------.
    03247 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
    03248 `-------------------------------------------------------------*/
    03249 yyerrlab1:
    03250   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
    03251
    03252   for (;;)
    03253     {
    03254       yyn = yypact[yystate];
    03255       if (yyn != YYPACT_NINF)
    03256         {
    03257           yyn += YYTERROR;
    03258           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
    03259             {
    03260               yyn = yytable[yyn];
    03261               if (0 < yyn)
    03262                 break;
    03263             }
    03264         }
    03265
    03266       /* Pop the current state because it cannot handle the error token.  */
    03267       if (yyssp == yyss)
    03268         YYABORT;
    03269
    03270       yyerror_range[0] = *yylsp;
    03271       yydestruct ("Error: popping",
    03272                   yystos[yystate], yyvsp, yylsp, osinstance, parserData);
    03273       YYPOPSTACK (1);
    03274       yystate = *yyssp;
    03275       YY_STACK_PRINT (yyss, yyssp);
    03276     }
    03277
    03278   *++yyvsp = yylval;
    03279
    03280   yyerror_range[1] = yylloc;
    03281   /* Using YYLLOC is tempting, but would change the location of
    03282      the lookahead.  YYLOC is available though.  */
    03283   YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
    03284   *++yylsp = yyloc;
    03285
    03286   /* Shift the error token.  */
    03287   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
    03288
    03289   yystate = yyn;
    03290   goto yynewstate;
    03291
    03292
    03293 /*-------------------------------------.
    03294 | yyacceptlab -- YYACCEPT comes here.  |
    03295 `-------------------------------------*/
    03296 yyacceptlab:
    03297   yyresult = 0;
    03298   goto yyreturn;
    03299
    03300 /*-----------------------------------.
    03301 | yyabortlab -- YYABORT comes here.  |
    03302 `-----------------------------------*/
    03303 yyabortlab:
    03304   yyresult = 1;
    03305   goto yyreturn;
    03306
    03307 #if !defined(yyoverflow) || YYERROR_VERBOSE
    03308 /*-------------------------------------------------.
    03309 | yyexhaustedlab -- memory exhaustion comes here.  |
    03310 `-------------------------------------------------*/
    03311 yyexhaustedlab:
    03312   yyerror (&yylloc, osinstance, parserData, YY_("memory exhausted"));
    03313   yyresult = 2;
    03314   /* Fall through.  */
    03315 #endif
    03316
    03317 yyreturn:
    03318   if (yychar != YYEMPTY)
    03319      yydestruct ("Cleanup: discarding lookahead",
    03320                  yytoken, &yylval, &yylloc, osinstance, parserData);
    03321   /* Do not reclaim the symbols of the rule which action triggered
    03322      this YYABORT or YYACCEPT.  */
    03323   YYPOPSTACK (yylen);
    03324   YY_STACK_PRINT (yyss, yyssp);
    03325   while (yyssp != yyss)
    03326     {
    03327       yydestruct ("Cleanup: popping",
    03328                   yystos[*yyssp], yyvsp, yylsp, osinstance, parserData);
    03329       YYPOPSTACK (1);
    03330     }
    03331 #ifndef yyoverflow
    03332   if (yyss != yyssa)
    03333     YYSTACK_FREE (yyss);
    03334 #endif
    03335 #if YYERROR_VERBOSE
    03336   if (yymsg != yymsgbuf)
    03337     YYSTACK_FREE (yymsg);
    03338 #endif
    03339   /* Make sure YYID is used.  */
    03340   return YYID (yyresult);
    03341 }
    03342
    03343
    03344
    03345
    03346
    03347
    03348 // user defined functions
    03349
    03350 void osilerror(YYLTYPE* mytype, OSInstance *osinstance, OSiLParserData* parserData, const char* errormsg ) {
    03351         std::ostringstream outStr;
    03352         std::string error = errormsg;
    03353         error = "PARSER ERROR:  Input is either not valid or well formed: "  + error;
    03354         outStr << error << endl;
    03355         outStr << endl;
    03356         outStr << "See line number: " << osilget_lineno( scanner) << endl;
    03357         outStr << "The offending text is: " << osilget_text ( scanner ) << endl;
    03358         error = outStr.str();
    03359         //osillex_destroy(scanner);
    03360         throw ErrorClass( error);
    03361 }//end osilerror()
    03362
    03363
    03364 void  yygetOSInstance( const char *osil, OSInstance* osinstance, OSiLParserData *parserData) throw (ErrorClass) {
    03365         try {
    03366                 parseInstanceHeader( &osil, osinstance, &parserData->osillineno);
    03367                 parseInstanceData( &osil, osinstance, &parserData->osillineno);
    03373                 osil_scan_string( osil, scanner );
    03374                 osilset_lineno (parserData->osillineno , scanner );
    03375                 //
    03376                 // call the Bison parser
    03377                 //
    03378                 if(  osilparse( osinstance,  parserData) != 0) {
    03379                         throw ErrorClass(  "Error parsing the OSiL");
    03380                 }
    03381         }
    03382         catch(const ErrorClass& eclass){
    03383                 throw ErrorClass(  eclass.errormsg);
    03384         }
    03385 }//end yygetOSInstance
    03386
    03387 bool isnewline(char c, int* osillineno){
    03388         if(c != '\n') return false;
    03389         (*osillineno)++;
    03390         return true;
    03391 }//end isnewline()
    03392
    03393 bool parseInstanceHeader( const char **p, OSInstance *osinstance, int* osillineno){
    03394         //
    03395         *osillineno = 1;
    03396         const char *pchar = *p;
    03397
    03398
    03399         //first check of osil start
    03400         const char *startOSiL = "<osil";
    03401         const char *pOSiLStart = strstr(pchar, startOSiL);
    03402         if(pOSiLStart == NULL){
    03403           osilerror_wrapper( pchar,osillineno,"<osil> element missing");
    03404           return false;
    03405         }else{
    03406                 //look for osil end
    03407                         const char *pOSiLEnd = strstr(pOSiLStart, ">");
    03408                 if(pOSiLEnd == NULL) {  osilerror_wrapper( pchar,osillineno,"end of <osil> element missing"); return false;
    03409                         } else {
    03410                         pchar = pOSiLEnd;
    03411                         pchar++;
    03412                 }
    03413         }
    03414
    03415
    03416
    03417
    03418         // create a char array that holds the instance header information
    03419         const char *startInstanceHeader = "<instanceHeader";
    03420         const char *endInstanceHeader = "</instanceHeader";
    03421         const char *startName = "<name";
    03422         const char *endName = "</name";
    03423         const char *startSource = "<source";
    03424         const char *endSource = "</source";
    03425         const char *startDescription = "<description";
    03426         const char *endDescription = "</description";
    03427         const char *startFileCreator = "<fileCreator";
    03428         const char *endFileCreator = "</fileCreator";
    03429         const char *startLicence = "<licence";
    03430         const char *endLicence = "</licence";
    03431         const char *pinstanceHeadStart = strstr(pchar, startInstanceHeader);
    03432         char *pelementText = NULL;
    03433         const char *ptemp = NULL;
    03434         int elementSize;
    03435         if(pinstanceHeadStart == NULL ) {
    03436                 const char *startInstanceData = "<instanceData";
    03437                 *p = strstr(pchar, startInstanceData);
    03438                 return true;
    03439         }
    03440         //if(pinstanceHeadStart == NULL) {  osilerror_wrapper( pchar,osillineno,"<instanceHeader> element missing"); return false;}
    03441         // increment the line number counter if there are any newlines between the start of
    03442         // the osil string and pinstanceHeadStart
    03443         int     kount = pinstanceHeadStart - pchar;
    03444         while( kount-- > 0) if(*(pchar++) == '\n')      (*osillineno)++;
    03445         // important! pchar now points to the '<' in <instanceHeader
    03446         // that is both pinstanceHeadStart and pchar point to the same thing
    03447         //
    03448         // move to the end of <instanceHeader
    03449         pchar+=15;
    03450         // burn any whitespace
    03451         for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03452         // pchar better be pointing to the '>' in the <instanceHeader> element
    03453         // or to /> if we have <instanceHeader />
    03454         if( *pchar == '/'){
    03455                 pchar++;
    03456                 // better point to a '>'
    03457                 if(*pchar != '>') {  osilerror_wrapper( pchar,osillineno,"improperly formed <instanceHeader> element"); return false;}
    03458                 // there is no instanceHeader data
    03459                 pchar++;
    03460                 *p = pchar;
    03461                 return true;
    03462         }
    03463         else{
    03464                 // pchar better be '>' or there is an error
    03465                 if(*pchar != '>') {  osilerror_wrapper( pchar,osillineno,"improperly formed <instanceHeader> element"); return false;}
    03466         }
    03467         pchar++;
    03468         // we are pointing to the character after <instanceHeader>
    03469         //
    03470         //
    03471         //
    03472         // process the <name> element which is optional
    03473         //
    03474         // first burn any whitespace
    03475         for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03476         // if, present we should be pointing to <name element if there -- it is not required
    03477         //remember where we are
    03478         *p = pchar;
    03479         while(*startName++  == *pchar) pchar++;
    03480         if( (pchar - *p)  != 5) {
    03481                 //reset pchar
    03482                 pchar = *p;
    03483         }
    03484         else{
    03485         // we have a name element, process the text
    03486         // burn the whitespace
    03487                 for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03488                 if( *pchar == '/'){
    03489                         pchar++;
    03490                         // better point to a '>'
    03491                         if(*pchar != '>') {  osilerror_wrapper( pchar,osillineno,"improperly formed <name> element"); return false;}
    03492                         pchar++;
    03493                 }
    03494                 else{
    03495                         // pchar better be '>' or there is an error
    03496                         if(*pchar != '>') {  osilerror_wrapper( pchar,osillineno,"improperly formed <name> element"); return false;}
    03497                         pchar++;
    03498                         // process <name> element text
    03499                         // there better be a </name
    03500                         ptemp = strstr( pchar, endName);
    03501                         if( ptemp == NULL) {  osilerror_wrapper( pchar,osillineno,"improperly formed </name> element"); return false;}
    03502                         elementSize = ptemp - pchar;
    03503                         pelementText = new char[ elementSize + 1];
    03504                         strncpy(pelementText, pchar, elementSize);
    03505                         pelementText[ elementSize] = '\0';
    03506                         osinstance->instanceHeader->name = pelementText;
    03507                         //garbage collection
    03508                         delete [] pelementText;
    03509                         // move pchar up to the end of </name
    03510                         while(elementSize-- > 0){
    03511                                 if(*pchar++ == '\n') (*osillineno)++;
    03512                         }
    03513                         // pchar should now be pointing to the start of </name
    03514                         // move to first char after </name
    03515                         pchar += 6;
    03516                         // get rid of the whitespace
    03517                         for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03518                         // we better have the '>' for the end of name
    03519                         if(*pchar++ != '>'){  osilerror_wrapper( pchar,osillineno,"improperly formed </name> element"); return false;}
    03520                 }
    03521         }// end of else after discovering a name element
    03522         //done processing name element
    03523         //
    03524         //
    03525         // process the <source> element which is optional
    03526         //
    03527         // first burn any whitespace
    03528         for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03529         // if, present we should be pointing to <source element if there -- it is not required
    03530         *p = pchar;
    03531         while(*startSource++  == *pchar) pchar++;
    03532         if(pchar - *p != 7) {
    03533                 //reset pchar
    03534                 pchar = *p;
    03535         }
    03536         else{
    03537         // we have a source element, process the text
    03538         // burn the whitespace
    03539                 for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03540                 if( *pchar == '/'){
    03541                         pchar++;
    03542                         // better point to a '>'
    03543                         if(*pchar != '>') {  osilerror_wrapper( pchar,osillineno,"improperly formed <source> element"); return false;}
    03544                         pchar++;
    03545                 }
    03546                 else{
    03547                         // pchar better be '>' or there is an error
    03548                         if(*pchar != '>') {  osilerror_wrapper( pchar,osillineno,"improperly formed <source> element"); return false;}
    03549                         pchar++;
    03550                         // process <source> element text
    03551                         // there better be a </source
    03552                         ptemp = strstr( pchar, endSource);
    03553                         if( ptemp == NULL) {  osilerror_wrapper( pchar,osillineno,"improperly formed </source> element"); return false;}
    03554                         elementSize = ptemp - pchar;
    03555                         pelementText = new char[ elementSize + 1];
    03556                         strncpy(pelementText, pchar, elementSize);
    03557                         pelementText[ elementSize] = '\0';
    03558                         osinstance->instanceHeader->source = pelementText;
    03559                         //garbage collection
    03560                         delete [] pelementText;
    03561                         // move pchar up to the end of </source
    03562                         while(elementSize-- > 0){
    03563                                 if(*pchar++ == '\n') (*osillineno)++;
    03564                         }
    03565                         // pchar should now be pointing to the start of </source
    03566                         // move to first char after </source
    03567                         pchar += 8;
    03568                         // get rid of the whitespace
    03569                         for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03570                         // we better have the '>' for the end of source
    03571                         if(*pchar++ != '>'){  osilerror_wrapper( pchar,osillineno,"improperly formed </source> element"); return false;}
    03572                 }
    03573         }// end of else after discovering a source element
    03574         //done processing <source> element
    03575         //
    03576         //
    03577         //process the <description> element
    03578         //
    03579         // first burn any whitespace
    03580         for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03581         // if, present we should be pointing to <description element if there -- it is not required
    03582         *p = pchar;
    03583         while(*startDescription++  == *pchar) pchar++;
    03584         if( (pchar - *p) != 12) {
    03585                 //reset pchar
    03586                 pchar = *p;
    03587         }
    03588         else{
    03589         // we have a description element, process the text
    03590         // burn the whitespace
    03591                 for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03592                 if( *pchar == '/'){
    03593                         pchar++;
    03594                         // better point to a '>'
    03595                         if(*pchar != '>') {  osilerror_wrapper( pchar,osillineno,"improperly formed <description> element"); return false;}
    03596                         pchar++;
    03597                 }
    03598                 else{
    03599                         // pchar better be '>' or there is an error
    03600                         if(*pchar != '>') {  osilerror_wrapper( pchar,osillineno,"improperly formed <description> element"); return false;}
    03601                         pchar++;
    03602                         // process <description> element text
    03603                         // there better be a </description
    03604                         ptemp = strstr( pchar, endDescription);
    03605                         if( ptemp == NULL) {  osilerror_wrapper( pchar,osillineno,"improperly formed </description> element"); return false;}
    03606                         elementSize = ptemp - pchar;
    03607                         pelementText = new char[ elementSize + 1];
    03608                         strncpy(pelementText, pchar, elementSize);
    03609                         pelementText[ elementSize] = '\0';
    03610                         osinstance->instanceHeader->description = pelementText;
    03611                         //garbage collection
    03612                         delete [] pelementText;
    03613                         // move pchar up to the end of </description
    03614                         while(elementSize-- > 0){
    03615                                 if(*pchar++ == '\n') (*osillineno)++;
    03616                         }
    03617                         // pchar should now be pointing to the start of </description
    03618                         // move to first char after </description
    03619                         pchar += 13;
    03620                         // get rid of the whitespace
    03621                         for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03622                         // we better have the '>' for the end of </description>
    03623                         if(*pchar++ != '>'){  osilerror_wrapper( pchar,osillineno,"improperly formed </description> element"); return false;}
    03624                 }
    03625         }// end of else after discovering a description element
    03626         //done processing <description> element
    03627
    03628         //
    03629         //
    03630         //process the <fileCreator> element
    03631         //
    03632         // first burn any whitespace
    03633         for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03634         // if, present we should be pointing to <fileCreator element if there -- it is not required
    03635         *p = pchar;
    03636         while(*startFileCreator++  == *pchar) pchar++;
    03637         if( (pchar - *p) != 12) {
    03638                 //reset pchar
    03639                 pchar = *p;
    03640         }
    03641         else{
    03642         // we have a fileCreator element, process the text
    03643         // burn the whitespace
    03644                 for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03645                 if( *pchar == '/'){
    03646                         pchar++;
    03647                         // better point to a '>'
    03648                         if(*pchar != '>') {  osilerror_wrapper( pchar,osillineno,"improperly formed <fileCreator> element"); return false;}
    03649                         pchar++;
    03650                 }
    03651                 else{
    03652                         // pchar better be '>' or there is an error
    03653                         if(*pchar != '>') {  osilerror_wrapper( pchar,osillineno,"improperly formed <fileCreator> element"); return false;}
    03654                         pchar++;
    03655                         // process <fileCreator> element text
    03656                         // there better be a </fileCreator
    03657                         ptemp = strstr( pchar, endFileCreator);
    03658                         if( ptemp == NULL) {  osilerror_wrapper( pchar,osillineno,"improperly formed </fileCreator> element"); return false;}
    03659                         elementSize = ptemp - pchar;
    03660                         pelementText = new char[ elementSize + 1];
    03661                         strncpy(pelementText, pchar, elementSize);
    03662                         pelementText[ elementSize] = '\0';
    03663                         osinstance->instanceHeader->fileCreator = pelementText;
    03664                         //garbage collection
    03665                         delete [] pelementText;
    03666                         // move pchar up to the end of </description
    03667                         while(elementSize-- > 0){
    03668                                 if(*pchar++ == '\n') (*osillineno)++;
    03669                         }
    03670                         // pchar should now be pointing to the start of </fileCreator
    03671                         // move to first char after </fileCreator
    03672                         pchar += 13;
    03673                         // get rid of the whitespace
    03674                         for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03675                         // we better have the '>' for the end of </fileCreator>
    03676                         if(*pchar++ != '>'){  osilerror_wrapper( pchar,osillineno,"improperly formed </fileCreator> element"); return false;}
    03677                 }
    03678         }// end of else after discovering a fileCreator element
    03679         //done processing <fileCreator> element
    03680         //
    03681         //
    03682         //process the <licence> element
    03683         //
    03684         // first burn any whitespace
    03685         for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03686         // if, present we should be pointing to <licence element if there -- it is not required
    03687         *p = pchar;
    03688         while(*startLicence++  == *pchar) pchar++;
    03689         if( (pchar - *p) != 8) {
    03690                 //reset pchar
    03691                 pchar = *p;
    03692         }
    03693         else{
    03694         // we have a licence element, process the text
    03695         // burn the whitespace
    03696                 for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03697                 if( *pchar == '/'){
    03698                         pchar++;
    03699                         // better point to a '>'
    03700                         if(*pchar != '>') {  osilerror_wrapper( pchar,osillineno,"improperly formed <licence> element"); return false;}
    03701                         pchar++;
    03702                 }
    03703                 else{
    03704                         // pchar better be '>' or there is an error
    03705                         if(*pchar != '>') {  osilerror_wrapper( pchar,osillineno,"improperly formed <licence> element"); return false;}
    03706                         pchar++;
    03707                         // process <licence> element text
    03708                         // there better be a </licence
    03709                         ptemp = strstr( pchar, endLicence);
    03710                         if( ptemp == NULL) {  osilerror_wrapper( pchar,osillineno,"improperly formed </licence> element"); return false;}
    03711                         elementSize = ptemp - pchar;
    03712                         pelementText = new char[ elementSize + 1];
    03713                         strncpy(pelementText, pchar, elementSize);
    03714                         pelementText[ elementSize] = '\0';
    03715                         osinstance->instanceHeader->licence = pelementText;
    03716                         //garbage collection
    03717                         delete [] pelementText;
    03718                         // move pchar up to the end of </licence
    03719                         while(elementSize-- > 0){
    03720                                 if(*pchar++ == '\n') (*osillineno)++;
    03721                         }
    03722                         // pchar should now be pointing to the start of </licence
    03723                         // move to first char after </licence
    03724                         pchar += 9;
    03725                         // get rid of the whitespace
    03726                         for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03727                         // we better have the '>' for the end of </description>
    03728                         if(*pchar++ != '>'){  osilerror_wrapper( pchar,osillineno,"improperly formed </licence> element"); return false;}
    03729                 }
    03730         }// end of else after discovering a licence element
    03731         //done processing <licence> element
    03732
    03733
    03734         //
    03735         // if we are here there must be an </instanceHeader > element
    03736         // burn the whitespace
    03737         for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03738         // we should be pointing to </instanceHeader
    03739         *p = pchar;
    03740         while(*endInstanceHeader++  == *pchar) pchar++;
    03741         if( (pchar - *p) != 16) {  osilerror_wrapper( pchar,osillineno,"improperly formed </instanceHeader> element"); return false;}
    03742         // pchar now points to the first character after </instanceHeader
    03743         // get rid of white space
    03744         for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03745         // pchar must point to '>' or there is an error
    03746         if(*pchar != '>'){  osilerror_wrapper( pchar,osillineno,"improperly formed </instanceHeader> element"); return false;}
    03747         pchar++;
    03748         *p = pchar;
    03749         return true;
    03750 }//end parseInstanceHeader
    03751
    03752
    03753 bool parseInstanceData( const char **p, OSInstance *osinstance, int* osillineno){
    03754         //
    03755         const char *pchar = *p;
    03756         const char *startInstanceData = "<instanceData";
    03757         // at this point *pchar should be pointing to the first char after the > in </instanceHeader>
    03758         // burn the white space
    03759         for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03760         // pchar should be point to a '<', if not there is an error
    03761         if(*pchar != '<'){  osilerror_wrapper( pchar,osillineno,"improperly formed <instanceData element"); return false;}
    03762         // make sure the element is <instanceData
    03763         *p = pchar;
    03764         while(*startInstanceData++  == *pchar) pchar++;
    03765         if( (pchar - *p) != 13) {  osilerror_wrapper( pchar,osillineno,"improperly formed <instanceData> element"); return false;}
    03766         // now burn whitespace
    03767         for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03768         // pchar must point to '>' or there is an error
    03769         if(*pchar == '>'){
    03770                 pchar++;
    03771                 // we are now pointing to the first char after <instanceData>
    03772                 // burn any whitespace
    03773                 for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03774                 // we should be pointing to the '<' char in <variables>
    03775                 *p = pchar;
    03776                 if( parseVariables( p, osinstance, osillineno) != true) {throw ErrorClass("error in parseVariables");}
    03777                 if( parseObjectives( p, osinstance, osillineno) != true)  throw ErrorClass("error in parseObjectives");
    03778                 if( parseConstraints( p, osinstance, osillineno) != true) throw ErrorClass("error in parseConstraints");
    03779                 if( parseLinearConstraintCoefficients( p, osinstance, osillineno) != true) throw ErrorClass("error in parseLinearConstraintCoefficients");
    03780         }else{
    03781                 //osilerror_wrapper( pchar,osillineno,"improperly formed <instanceData> element");
    03782                 return true;
    03783         }
    03784         //for( ; ISWHITESPACE( *pchar) || isnewline( *pchar, osillineno); pchar++ ) ;
    03785         // we should be pointing to the '<' char in <variables>
    03786         //*p = pchar;
    03787         return true;
    03788 }// end parseInstanceData
    03789
    03790
    03791 bool parseVariables( const char **p,  OSInstance *osinstance, int* osillineno){
    03792         clock_t start, finish;
    03793         #ifdef CHECK_PARSE_TIME
    03794         double duration;
    03795         #endif
    03796         int ki, numChar;
    03797         char *attTextEnd;
    03798         const char *ch = *p;
    03799         start = clock();
    03800         const char *c_numberOfVariables = "numberOfVariables";
    03801         const char *startVariables = "<variables";
    03802         const char *endVariables = "</variables";
    03803         const char *startVar = "<var";
    03804         const char *endVar = "</var";
    03805         // the attributes
    03806         char *attText = NULL;
    03807         const char *name = "name";
    03808         //const char *initString = "initString";
    03809         const char *type = "type";
    03810         const char *mult = "mult";
    03811         // others
    03812         int i;
    03813         int varcount = 0;
    03814         int vt;
    03815         int numberOfVariables = 0;
    03816 // variable attribute boolean variables
    03817         bool varlbattON  = false;
    03818         bool varubattON = false ;
    03819         bool vartypeattON  = false;
    03820         bool varnameattON = false ;
    03821         //bool varinitattON = false ;
    03822         //bool varinitStringattON = false ;
    03823         bool varmultattON = false;
    03824         bool foundVar = false;
    03825         int varmult;
    03826         //
    03827         // start parsing -- okay not to have variables
    03828         // burn white space
    03829         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    03830         *p = ch;
    03831         while(*startVariables++  == *ch) ch++;
    03832         //if( (ch - *p) != 10) {  osilerror_wrapper( ch,osillineno,"incorrect <variables tag>"); return false;}
    03833         if( (ch - *p) != 10) {   return true;}
    03834         // find numberOfVariables attribute
    03835         // eat the white space
    03836         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    03837         *p = ch;
    03838         while(*c_numberOfVariables++  == *ch) ch++;
    03839         if( (ch - *p) != 17) {  osilerror_wrapper( ch,osillineno,"incorrect numberOfVariables attribute in <variables tag>"); return false;}
    03840         // buf_index should be pointing to the first character after numberOfVariables
    03841         GETATTRIBUTETEXT;
    03842         ch++;
    03843         numberOfVariables = atoimod1( osillineno, attText, attTextEnd);
    03844         delete [] attText;
    03845         if(numberOfVariables <  0) {
    03846                 osilerror_wrapper( ch,osillineno,"there must be a nonnegative number of variables"); return false;
    03847         }
    03848         osinstance->instanceData->variables->numberOfVariables = numberOfVariables;
    03849         if(numberOfVariables > 0){
    03850                 osinstance->instanceData->variables->var = new Variable*[ numberOfVariables];
    03851                 for(i = 0; i < numberOfVariables; i++){
    03852                         osinstance->instanceData->variables->var[ i] = new Variable();
    03853                 }
    03854         }
    03855         // get rid of white space after the numberOfVariables element
    03856         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    03857         // since there must be at least one variable,  this element must end with >
    03858         if(numberOfVariables > 0){
    03859                 // better have an > sign or not valid
    03860                 if(*ch != '>' ) {  osilerror_wrapper( ch,osillineno,"variables element does not have a proper closing >"); return false;}
    03861                 ch++;
    03862                 // get rid of white space
    03863                 for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    03864                 // now loop over the var element when the numberOfVariables is strictly positive
    03865                 *p = ch;
    03866                 while(*startVar++  == *ch) ch++;
    03867                 if( (ch - *p) ==  4) foundVar = true;
    03868                         else {  osilerror_wrapper( ch,osillineno,"there must be at least one <var> element"); return false;}
    03869                 startVar -= 5;
    03870                 while(foundVar){
    03871                         varlbattON  = false;
    03872                         varubattON = false ;
    03873                         vartypeattON  = false;
    03874                         varnameattON = false ;
    03875                         //varinitattON = false ;
    03876                         //varinitStringattON = false ;
    03877                         varmultattON = false;
    03878                         varmult = 1;
    03879                         foundVar = false;
    03880                         // assume we are pointing to the first character after the r in <var
    03881                         // it should be whitespace
    03882                         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    03883                         while(*ch != '/' && *ch != '>'){
    03884                                 switch (*ch) {
    03885                                 case 'n':
    03886                                         *p = ch;
    03887                                         while(*name++  == *ch) ch++;
    03888                                         if( (ch - *p) != 4 ) {  osilerror_wrapper( ch,osillineno,"error in variables name attribute"); return false;}
    03889                                         name -= 5;
    03890                                         if(varnameattON == true) {  osilerror_wrapper( ch,osillineno,"too many variable name attributes"); return false;}
    03891                                         varnameattON = true;
    03892                                         GETATTRIBUTETEXT;
    03893                                         osinstance->instanceData->variables->var[varcount]->name=attText;
    03894                                         delete [] attText;
    03895                                         //printf("ATTRIBUTE = %s\n", attText);
    03896                                         break;
    03897                                         /*
    03898                                 case 'i':
    03899                                         *p = ch;
    03900                                         while(*initString++  == *ch) ch++;
    03901                                         // if i < 4 there is an error
    03902                                         // if i = 4 we matched init
    03903                                         // if i = 10 we matched initString
    03904                                         if( ( (ch - *p) != 4)  && ( (ch - *p) != 10)) {  osilerror_wrapper( ch,osillineno,"error in variables init or initString attribute"); return false;}
    03905                                         if((ch - *p) == 4){
    03906                                                 if(varinitattON == true) {  osilerror_wrapper( ch,osillineno,"too many variable init attributes"); return false;}
    03907                                                 varinitattON = true;
    03908                                                 GETATTRIBUTETEXT;
    03909                                                 //printf("ATTRIBUTE = %s\n", attText);
    03910                                                 osinstance->instanceData->variables->var[varcount]->init=atofmod1( osillineno,attText, attTextEnd);
    03911                                                 delete [] attText;
    03912                                                 initString -= 5;
    03913                                         }
    03914                                         else{
    03915                                                 if(varinitStringattON == true) {  osilerror_wrapper( ch,osillineno,"too many variable initString attributes"); return false;}
    03916                                                 varinitStringattON = true;
    03917                                                 GETATTRIBUTETEXT;
    03918                                                 //printf("ATTRIBUTE = %s\n", attText);
    03919                                                 osinstance->instanceData->variables->var[varcount]->initString=attText;
    03920                                                 delete [] attText;
    03921                                                 initString -= 11;
    03922                                         }
    03923                                         break;
    03924                                         */
    03925                                 case 't':
    03926                                         *p = ch;
    03927                                         while(*type++  == *ch) ch++;
    03928                                         if( (ch - *p) != 4) {  osilerror_wrapper( ch,osillineno,"error in variables type attribute"); return false;}
    03929                                         type -= 5;
    03930                                         if(vartypeattON == true) {  osilerror_wrapper( ch,osillineno,"too many variable type attributes"); return false;}
    03931                                         vartypeattON = true;
    03932                                         GETATTRIBUTETEXT;
    03933                                         vt = returnVarType(attText[0]);
    03934                                         if( vt == 0 ) {  osilerror_wrapper( ch,osillineno,"variable type not recognized"); return false;}
    03935                                         osinstance->instanceData->variables->var[varcount]->type = attText[0];
    03936                                         if (vt == ENUM_VARTYPE_BINARY) osinstance->instanceData->variables->var[varcount]->ub = 1.0;
    03937                                         delete [] attText;
    03938                                         break;
    03939                                 case 'l':
    03940                                         ch++;
    03941                                         if(*ch++ != 'b') {  osilerror_wrapper( ch,osillineno,"error in variables lower bound attribute"); return false;}
    03942                                         if(varlbattON == true) {  osilerror_wrapper( ch,osillineno,"too many variable lb attributes"); return false;}
    03943                                         varlbattON = true;
    03944                                         GETATTRIBUTETEXT;
    03945                                         osinstance->instanceData->variables->var[varcount]->lb = atofmod1( osillineno,attText, attTextEnd);
    03946                                         delete [] attText;
    03947                                         //printf("ATTRIBUTE = %s\n", attText);
    03948                                         break;
    03949                                 case 'u':
    03950                                         ch++;
    03951                                         if(*ch++ != 'b') {  osilerror_wrapper( ch,osillineno,"error in variables upper bound attribute"); return false;}
    03952                                         if(varubattON == true) {  osilerror_wrapper( ch,osillineno,"too many variable ub attributes"); return false;}
    03953                                         varubattON = true;
    03954                                         GETATTRIBUTETEXT;
    03955                                         osinstance->instanceData->variables->var[varcount]->ub = atofmod1( osillineno,attText, attTextEnd);
    03956                                         delete [] attText;
    03957                                         //printf("ATTRIBUTE = %s\n", attText);
    03958                                         break;
    03959                                 case 'm':
    03960                                         *p = ch;
    03961                                         while(*mult++  == *ch) ch++;
    03962                                         if( (ch - *p) != 4) {  osilerror_wrapper( ch,osillineno,"error in variables mult attribute"); return false;}
    03963                                         mult -= 5;
    03964                                         if(varmultattON == true) {  osilerror_wrapper( ch,osillineno,"too many variable mult attributes"); return false;}
    03965                                         varmultattON = true;
    03966                                         GETATTRIBUTETEXT;
    03967                                         varmult = atoimod1( osillineno,attText, attTextEnd);
    03968                                         delete [] attText;
    03969                                         //printf("ATTRIBUTE = %s\n", attText);
    03970                                         break;
    03971                                 case ' ':
    03972                                         break;
    03973                                 case '\n':
    03974                                         (*osillineno)++;
    03975                                         break;
    03976                                 case '\t':
    03977                                         break;
    03978                                 case '\r':
    03979                                         break;
    03980                                 default:
    03981                                         osilerror_wrapper( ch,osillineno,"invalid attribute character");
    03982                                         return false;
    03983                                         break;
    03984                                 }
    03985                                 ch++;
    03986                         }
    03987                         //
    03988                         // assume all the attributes have been processed
    03989                         // must have either /> or > and then whitespace and </var whitespace>
    03990                         if( *ch != '/' && *ch != '>') {  osilerror_wrapper( ch,osillineno,"incorrect end of <var> element"); return false;}
    03991                         if(*ch == '/'){
    03992                                 ch++;
    03993                                 if(*ch != '>') {  osilerror_wrapper( ch,osillineno,"incorrect end of <var> element"); return false;}
    03994                                 // get rid of whitespace
    03995                                 ch++;
    03996                                 for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    03997                                 // either have another <var> element or foundVar = false;
    03998                                 *p = ch;
    03999                                 while(*startVar++  == *ch) ch++;
    04000                                 if( (ch - *p) == 4) {
    04001                                         foundVar = true;
    04002                                         startVar -= 5;
    04003                                 }
    04004                                 else {
    04005                                         foundVar = false;
    04006                                         ch = *p;
    04007                                 }
    04008                         }
    04009                         else{
    04010                                 // the buf_index is the > at the end of the var element
    04011                                 // double check to make sure it really is a >
    04012                                 if(*ch != '>') {  osilerror_wrapper( ch,osillineno,"improper ending to a <var> element"); return false;}
    04013                                 // look for </var
    04014                                 // fist get rid of white space
    04015                                 ch++;
    04016                                 for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04017                                 // we should be at </var or there is an error
    04018                                 *p = ch;
    04019                                 while(*endVar++  == *ch) ch++;
    04020                                 endVar -= 6;
    04021                                 if( (ch - *p) != 5) {  osilerror_wrapper( ch,osillineno,"</var> element missing"); return false;}
    04022                                 // burn off the whitespace
    04023                                 for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04024                                 // better have an > to end </var
    04025                                 if(*ch++ != '>') {  osilerror_wrapper( ch,osillineno,"</var> element missing >"); return false;}
    04026                                 // look for a new <var> element
    04027                                 // get rid of whitespace
    04028                                 ch++;
    04029                                 for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04030                                 // either have another <var> element or foundVar = false;
    04031                                 *p = ch;
    04032                                 while(*startVar++  == *ch) ch++;
    04033                                 if( (ch - *p) == 4) {
    04034                                         foundVar = true;
    04035                                         startVar -= 5;
    04036                                 }
    04037                                 else {
    04038                                         foundVar = false;
    04039                                         ch = *p;
    04040                                 }
    04041                         }
    04042                         if( ((varcount+varmult) == numberOfVariables) && (foundVar == true) ) {   osilerror_wrapper( ch,osillineno,"attribute numberOfVariables is less than actual number found");  return false;}
    04043                         for (int k=1; k < varmult; k++)
    04044                         {
    04045                                 osinstance->instanceData->variables->var[varcount+k]->name
    04046                                 = osinstance->instanceData->variables->var[varcount]->name;
    04047                                 osinstance->instanceData->variables->var[varcount+k]->type
    04048                                 = osinstance->instanceData->variables->var[varcount]->type;
    04049                                 osinstance->instanceData->variables->var[varcount+k]->lb
    04050                                 = osinstance->instanceData->variables->var[varcount]->lb;
    04051                                 osinstance->instanceData->variables->var[varcount+k]->ub
    04052                                 = osinstance->instanceData->variables->var[varcount]->ub;
    04053                         }
    04054                         varcount += varmult;
    04055                 }// end while(foundVar)
    04056                 if(varcount < numberOfVariables) {  osilerror_wrapper( ch,osillineno,"attribute numberOfVariables is greater than actual number found");   return false;}
    04057                 // get the </variables> tag
    04058                 *p = ch;
    04059                 while(*endVariables++  == *ch) ch++;
    04060                 if( (ch - *p) != 11) {   osilerror_wrapper( ch,osillineno,"cannot find </variables> tag"); return false;}
    04061                 for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04062                 // better have >
    04063                 if(*ch != '>') {   osilerror_wrapper( ch,osillineno,"improperly formed </variables> tag"); return false;}
    04064                 ch++;
    04065         }else {//end if(numberOfVariables > 0)
    04066                 // error if the number is negative
    04067                 if(numberOfVariables < 0) {  osilerror_wrapper( ch,osillineno,"cannot have a negative number of variables"); return false;}
    04068                 // if we are here we have numberOfVariables = 0
    04069                 // must close with /> or </variables>
    04070                 // get rid of white space
    04071                 for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04072                 if( *ch == '/'){
    04073                         // better have a >
    04074                         ch++;
    04075                         if( *ch  != '>') {  osilerror_wrapper( ch,osillineno,"improperly closed variables tag"); return false;}
    04076                         ch++;
    04077                 }
    04078                 else{
    04079                         // if we are here we must have an '>' and then  </constraints> tag
    04080                         if( *ch  != '>') {  osilerror_wrapper( ch,osillineno,"improperly closed variables tag"); return false;}
    04081                         ch++;
    04082                         // burn white space
    04083                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04084                         *p = ch;
    04085                         while( *endVariables++  == *ch) ch++;
    04086                         if( (ch - *p) != 11) {  osilerror_wrapper( ch,osillineno, "cannot find </variables> tag"); return false; }
    04087                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04088                         // better have >
    04089                         if(*ch != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed </variables> tag"); return false;}
    04090                         ch++;
    04091                 }
    04092
    04093         }
    04094         finish = clock();
    04095         #ifdef CHECK_PARSE_TIME
    04096         duration = (double) (finish - start) / CLOCKS_PER_SEC;
    04097         printf("TIME TO PARSE VARIABLES = %f\n", duration);
    04098         #endif
    04099         *p = ch;
    04100         return true;
    04101 }//end parseVariables
    04102
    04103
    04104 bool parseObjectives( const char **p, OSInstance *osinstance, int* osillineno){
    04105         clock_t start, finish;
    04106         #ifdef CHECK_PARSE_TIME
    04107         double duration;
    04108         #endif
    04109         int ki, numChar;
    04110         char *attTextEnd;
    04111         const char *ch = *p;
    04112         start = clock();
    04113         const char *c_numberOfObjectives = "numberOfObjectives";
    04114         const char *startObjectives = "<objectives";
    04115         const char *endObjectives = "</objectives";
    04116         const char *startObj = "<obj";
    04117         const char *endObj = "</obj";
    04118         // attributes
    04119         char *attText = NULL;
    04120         const char *constant = "constant";
    04121         const char *maxOrMin = "maxOrMin";
    04122         const char *numberOfObjCoef = "numberOfObjCoef";
    04123         const char *weight = "weight";
    04124         const char *name = "name";
    04125         const char *mult = "mult";
    04126         // others
    04127         int i;
    04128         // objective function attribute boolean variables
    04129         bool objmaxOrMinattON = false;
    04130         bool objnameattON = false;
    04131         bool objconstantattON = false;
    04132         bool objweightattON = false;
    04133         bool objmultattON = false;
    04134         bool objnumberOfObjCoefattON = false;
    04135         int objcount = 0;
    04136         int numberOfObjectives;
    04137         bool foundObj;
    04138         int objmult;
    04139         // start parsing
    04140         // burn white space
    04141         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    04142         // if, present we should be pointing to <objectives element if there -- it is not required
    04143         *p = ch;
    04144         while( *startObjectives++  == *ch) ch++;
    04145         if( (ch - *p) != 11) {
    04146                 //  note if we are here even though ch > *p we want to return *p
    04147                 return true;
    04148         }
    04149         // find numberOfObjectives attribute -- it is valid for this attribute to be missing.
    04150         // However if the  number attribute is missing assume it is     1
    04151         // eat the white space
    04152         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    04153         // we just ate the white space. If numberOfObjectives is missing we assume it is 1
    04154         // we therefore must have > char
    04155         if(*ch == '>'){
    04156                 numberOfObjectives = 1;
    04157                 //ch++;
    04158         }
    04159         else{
    04160                 *p = ch;
    04161                 while( *c_numberOfObjectives++  == *ch) ch++;
    04162                 if( (ch - *p) != 18) {  osilerror_wrapper( ch,osillineno,"incorrect numberOfObjectives attribute in <objectives> tag"); return false;}
    04163                 GETATTRIBUTETEXT;
    04164                 numberOfObjectives = atoimod1( osillineno, attText, attTextEnd);
    04165                 delete [] attText;
    04166                 ch++;
    04167         }
    04168         if(numberOfObjectives > 0){
    04169                 // get rid of white space after the numberOfObjectives attribute
    04170                 for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    04171                 // we must have an >
    04172                 /*if(*ch == '/'){
    04173                         ch++;
    04174                         if( *ch++ != '>') {  osilerror_wrapper( ch,osillineno,"the objectives element does not have a proper closing"); return false; }
    04175                         else{
    04176                                 if(numberOfObjectives > 0){   osilerror_wrapper( ch,osillineno,"numberOfObjectives positive but there are no objectives"); return false;}
    04177                                 return false;
    04178                         }
    04179                 }*/
    04180                 //  we better have an >
    04181                 if( *ch++ != '>') {  osilerror_wrapper( ch,osillineno,"the objectives element does not have a proper closing"); return false;}
    04182                 osinstance->instanceData->objectives->numberOfObjectives = numberOfObjectives;
    04183                 osinstance->instanceData->objectives->obj = new Objective*[ numberOfObjectives];
    04184                 for(i = 0; i < numberOfObjectives; i++){
    04185                         osinstance->instanceData->objectives->obj[ i] = new Objective();
    04186                 }
    04187         // get rid of white space after the <objectives> element
    04188         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    04189         // now loop over the obj elements, there must be at least one obj element
    04190         *p = ch;
    04191         while( *startObj++  == *ch) ch++;
    04192         if( (ch - *p) == 4) foundObj = true;
    04193                 else {  osilerror_wrapper( ch,osillineno,"there must be at least one <obj> element"); return false;}
    04194         startObj -= 5;
    04195         start = clock();
    04196         while(foundObj){
    04197                 objmaxOrMinattON = false;
    04198                 objnameattON = false;
    04199                 objconstantattON = false;
    04200                 objweightattON = false;
    04201                 objmultattON = false;
    04202                 objnumberOfObjCoefattON = false;
    04203                 objmult = 1;
    04204                 // assume we are pointing to the first character after the r in <obj
    04205                 // it should be a space so let's increment ch
    04206                 ch++;
    04207                 while(*ch != '/' && *ch != '>'){
    04208                         switch (*ch) {
    04209                         case 'n':
    04210                                 if( *(ch+1) == 'u'){
    04211                                         *p = ch;
    04212                                         while( *numberOfObjCoef++  == *ch) ch++;
    04213                                         numberOfObjCoef -= 16;
    04214                                         if( ( (ch - *p) != 15)  ) {  osilerror_wrapper( ch,osillineno,"error in objective numberOfObjCoef attribute"); return false;}
    04215                                         else{
    04216                                                 if(objnumberOfObjCoefattON == true) {  osilerror_wrapper( ch,osillineno,"too many obj numberOfObjCoef attributes"); return false;}
    04217                                                 objnumberOfObjCoefattON = true;
    04218                                                 GETATTRIBUTETEXT;
    04219                                                 //printf("ATTRIBUTE = %s\n", attText);
    04220                                                 osinstance->instanceData->objectives->obj[objcount]->numberOfObjCoef=atoimod1( osillineno,attText, attTextEnd);
    04221                                                 if(osinstance->instanceData->objectives->obj[objcount]->numberOfObjCoef > 0 && osinstance->instanceData->variables->numberOfVariables == 0){  osilerror_wrapper( ch,osillineno,"we have zero variables, but have objective function coefficients"); return false;}
    04222                                                 osinstance->instanceData->objectives->obj[objcount]->coef = new ObjCoef*[osinstance->instanceData->objectives->obj[ objcount]->numberOfObjCoef];
    04223                                                 for(int i = 0; i < osinstance->instanceData->objectives->obj[ objcount]->numberOfObjCoef; i++)osinstance->instanceData->objectives->obj[objcount]->coef[i] = new ObjCoef();
    04224                                                 delete [] attText;
    04225                                         }
    04226                                 }
    04227                                 else{
    04228                                         *p = ch;
    04229                                         while( *name++  == *ch) ch++;
    04230                                         name -= 5;
    04231                                         if( ( (ch - *p) != 4)  ) {  osilerror_wrapper( ch,osillineno,"error in objective name attribute"); return false;}
    04232                                         else{
    04233                                                 if(objnameattON == true) {  osilerror_wrapper( ch,osillineno,"too many obj name attributes"); return false;}
    04234                                                 objnameattON = true;
    04235                                                 GETATTRIBUTETEXT;
    04236                                                 //printf("ATTRIBUTE = %s\n", attText);
    04237                                                 osinstance->instanceData->objectives->obj[objcount]->name=attText;
    04238                                                 delete [] attText;
    04239                                         }
    04240                                 }
    04241                                 break;
    04242                         case 'c':
    04243                                 *p = ch;
    04244                                 while( *constant++  == *ch) ch++;
    04245                                 constant -= 9;
    04246                                 if( ( (ch - *p) != 8)  ) {  osilerror_wrapper( ch,osillineno,"error in objective constant attribute"); return false;}
    04247                                 else{
    04248                                         if(objconstantattON == true) {  osilerror_wrapper( ch,osillineno,"too many obj constant attributes"); return false;}
    04249                                         objconstantattON = true;
    04250                                         GETATTRIBUTETEXT;
    04251                                         //printf("ATTRIBUTE = %s\n", attText);
    04252                                         osinstance->instanceData->objectives->obj[objcount]->constant=atofmod1( osillineno,attText, attTextEnd);
    04253                                         delete [] attText;
    04254                                 }
    04255                                 break;
    04256                         case 'w':
    04257                                 *p = ch;
    04258                                 while( *weight++  == *ch) ch++;
    04259                                 weight -= 7;
    04260                                 if( ( (ch - *p) != 6)  ) {  osilerror_wrapper( ch,osillineno,"error in objective weight attribute"); return false;}
    04261                                 else{
    04262                                         if(objweightattON == true) {  osilerror_wrapper( ch,osillineno,"too many obj weight attributes"); return false;}
    04263                                         objweightattON = true;
    04264                                         GETATTRIBUTETEXT;
    04265                                         //printf("ATTRIBUTE = %s\n", attText);
    04266                                         osinstance->instanceData->objectives->obj[objcount]->weight=atofmod1( osillineno,attText, attTextEnd);
    04267                                         delete [] attText;
    04268                                 }
    04269                                 break;
    04270                         case 'm':
    04271                                 if(*(ch+1) == 'a'){
    04272                                         *p = ch;
    04273                                         while( *maxOrMin++  == *ch) ch++;
    04274                                         maxOrMin -= 9;
    04275                                         if( ( ( ch - *p)  != 8)  ) {  osilerror_wrapper( ch,osillineno,"error in objective maxOrMin attribute"); return false;}
    04276                                         else{
    04277                                                 if(objmaxOrMinattON == true) {  osilerror_wrapper( ch,osillineno,"too many obj maxOrMin attributes"); return false;}
    04278                                                 objmaxOrMinattON = true;
    04279                                                 GETATTRIBUTETEXT;
    04280                                                 //printf("ATTRIBUTE = %s\n", attText);
    04281                                                 if( (strcmp("max", attText) != 0 ) && (strcmp("min", attText) != 0 ) ){osilerror_wrapper( ch,osillineno,"maxOrMin attribute in objective must be a max or min"); return false;}
    04282                                                 osinstance->instanceData->objectives->obj[objcount]->maxOrMin = attText;
    04283                                                 delete [] attText;
    04284                                         }
    04285                                 }
    04286                                 else{
    04287                                         *p = ch;
    04288                                         while( *mult++  == *ch) ch++;
    04289                                         mult -= 5;
    04290                                         if( ( (ch - *p) != 4)  ) {  osilerror_wrapper( ch,osillineno,"error in objective mult attribute"); return false;}
    04291                                         else{
    04292                                                 if(objmultattON == true) {  osilerror_wrapper( ch,osillineno,"too many obj mult attributes"); return false;}
    04293                                                 objmultattON = true;
    04294                                                 GETATTRIBUTETEXT;
    04295                                                 objmult = atoimod1( osillineno,attText, attTextEnd);
    04296                                                 //printf("ATTRIBUTE = %s\n", attText);
    04297                                                 //osinstance->instanceData->objectives->obj[objcount]->name=attText;
    04298                                                 delete [] attText;
    04299                                         }
    04300                                 }
    04301                                 break;
    04302                         // come back and do multiplicity
    04303                         case ' ':
    04304                                 break;
    04305                         case '\n':
    04306                                 (*osillineno)++;
    04307                                 break;
    04308                         case '\t':
    04309                                 break;
    04310                         case '\r':
    04311                                 break;
    04312                         default:
    04313
    04314                                 osilerror_wrapper( ch,osillineno,"invalid attribute character");
    04315                                 return false;
    04316                                 break;
    04317                         }
    04318                         ch++;
    04319                 }
    04320                 //
    04321                 // assume all the attributes have been processed
    04322                 // must have either /> or > and then whitespace and </obj whitespace>
    04323                 if( *ch != '/' && *ch != '>') {   osilerror_wrapper( ch,osillineno,"incorrect end of <obj> element"); return false;}
    04324                 if(*ch == '/'){
    04325                         ch++;
    04326                         if(*ch != '>') {  osilerror_wrapper( ch,osillineno,"incorrect end of <obj> element"); return false;}
    04327                         // get rid of whitespace
    04328                         ch++;
    04329                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04330                         // either have another <obj> element or foundObj = false;
    04331                         for(i = 0; startObj[i]  == *ch; i++, ch++);
    04332                         if(i == 4) foundObj = true;
    04333                                 else foundObj = false;
    04334                 }
    04335                 else{
    04336                         // the ch is the > at the end of the obj element
    04337                         // double check to make sure it really is a >
    04338                         if(*ch != '>') {  osilerror_wrapper( ch,osillineno,"improper ending to a <obj> element"); return false;}
    04339                         // look for </obj
    04340                         // fist get rid of white space
    04341                         ch++;
    04342                         // first get the <coef> elements
    04343                         parseObjCoef(&ch,  objcount, osinstance, osillineno);
    04344                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04345                         // we should be at </obj or there is an error
    04346                         for(i = 0; endObj[i]  == *ch; i++, ch++);
    04347                         if(i != 5) {  osilerror_wrapper( ch,osillineno,"</obj> element missing"); return false;}
    04348                         // burn off the whitespace
    04349                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04350                         // better have an > to end </obj
    04351                         if(*ch++ != '>'){   osilerror_wrapper( ch,osillineno,"</obj> element missing"); return false;}
    04352                         // look for a new <obj> element
    04353                         // get rid of whitespace
    04354                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04355                         // either have another <obj> element or foundObj = false;
    04356                         for(i = 0; startObj[i]  == *ch; i++, ch++);
    04357                         if(i == 4) foundObj = true;
    04358                                 else foundObj = false;
    04359                 }
    04360                 if( ((objcount+objmult) == numberOfObjectives) && (foundObj == true)) {  osilerror_wrapper( ch,osillineno,"attribute numberOfObjectives is less than actual number found"); return false;}
    04361                 for (int k=1; k < objmult; k++)
    04362                 {
    04363                         osinstance->instanceData->objectives->obj[objcount+k]->name
    04364                         = osinstance->instanceData->objectives->obj[objcount]->name;
    04365                         osinstance->instanceData->objectives->obj[objcount+k]->maxOrMin
    04366                         = osinstance->instanceData->objectives->obj[objcount]->maxOrMin;
    04367                         osinstance->instanceData->objectives->obj[objcount+k]->constant
    04368                         = osinstance->instanceData->objectives->obj[objcount]->constant;
    04369                         osinstance->instanceData->objectives->obj[objcount+k]->weight
    04370                         = osinstance->instanceData->objectives->obj[objcount]->weight;
    04371                         osinstance->instanceData->objectives->obj[objcount+k]->numberOfObjCoef
    04372                         = osinstance->instanceData->objectives->obj[objcount]->numberOfObjCoef;
    04373                         if (osinstance->instanceData->objectives->obj[objcount]->numberOfObjCoef > 0)
    04374                         {
    04375                                 osinstance->instanceData->objectives->obj[objcount+k]->coef = new ObjCoef*[osinstance->instanceData->objectives->obj[ objcount]->numberOfObjCoef];
    04376                                 for(int i = 0; i < osinstance->instanceData->objectives->obj[ objcount]->numberOfObjCoef; i++)
    04377                                 {
    04378                                         osinstance->instanceData->objectives->obj[objcount+k]->coef[i] = new ObjCoef();
    04379                                         osinstance->instanceData->objectives->obj[objcount+k]->coef[i]->idx =
    04380                                           osinstance->instanceData->objectives->obj[objcount]->coef[i]->idx;
    04381                                         osinstance->instanceData->objectives->obj[objcount+k]->coef[i]->value =
    04382                                           osinstance->instanceData->objectives->obj[objcount]->coef[i]->value;
    04383                                 }
    04384                         }
    04385                 }
    04386                 objcount += objmult;
    04387         }
    04388         if(objcount < numberOfObjectives) {  osilerror_wrapper( ch,osillineno,"attribute numberOfObjectives is greater than actual number found"); return false;}
    04389         ch -= i;
    04390         // get the </objectives> tag
    04391         for(i = 0; endObjectives[i]  == *ch; i++, ch++);
    04392         if(i != 12) {  osilerror_wrapper( ch,osillineno, "cannot find </objectives> tag"); return false; }
    04393         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04394         // better have >
    04395         if(*ch != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed </objectives> tag"); return false;}
    04396         ch++;
    04397         } // finish the (if numberOfObjectives > 0)
    04398         else{
    04399                 // error if the number is negative
    04400                 if(numberOfObjectives < 0) {  osilerror_wrapper( ch,osillineno,"cannot have a negative number of objectives"); return false;}
    04401                 // if we are here we have exactly 0 objectives
    04402                 // must close with /> or </objectives>
    04403                 // get rid of white space
    04404                 for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04405                 if( *ch == '/'){
    04406                         // better have a >
    04407                         ch++;
    04408                         if( *ch  != '>') {  osilerror_wrapper( ch,osillineno,"improperly closed objectives tag"); return false;}
    04409                         ch++;
    04410                 }
    04411                 else{
    04412                         // if we are here we must have an '>' and then  </objectives> tag
    04413                         if( *ch  != '>') {  osilerror_wrapper( ch,osillineno,"improperly closed objectives tag"); return false;}
    04414                         ch++;
    04415                         // burn white space
    04416                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04417                         for(i = 0; endObjectives[i]  == *ch; i++, ch++);
    04418                         if(i != 12) {  osilerror_wrapper( ch,osillineno, "cannot find </objectives> tag"); return false; }
    04419                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04420                         // better have >
    04421                         if(*ch != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed </objectives> tag"); return false;}
    04422                         ch++;
    04423                 }
    04424         }
    04425         finish = clock();
    04426         #ifdef CHECK_PARSE_TIME
    04427         duration = (double) (finish - start) / CLOCKS_PER_SEC;
    04428         printf("TIME TO PARSE OBJECTIVES = %f\n", duration);
    04429         #endif
    04430         *p = ch;
    04431         return true;
    04432 }//end parseObjectives
    04433
    04434 bool parseConstraints( const char **p, OSInstance *osinstance, int* osillineno){
    04435         clock_t start, finish;
    04436         #ifdef CHECK_PARSE_TIME
    04437         double duration;
    04438         #endif
    04439         int ki, numChar;
    04440         char *attTextEnd;
    04441         const char *ch = *p;
    04442         start = clock();
    04443         const char *c_numberOfConstraints = "numberOfConstraints";
    04444         const char *startConstraints = "<constraints";
    04445         const char *endConstraints = "</constraints";
    04446         const char *startCon = "<con";
    04447         const char *endCon = "</con";
    04448         // attributes
    04449         char *attText = NULL;
    04450         const char *name = "name";
    04451         const char *constant = "constant";
    04452         const char *mult = "mult";
    04453         // others
    04454         int i;
    04455         int concount = 0;
    04456         int numberOfConstraints = 0;
    04457         // constraint attribute boolean variables
    04458         bool conlbattON = false ;
    04459         bool conubattON  = false;
    04460         bool connameattON = false;
    04461         bool conconstantattON  = false;
    04462         bool conmultattON = false;
    04463         bool foundCon = false;
    04464         int conmult;
    04465         //
    04466         // start parsing -- ok not to have constraints
    04467         // burn white space
    04468         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    04469         // if, present we should be pointing to <constraints element if there -- it is not required
    04470         *p = ch;
    04471         for(i = 0; startConstraints[i]  == *ch; i++, ch++);
    04472         while( *startConstraints++  == *ch) ch++;
    04473         if( (ch - *p) != 12) {
    04474                 //  *p is the correct value for the pointer
    04475                 return true;
    04476         }
    04477         // find numberOfConstraints attribute
    04478         // eat the white space
    04479         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    04480         *p = ch;
    04481         while( *c_numberOfConstraints++  == *ch) ch++;
    04482         if( (ch - *p) != 19) {  osilerror_wrapper( ch,osillineno,"incorrect numberOfConstraints attribute in <constraints> tag"); return false;}
    04483         // ch should be pointing to the first character after numberOfConstraints
    04484         GETATTRIBUTETEXT;
    04485         ch++;
    04486         numberOfConstraints = atoimod1( osillineno, attText, attTextEnd);
    04487         delete [] attText;
    04488         // key if
    04489         //
    04490         if(numberOfConstraints > 0){
    04491                 osinstance->instanceData->constraints->numberOfConstraints = numberOfConstraints;
    04492                 osinstance->instanceData->constraints->con = new Constraint*[ numberOfConstraints];
    04493                 for(i = 0; i < numberOfConstraints; i++){
    04494                         osinstance->instanceData->constraints->con[ i] = new Constraint();
    04495                 }
    04496         // get rid of white space after the numberOfConstraints element
    04497         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    04498         //  we better have an >
    04499         if( *ch++ != '>') {   osilerror_wrapper( ch,osillineno,"the constraints element does not have a proper closing"); return false;}
    04500         // get rid of white space after the <constraints> element
    04501         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    04502         // now loop over the con elements, there must be at least one con element
    04503         *p = ch;
    04504         while( *startCon++  == *ch) ch++;
    04505         if( (ch - *p) == 4) foundCon = true;
    04506                 else {  osilerror_wrapper( ch,osillineno,"there must be at least one <con> element"); return false;}
    04507         startCon -= 5;
    04508         while(foundCon){
    04509                 conlbattON = false ;
    04510                 conubattON  = false;
    04511                 connameattON = false;
    04512                 conconstantattON  = false;
    04513                 conmultattON = false;
    04514                 conmult = 1;
    04515
    04516                 // assume we are pointing to the first character after the n in <con
    04517                 // it should be a space so let's increment ch
    04518                 for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04519                 while(*ch != '/' && *ch != '>'){
    04520                         switch (*ch) {
    04521                         case 'n':
    04522                                 *p = ch;
    04523                                 while( *name++  == *ch) ch++;
    04524                                 if( (ch - *p) != 4) {  osilerror_wrapper( ch,osillineno,"error in constraints name attribute"); return false;}
    04525                                 if(connameattON == true) {  osilerror_wrapper( ch,osillineno,"too many con name attributes"); return false;}
    04526                                 name -= 5;
    04527                                 connameattON = true;
    04528                                 GETATTRIBUTETEXT;
    04529                                 osinstance->instanceData->constraints->con[concount]->name=attText;
    04530                                 delete [] attText;
    04531                                 //printf("ATTRIBUTE = %s\n", attText);
    04532                                 break;
    04533                         case 'c':
    04534                                 *p = ch;
    04535                                 while( *constant++  == *ch) ch++;
    04536                                 if( ((ch - *p)  != 8)  ) {  osilerror_wrapper( ch,osillineno,"error in constraint constant attribute"); return false;}
    04537                                 if(conconstantattON == true) {  osilerror_wrapper( ch,osillineno,"too many con constant attributes"); return false;}
    04538                                 constant -= 9;
    04539                                 conconstantattON = true;
    04540                                 GETATTRIBUTETEXT;
    04541                                 //printf("ATTRIBUTE = %s\n", attText);
    04542                                 osinstance->instanceData->constraints->con[concount]->constant=atofmod1( osillineno,attText, attTextEnd);
    04543                                 delete [] attText;
    04544                                 break;
    04545                         case 'l':
    04546                                 ch++;
    04547                                 if(*ch++ != 'b') {   osilerror_wrapper( ch,osillineno,"error in constraint lb attribute"); return false;}
    04548                                 if(conlbattON == true) {  osilerror_wrapper( ch,osillineno,"too many con lb attributes"); return false;}
    04549                                 conlbattON = true;
    04550                                 GETATTRIBUTETEXT;
    04551                                 osinstance->instanceData->constraints->con[concount]->lb = atofmod1( osillineno,attText, attTextEnd);
    04552                                 delete [] attText;
    04553                                 //printf("ATTRIBUTE = %s\n", attText);
    04554                                 break;
    04555                         case 'u':
    04556                                 ch++;
    04557                                 if(*ch++ != 'b') {  osilerror_wrapper( ch,osillineno,"error in constraint ub attribute"); return false;}
    04558                                 if(conubattON == true) {  osilerror_wrapper( ch,osillineno,"too many con ub attributes"); return false;}
    04559                                 conubattON = true;
    04560                                 GETATTRIBUTETEXT;
    04561                                 osinstance->instanceData->constraints->con[concount]->ub = atofmod1( osillineno,attText, attTextEnd);
    04562                                 delete [] attText;
    04563                                 //printf("ATTRIBUTE = %s\n", attText);
    04564                                 break;
    04565                         case 'm':
    04566                                 *p = ch;
    04567                                 while( *mult++  == *ch) ch++;
    04568                                 if( (ch - *p) != 4) {  osilerror_wrapper( ch,osillineno,"error in constraints mult attribute"); return false;}
    04569                                 if(conmultattON == true) {  osilerror_wrapper( ch,osillineno,"too many con mult attributes"); return false;}
    04570                                 mult -= 5;
    04571                                 conmultattON = true;
    04572                                 GETATTRIBUTETEXT;
    04573                                 conmult = atoimod1( osillineno,attText, attTextEnd);
    04574                                 delete [] attText;
    04575                                 //printf("ATTRIBUTE = %s\n", attText);
    04576                                 break;
    04577                         case ' ':
    04578                                 break;
    04579                         case '\n':
    04580                                 (*osillineno)++;
    04581                                 break;
    04582                         case '\t':
    04583                                 break;
    04584                         case '\r':
    04585                                 break;
    04586                         default:
    04587                                 osilerror_wrapper( ch,osillineno,"invalid attribute character");
    04588                                 return false;
    04589                                 break;
    04590                         }
    04591                         ch++;
    04592                 }
    04593                 //
    04594                 // assume all the attributes have been processed
    04595                 // must have either /> or > and then whitespace and </con whitespace>
    04596                 if( *ch != '/' && *ch != '>') {  osilerror_wrapper( ch,osillineno,"incorrect end of <con> element"); return false;}
    04597                 if(*ch == '/'){
    04598                         ch++;
    04599                         if(*ch != '>') {  osilerror_wrapper( ch,osillineno,"incorrect end of <con> element"); return false;}
    04600                         // get rid of whitespace
    04601                         ch++;
    04602                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04603                         // either have another <con> element or foundCon = false;
    04604                         *p = ch;
    04605                         while( *startCon++  == *ch) ch++;
    04606                         if( (ch - *p) == 4){
    04607                                 foundCon = true;
    04608                                 startCon -= 5;
    04609                         }
    04610                         else{
    04611                                 foundCon = false;
    04612                                 ch = *p;
    04613                         }
    04614                 }
    04615                 else{
    04616                         // the ch is the > at the end of the con element
    04617                         // double check to make sure it really is a >
    04618                         if(*ch != '>') {  osilerror_wrapper( ch,osillineno,"improper ending to a <con> element"); return false;}
    04619                         // look for </con
    04620                         // fist get rid of white space
    04621                         ch++;
    04622                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04623                         // we should be at </con or there is an error
    04624                         *p = ch;
    04625                         while( *endCon++  == *ch) ch++;
    04626                         if( (ch - *p) != 5) {  osilerror_wrapper( ch,osillineno,"</con> element missing"); return false;}
    04627                         endCon -= 6;
    04628                         // burn off the whitespace
    04629                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04630                         // better have an > to end </con
    04631                         if(*ch++ != '>') {  osilerror_wrapper( ch,osillineno,"</con> element missing >"); return false;}
    04632                         // look for a new <con> element
    04633                         // get rid of whitespace
    04634                         ch++;
    04635                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04636                         // either have another <con> element or foundVar = false;
    04637                         *p = ch;
    04638                         while( *startCon++  == *ch) ch++;
    04639                         if( (ch - *p) == 4){
    04640                                 foundCon = true;
    04641                                 startCon -= 5;
    04642                         }
    04643                         else{
    04644                                 foundCon = false;
    04645                                 ch = *p;
    04646                         }
    04647                 }
    04648                 if( ((concount+conmult) == numberOfConstraints) && (foundCon == true) ) {  osilerror_wrapper( ch,osillineno,"attribute numberOfConstraints is less than actual number found"); return false;}
    04649                 for (int k=1; k < conmult; k++)
    04650                 {
    04651                         osinstance->instanceData->constraints->con[concount+k]->name
    04652                         = osinstance->instanceData->constraints->con[concount]->name ;
    04653                         osinstance->instanceData->constraints->con[concount+k]->constant
    04654                         = osinstance->instanceData->constraints->con[concount]->constant ;
    04655                         osinstance->instanceData->constraints->con[concount+k]->lb
    04656                         = osinstance->instanceData->constraints->con[concount]->lb ;
    04657                         osinstance->instanceData->constraints->con[concount+k]->ub
    04658                         = osinstance->instanceData->constraints->con[concount]->ub ;
    04659                 }
    04660                 concount += conmult;
    04661         }
    04662         if(concount < numberOfConstraints) {  osilerror_wrapper( ch,osillineno,"attribute numberOfConstraints is greater than actual number found"); return false;}
    04663         // get the </constraints> tag
    04664         *p = ch;
    04665         while( *endConstraints++  == *ch) ch++;
    04666         if( (ch - *p) != 13) {  osilerror_wrapper( ch,osillineno, "cannot find </constraints> tag"); return false;}
    04667         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04668         // better have >
    04669         if(*ch != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed </constraints> tag");     return false;}
    04670         ch++;
    04671         }// end if(numberOfConstraints > 0)
    04672         else{
    04673                 // error if the number is negative
    04674                 if(numberOfConstraints < 0) {  osilerror_wrapper( ch,osillineno,"cannot have a negative number of constraints"); return false;}
    04675                 // if we are here we have numberOfConstraints = 0
    04676                 // must close with /> or </constraints>
    04677                 // get rid of white space
    04678                 for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04679                 if( *ch == '/'){
    04680                         // better have a >
    04681                         ch++;
    04682                         if( *ch  != '>') {  osilerror_wrapper( ch,osillineno,"improperly closed constraints tag"); return false;}
    04683                         ch++;
    04684                 }
    04685                 else{
    04686                         // if we are here we must have an '>' and then  </constraints> tag
    04687                         if( *ch  != '>') {  osilerror_wrapper( ch,osillineno,"improperly closed constraints tag"); return false;}
    04688                         ch++;
    04689                         // burn white space
    04690                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04691                         *p = ch;
    04692                         while( *endConstraints++  == *ch) ch++;
    04693                         if( (ch - *p) != 13) {  osilerror_wrapper( ch,osillineno, "cannot find </constraints> tag"); return false; }
    04694                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04695                         // better have >
    04696                         if(*ch != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed </constraints> tag"); return false;}
    04697                         ch++;
    04698                 }
    04699         }
    04700         finish = clock();
    04701         #ifdef CHECK_PARSE_TIME
    04702         duration = (double) (finish - start) / CLOCKS_PER_SEC;
    04703         printf("TIME TO PARSE CONSTRAINTS = %f\n", duration);
    04704         #endif
    04705         *p = ch;
    04706         return true;
    04707 }//end parseConstraints
    04708
    04709 bool parseLinearConstraintCoefficients( const char **p, OSInstance *osinstance, int* osillineno){;
    04710         int ki, numChar;
    04711         char *attTextEnd;
    04712         const char *ch = *p;
    04713         const char *c_numberOfValues = "numberOfValues";
    04714         const char *startlinearConstraintCoefficients = "<linearConstraintCoefficients";
    04715         const char *endlinearConstraintCoefficients = "</linearConstraintCoefficients";
    04716         // attributes
    04717         char *attText = NULL;
    04718         // others
    04719         int numberOfValues;
    04720         // start parsing
    04721         // burn white space
    04722         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    04723         // if, present we should be pointing to <linearConstraintCoefficients element if there -- it is not required
    04724         *p = ch;
    04725         while( *startlinearConstraintCoefficients++  == *ch) ch++;
    04726         if( (ch - *p) != 29) {
    04727                 //reset ch
    04728                 ch = *p;
    04729                 return true;
    04730         }
    04731         // find numberOfValues attribute
    04732         // eat the white space
    04733         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    04734         *p = ch;
    04735         while( *c_numberOfValues++  == *ch) ch++;
    04736         if( (ch - *p) != 14) {  osilerror_wrapper( ch,osillineno,"incorrect numberOfValues attribute in <linearConstraintCoefficients> tag"); return false;}
    04737         // ch should be pointing to the first character after numberOfValues
    04738         GETATTRIBUTETEXT;
    04739         ch++;
    04740         numberOfValues = atoimod1( osillineno, attText, attTextEnd);
    04741         if(numberOfValues > 0 && osinstance->instanceData->variables->numberOfVariables == 0){  osilerror_wrapper( ch,osillineno,"we have zero variables, but A matrix coefficients"); return false;}
    04742         delete [] attText;
    04743         if(numberOfValues <= 0) {  osilerror_wrapper( ch,osillineno,"the number of nonlinear nonzeros must be positive"); return false;}
    04744         osinstance->instanceData->linearConstraintCoefficients->numberOfValues = numberOfValues;
    04745         // get rid of white space after the numberOfConstraints element
    04746         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    04747         // we should have either an />  OR an >
    04748         if(*ch == '/'){
    04749                 ch++;
    04750                 if( *ch++ != '>') {  osilerror_wrapper( ch,osillineno,"the linearConstraintCoefficients element does not have a proper closing"); return false;}
    04751                 else{
    04752                         if(numberOfValues > 0) {  osilerror_wrapper( ch,osillineno,"numberOfValues positive, but there are no values"); return false;}
    04753                         return false;
    04754                 }
    04755         }
    04756         //  we better have an >
    04757         if( *ch++ != '>') {  osilerror_wrapper( ch,osillineno,"the <linearConstraintCoefficients> element does not have a proper closing"); return false;}
    04758         // get rid of white space after the <linearConstraintCoefficients> element
    04759         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    04760         if(  parseStart(  &ch, osinstance, osillineno) != true) {osilerror_wrapper( ch,osillineno,"error processing <start> element"); return false;}
    04761 //      if( (parseColIdx( &ch, osinstance, osillineno) != true) && (parseRowIdx( &ch, osinstance, osillineno) != true)) return false;
    04762 //      if( (parseColIdx( &ch, osinstance, osillineno) == true) && (parseRowIdx( &ch, osinstance, osillineno) == true)) {osilerror_wrapper( ch,osillineno,"cannot store by both row and column"); return false;}
    04763
    04764         if(  parseColIdx( &ch, osinstance, osillineno) == true) // <colIdx> is found as first element
    04765         {
    04766                 if( parseRowIdx( &ch, osinstance, osillineno) == true) //also have <rowIdx> --- can't happen
    04767                 {
    04768                         osilerror_wrapper( ch,osillineno,"cannot store by both row and column");
    04769                         return false;
    04770                 }
    04771         }
    04772         else //<colIdx> is not the first element
    04773         {
    04774                 if( parseRowIdx( &ch, osinstance, osillineno) != true) // neither <rowIdx> nor <colIdx> is present
    04775                 {
    04776                         osilerror_wrapper( ch,osillineno,"must have either RowIdx or ColIdx");
    04777                         return false;
    04778                 }
    04779                 else //<rowIdx> is found as first element
    04780                 {
    04781                         if ( parseColIdx( &ch, osinstance, osillineno) == true ) //also have <colIdx> --- can't happen
    04782                         {
    04783                                 osilerror_wrapper( ch,osillineno,"cannot store by both row and column");
    04784                                 return false;
    04785                         }
    04786                 }
    04787         }
    04788
    04789         if(  parseValue(  &ch, osinstance, osillineno) != true) {osilerror_wrapper( ch,osillineno, "could not parse <value> element"); return false;}
    04790         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    04791         // get the </linearConstraintCoefficients> tag
    04792         *p = ch;
    04793         while( *endlinearConstraintCoefficients++  == *ch) ch++;
    04794         if( (ch - *p) != 30) {  osilerror_wrapper( ch,osillineno, "cannot find </linearConstraintCoefficients> tag"); return false;}
    04795         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04796         // better have >
    04797         if(*ch != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed </linearConstraintCoefficients> tag"); return false;}
    04798         ch++;
    04799         *p = ch;
    04800         return true;
    04801 }//end parseLinearConstraintCoefficients
    04802
    04803 bool parseStart(const char **p, OSInstance *osinstance, int* osillineno){
    04804         clock_t start, finish;
    04805         #ifdef CHECK_PARSE_TIME
    04806         double duration;
    04807         #endif
    04808         int ki, numChar;
    04809         char *attTextEnd;
    04810         const char *ch = *p;
    04811         start = clock();
    04812         const char* startStart = "<start";
    04813         const char* endStart = "</start";
    04814         const char* startEl = "<el";
    04815         const char* endEl = "</el";
    04816         // attributes
    04817         char *attText = NULL;
    04818         const char *incr = "incr";
    04819         const char *mult = "mult";
    04820         int kount = 0;
    04821         int i;
    04822         // element attribute boolean variables
    04823         bool elmultattON = false ;
    04824         bool elincrattON = false;
    04825         bool foundEl = false;
    04826         int elmult;
    04827         int elincr;
    04828         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    04829         // if, present we should be pointing to <start element
    04830         *p = ch;
    04831         while( *startStart++  == *ch) ch++;
    04832         if( (ch - *p) != 6) {
    04833                 //reset ch
    04834                 ch = *p;
    04835                 return false;
    04836         }
    04837         // get rid of white space after <start
    04838         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    04839         // we should have either an >
    04840         if(*ch != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed <start> element"); return false;}
    04841         ch++;
    04842         // get rid of white space
    04843         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    04844         // look for an <el> -- if none present must have b64 data
    04845         *p = ch;
    04846         while( *startEl++  == *ch) ch++;
    04847         startEl -= 4;
    04848         if( (ch - *p) != 3) {
    04849                 //reset ch
    04850                 ch = *p;
    04851                 // call base64 parse here
    04852                 int dataSize = 0;
    04853                 char* b64string = parseBase64(&ch, &dataSize, osillineno );
    04854                 if( b64string == NULL) {  osilerror_wrapper( ch,osillineno,"<start> must have children or base64 data"); return false;}
    04855                 std::string base64decodeddata = Base64::decodeb64( b64string );
    04856                 int base64decodeddatalength = base64decodeddata.length();
    04857                 int *intvec = NULL;
    04858                 osinstance->instanceData->linearConstraintCoefficients->start->el = new int[(base64decodeddatalength/dataSize) ];
    04859                 intvec = (int*)&base64decodeddata[0];
    04860                 for (i = 0; i < (base64decodeddatalength/dataSize); i++){
    04861                         osinstance->instanceData->linearConstraintCoefficients->start->el[ i] = *(intvec++);
    04862                 }
    04863                 delete [] b64string;
    04864         }
    04865         else{
    04866                 foundEl = true;
    04867                 osinstance->instanceData->linearConstraintCoefficients->start->el =
    04868                 new int[ std::max( osinstance->instanceData->constraints->numberOfConstraints,
    04869                 osinstance->instanceData->variables->numberOfVariables) + 1];
    04870                 while(foundEl){
    04871
    04872                         elmultattON = false ;
    04873                         elincrattON  = false;
    04874                         elmult = 1;
    04875                         elincr = 0;
    04876
    04877                         // assume we are pointing to the first character after the l in <el
    04878                         // it should be a space so let's increment ch
    04879                         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04880                         while(*ch != '/' && *ch != '>'){
    04881                                 switch (*ch) {
    04882                                 case 'i':
    04883                                         *p = ch;
    04884                                         while( *incr++  == *ch) ch++;
    04885                                         if( (ch - *p) != 4) {  osilerror_wrapper( ch,osillineno,"error in starts incr attribute"); return false;}
    04886                                         if(elincrattON == true) {  osilerror_wrapper( ch,osillineno,"too many el incr attributes"); return false;}
    04887                                         incr -= 5;
    04888                                         elincrattON = true;
    04889                                         GETATTRIBUTETEXT;
    04890                                         elincr = atoimod1( osillineno,attText, attTextEnd);
    04891                                         delete [] attText;
    04892                                         //printf("ATTRIBUTE = %s\n", attText);
    04893                                         break;
    04894                                 case 'm':
    04895                                         *p = ch;
    04896                                         while( *mult++  == *ch) ch++;
    04897                                         if( (ch - *p) != 4) {  osilerror_wrapper( ch,osillineno,"error in starts mult attribute"); return false;}
    04898                                         if(elmultattON == true) {  osilerror_wrapper( ch,osillineno,"too many el mult attributes"); return false;}
    04899                                         mult -= 5;
    04900                                         elmultattON = true;
    04901                                         GETATTRIBUTETEXT;
    04902                                         elmult = atoimod1( osillineno,attText, attTextEnd);
    04903                                         delete [] attText;
    04904                                         //printf("ATTRIBUTE = %s\n", attText);
    04905                                         break;
    04906                                 case ' ':
    04907                                         break;
    04908                                 case '\n':
    04909                                         (*osillineno)++;
    04910                                         break;
    04911                                 case '\t':
    04912                                         break;
    04913                                 case '\r':
    04914                                         break;
    04915                                 default:
    04916                                         osilerror_wrapper( ch,osillineno,"invalid attribute character");
    04917                                         return false;
    04918                                         break;
    04919                                 }
    04920                                 ch++;
    04921                         }
    04922
    04923                         // start eating white space until an '>' is found,
    04924                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04925                         if( *ch++ != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed <el> tag"); return false;}
    04926                         // eat white space again,
    04927                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04928                         // okay we better have a number, we will check later
    04929                         *p = ch;
    04930                         // find the end of the number, it better be an </el>
    04931                         // find </el
    04932                         while( *ch != '<' && *ch  != EOF){
    04933                                 ch++;
    04934                         }
    04935                         // we better have a <, or not valid
    04936                         if(*ch != '<') {  osilerror_wrapper( ch,osillineno,"cannot find an </el>"); return false;}
    04937
    04938                         // we better not exceed allocation
    04939                         if(kount +elmult > std::max(osinstance->instanceData->constraints->numberOfConstraints,
    04940                                                                                 osinstance->instanceData->variables->numberOfVariables) + 1 )
    04941                         {
    04942                                 osilerror_wrapper( ch, osillineno,"number of start elements exceeds the maximum number of rows or columns plus  1");
    04943                         }
    04944                         osinstance->instanceData->linearConstraintCoefficients->start->el[kount] = atoimod1( osillineno, *p, ch);
    04945                         for (int k=1; k < elmult; k++)
    04946                         {
    04947                                 osinstance->instanceData->linearConstraintCoefficients->start->el[ kount+k]
    04948                                 = osinstance->instanceData->linearConstraintCoefficients->start->el[ kount] + k*elincr;
    04949                         }
    04950                         kount += elmult;
    04951                         //printf("number = %s\n", *p);
    04952                         // we are pointing to <, make sure there is /el
    04953                         *p = ch;
    04954                         while( *endEl++  == *ch) ch++;
    04955                         endEl -= 5;
    04956                         if( (ch - *p) != 4 ) {  osilerror_wrapper( ch,osillineno,"cannot find an </el>"); return false;}
    04957                         // start eating white space until an '>' is found for </el>,
    04958                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    04959                         if( *ch++ != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed </el> tag"); return false;}
    04960                         // eat white space again,
    04961                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04962                         // either have another <el> element or foundEl = false;
    04963                         *p = ch;
    04964                         while( *startEl++  == *ch) ch++;
    04965                         if( (ch - *p)  == 3){
    04966                                  foundEl = true;
    04967                                  startEl -= 4;
    04968                         }
    04969                         else{
    04970                                 foundEl = false;
    04971                                 ch = *p;
    04972                         }
    04973                 }
    04974
    04975                 if(osinstance->instanceData->linearConstraintCoefficients->start->el[ kount - 1 ] !=
    04976                 osinstance->instanceData->linearConstraintCoefficients->numberOfValues )
    04977                 osilerror_wrapper( ch, osillineno,"the value of the last start element is not equal to numberOfValues");
    04978         }
    04979         // get the </start> tag
    04980         *p = ch;
    04981         while( *endStart++  == *ch) ch++;
    04982         if( (ch - *p) != 7) {  osilerror_wrapper( ch,osillineno, "cannot find </start> tag"); return false;}
    04983         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    04984         // better have >
    04985         if(*ch != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed </start> tag");   return false;}
    04986         ch++;
    04987         // get the end element
    04988         finish = clock();
    04989         #ifdef CHECK_PARSE_TIME
    04990         duration = (double) (finish - start) / CLOCKS_PER_SEC;
    04991         printf("TIME TO PARSE STARTS  = %f\n", duration);
    04992         #endif
    04993         *p = ch;
    04994         osinstance->instanceData->linearConstraintCoefficients->iNumberOfStartElements = kount;
    04995
    04996         return true;
    04997 }//end parseStart
    04998
    04999 bool parseRowIdx( const char **p, OSInstance *osinstance, int* osillineno){
    05000         clock_t start, finish;
    05001         #ifdef CHECK_PARSE_TIME
    05002         double duration;
    05003         #endif
    05004         int ki, numChar;
    05005         char *attTextEnd;
    05006         const char *ch = *p;
    05007         start = clock();
    05008         const char* startRowIdx = "<rowIdx";
    05009         const char* endRowIdx = "</rowIdx";
    05010         const char* startEl = "<el";
    05011         const char* endEl = "</el";
    05012         // attributes
    05013         char *attText = NULL;
    05014         const char *incr = "incr";
    05015         const char *mult = "mult";
    05016         int kount = 0;
    05017         int i;
    05018         // element attribute boolean variables
    05019         bool elmultattON = false ;
    05020         bool elincrattON = false;
    05021         bool foundEl = false;
    05022         int elmult;
    05023         int elincr;
    05024         int numberOfEl;
    05025
    05026         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    05027         // if, present we should be pointing to <rowIdx element
    05028         *p = ch;
    05029         while( *startRowIdx++  == *ch) ch++;
    05030         if( (ch - *p) != 7) {
    05031                 //reset ch
    05032                 ch = *p;
    05033                 return false;
    05034         }
    05035         // get rid of white space after <rowIdx
    05036         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    05037         // we should have either an >
    05038         if(*ch != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed <rowIdx> element"); return false;}
    05039         ch++;
    05040         // get rid of white space
    05041         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    05042         // look for an <el> -- if none present must have b64 data
    05043         *p = ch;
    05044         while( *startEl++  == *ch) ch++;
    05045         startEl -= 4;
    05046         if( (ch - *p) != 3) {
    05047                 //reset ch
    05048                 ch = *p;
    05049                 // call base64 parse here
    05050                 int dataSize = 0;
    05051                 char* b64string = parseBase64(&ch, &dataSize, osillineno );
    05052                 if( b64string == NULL)  {  osilerror_wrapper( ch,osillineno,"<rowIdx> must have children or base64 data"); return false;}
    05053                 std::string base64decodeddata = Base64::decodeb64( b64string );
    05054                 int base64decodeddatalength = base64decodeddata.length();
    05055                 int *intvec = NULL;
    05056                 numberOfEl = (base64decodeddatalength/dataSize);
    05057                 osinstance->instanceData->linearConstraintCoefficients->rowIdx->el = new int[numberOfEl ];
    05058                 osinstance->instanceData->linearConstraintCoefficients->colIdx->el = NULL;
    05059                 osinstance->instanceData->linearConstraintCoefficients->rowIdx->numberOfEl = numberOfEl;
    05060                 osinstance->instanceData->linearConstraintCoefficients->colIdx->numberOfEl = 0;
    05061                 osinstance->instanceData->linearConstraintCoefficients->start->numberOfEl = osinstance->instanceData->variables->numberOfVariables + 1;
    05062                 intvec = (int*)&base64decodeddata[0];
    05063                 for(i = 0; i < numberOfEl; i++){
    05064                         osinstance->instanceData->linearConstraintCoefficients->rowIdx->el[ i] = *(intvec++);
    05065                         kount++;
    05066                 }
    05067                 delete [] b64string;
    05068         }
    05069         else{
    05070                 foundEl = true;
    05071                 // if we are here we are storing the problem by column
    05072                 // this means the number of start elements must equal the number of columns + 1
    05073                 if( osinstance->instanceData->linearConstraintCoefficients->iNumberOfStartElements != osinstance->instanceData->variables->numberOfVariables  + 1)
    05074                 osilerror_wrapper( ch, osillineno,"we are storing in column major format, but number of start elements not equal number of variables + 1");
    05075                 osinstance->instanceData->linearConstraintCoefficients->rowIdx->el = new int[ osinstance->instanceData->linearConstraintCoefficients->numberOfValues];
    05076                 osinstance->instanceData->linearConstraintCoefficients->colIdx->el = NULL;
    05077                 osinstance->instanceData->linearConstraintCoefficients->rowIdx->numberOfEl = osinstance->instanceData->linearConstraintCoefficients->numberOfValues;
    05078                 osinstance->instanceData->linearConstraintCoefficients->colIdx->numberOfEl = 0;
    05079                 osinstance->instanceData->linearConstraintCoefficients->start->numberOfEl = osinstance->instanceData->variables->numberOfVariables + 1;
    05080                 while(foundEl){
    05081
    05082                         elmultattON = false ;
    05083                         elincrattON  = false;
    05084                         elmult = 1;
    05085                         elincr = 0;
    05086
    05087                         // assume we are pointing to the first character after the l in <el
    05088                         // it should be a space so let's increment ch
    05089                         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    05090                         while(*ch != '/' && *ch != '>'){
    05091                                 switch (*ch) {
    05092                                 case 'i':
    05093                                         *p = ch;
    05094                                         while( *incr++  == *ch) ch++;
    05095                                         if( (ch - *p) != 4) {  osilerror_wrapper( ch,osillineno,"error in rowIdx incr attribute"); return false;}
    05096                                         if(elincrattON == true) {  osilerror_wrapper( ch,osillineno,"too many el incr attributes"); return false;}
    05097                                         incr -= 5;
    05098                                         elincrattON = true;
    05099                                         GETATTRIBUTETEXT;
    05100                                         elincr = atoimod1( osillineno,attText, attTextEnd);
    05101                                         delete [] attText;
    05102                                         //printf("ATTRIBUTE = %s\n", attText);
    05103                                         break;
    05104                                 case 'm':
    05105                                         *p = ch;
    05106                                         while( *mult++  == *ch) ch++;
    05107                                         if( (ch - *p) != 4) {  osilerror_wrapper( ch,osillineno,"error in rowIdx mult attribute"); return false;}
    05108                                         if(elmultattON == true) {  osilerror_wrapper( ch,osillineno,"too many el mult attributes"); return false;}
    05109                                         mult -= 5;
    05110                                         elmultattON = true;
    05111                                         GETATTRIBUTETEXT;
    05112                                         elmult = atoimod1( osillineno,attText, attTextEnd);
    05113                                         delete [] attText;
    05114                                         //printf("ATTRIBUTE = %s\n", attText);
    05115                                         break;
    05116                                 case ' ':
    05117                                         break;
    05118                                 case '\n':
    05119                                         (*osillineno)++;
    05120                                         break;
    05121                                 case '\t':
    05122                                         break;
    05123                                 case '\r':
    05124                                         break;
    05125                                 default:
    05126                                         osilerror_wrapper( ch,osillineno,"invalid attribute character");
    05127                                         return false;
    05128                                         break;
    05129                                 }
    05130                                 ch++;
    05131                         }
    05132
    05133                         // start munging white space until an '>' is found,
    05134                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    05135                         if( *ch++ != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed <el> tag"); return false;}
    05136                         // mung white space again,
    05137                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    05138                         // okay we better have a number, we will check later
    05139                         *p = ch;
    05140                         // find the end of the number, it better be an </el>
    05141                         // find </el
    05142                         while( *ch != '<' && *ch  != EOF){
    05143                                 ch++;
    05144                         }
    05145                         // we better have a <, or not valid
    05146                         if(*ch != '<') {   osilerror_wrapper( ch,osillineno,"cannot find an </el>"); return false;}
    05147
    05148                         // we better not exceed allocation
    05149                         if(kount + elmult > osinstance->instanceData->linearConstraintCoefficients->numberOfValues)
    05150                         {
    05151                                 osilerror_wrapper( ch, osillineno,"number of rowIdx elements exceeds the number declared");
    05152                         }
    05153                         osinstance->instanceData->linearConstraintCoefficients->rowIdx->el[ kount] = atoimod1( osillineno, *p, ch);
    05154                         for (int k=1; k < elmult; k++)
    05155                         {
    05156                                 osinstance->instanceData->linearConstraintCoefficients->rowIdx->el[ kount+k]
    05157                                 = osinstance->instanceData->linearConstraintCoefficients->rowIdx->el[ kount] + k*elincr;
    05158                         }
    05159                         kount += elmult;
    05160                         //printf("number = %s\n", *p);
    05161                         // we are pointing to <, make sure there is /el
    05162                         *p = ch;
    05163                         while( *endEl++  == *ch) ch++;
    05164                         endEl -= 5;
    05165                         if( (ch - *p)  != 4 ) {  osilerror_wrapper( ch,osillineno,"cannot find an </el>"); return false;}
    05166                         // start munging white space until an '>' is found for </el>,
    05167                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    05168                         if( *ch++ != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed </el> tag"); return false;}
    05169                         // eat white space again,
    05170                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    05171                         // either have another <el> element or foundEl = false;
    05172                         *p = ch;
    05173                         while( *startEl++  == *ch) ch++;
    05174                         if( (ch - *p) == 3){
    05175                                 foundEl = true;
    05176                                 startEl -= 4;
    05177                         }
    05178                         else{
    05179                                 foundEl = false;
    05180                                 ch = *p;
    05181                         }
    05182                 }
    05183         }
    05184         // get the </rowIdx> tag
    05185         *p = ch;
    05186         while( *endRowIdx++  == *ch) ch++;
    05187         if( (ch - *p) != 8) {  osilerror_wrapper( ch,osillineno, "cannot find </rowIdx> tag"); return false;}
    05188         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    05189         // better have >
    05190         if(*ch != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed </rowIdx> tag");}
    05191         ch++;
    05192         if(kount > osinstance->instanceData->linearConstraintCoefficients->numberOfValues) { osilerror_wrapper( ch,osillineno,"numberOfLinearCoefficients attribute less than number of row indices found"); return false;}
    05193         if(kount < osinstance->instanceData->linearConstraintCoefficients->numberOfValues) { osilerror_wrapper( ch,osillineno,"numberOfLinearCoefficients attribute greater than number of row indices found"); return false;}
    05194         finish = clock();
    05195         #ifdef CHECK_PARSE_TIME
    05196         duration = (double) (finish - start) / CLOCKS_PER_SEC;
    05197         printf("TIME TO PARSE ROW INDEXES = %f\n", duration);
    05198         #endif
    05199         *p = ch;
    05200         return true;
    05201 }//end parseRowIdx
    05202
    05203
    05204 bool parseColIdx( const char **p, OSInstance *osinstance, int* osillineno){
    05205         clock_t start, finish;
    05206         #ifdef CHECK_PARSE_TIME
    05207         double duration;
    05208         #endif
    05209         int ki, numChar;
    05210         char *attTextEnd;
    05211         const char *ch = *p;
    05212         start = clock();
    05213         const char* startColIdx = "<colIdx";
    05214         const char* endColIdx = "</colIdx";
    05215         const char* startEl = "<el";
    05216         const char* endEl = "</el";
    05217         // attributes
    05218         char *attText = NULL;
    05219         const char *incr = "incr";
    05220         const char *mult = "mult";
    05221         int kount = 0;
    05222         int i;
    05223         // element attribute boolean variables
    05224         bool elmultattON = false ;
    05225         bool elincrattON = false;
    05226         bool foundEl = false;
    05227         int elmult;
    05228         int elincr;
    05229         int numberOfEl;
    05230
    05231         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    05232         // if, present we should be pointing to <colIdx element
    05233         *p = ch;
    05234         while( *startColIdx++  == *ch) ch++;
    05235         if( (ch - *p) != 7) {
    05236                 //reset ch
    05237                 ch = *p;
    05238                 return false;
    05239         }
    05240         // get rid of white space after <colIdx
    05241         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    05242         // we should have either an >
    05243         if(*ch != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed <colIdx> element"); return false;}
    05244         ch++;
    05245         // get rid of white space
    05246         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    05247         // look for an <el> -- if none present must have b64 data
    05248         *p = ch;
    05249         while( *startEl++  == *ch) ch++;
    05250         startEl -= 4;
    05251         if( (ch - *p) != 3) {
    05252                 //reset ch
    05253                 ch = *p;
    05254                 // call base64 parse here
    05255                 int dataSize = 0;
    05256                 char* b64string = parseBase64(&ch, &dataSize, osillineno );
    05257                 if( b64string == NULL)  {  osilerror_wrapper( ch,osillineno,"<colIdx> must have children or base64 data"); return false;}
    05258                 std::string base64decodeddata = Base64::decodeb64( b64string );
    05259                 int base64decodeddatalength = base64decodeddata.length();
    05260                 int *intvec = NULL;
    05261                 numberOfEl = (base64decodeddatalength/dataSize);
    05262                 osinstance->instanceData->linearConstraintCoefficients->colIdx->el = new int[numberOfEl ];
    05263                 osinstance->instanceData->linearConstraintCoefficients->rowIdx->el = NULL;
    05264                 osinstance->instanceData->linearConstraintCoefficients->colIdx->numberOfEl = numberOfEl;
    05265                 osinstance->instanceData->linearConstraintCoefficients->rowIdx->numberOfEl = 0;
    05266                 osinstance->instanceData->linearConstraintCoefficients->start->numberOfEl = osinstance->instanceData->constraints->numberOfConstraints + 1;
    05267                 intvec = (int*)&base64decodeddata[0];
    05268                 for(i = 0; i < numberOfEl; i++){
    05269                         osinstance->instanceData->linearConstraintCoefficients->colIdx->el[ i] = *(intvec++);
    05270                         kount++;
    05271                 }
    05272                 delete [] b64string;
    05273         }
    05274         else{
    05275                 foundEl = true;
    05276                 // if we are here we are storing the problem by row
    05277                 // this means the number of start elements must equal the number of rows
    05278                 if(osinstance->instanceData->linearConstraintCoefficients->iNumberOfStartElements != osinstance->instanceData->constraints->numberOfConstraints  + 1)
    05279                 osilerror_wrapper( ch, osillineno,"we are storing in row major format, but number of start elements not equal number of rows + 1");
    05280                 osinstance->instanceData->linearConstraintCoefficients->colIdx->el = new int[ osinstance->instanceData->linearConstraintCoefficients->numberOfValues];
    05281                 osinstance->instanceData->linearConstraintCoefficients->rowIdx->el = NULL;
    05282                 osinstance->instanceData->linearConstraintCoefficients->colIdx->numberOfEl = osinstance->instanceData->linearConstraintCoefficients->numberOfValues;
    05283                 osinstance->instanceData->linearConstraintCoefficients->rowIdx->numberOfEl = 0;
    05284                 osinstance->instanceData->linearConstraintCoefficients->start->numberOfEl = osinstance->instanceData->constraints->numberOfConstraints + 1;
    05285                 while(foundEl){
    05286
    05287                         elmultattON = false ;
    05288                         elincrattON  = false;
    05289                         elmult = 1;
    05290                         elincr = 0;
    05291
    05292                         // assume we are pointing to the first character after the l in <el
    05293                         // it should be a space so let's increment ch
    05294                         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    05295                         while(*ch != '/' && *ch != '>'){
    05296                                 switch (*ch) {
    05297                                 case 'i':
    05298                                         *p = ch;
    05299                                         while( *incr++  == *ch) ch++;
    05300                                         if( (ch - *p) != 4) {  osilerror_wrapper( ch,osillineno,"error in colIdx incr attribute"); return false;}
    05301                                         if(elincrattON == true) {  osilerror_wrapper( ch,osillineno,"too many el incr attributes"); return false;}
    05302                                         incr -= 5;
    05303                                         elincrattON = true;
    05304                                         GETATTRIBUTETEXT;
    05305                                         elincr = atoimod1( osillineno,attText, attTextEnd);
    05306                                         delete [] attText;
    05307                                         //printf("ATTRIBUTE = %s\n", attText);
    05308                                         break;
    05309                                 case 'm':
    05310                                         *p = ch;
    05311                                         while( *mult++  == *ch) ch++;
    05312                                         if( (ch - *p) != 4) {  osilerror_wrapper( ch,osillineno,"error in colIdx mult attribute"); return false;}
    05313                                         if(elmultattON == true) {  osilerror_wrapper( ch,osillineno,"too many el mult attributes"); return false;}
    05314                                         mult -= 5;
    05315                                         elmultattON = true;
    05316                                         GETATTRIBUTETEXT;
    05317                                         elmult = atoimod1( osillineno,attText, attTextEnd);
    05318                                         delete [] attText;
    05319                                         //printf("ATTRIBUTE = %s\n", attText);
    05320                                         break;
    05321                                 case ' ':
    05322                                         break;
    05323                                 case '\n':
    05324                                         (*osillineno)++;
    05325                                         break;
    05326                                 case '\t':
    05327                                         break;
    05328                                 case '\r':
    05329                                         break;
    05330                                 default:
    05331                                         osilerror_wrapper( ch,osillineno,"invalid attribute character");
    05332                                         return false;
    05333                                         break;
    05334                                 }
    05335                                 ch++;
    05336                         }
    05337
    05338                         // start eating white space until an '>' is found,
    05339                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    05340                         if( *ch++ != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed <el> tag"); return false;}
    05341                         // eat white space again,
    05342                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    05343                         // okay we better have a number, we will check later
    05344                         *p = ch;
    05345                         // find the end of the number, it better be an </el>
    05346                         // find </el
    05347                         while( *ch != '<' && *ch  != EOF){
    05348                                 ch++;
    05349                         }
    05350                         // we better have a <, or not valid
    05351                         if(*ch != '<') {  osilerror_wrapper( ch,osillineno,"cannot find an </el>"); return false;}
    05352                         // we better not exceed allocation
    05353                         if(kount + elmult > osinstance->instanceData->linearConstraintCoefficients->numberOfValues)
    05354                         {
    05355                                 osilerror_wrapper( ch, osillineno,"number of colIdx elements exceeds the number declared");
    05356                         }
    05357                         osinstance->instanceData->linearConstraintCoefficients->colIdx->el[ kount] = atoimod1( osillineno, *p, ch);
    05358                         for (int k=1; k < elmult; k++)
    05359                         {
    05360                                 osinstance->instanceData->linearConstraintCoefficients->colIdx->el[ kount+k]
    05361                                 = osinstance->instanceData->linearConstraintCoefficients->colIdx->el[ kount] + k*elincr;
    05362                         }
    05363                         kount += elmult;
    05364                         //printf("number = %s\n", *p);
    05365                         // we are pointing to <, make sure there is /el
    05366                         *p = ch;
    05367                         while( *endEl++  == *ch) ch++;
    05368                         endEl -= 5;
    05369                         if( (ch - *p) != 4 ) {  osilerror_wrapper( ch,osillineno,"cannot find an </el>"); return false;}
    05370                         // start eating white space until an '>' is found for </el>,
    05371                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    05372                         if( *ch++ != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed </el> tag"); return false;}
    05373                         // eat white space again,
    05374                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    05375                         // either have another <el> element or foundEl = false;
    05376                         *p = ch;
    05377                         while( *startEl++  == *ch) ch++;
    05378                         if( (ch - *p) == 3){
    05379                                 foundEl = true;
    05380                                 startEl -= 4;
    05381                         }
    05382                         else{
    05383                                 foundEl = false;
    05384                                 ch = *p;
    05385                         }
    05386                 }
    05387         }
    05388         // get the </colIdx> tag
    05389         *p = ch;
    05390         while( *endColIdx++  == *ch) ch++;
    05391         if( (ch - *p) != 8) {  osilerror_wrapper( ch,osillineno, "cannot find </colIdx> tag"); return false;}
    05392         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    05393         // better have >
    05394         if(*ch != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed </colIdx> tag"); return false;}
    05395         ch++;
    05396         if(kount > osinstance->instanceData->linearConstraintCoefficients->numberOfValues) {  osilerror_wrapper( ch,osillineno,"numberOfLinearCoefficients attribute less than number of column indices found"); return false;}
    05397         if(kount < osinstance->instanceData->linearConstraintCoefficients->numberOfValues) {  osilerror_wrapper( ch,osillineno,"numberOfLinearCoefficients attribute greater than number of column indices found"); return false;}
    05398         finish = clock();
    05399         #ifdef CHECK_PARSE_TIME
    05400         duration = (double) (finish - start) / CLOCKS_PER_SEC;
    05401         printf("TIME TO PARSE COLUMN INDEXES = %f\n", duration);
    05402         #endif
    05403         *p = ch;
    05404         return true;
    05405 }//end parseColIdx
    05406
    05407
    05408 bool parseValue( const char **p, OSInstance *osinstance, int* osillineno){
    05409         clock_t start, finish;
    05410         #ifdef CHECK_PARSE_TIME
    05411         double duration;
    05412         #endif
    05413         int ki, numChar;
    05414         char *attTextEnd;
    05415         const char *ch = *p;
    05416         start = clock();
    05417         const char* startValue = "<value";
    05418         const char* endValue = "</value";
    05419         const char* startEl = "<el";
    05420         const char* endEl = "</el";
    05421         // attributes
    05422         char *attText = NULL;
    05423         const char *incr = "incr";
    05424         const char *mult = "mult";
    05425         int kount = 0;
    05426         int i;
    05427         // element attribute boolean variables
    05428         bool elmultattON = false ;
    05429         bool elincrattON = false;
    05430         bool foundEl = false;
    05431         int elmult;
    05432         double elincr;
    05433         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno) ; ch++ ) ;
    05434         // if present we should be pointing to <value element
    05435         *p = ch;
    05436         while( *startValue++  == *ch) ch++;
    05437         if( (ch - *p) != 6) {
    05438                 //reset ch
    05439                 ch = *p;
    05440                 return false;
    05441         }
    05442         // get rid of white space after <value
    05443         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno) ; ch++ ) ;
    05444         // we should have either an >
    05445         if(*ch != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed <value> element"); return false;}
    05446         ch++;
    05447         // get rid of white space
    05448         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno) ; ch++ ) ;
    05449         // look for an <el> -- if none present must have b64 data
    05450         *p = ch;
    05451         while( *startEl++  == *ch) ch++;
    05452         startEl -= 4;
    05453         if( (ch - *p) != 3) {
    05454                 //reset ch
    05455                 ch = *p;
    05456                 // call base64 parse here
    05457                 int dataSize = 0;
    05458                 char* b64string = parseBase64(&ch, &dataSize, osillineno );
    05459                 if( b64string == NULL)  {  osilerror_wrapper( ch,osillineno,"<start> must have children or base64 data"); return false;};
    05460                 std::string base64decodeddata = Base64::decodeb64( b64string );
    05461                 int base64decodeddatalength = base64decodeddata.length();
    05462                 osinstance->instanceData->linearConstraintCoefficients->value->el = new double[(base64decodeddatalength/dataSize) ];
    05463                 int kountChar = 0;
    05464                 int kj;
    05465                 /* Take care of Lou's memory alignment problem */
    05466                 /* dataSize had better equal sizeof( double) or we need to abandon ship */
    05467                 if( sizeof( double)  != dataSize ) {
    05468                         osilerror_wrapper( ch, osillineno,
    05469                                 "base 64 encoded with a size of double different than on this machine");
    05470                         return false;
    05471                 }
    05472                 union doubleBuffer{
    05473                         char memAlign[sizeof(double)];
    05474                         double dble;
    05475                 };
    05476                 doubleBuffer dbuf;
    05477                 for(i = 0; i < (base64decodeddatalength/dataSize); i++){
    05478                         for(kj = 0; kj < dataSize; kj++){
    05479                                 dbuf.memAlign[ kj] = base64decodeddata[kountChar];
    05480                                 kountChar++;
    05481                         }
    05482                         osinstance->instanceData->linearConstraintCoefficients->value->el[ i] = dbuf.dble;
    05483                         std::cout << dbuf.dble << std::endl;
    05484                         kount++;
    05485                 }
    05486                 delete [] b64string;
    05487         }
    05488         else{
    05489                 foundEl = true;
    05490                 osinstance->instanceData->linearConstraintCoefficients->value->el =
    05491                         new double[ osinstance->instanceData->linearConstraintCoefficients->numberOfValues];
    05492                 while( foundEl){
    05493
    05494                         elmultattON = false ;
    05495                         elincrattON  = false;
    05496                         elmult = 1;
    05497                         elincr = 0;
    05498
    05499                         // assume we are pointing to the first character after the l in <el
    05500                         // it should be a space so let's increment ch
    05501                         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ );
    05502                         while(*ch != '/' && *ch != '>'){
    05503                                 switch (*ch) {
    05504                                 case 'i':
    05505                                         *p = ch;
    05506                                         while( *incr++  == *ch) ch++;
    05507                                         if( (ch - *p) != 4) {  osilerror_wrapper( ch,osillineno,"error in values incr attribute"); return false;}
    05508                                         if(elincrattON == true) {  osilerror_wrapper( ch,osillineno,"too many el incr attributes"); return false;}
    05509                                         incr -= 5;
    05510                                         elincrattON = true;
    05511                                         GETATTRIBUTETEXT;
    05512                                         elincr = atofmod1( osillineno,attText, attTextEnd);
    05513                                         delete [] attText;
    05514                                         //printf("ATTRIBUTE = %s\n", attText);
    05515                                         break;
    05516                                 case 'm':
    05517                                         *p = ch;
    05518                                         while( *mult++  == *ch) ch++;
    05519                                         if( (ch - *p) != 4) {  osilerror_wrapper( ch,osillineno,"error in values mult attribute"); return false;}
    05520                                         if(elmultattON == true) {  osilerror_wrapper( ch,osillineno,"too many el mult attributes"); return false;}
    05521                                         mult -= 5;
    05522                                         elmultattON = true;
    05523                                         GETATTRIBUTETEXT;
    05524                                         elmult = atoimod1( osillineno,attText, attTextEnd);
    05525                                         delete [] attText;
    05526                                         //printf("ATTRIBUTE = %s\n", attText);
    05527                                         break;
    05528                                 case ' ':
    05529                                         break;
    05530                                 case '\n':
    05531                                         (*osillineno)++;
    05532                                         break;
    05533                                 case '\t':
    05534                                         break;
    05535                                 case '\r':
    05536                                         break;
    05537                                 default:
    05538                                         osilerror_wrapper( ch,osillineno,"invalid attribute character");
    05539                                         return false;
    05540                                         break;
    05541                                 }
    05542                                 ch++;
    05543                         }
    05544
    05545                         // start eat white space until an '>' is found,
    05546                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno) ; ch++ );
    05547                         if( *ch++ != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed <el> tag"); return false;}
    05548                         // eat white space again,
    05549                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno) ; ch++ ) ;
    05550                         *p = ch;
    05551                         // find the end of the number, it better be an </el>
    05552                         // find the < which begins the </el
    05553                         while( *ch != '<' && *ch != EOF){
    05554                                 ch++;
    05555                         }
    05556                         // we better have a <, or not valid
    05557                         if(*ch != '<') {  osilerror_wrapper( ch,osillineno,"cannot find an </el>"); return false;}
    05558                         // we better not exceed allocation
    05559                         if(kount + elmult > osinstance->instanceData->linearConstraintCoefficients->numberOfValues)
    05560                         {
    05561                                 osilerror_wrapper( ch, osillineno,"number of nonzero elements exceeds the number declared");
    05562                         }
    05563                         osinstance->instanceData->linearConstraintCoefficients->value->el[ kount] = atofmod1( osillineno, *p, ch);
    05564                         for (int k=1; k < elmult; k++)
    05565                         {
    05566                                 osinstance->instanceData->linearConstraintCoefficients->value->el[ kount+k]
    05567                                 = osinstance->instanceData->linearConstraintCoefficients->value->el[ kount] + k*elincr;
    05568                         }
    05569                         kount += elmult;
    05570                         //printf("number = %s\n", *p);
    05571                         // we are pointing to <, make sure there is /el
    05572                         *p = ch;
    05573                         while( *endEl++  == *ch) ch++;
    05574                         endEl -= 5;
    05575                         if( (ch - *p) != 4 ) {  osilerror_wrapper( ch,osillineno,"cannot find an </el>"); return false;}
    05576                         // start eating white space until an '>' is found for </el>,
    05577                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno) ; ch++ );
    05578                         if( *ch++ != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed </el> tag"); return false;}
    05579                         // eat white space again,
    05580                         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno) ; ch++ );
    05581                         // either have another <el> element or foundEl = false;
    05582                         *p = ch;
    05583                         while( *startEl++  == *ch) ch++;
    05584                         if( (ch - *p) == 3){
    05585                                 foundEl = true;
    05586                                 startEl -= 4;
    05587                         }
    05588                         else{
    05589                                 foundEl = false;
    05590                                 ch = *p;
    05591                         }
    05592                 }
    05593         }
    05594         osinstance->instanceData->linearConstraintCoefficients->value->numberOfEl = osinstance->instanceData->linearConstraintCoefficients->numberOfValues;
    05595
    05596         // get the </value> tag
    05597         *p = ch;
    05598         while( *endValue++  == *ch) ch++;
    05599         if( (ch - *p) != 7) {  osilerror_wrapper( ch,osillineno, "cannot find </value> tag"); return false;}
    05600         for(; ISWHITESPACE( *ch) || isnewline( *ch, osillineno) ; ch++ );
    05601         // better have >
    05602         if(*ch != '>') {  osilerror_wrapper( ch,osillineno,"improperly formed </value> tag");    return false;}
    05603         ch++;
    05604         if(kount < osinstance->instanceData->linearConstraintCoefficients->numberOfValues){  osilerror_wrapper( ch,osillineno,"numberOfLinearCoefficients greater than number of values found"); return false;}
    05605         if(kount > osinstance->instanceData->linearConstraintCoefficients->numberOfValues){  osilerror_wrapper( ch,osillineno,"numberOfLinearCoefficients less than the number of values found"); return false;}
    05606         finish = clock();
    05607         #ifdef CHECK_PARSE_TIME
    05608         duration = (double) (finish - start) / CLOCKS_PER_SEC;
    05609         printf("TIME TO PARSE VALUES = %f\n", duration);
    05610         #endif
    05611         *p = ch;
    05612         return true;
    05613 }//end parseValue
    05614
    05615 bool parseObjCoef( const char **p, int objcount, OSInstance *osinstance, int* osillineno){
    05616         int ki, numChar;
    05617         char *attTextEnd;
    05618         const char *ch = *p;
    05619         const char* startCoef = "<coef";
    05620         const char* endCoef = "</coef";
    05621         const char* c_idx = "idx";
    05622         char *attText = NULL;
    05623         int k;
    05624         int numberOfObjCoef = 0;
    05625         if( osinstance->instanceData->objectives->numberOfObjectives <= 0)  {  osilerror_wrapper( ch,osillineno,"we can't have objective function coefficients without an objective function"); return false;}
    05626         numberOfObjCoef = osinstance->instanceData->objectives->obj[objcount]->numberOfObjCoef;
    05627         if(numberOfObjCoef > 0) {
    05628         for(k = 0; k < numberOfObjCoef; k++){
    05629                 for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    05630                 // if, present we should be pointing to <coef element
    05631                 *p = ch;
    05632                 while( *startCoef++  == *ch) ch++;
    05633                 if( (ch - *p) != 5) {  osilerror_wrapper( ch,osillineno,"improper <coef> element"); return false;}
    05634                 startCoef -= 6;
    05635                 // get the idx attribute
    05636                 // eat the white space after <coef
    05637                 for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    05638                 *p = ch;
    05639                 while( *c_idx++  == *ch) ch++;
    05640                 if( (ch - *p) != 3) {  osilerror_wrapper( ch,osillineno,"incorrect idx attribute in objective function <idx> tag"); return false;}
    05641                 c_idx -= 4;
    05642                 // ch should be pointing to the first character after idx attribute
    05643                 GETATTRIBUTETEXT;
    05644                 osinstance->instanceData->objectives->obj[objcount]->coef[ k]->idx  = atoimod1( osillineno, attText, attTextEnd);
    05645                 delete [] attText;
    05646                 ch++;
    05647                 // eat white space
    05648                 for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    05649                 // if we don't have a > there is an error
    05650                 if(*ch++ != '>') {  osilerror_wrapper( ch,osillineno,"incorrect <coef> element")        ; return false;}
    05651                 // we should be pointing to first character after <coef>
    05652                 *p = ch;
    05653                 // eat characters until we find <
    05654                 for(; *ch != '<' && *ch != EOF; ch++);
    05655                 // put back here
    05656
    05657                 // we should be pointing to a < in the </coef> tag
    05658                 if(*ch != '<') {  osilerror_wrapper( ch,osillineno,"improper </coef> tag"); return false;}
    05659                 osinstance->instanceData->objectives->obj[objcount]->coef[ k]->value  = atofmod1( osillineno, *p, ch);
    05660                 *p = ch;
    05661                 while( *endCoef++  == *ch) ch++;
    05662                 if( (ch - *p) != 6)  {  osilerror_wrapper( ch,osillineno,"improper </coef> element"); return false;}
    05663                 endCoef -= 7;
    05664                 // get rid of white space after </coef
    05665                 for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    05666                 // if we don't have a > there is an error
    05667                 if(*ch++ != '>') {  osilerror_wrapper( ch,osillineno,"incorrect </coef> element")       ; return false;}
    05668         }
    05669         }// end if(numberOfObjCoef > 0)
    05670         *p = ch;
    05671         return true;
    05672 }//end parseObjCoef
    05673
    05674 char *parseBase64(const char **p, int *dataSize, int* osillineno ){
    05675         int ki, numChar;
    05676         char *attTextEnd;
    05677         const char *ch = *p;
    05678         const char *sizeOf = "sizeOf";
    05679         //char *numericType = "numericType";
    05680         const char *startBase64BinaryData = "<base64BinaryData";
    05681         const char *endBase64BinaryData = "</base64BinaryData";
    05682         char *attText = NULL;
    05683         char *b64string = NULL;
    05684         int i;
    05685         // start parsing
    05686         for(i = 0; startBase64BinaryData[i]  == *ch; i++, ch++);
    05687         if(i != 17) {
    05688                 ch -= i;
    05689                 *p = ch;
    05690                 return b64string;
    05691         }
    05692         // find sizeOf attribute
    05693         // eat the white space
    05694         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    05695         for(i = 0; sizeOf[i]  == *ch; i++, ch++);
    05696         if(i != 6) {  osilerror_wrapper( ch,osillineno,"incorrect sizeOf attribute in <base64BinaryData> element"); return false;}
    05697         // ch should be pointing to the first character after sizeOf
    05698         GETATTRIBUTETEXT;
    05699         ch++;
    05700         *dataSize = atoimod1( osillineno, attText, attTextEnd);
    05701         delete [] attText;
    05702         // since the element must contain b64 data,  this element must end with >
    05703         // eat the white space
    05704         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    05705         // better have an > sign or not valid
    05706         if(*ch != '>' ) {  osilerror_wrapper( ch,osillineno,"<base64BinaryData> element does not have a proper closing >"); return false;}
    05707         ch++;
    05708         // we are now pointing start of the data
    05709         const char *b64textstart = ch;
    05710         // eat characters until we get to the </base64BinaryData element
    05711         for(; *ch != '<' && *ch != EOF; ch++);
    05712         const char *b64textend = ch;
    05713         // we should be pointing to </base64BinaryData>
    05714         for(i = 0; endBase64BinaryData[i]  == *ch; i++, ch++);
    05715         if(i != 18) { osilerror_wrapper( ch,osillineno," problem with <base64BinaryData> element"); return false;}
    05716         int b64len = b64textend - b64textstart;
    05717         b64string = new char[ b64len + 1];
    05718         for(ki = 0; ki < b64len; ki++) b64string[ki] = b64textstart[ ki];
    05719         b64string[ki] = '\0';
    05720         // burn the white space
    05721         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    05722         // better have an > sign or not valid
    05723         if(*ch != '>' ) {  osilerror_wrapper( ch,osillineno,"</base64BinaryData> element does not have a proper closing >"); return false;}
    05724         ch++;
    05725         for( ; ISWHITESPACE( *ch) || isnewline( *ch, osillineno); ch++ ) ;
    05726         *p = ch;
    05727         return b64string;
    05728 }
    05729
    05730
    05731 double atofmod1(int* osillineno, const char *number, const char *numberend){
    05732         double val;
    05733         char *pEnd;
    05734         val = os_strtod_wrap(number, &pEnd);
    05735         // pEnd should now point to the first character after the number;
    05736         // burn off any white space
    05737         for( ; ISWHITESPACE( *pEnd) || isnewline( *pEnd, osillineno); pEnd++ ) ;
    05738         // pEnd should now point to numberend, if not we have an error
    05739         if(pEnd != numberend) osilerror_wrapper( pEnd,   osillineno, "error in parsing an XSD:double");
    05740         return val;
    05821 }//end atofmod
    05822
    05823
    05824
    05825 int atoimod1(int* osillineno, const char *number, const char *numberend){
    05826         // modified atoi from Kernighan and Ritchie
    05827         int ival;
    05828         int i, sign;
    05829         int endWhiteSpace;
    05830         for(i = 0; ISWHITESPACE( number[ i]) || isnewline( number[ i], osillineno) ; i++);
    05831         endWhiteSpace = i;
    05832         sign = (number[ i] == '-') ? -1 : 1;
    05833         if (number[ i] == '+' || number[ i] == '-') i++;
    05834         for(ival = 0; ISDIGIT( number[ i]); i++){
    05835                 ival = 10*ival + (number[ i] - '0') ;
    05836         }
    05837         if(i == endWhiteSpace) {  osilerror_wrapper( number,osillineno, "error in parsing an XSD:int" );        }
    05838         // if we are here we should having nothing but white space until the end of the number
    05839         for( ; ISWHITESPACE( number[ i]) || isnewline( number[ i], osillineno) ; i++);
    05840         if(number[i] == *numberend){
    05841                 return sign*ival;
    05842         }
    05843         else {  osilerror_wrapper( number,osillineno, "error in parsing an XSD:int"); return OSINT_MAX; }
    05844 }//end atoimod1
    05845
    05846 void osilerror_wrapper( const char* ch, int* osillineno, const char* errormsg){
    05847         const int numErrorChar = 20;
    05848         char errorArray[100] = "";
    05849         strncpy(errorArray, ch, numErrorChar);
    05850         std::ostringstream outStr;
    05851         std::string error = errormsg;
    05852         error = "PARSER ERROR:  Input is either not valid or well formed: "  + error;
    05853         outStr << error << endl;
    05854         outStr << "Here are " ;
    05855         outStr << numErrorChar ;
    05856         outStr << " characters currently being pointed to in the input string: ";
    05857         outStr << errorArray;
    05858         outStr << endl;
    05859         outStr << "See line number: " << *osillineno << endl;
    05860         error = outStr.str();
    05861         //osillex_destroy(scanner);
    05862         throw ErrorClass( error);
    05863 }//end osilerror_wrapper
    05864
    05865
    05866