/* A Bison parser, made by GNU Bison 1.875c. */ /* Skeleton parser for Yacc-like parsing with Bison, Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison. */ /* Written by Richard Stallman by simplifying the original so called ``semantic'' parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ /* Identify Bison output. */ #define YYBISON 1 /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 0 /* Using locations. */ #define YYLSP_NEEDED 0 /* If NAME_PREFIX is specified substitute the variables and functions names. */ #define yyparse zzparse #define yylex zzlex #define yyerror zzerror #define yylval zzlval #define yychar zzchar #define yydebug zzdebug #define yynerrs zznerrs /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { INT = 258, DOUBLE = 259, NAME = 260, STRING = 261, ENDCMD = 262, MODEL = 263, DATA = 264, IN = 265, TO = 266, INITS = 267, PARAMETERS = 268, COMPILE = 269, INITIALIZE = 270, UPDATE = 271, BY = 272, MONITOR = 273, SET = 274, CLEAR = 275, THIN = 276, CODA = 277, STEM = 278, SEED = 279, EXIT = 280, NCHAINS = 281, CHAIN = 282, LIST = 283, STRUCTURE = 284, DIM = 285, NA = 286, R_NULL = 287, DIMNAMES = 288, ITER = 289, ARROW = 290, ENDDATA = 291, ASINTEGER = 292 }; #endif #define INT 258 #define DOUBLE 259 #define NAME 260 #define STRING 261 #define ENDCMD 262 #define MODEL 263 #define DATA 264 #define IN 265 #define TO 266 #define INITS 267 #define PARAMETERS 268 #define COMPILE 269 #define INITIALIZE 270 #define UPDATE 271 #define BY 272 #define MONITOR 273 #define SET 274 #define CLEAR 275 #define THIN 276 #define CODA 277 #define STEM 278 #define SEED 279 #define EXIT 280 #define NCHAINS 281 #define CHAIN 282 #define LIST 283 #define STRUCTURE 284 #define DIM 285 #define NA 286 #define R_NULL 287 #define DIMNAMES 288 #define ITER 289 #define ARROW 290 #define ENDDATA 291 #define ASINTEGER 292 /* Copy the first part of user declarations. */ #line 2 "parser.yy" #include #include #include #include #include #include #include #include #include #include #include #include "ReadData.h" #include #include int zzerror(const char *); int zzlex(); #define YYERROR_VERBOSE 0 static Console *console; static bool interactive = true; void setName(ParseTree *p, std::string *name); std::map _data_table; bool open_data_buffer(std::string const *name); void return_to_main_buffer(); void setMonitor(ParseTree const *var, int thin); void clearMonitor(ParseTree const *var); void doCoda (ParseTree const *var, std::string const &stem); void doAllCoda (std::string const &stem); void doDump (std::string const &file, bool observed); static void errordump(); static void updatestar(long niter, long refresh, int width); static void setParameters(ParseTree *p, ParseTree *param1); static void setParameters(ParseTree *p, std::vector *parameters); static void setParameters(ParseTree *p, ParseTree *param1, ParseTree *param2); /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 0 #endif #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) #line 41 "parser.yy" typedef union YYSTYPE { int intval; double val; std::string *stringptr; ParseTree *ptree; std::vector *pvec; std::vector *vec; std::vector *ivec; } YYSTYPE; /* Line 191 of yacc.c. */ #line 205 "parser.cc" # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 #endif /* Copy the second part of user declarations. */ /* Line 214 of yacc.c. */ #line 217 "parser.cc" #if ! defined (yyoverflow) || YYERROR_VERBOSE # ifndef YYFREE # define YYFREE free # endif # ifndef YYMALLOC # define YYMALLOC malloc # endif /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA # define YYSTACK_ALLOC alloca # endif # else # if defined (alloca) || defined (_ALLOCA_H) # define YYSTACK_ALLOC alloca # else # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # else # if defined (__STDC__) || defined (__cplusplus) # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # endif # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # endif #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ #if (! defined (yyoverflow) \ && (! defined (__cplusplus) \ || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { short yyss; YYSTYPE yyvs; }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY # if defined (__GNUC__) && 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else # define YYCOPY(To, From, Count) \ do \ { \ register YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ while (0) # endif # endif /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack, Stack, yysize); \ Stack = &yyptr->Stack; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0) #endif #if defined (__STDC__) || defined (__cplusplus) typedef signed char yysigned_char; #else typedef short yysigned_char; #endif /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 173 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 48 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 44 /* YYNRULES -- Number of rules. */ #define YYNRULES 97 /* YYNRULES -- Number of states. */ #define YYNSTATES 190 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 292 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ static const unsigned char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 39, 40, 44, 2, 38, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 43, 45, 2, 46, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 41, 2, 42, 2, 2, 2, 2, 2, 47, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37 }; #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ static const unsigned short yyprhs[] = { 0, 0, 3, 4, 7, 9, 12, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 45, 49, 51, 55, 59, 62, 66, 75, 77, 81, 85, 89, 91, 98, 100, 103, 111, 113, 115, 120, 122, 126, 128, 132, 134, 136, 138, 142, 151, 154, 162, 166, 168, 170, 173, 181, 184, 192, 195, 197, 200, 204, 208, 212, 219, 221, 223, 227, 231, 235, 237, 239, 244, 246, 251, 253, 257, 259, 261, 265, 267, 271, 273, 277, 279, 284, 286, 291, 296, 298, 300, 305, 307, 311, 313, 318, 320 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yysigned_char yyrhs[] = { 49, 0, -1, -1, 49, 50, -1, 7, -1, 51, 7, -1, 1, 7, -1, 52, -1, 53, -1, 54, -1, 56, -1, 57, -1, 58, -1, 60, -1, 61, -1, 62, -1, 68, -1, 72, -1, 73, -1, 63, -1, 8, 10, 71, -1, 55, 74, 36, -1, 55, -1, 9, 11, 71, -1, 9, 10, 71, -1, 9, 20, -1, 59, 74, 36, -1, 59, 74, 36, 38, 27, 39, 3, 40, -1, 59, -1, 13, 11, 71, -1, 13, 10, 71, -1, 12, 10, 71, -1, 14, -1, 14, 38, 26, 39, 3, 40, -1, 15, -1, 16, 3, -1, 16, 3, 38, 17, 39, 3, 40, -1, 25, -1, 5, -1, 5, 41, 65, 42, -1, 66, -1, 65, 38, 66, -1, 67, -1, 67, 43, 67, -1, 3, -1, 69, -1, 70, -1, 18, 19, 64, -1, 18, 19, 64, 38, 21, 39, 3, 40, -1, 18, 64, -1, 18, 64, 38, 21, 39, 3, 40, -1, 18, 20, 64, -1, 5, -1, 6, -1, 22, 64, -1, 22, 64, 38, 23, 39, 71, 40, -1, 22, 44, -1, 22, 44, 38, 23, 39, 71, 40, -1, 24, 3, -1, 75, -1, 74, 75, -1, 74, 45, 75, -1, 6, 35, 76, -1, 6, 35, 79, -1, 29, 39, 79, 38, 77, 40, -1, 78, -1, 84, -1, 77, 38, 84, -1, 77, 38, 78, -1, 30, 46, 79, -1, 80, -1, 81, -1, 37, 39, 81, 40, -1, 83, -1, 47, 39, 82, 40, -1, 83, -1, 82, 38, 83, -1, 4, -1, 31, -1, 5, 46, 87, -1, 86, -1, 85, 38, 86, -1, 87, -1, 5, 46, 87, -1, 88, -1, 37, 39, 88, 40, -1, 90, -1, 28, 39, 85, 40, -1, 29, 39, 85, 40, -1, 32, -1, 4, -1, 47, 39, 89, 40, -1, 4, -1, 89, 38, 4, -1, 6, -1, 47, 39, 91, 40, -1, 6, -1, 91, 38, 6, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const unsigned short yyrline[] = { 0, 102, 102, 103, 106, 107, 108, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 126, 132, 136, 139, 145, 156, 162, 169, 175, 178, 184, 193, 205, 206, 211, 218, 223, 228, 231, 234, 240, 243, 248, 251, 257, 260, 261, 264, 267, 270, 273, 278, 287, 288, 291, 294, 297, 300, 305, 310, 313, 316, 321, 324, 331, 342, 343, 344, 345, 348, 353, 354, 357, 360, 364, 370, 371, 374, 375, 381, 384, 385, 388, 389, 392, 393, 394, 395, 396, 397, 400, 401, 404, 405, 408, 409, 412, 413 }; #endif #if YYDEBUG || YYERROR_VERBOSE /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "INT", "DOUBLE", "NAME", "STRING", "ENDCMD", "MODEL", "DATA", "IN", "TO", "INITS", "PARAMETERS", "COMPILE", "INITIALIZE", "UPDATE", "BY", "MONITOR", "SET", "CLEAR", "THIN", "CODA", "STEM", "SEED", "EXIT", "NCHAINS", "CHAIN", "LIST", "STRUCTURE", "DIM", "NA", "R_NULL", "DIMNAMES", "ITER", "ARROW", "ENDDATA", "ASINTEGER", "','", "'('", "')'", "'['", "']'", "':'", "'*'", "';'", "'='", "'c'", "$accept", "input", "line", "command", "model", "data_in", "data_to", "data", "data_clear", "parameters_in", "parameters_to", "parameters", "compile", "initialize", "update", "exit", "var", "range_list", "range_element", "index", "monitor", "monitor_set", "monitor_clear", "file_name", "coda", "seed", "r_assignment_list", "r_assignment", "r_structure", "r_attribute_list", "r_dim", "r_collection", "r_integer_collection", "r_value_collection", "r_value_list", "r_value", "r_generic_attribute", "r_generic_list", "r_generic_list_element", "r_generic_vector", "r_numeric_vector", "r_double_list", "r_character_vector", "r_string_list", 0 }; #endif # ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ static const unsigned short yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 44, 40, 41, 91, 93, 58, 42, 59, 61, 99 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const unsigned char yyr1[] = { 0, 48, 49, 49, 50, 50, 50, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 52, 53, 53, 54, 55, 56, 57, 57, 57, 58, 59, 59, 60, 60, 61, 62, 62, 63, 64, 64, 65, 65, 66, 66, 67, 68, 68, 69, 69, 69, 69, 70, 71, 71, 72, 72, 72, 72, 73, 74, 74, 74, 75, 75, 76, 77, 77, 77, 77, 78, 79, 79, 80, 81, 81, 82, 82, 83, 83, 84, 85, 85, 86, 86, 87, 87, 87, 87, 87, 87, 88, 88, 89, 89, 90, 90, 91, 91 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const unsigned char yyr2[] = { 0, 2, 0, 2, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 1, 3, 3, 2, 3, 8, 1, 3, 3, 3, 1, 6, 1, 2, 7, 1, 1, 4, 1, 3, 1, 3, 1, 1, 1, 3, 8, 2, 7, 3, 1, 1, 2, 7, 2, 7, 2, 1, 2, 3, 3, 3, 6, 1, 1, 3, 3, 3, 1, 1, 4, 1, 4, 1, 3, 1, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 4, 1, 1, 4, 1, 3, 1, 4, 1, 3 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const unsigned char yydefact[] = { 2, 0, 1, 0, 4, 0, 0, 0, 0, 32, 34, 0, 0, 0, 0, 37, 3, 0, 7, 8, 9, 22, 10, 11, 12, 28, 13, 14, 15, 19, 16, 45, 46, 17, 18, 6, 0, 0, 0, 25, 0, 0, 0, 0, 35, 38, 0, 0, 49, 56, 54, 58, 5, 0, 0, 59, 0, 52, 53, 20, 24, 23, 31, 30, 29, 0, 0, 0, 47, 51, 0, 0, 0, 0, 21, 0, 60, 26, 0, 0, 44, 0, 40, 42, 0, 0, 0, 0, 77, 0, 78, 0, 0, 62, 63, 70, 71, 73, 61, 0, 0, 0, 0, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 41, 43, 0, 0, 0, 0, 0, 0, 0, 75, 0, 36, 0, 50, 57, 55, 0, 72, 0, 74, 0, 48, 0, 0, 0, 65, 66, 76, 27, 0, 0, 0, 64, 90, 94, 0, 0, 89, 0, 0, 79, 84, 86, 69, 68, 67, 0, 0, 0, 0, 0, 0, 80, 82, 0, 0, 0, 92, 96, 0, 0, 0, 0, 87, 88, 0, 85, 0, 91, 0, 95, 83, 81, 93, 97 }; /* YYDEFGOTO[NTERM-NUM]. */ static const short yydefgoto[] = { -1, 1, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 48, 81, 82, 83, 30, 31, 32, 59, 33, 34, 54, 55, 93, 139, 140, 94, 95, 96, 123, 97, 141, 166, 167, 168, 156, 174, 157, 175 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -121 static const short yypact[] = { -121, 68, -121, 9, -121, -1, 54, 33, 92, -15, -121, 101, 53, 17, 102, -121, -121, 52, -121, -121, -121, 103, -121, -121, -121, 103, -121, -121, -121, -121, -121, -121, -121, -121, -121, -121, 73, 73, 73, -121, 73, 73, 73, 81, 70, 69, 106, 106, 74, 75, 76, -121, -121, 80, -4, -121, 12, -121, -121, -121, -121, -121, -121, -121, -121, 77, 100, 115, 82, -121, 98, 99, 104, 13, -121, 103, -121, 83, 120, 86, -121, -17, -121, 87, 105, 89, 90, 93, -121, 94, -121, 95, 96, -121, -121, -121, -121, -121, -121, 97, 91, 133, 115, -121, 115, 107, 134, 73, 73, 15, 7, 16, 108, -121, 109, -121, -121, 135, 110, 111, 112, 116, 113, -12, -121, 136, -121, 117, -121, -121, -121, 58, -121, 16, -121, 118, -121, 114, 119, -11, -121, -121, -121, -121, 8, 15, 58, -121, -121, -121, 122, 123, -121, 124, 125, -121, -121, -121, -121, -121, -121, 2, 2, 6, 85, 121, 56, -121, -121, 57, 127, 128, -121, -121, 60, 61, 8, 2, -121, -121, 137, -121, 138, -121, 139, -121, -121, -121, -121, -121 }; /* YYPGOTO[NTERM-NUM]. */ static const short yypgoto[] = { -121, -121, -121, -121, -121, -121, -121, -121, -121, -121, -121, -121, -121, -121, -121, -121, 20, -121, 38, 39, -121, -121, -121, -37, -121, -121, 130, 31, -121, -121, -2, -94, -121, 46, -121, -98, 23, -14, -18, -120, 10, -121, -121, -121 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -1 static const unsigned char yytable[] = { 60, 61, 53, 62, 63, 64, 148, 165, 149, 36, 148, 88, 148, 124, 149, 121, 35, 88, 53, 88, 88, 102, 45, 43, 155, 103, 133, 146, 134, 147, 150, 151, 74, 50, 152, 142, 150, 151, 90, 153, 152, 75, 89, 40, 90, 153, 90, 90, 77, 154, 91, 158, 91, 170, 92, 154, 186, 75, 45, 52, 92, 49, 92, 137, 37, 38, 68, 69, 2, 3, 119, 120, 46, 47, 39, 4, 5, 6, 57, 58, 7, 8, 9, 10, 11, 76, 12, 76, 138, 172, 13, 173, 14, 15, 177, 177, 178, 179, 182, 184, 183, 185, 41, 42, 44, 51, 98, 65, 66, 53, 67, 45, 70, 71, 72, 73, 78, 79, 80, 85, 84, 99, 86, 100, 112, 101, 105, 87, 106, 107, 104, 113, 108, 109, 110, 111, 114, 118, 127, 135, 115, 172, 188, 116, 159, 189, 117, 125, 169, 126, 128, 129, 130, 132, 131, 56, 122, 136, 143, 187, 144, 161, 162, 163, 164, 145, 180, 176, 181, 160, 0, 0, 0, 171 }; static const short yycheck[] = { 37, 38, 6, 40, 41, 42, 4, 5, 6, 10, 4, 4, 4, 111, 6, 109, 7, 4, 6, 4, 4, 38, 5, 38, 144, 42, 38, 38, 40, 40, 28, 29, 36, 13, 32, 133, 28, 29, 31, 37, 32, 45, 29, 10, 31, 37, 31, 31, 36, 47, 37, 145, 37, 47, 47, 47, 176, 45, 5, 7, 47, 44, 47, 5, 10, 11, 46, 47, 0, 1, 107, 108, 19, 20, 20, 7, 8, 9, 5, 6, 12, 13, 14, 15, 16, 54, 18, 56, 30, 4, 22, 6, 24, 25, 38, 38, 40, 40, 38, 38, 40, 40, 10, 11, 3, 3, 75, 26, 38, 6, 41, 5, 38, 38, 38, 35, 39, 17, 3, 21, 38, 38, 23, 3, 27, 39, 21, 23, 39, 39, 43, 40, 39, 39, 39, 39, 3, 3, 3, 3, 102, 4, 4, 104, 146, 6, 39, 39, 162, 40, 40, 40, 40, 40, 38, 25, 110, 40, 40, 177, 46, 39, 39, 39, 39, 46, 39, 46, 40, 146, -1, -1, -1, 163 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const unsigned char yystos[] = { 0, 49, 0, 1, 7, 8, 9, 12, 13, 14, 15, 16, 18, 22, 24, 25, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 68, 69, 70, 72, 73, 7, 10, 10, 11, 20, 10, 10, 11, 38, 3, 5, 19, 20, 64, 44, 64, 3, 7, 6, 74, 75, 74, 5, 6, 71, 71, 71, 71, 71, 71, 26, 38, 41, 64, 64, 38, 38, 38, 35, 36, 45, 75, 36, 39, 17, 3, 65, 66, 67, 38, 21, 23, 23, 4, 29, 31, 37, 47, 76, 79, 80, 81, 83, 75, 38, 3, 39, 38, 42, 43, 21, 39, 39, 39, 39, 39, 39, 27, 40, 3, 66, 67, 39, 3, 71, 71, 79, 81, 82, 83, 39, 40, 3, 40, 40, 40, 38, 40, 38, 40, 3, 40, 5, 30, 77, 78, 84, 83, 40, 46, 46, 38, 40, 4, 6, 28, 29, 32, 37, 47, 87, 88, 90, 79, 78, 84, 39, 39, 39, 39, 5, 85, 86, 87, 85, 47, 88, 4, 6, 89, 91, 46, 38, 40, 40, 39, 40, 38, 40, 38, 40, 87, 86, 4, 6 }; #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) # define YYSIZE_T __SIZE_TYPE__ #endif #if ! defined (YYSIZE_T) && defined (size_t) # define YYSIZE_T size_t #endif #if ! defined (YYSIZE_T) # if defined (__STDC__) || defined (__cplusplus) # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # endif #endif #if ! defined (YYSIZE_T) # define YYSIZE_T unsigned int #endif #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { \ yyerror ("syntax error: cannot back up");\ YYERROR; \ } \ while (0) #define YYTERROR 1 #define YYERRCODE 256 /* YYLLOC_DEFAULT -- Compute the default location (before the actions are run). */ #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ ((Current).first_line = (Rhs)[1].first_line, \ (Current).first_column = (Rhs)[1].first_column, \ (Current).last_line = (Rhs)[N].last_line, \ (Current).last_column = (Rhs)[N].last_column) #endif /* YYLEX -- calling `yylex' with the right arguments. */ #ifdef YYLEX_PARAM # define YYLEX yylex (YYLEX_PARAM) #else # define YYLEX yylex () #endif /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (0) # define YYDSYMPRINT(Args) \ do { \ if (yydebug) \ yysymprint Args; \ } while (0) # define YYDSYMPRINTF(Title, Token, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yysymprint (stderr, \ Token, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ #if defined (__STDC__) || defined (__cplusplus) static void yy_stack_print (short *bottom, short *top) #else static void yy_stack_print (bottom, top) short *bottom; short *top; #endif { YYFPRINTF (stderr, "Stack now"); for (/* Nothing. */; bottom <= top; ++bottom) YYFPRINTF (stderr, " %d", *bottom); YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (0) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ #if defined (__STDC__) || defined (__cplusplus) static void yy_reduce_print (int yyrule) #else static void yy_reduce_print (yyrule) int yyrule; #endif { int yyi; unsigned int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", yyrule - 1, yylno); /* Print the symbols being reduced, and their result. */ for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (Rule); \ } while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YYDSYMPRINT(Args) # define YYDSYMPRINTF(Title, Token, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 # undef YYMAXDEPTH #endif #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined (__GLIBC__) && defined (_STRING_H) # define yystrlen strlen # else /* Return the length of YYSTR. */ static YYSIZE_T # if defined (__STDC__) || defined (__cplusplus) yystrlen (const char *yystr) # else yystrlen (yystr) const char *yystr; # endif { register const char *yys = yystr; while (*yys++ != '\0') continue; return yys - yystr - 1; } # endif # endif # ifndef yystpcpy # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ static char * # if defined (__STDC__) || defined (__cplusplus) yystpcpy (char *yydest, const char *yysrc) # else yystpcpy (yydest, yysrc) char *yydest; const char *yysrc; # endif { register char *yyd = yydest; register const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif #endif /* !YYERROR_VERBOSE */ #if YYDEBUG /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ #if defined (__STDC__) || defined (__cplusplus) static void yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) #else static void yysymprint (yyoutput, yytype, yyvaluep) FILE *yyoutput; int yytype; YYSTYPE *yyvaluep; #endif { /* Pacify ``unused variable'' warnings. */ (void) yyvaluep; if (yytype < YYNTOKENS) { YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); # ifdef YYPRINT YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # endif } else YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); switch (yytype) { default: break; } YYFPRINTF (yyoutput, ")"); } #endif /* ! YYDEBUG */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ #if defined (__STDC__) || defined (__cplusplus) static void yydestruct (int yytype, YYSTYPE *yyvaluep) #else static void yydestruct (yytype, yyvaluep) int yytype; YYSTYPE *yyvaluep; #endif { /* Pacify ``unused variable'' warnings. */ (void) yyvaluep; switch (yytype) { default: break; } } /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM # if defined (__STDC__) || defined (__cplusplus) int yyparse (void *YYPARSE_PARAM); # else int yyparse (); # endif #else /* ! YYPARSE_PARAM */ #if defined (__STDC__) || defined (__cplusplus) int yyparse (void); #else int yyparse (); #endif #endif /* ! YYPARSE_PARAM */ /* The lookahead symbol. */ int yychar; /* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; /*----------. | yyparse. | `----------*/ #ifdef YYPARSE_PARAM # if defined (__STDC__) || defined (__cplusplus) int yyparse (void *YYPARSE_PARAM) # else int yyparse (YYPARSE_PARAM) void *YYPARSE_PARAM; # endif #else /* ! YYPARSE_PARAM */ #if defined (__STDC__) || defined (__cplusplus) int yyparse (void) #else int yyparse () #endif #endif { register int yystate; register int yyn; int yyresult; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* Lookahead token as an internal (translated) token number. */ int yytoken = 0; /* Three stacks and their tools: `yyss': related to states, `yyvs': related to semantic values, `yyls': related to locations. Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ short yyssa[YYINITDEPTH]; short *yyss = yyssa; register short *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs = yyvsa; register YYSTYPE *yyvsp; #define YYPOPSTACK (yyvsp--, yyssp--) YYSIZE_T yystacksize = YYINITDEPTH; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; /* When reducing, the number of symbols on the RHS of the reduced rule. */ int yylen; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss; yyvsp = yyvs; goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. so pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; short *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow ("parser stack overflow", &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyoverflowlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyoverflowlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { short *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyoverflowlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. */ /* Read a lookahead token if we need one and don't already have one. */ /* yyresume: */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yyn == 0 || yyn == YYTABLE_NINF) goto yyerrlab; yyn = -yyn; goto yyreduce; } if (yyn == YYFINAL) YYACCEPT; /* Shift the lookahead token. */ YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; yystate = yyn; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; YY_REDUCE_PRINT (yyn); switch (yyn) { case 2: #line 102 "parser.yy" {if (interactive) std::cout << ". " << std::flush;} break; case 3: #line 103 "parser.yy" {if (interactive) std::cout << ". " << std::flush;} break; case 4: #line 106 "parser.yy" {} break; case 5: #line 107 "parser.yy" {} break; case 6: #line 108 "parser.yy" {if(interactive) yyerrok; else exit(1);} break; case 20: #line 126 "parser.yy" { console->checkModel(*yyvsp[0].stringptr); delete yyvsp[0].stringptr; } break; case 21: #line 132 "parser.yy" { readRData(yyvsp[-1].pvec, _data_table); delete yyvsp[-1].pvec; } break; case 22: #line 136 "parser.yy" {} break; case 23: #line 139 "parser.yy" { doDump(*yyvsp[0].stringptr, true); delete yyvsp[0].stringptr; } break; case 24: #line 145 "parser.yy" { if(open_data_buffer(yyvsp[0].stringptr)) { std::cout << "Reading data file " << *yyvsp[0].stringptr << std::endl; } else { std::cerr << "Unable to open file " << *yyvsp[0].stringptr << std::endl << std::flush; } delete yyvsp[0].stringptr; } break; case 25: #line 156 "parser.yy" { std::cout << "Clearing data table " << std::endl; _data_table.clear(); } break; case 26: #line 163 "parser.yy" { std::map parameter_table; readRData(yyvsp[-1].pvec, parameter_table); delete yyvsp[-1].pvec; console->setParameters(parameter_table, 1); } break; case 27: #line 169 "parser.yy" { std::map parameter_table; readRData(yyvsp[-6].pvec, parameter_table); delete yyvsp[-6].pvec; console->setParameters(parameter_table, yyvsp[-1].intval); } break; case 28: #line 175 "parser.yy" {} break; case 29: #line 178 "parser.yy" { doDump(*yyvsp[0].stringptr, false); delete yyvsp[0].stringptr; } break; case 30: #line 184 "parser.yy" { if(open_data_buffer(yyvsp[0].stringptr)) { std::cout << "Reading parameter file " << *yyvsp[0].stringptr << std::endl; } else { std::cerr << "Unable to open file " << *yyvsp[0].stringptr << std::endl << std::flush; } delete yyvsp[0].stringptr; } break; case 31: #line 193 "parser.yy" { /* Legacy option to not break existing scripts */ if(open_data_buffer(yyvsp[0].stringptr)) { std::cout << "Reading initial values file " << *yyvsp[0].stringptr << std::endl; } else { std::cerr << "Unable to open file " << *yyvsp[0].stringptr << std::endl << std::flush; } delete yyvsp[0].stringptr; } break; case 32: #line 205 "parser.yy" {console->compile(_data_table, 1);} break; case 33: #line 206 "parser.yy" { console->compile(_data_table, yyvsp[-1].intval); } break; case 34: #line 211 "parser.yy" { if (!console->initialize()) { errordump(); } } break; case 35: #line 218 "parser.yy" { //fixme: put refresh option long refresh = yyvsp[0].intval/40; updatestar(yyvsp[0].intval, refresh, 40); } break; case 36: #line 223 "parser.yy" { updatestar(yyvsp[-5].intval,yyvsp[-1].intval, 40); } break; case 37: #line 228 "parser.yy" {return 0;} break; case 38: #line 231 "parser.yy" { yyval.ptree = new ParseTree(P_VAR); setName(yyval.ptree, yyvsp[0].stringptr); } break; case 39: #line 234 "parser.yy" { yyval.ptree = new ParseTree(P_VAR); setName(yyval.ptree, yyvsp[-3].stringptr); setParameters(yyval.ptree, yyvsp[-1].pvec); } break; case 40: #line 240 "parser.yy" { yyval.pvec = new std::vector(1, yyvsp[0].ptree); } break; case 41: #line 243 "parser.yy" { yyval.pvec=yyvsp[-2].pvec; yyval.pvec->push_back(yyvsp[0].ptree); } break; case 42: #line 248 "parser.yy" { yyval.ptree = new ParseTree(P_RANGE); setParameters(yyval.ptree,yyvsp[0].ptree); } break; case 43: #line 251 "parser.yy" { yyval.ptree = new ParseTree(P_RANGE); setParameters(yyval.ptree, yyvsp[-2].ptree, yyvsp[0].ptree); } break; case 44: #line 257 "parser.yy" {yyval.ptree = new ParseTree(P_VALUE); yyval.ptree->setValue(yyvsp[0].intval);} break; case 47: #line 264 "parser.yy" { setMonitor(yyvsp[0].ptree, 1); delete yyvsp[0].ptree; } break; case 48: #line 267 "parser.yy" { setMonitor(yyvsp[-5].ptree, yyvsp[-1].intval); delete yyvsp[-5].ptree; } break; case 49: #line 270 "parser.yy" { setMonitor(yyvsp[0].ptree, 1); delete yyvsp[0].ptree; } break; case 50: #line 273 "parser.yy" { setMonitor(yyvsp[-5].ptree, yyvsp[-1].intval); delete yyvsp[-5].ptree; } break; case 51: #line 278 "parser.yy" { clearMonitor(yyvsp[0].ptree); delete yyvsp[0].ptree; } break; case 52: #line 287 "parser.yy" { yyval.stringptr = yyvsp[0].stringptr;} break; case 53: #line 288 "parser.yy" { yyval.stringptr = yyvsp[0].stringptr; } break; case 54: #line 291 "parser.yy" { doCoda (yyvsp[0].ptree, "jags"); delete yyvsp[0].ptree; } break; case 55: #line 294 "parser.yy" { doCoda (yyvsp[-5].ptree, *yyvsp[-1].stringptr); delete yyvsp[-5].ptree; delete yyvsp[-1].stringptr; } break; case 56: #line 297 "parser.yy" { doAllCoda ("jags"); } break; case 57: #line 300 "parser.yy" { doAllCoda (*yyvsp[-1].stringptr); delete yyvsp[-1].stringptr; } break; case 58: #line 305 "parser.yy" { console->setSeed(static_cast(yyvsp[0].intval)); } break; case 59: #line 310 "parser.yy" { yyval.pvec = new std::vector(1, yyvsp[0].ptree); } break; case 60: #line 313 "parser.yy" { yyval.pvec = yyvsp[-1].pvec; yyval.pvec->push_back(yyvsp[0].ptree); } break; case 61: #line 316 "parser.yy" { yyval.pvec = yyvsp[-2].pvec; yyval.pvec->push_back(yyvsp[0].ptree); } break; case 62: #line 321 "parser.yy" { yyval.ptree = yyvsp[0].ptree; setName(yyval.ptree, yyvsp[-2].stringptr); } break; case 63: #line 324 "parser.yy" { yyval.ptree = new ParseTree(P_ARRAY); setName(yyval.ptree, yyvsp[-2].stringptr); setParameters(yyval.ptree, yyvsp[0].ptree); } break; case 64: #line 331 "parser.yy" { yyval.ptree = new ParseTree(P_ARRAY); if (yyvsp[-1].ptree) setParameters(yyval.ptree, yyvsp[-3].ptree, yyvsp[-1].ptree); else setParameters(yyval.ptree, yyvsp[-3].ptree); } break; case 66: #line 343 "parser.yy" {yyval.ptree=0;} break; case 68: #line 345 "parser.yy" {yyval.ptree=yyvsp[0].ptree;} break; case 69: #line 348 "parser.yy" { yyval.ptree = yyvsp[0].ptree; } break; case 72: #line 357 "parser.yy" {yyval.ptree = yyvsp[-1].ptree;} break; case 73: #line 360 "parser.yy" { yyval.ptree = new ParseTree(P_VECTOR); setParameters(yyval.ptree, yyvsp[0].ptree); } break; case 74: #line 364 "parser.yy" { yyval.ptree = new ParseTree(P_VECTOR); setParameters(yyval.ptree, yyvsp[-1].pvec); } break; case 75: #line 370 "parser.yy" {yyval.pvec = new std::vector(1, yyvsp[0].ptree); } break; case 76: #line 371 "parser.yy" {yyval.pvec = yyvsp[-2].pvec; yyval.pvec->push_back(yyvsp[0].ptree);} break; case 77: #line 374 "parser.yy" {yyval.ptree = new ParseTree(P_VALUE); yyval.ptree->setValue(yyvsp[0].val);} break; case 78: #line 375 "parser.yy" {yyval.ptree = new ParseTree(P_VALUE); yyval.ptree->setValue(JAGS_NA);} break; case 79: #line 381 "parser.yy" {;} break; case 80: #line 384 "parser.yy" {;} break; case 81: #line 385 "parser.yy" {;} break; case 82: #line 388 "parser.yy" {;} break; case 83: #line 389 "parser.yy" {;} break; case 84: #line 392 "parser.yy" {;} break; case 85: #line 393 "parser.yy" {;} break; case 86: #line 394 "parser.yy" {;} break; case 87: #line 395 "parser.yy" {;} break; case 88: #line 396 "parser.yy" {;} break; case 89: #line 397 "parser.yy" {;} break; case 90: #line 400 "parser.yy" {;} break; case 92: #line 404 "parser.yy" {;} break; case 93: #line 405 "parser.yy" {;} break; case 94: #line 408 "parser.yy" {;} break; case 95: #line 409 "parser.yy" {;} break; case 96: #line 412 "parser.yy" {;} break; case 97: #line 413 "parser.yy" {;} break; } /* Line 1000 of yacc.c. */ #line 1770 "parser.cc" yyvsp -= yylen; yyssp -= yylen; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; /*------------------------------------. | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if YYERROR_VERBOSE yyn = yypact[yystate]; if (YYPACT_NINF < yyn && yyn < YYLAST) { YYSIZE_T yysize = 0; int yytype = YYTRANSLATE (yychar); const char* yyprefix; char *yymsg; int yyx; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yycount = 0; yyprefix = ", expecting "; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); yycount += 1; if (yycount == 5) { yysize = 0; break; } } yysize += (sizeof ("syntax error, unexpected ") + yystrlen (yytname[yytype])); yymsg = (char *) YYSTACK_ALLOC (yysize); if (yymsg != 0) { char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); yyp = yystpcpy (yyp, yytname[yytype]); if (yycount < 5) { yyprefix = ", expecting "; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { yyp = yystpcpy (yyp, yyprefix); yyp = yystpcpy (yyp, yytname[yyx]); yyprefix = " or "; } } yyerror (yymsg); YYSTACK_FREE (yymsg); } else yyerror ("syntax error; also virtual memory exhausted"); } else #endif /* YYERROR_VERBOSE */ yyerror ("syntax error"); } if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) { /* If at end of input, pop the error token, then the rest of the stack, then return failure. */ if (yychar == YYEOF) for (;;) { YYPOPSTACK; if (yyssp == yyss) YYABORT; YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); yydestruct (yystos[*yyssp], yyvsp); } } else { YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); yydestruct (yytoken, &yylval); yychar = YYEMPTY; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: #ifdef __GNUC__ /* Pacify GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (0) goto yyerrorlab; #endif yyvsp -= yylen; yyssp -= yylen; yystate = *yyssp; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (yyn != YYPACT_NINF) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); yydestruct (yystos[yystate], yyvsp); YYPOPSTACK; yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } if (yyn == YYFINAL) YYACCEPT; YYDPRINTF ((stderr, "Shifting error token, ")); *++yyvsp = yylval; yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #ifndef yyoverflow /*----------------------------------------------. | yyoverflowlab -- parser overflow comes here. | `----------------------------------------------*/ yyoverflowlab: yyerror ("parser stack overflow"); yyresult = 2; /* Fall through. */ #endif yyreturn: #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif return yyresult; } #line 416 "parser.yy" int zzerror (const char *s) { return_to_main_buffer(); std::cerr << s << std::endl; return 0; } int main (int argc, char **argv) { extern FILE *zzin; FILE *cmdfile = 0; if (argc > 2) { std::cerr << "Too many arguments" << std::endl; } else if (argc == 2) { interactive = false; cmdfile = fopen(argv[1],"r"); if (cmdfile) { zzin = cmdfile; } else { std::cerr << "Unable to open command file " << argv[1] << std::endl; return 1; } } time_t t; time(&t); std::cout << "Welcome to JAGS " << JAGS_VERSION << " on " << ctime(&t); unsigned int seed = static_cast(t); std::cout << "(seed = " << seed << ")" << std::endl; std::cout << "JAGS is free software and comes with ABSOLUTELY NO WARRANTY" << std::endl; console = new Console(std::cout, std::cerr); console->setSeed(seed); zzparse(); if (argc==2) { fclose(cmdfile); } _data_table.clear(); //Need this to avoid segfault delete console; } static Range getRange(ParseTree const *var) { /* Blank arguments, e.g. foo[] or bar[,1] are not allowed. */ unsigned int size = var->parameters().size(); Index ind_lower(size), ind_upper(size); for (unsigned int i = 0; i < size; ++i) { ParseTree const *range_element = var->parameters()[i]; switch(range_element->parameters().size()) { case 1: ind_lower[i] = (long) (range_element->parameters()[0]->value() + 1.0E-6); ind_upper[i] = ind_lower[i]; break; case 2: ind_lower[i] = (long) (range_element->parameters()[0]->value() + 1.0E-6); ind_upper[i] = (long) (range_element->parameters()[1]->value() + 1.0E-6); break; default: //Error! FIXME break; } } return Range(ind_lower, ind_upper); } void setMonitor(ParseTree const *var, int thin) { std::string const &name = var->name(); if (var->parameters().empty()) { /* Requesting the whole node */ console->setMonitor(name, thin); } else { /* Requesting subset of a multivariate node */ Range range = getRange(var); console->setMonitor(name, range, thin); } } void clearMonitor(ParseTree const *var) { std::string const &name = var->name(); if (var->parameters().empty()) { /* Requesting the whole node */ console->clearMonitor(name); } else { /* Requesting subset of a multivariate node */ Range range = getRange(var); console->clearMonitor(name, range); } } void doCoda (ParseTree const *var, std::string const &stem) { /* Open output file */ std::string outname(stem); outname.append(".out"); std::ofstream out(outname.c_str()); if (!out) { std::cerr << "Failed to open file " << outname << std::endl; return; } /* Open index file */ std::string indname(stem); indname.append(".ind"); std::ofstream ind(indname.c_str()); if (!ind) { std::cerr << "Failed to open file " << indname << std::endl; out.close(); return; } if (var->parameters().empty()) { /* Requesting the whole node */ console->coda(var->name(), out, ind); } else { /* Requesting subset of a multivariate node */ console->coda(var->name(), getRange(var), out, ind); } out.close(); ind.close(); } void doAllCoda (std::string const &stem) { /* Open output file */ std::string outname(stem); outname.append(".out"); std::ofstream out(outname.c_str()); if (!out) { std::cerr << "Failed to open file " << outname << std::endl; return; } /* Open indemax file */ std::string indname(stem); indname.append(".ind"); std::ofstream ind(indname.c_str()); if (!ind) { std::cerr << "Failed to open file " << indname << std::endl; out.close(); return; } console->coda(out, ind); out.close(); ind.close(); } /* Helper function for doDump that handles all the special cases (missing values etc) when writing a double value */ static void writeDouble(double x, std::ostream &out) { if (x == JAGS_NA) { out << "NA"; } else if (ISNAN(x)) { out << "NaN"; } else if (!R_FINITE(x)) { if (x > 0) { out << "Inf"; } else { out << "-Inf"; } } else { out << x; } } void doDump(std::string const &file, bool observed) { std::map data_table; if (!console->dumpState(data_table, 1, observed)) return; /* Open output file */ std::ofstream out(file.c_str()); if (!out) { std::cerr << "Failed to open file " << file << std::endl; return; } for (std::map::const_iterator p = data_table.begin(); p != data_table.end(); ++p) { std::string const &name = p->first; SArray const &sarray = p->second; double const *value = sarray.value(); long length = sarray.length(); out << "\"" << name << "\" <- " << std::endl; Index const &dim = sarray.dim(false); if (dim.size() == 1) { // Vector if (dim[0] == 1) { // Scalar writeDouble(value[0], out); out << std::endl; } else { // Vector of length > 1 out << "c("; for (int i = 0; i < length; ++i) { if (i > 0) { out << ","; } writeDouble(value[i], out); } out << ")" << std::endl; } } else { // Array out << "structure(c("; for (int i = 0; i < length; ++i) { if (i > 0) { out << ","; } writeDouble(value[i], out); } out << "), .Dim = c("; for (unsigned int j = 0; j < dim.size(); ++j) { if (j > 0) { out << ","; } out << dim[j]; } out << "))" << std::endl; } } out.close(); } void setParameters(ParseTree *p, std::vector *parameters) { /* The parser dynamically allocates vectors of (pointers to) parameters. These vectors must be deleted when we are done with them. */ p->setParameters(*parameters); delete parameters; } void setParameters(ParseTree *p, ParseTree *param1) { /* Wrapper function that creates a vector containing param1 to be passed to ParseTree::setParameters. */ std::vector parameters(1, param1); p->setParameters(parameters); } void setParameters(ParseTree *p, ParseTree *param1, ParseTree *param2) { /* Wrapper function that creates a vector containing param1 and param2, to be passed to ParseTree::setParameters */ std::vector parameters; parameters.push_back(param1); parameters.push_back(param2); p->setParameters(parameters); } void setName(ParseTree *p, std::string *name) { p->setName(*name); delete name; } static void errordump() { if (console->model()) { std::cout << "Dumping state at iteration " << console->iter() << " to file jags.dump" << std::endl; doDump("jags.dump", false); } } static void updatestar(long niter, long refresh, int width) { if (refresh == 0) { console->update(niter); return; } if (width > niter / refresh + 1) width = niter / refresh + 1; std::cout << "Updating " << niter << std::endl; for (int i = 0; i < width - 1; ++i) { std::cout << "-"; } std::cout << "| " << std::min(width * refresh, niter) << std::endl << std::flush; int col = 0; for (long n = niter; n > 0; n -= refresh) { long nupdate = std::min(n, refresh); if(console->update(nupdate)) std::cout << "*" << std::flush; else { std::cout << std::endl; errordump(); return; } col++; if (col == width || n <= nupdate) { int percent = 100 - (n-nupdate) * 100/niter; std::cout << " " << percent << "%" << std::endl; if (n > nupdate) { col = 0; } } } }