1130803Smarcel/* A Bison parser, made by GNU Bison 1.875. */ 2130803Smarcel 3130803Smarcel/* Skeleton parser for Yacc-like parsing with Bison, 4130803Smarcel Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. 5130803Smarcel 6130803Smarcel This program is free software; you can redistribute it and/or modify 7130803Smarcel it under the terms of the GNU General Public License as published by 8130803Smarcel the Free Software Foundation; either version 2, or (at your option) 9130803Smarcel any later version. 10130803Smarcel 11130803Smarcel This program is distributed in the hope that it will be useful, 12130803Smarcel but WITHOUT ANY WARRANTY; without even the implied warranty of 13130803Smarcel MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14130803Smarcel GNU General Public License for more details. 15130803Smarcel 16130803Smarcel You should have received a copy of the GNU General Public License 17130803Smarcel along with this program; if not, write to the Free Software 18130803Smarcel Foundation, Inc., 59 Temple Place - Suite 330, 19130803Smarcel Boston, MA 02111-1307, USA. */ 20130803Smarcel 21130803Smarcel/* As a special exception, when this file is copied by Bison into a 22130803Smarcel Bison output file, you may use that output file without restriction. 23130803Smarcel This special exception was added by the Free Software Foundation 24130803Smarcel in version 1.24 of Bison. */ 25130803Smarcel 26130803Smarcel/* Written by Richard Stallman by simplifying the original so called 27130803Smarcel ``semantic'' parser. */ 28130803Smarcel 29130803Smarcel/* All symbols defined below should begin with yy or YY, to avoid 30130803Smarcel infringing on user name space. This should be done even for local 31130803Smarcel variables, as they might otherwise be expanded by user macros. 32130803Smarcel There are some unavoidable exceptions within include files to 33130803Smarcel define necessary library symbols; they are noted "INFRINGES ON 34130803Smarcel USER NAME SPACE" below. */ 35130803Smarcel 36130803Smarcel/* Identify Bison output. */ 37130803Smarcel#define YYBISON 1 38130803Smarcel 39130803Smarcel/* Skeleton name. */ 40130803Smarcel#define YYSKELETON_NAME "yacc.c" 41130803Smarcel 42130803Smarcel/* Pure parsers. */ 43130803Smarcel#define YYPURE 0 44130803Smarcel 45130803Smarcel/* Using locations. */ 46130803Smarcel#define YYLSP_NEEDED 0 47130803Smarcel 48130803Smarcel 49130803Smarcel 50130803Smarcel/* Tokens. */ 51130803Smarcel#ifndef YYTOKENTYPE 52130803Smarcel# define YYTOKENTYPE 53130803Smarcel /* Put the tokens into the symbol table, so that GDB and other debuggers 54130803Smarcel know about them. */ 55130803Smarcel enum yytokentype { 56130803Smarcel INT = 258, 57130803Smarcel FLOAT = 259, 58130803Smarcel STRING_LITERAL = 260, 59130803Smarcel BOOLEAN_LITERAL = 261, 60130803Smarcel NAME = 262, 61130803Smarcel TYPENAME = 263, 62130803Smarcel NAME_OR_INT = 264, 63130803Smarcel SIZEOF = 265, 64130803Smarcel ERROR = 266, 65130803Smarcel INT_KEYWORD = 267, 66130803Smarcel INT_S2_KEYWORD = 268, 67130803Smarcel LOGICAL_S1_KEYWORD = 269, 68130803Smarcel LOGICAL_S2_KEYWORD = 270, 69130803Smarcel LOGICAL_KEYWORD = 271, 70130803Smarcel REAL_KEYWORD = 272, 71130803Smarcel REAL_S8_KEYWORD = 273, 72130803Smarcel REAL_S16_KEYWORD = 274, 73130803Smarcel COMPLEX_S8_KEYWORD = 275, 74130803Smarcel COMPLEX_S16_KEYWORD = 276, 75130803Smarcel COMPLEX_S32_KEYWORD = 277, 76130803Smarcel BOOL_AND = 278, 77130803Smarcel BOOL_OR = 279, 78130803Smarcel BOOL_NOT = 280, 79130803Smarcel CHARACTER = 281, 80130803Smarcel VARIABLE = 282, 81130803Smarcel ASSIGN_MODIFY = 283, 82130803Smarcel ABOVE_COMMA = 284, 83130803Smarcel NOTEQUAL = 285, 84130803Smarcel EQUAL = 286, 85130803Smarcel GEQ = 287, 86130803Smarcel LEQ = 288, 87130803Smarcel GREATERTHAN = 289, 88130803Smarcel LESSTHAN = 290, 89130803Smarcel RSH = 291, 90130803Smarcel LSH = 292, 91130803Smarcel UNARY = 293 92130803Smarcel }; 93130803Smarcel#endif 94130803Smarcel#define INT 258 95130803Smarcel#define FLOAT 259 96130803Smarcel#define STRING_LITERAL 260 97130803Smarcel#define BOOLEAN_LITERAL 261 98130803Smarcel#define NAME 262 99130803Smarcel#define TYPENAME 263 100130803Smarcel#define NAME_OR_INT 264 101130803Smarcel#define SIZEOF 265 102130803Smarcel#define ERROR 266 103130803Smarcel#define INT_KEYWORD 267 104130803Smarcel#define INT_S2_KEYWORD 268 105130803Smarcel#define LOGICAL_S1_KEYWORD 269 106130803Smarcel#define LOGICAL_S2_KEYWORD 270 107130803Smarcel#define LOGICAL_KEYWORD 271 108130803Smarcel#define REAL_KEYWORD 272 109130803Smarcel#define REAL_S8_KEYWORD 273 110130803Smarcel#define REAL_S16_KEYWORD 274 111130803Smarcel#define COMPLEX_S8_KEYWORD 275 112130803Smarcel#define COMPLEX_S16_KEYWORD 276 113130803Smarcel#define COMPLEX_S32_KEYWORD 277 114130803Smarcel#define BOOL_AND 278 115130803Smarcel#define BOOL_OR 279 116130803Smarcel#define BOOL_NOT 280 117130803Smarcel#define CHARACTER 281 118130803Smarcel#define VARIABLE 282 119130803Smarcel#define ASSIGN_MODIFY 283 120130803Smarcel#define ABOVE_COMMA 284 121130803Smarcel#define NOTEQUAL 285 122130803Smarcel#define EQUAL 286 123130803Smarcel#define GEQ 287 124130803Smarcel#define LEQ 288 125130803Smarcel#define GREATERTHAN 289 126130803Smarcel#define LESSTHAN 290 127130803Smarcel#define RSH 291 128130803Smarcel#define LSH 292 129130803Smarcel#define UNARY 293 130130803Smarcel 131130803Smarcel 132130803Smarcel 133130803Smarcel 134130803Smarcel/* Copy the first part of user declarations. */ 135130803Smarcel#line 44 "f-exp.y" 136130803Smarcel 137130803Smarcel 138130803Smarcel#include "defs.h" 139130803Smarcel#include "gdb_string.h" 140130803Smarcel#include "expression.h" 141130803Smarcel#include "value.h" 142130803Smarcel#include "parser-defs.h" 143130803Smarcel#include "language.h" 144130803Smarcel#include "f-lang.h" 145130803Smarcel#include "bfd.h" /* Required by objfiles.h. */ 146130803Smarcel#include "symfile.h" /* Required by objfiles.h. */ 147130803Smarcel#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */ 148130803Smarcel#include "block.h" 149130803Smarcel#include <ctype.h> 150130803Smarcel 151130803Smarcel/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), 152130803Smarcel as well as gratuitiously global symbol names, so we can have multiple 153130803Smarcel yacc generated parsers in gdb. Note that these are only the variables 154130803Smarcel produced by yacc. If other parser generators (bison, byacc, etc) produce 155130803Smarcel additional global names that conflict at link time, then those parser 156130803Smarcel generators need to be fixed instead of adding those names to this list. */ 157130803Smarcel 158130803Smarcel#define yymaxdepth f_maxdepth 159130803Smarcel#define yyparse f_parse 160130803Smarcel#define yylex f_lex 161130803Smarcel#define yyerror f_error 162130803Smarcel#define yylval f_lval 163130803Smarcel#define yychar f_char 164130803Smarcel#define yydebug f_debug 165130803Smarcel#define yypact f_pact 166130803Smarcel#define yyr1 f_r1 167130803Smarcel#define yyr2 f_r2 168130803Smarcel#define yydef f_def 169130803Smarcel#define yychk f_chk 170130803Smarcel#define yypgo f_pgo 171130803Smarcel#define yyact f_act 172130803Smarcel#define yyexca f_exca 173130803Smarcel#define yyerrflag f_errflag 174130803Smarcel#define yynerrs f_nerrs 175130803Smarcel#define yyps f_ps 176130803Smarcel#define yypv f_pv 177130803Smarcel#define yys f_s 178130803Smarcel#define yy_yys f_yys 179130803Smarcel#define yystate f_state 180130803Smarcel#define yytmp f_tmp 181130803Smarcel#define yyv f_v 182130803Smarcel#define yy_yyv f_yyv 183130803Smarcel#define yyval f_val 184130803Smarcel#define yylloc f_lloc 185130803Smarcel#define yyreds f_reds /* With YYDEBUG defined */ 186130803Smarcel#define yytoks f_toks /* With YYDEBUG defined */ 187130803Smarcel#define yyname f_name /* With YYDEBUG defined */ 188130803Smarcel#define yyrule f_rule /* With YYDEBUG defined */ 189130803Smarcel#define yylhs f_yylhs 190130803Smarcel#define yylen f_yylen 191130803Smarcel#define yydefred f_yydefred 192130803Smarcel#define yydgoto f_yydgoto 193130803Smarcel#define yysindex f_yysindex 194130803Smarcel#define yyrindex f_yyrindex 195130803Smarcel#define yygindex f_yygindex 196130803Smarcel#define yytable f_yytable 197130803Smarcel#define yycheck f_yycheck 198130803Smarcel 199130803Smarcel#ifndef YYDEBUG 200130803Smarcel#define YYDEBUG 1 /* Default to yydebug support */ 201130803Smarcel#endif 202130803Smarcel 203130803Smarcel#define YYFPRINTF parser_fprintf 204130803Smarcel 205130803Smarcelint yyparse (void); 206130803Smarcel 207130803Smarcelstatic int yylex (void); 208130803Smarcel 209130803Smarcelvoid yyerror (char *); 210130803Smarcel 211130803Smarcelstatic void growbuf_by_size (int); 212130803Smarcel 213130803Smarcelstatic int match_string_literal (void); 214130803Smarcel 215130803Smarcel 216130803Smarcel 217130803Smarcel/* Enabling traces. */ 218130803Smarcel#ifndef YYDEBUG 219130803Smarcel# define YYDEBUG 0 220130803Smarcel#endif 221130803Smarcel 222130803Smarcel/* Enabling verbose error messages. */ 223130803Smarcel#ifdef YYERROR_VERBOSE 224130803Smarcel# undef YYERROR_VERBOSE 225130803Smarcel# define YYERROR_VERBOSE 1 226130803Smarcel#else 227130803Smarcel# define YYERROR_VERBOSE 0 228130803Smarcel#endif 229130803Smarcel 230130803Smarcel#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) 231130803Smarcel#line 130 "f-exp.y" 232130803Smarceltypedef union YYSTYPE { 233130803Smarcel LONGEST lval; 234130803Smarcel struct { 235130803Smarcel LONGEST val; 236130803Smarcel struct type *type; 237130803Smarcel } typed_val; 238130803Smarcel DOUBLEST dval; 239130803Smarcel struct symbol *sym; 240130803Smarcel struct type *tval; 241130803Smarcel struct stoken sval; 242130803Smarcel struct ttype tsym; 243130803Smarcel struct symtoken ssym; 244130803Smarcel int voidval; 245130803Smarcel struct block *bval; 246130803Smarcel enum exp_opcode opcode; 247130803Smarcel struct internalvar *ivar; 248130803Smarcel 249130803Smarcel struct type **tvec; 250130803Smarcel int *ivec; 251130803Smarcel } YYSTYPE; 252130803Smarcel/* Line 191 of yacc.c. */ 253130803Smarcel# define yystype YYSTYPE /* obsolescent; will be withdrawn */ 254130803Smarcel# define YYSTYPE_IS_DECLARED 1 255130803Smarcel# define YYSTYPE_IS_TRIVIAL 1 256130803Smarcel#endif 257130803Smarcel 258130803Smarcel 259130803Smarcel 260130803Smarcel/* Copy the second part of user declarations. */ 261130803Smarcel#line 151 "f-exp.y" 262130803Smarcel 263130803Smarcel/* YYSTYPE gets defined by %union */ 264130803Smarcelstatic int parse_number (char *, int, int, YYSTYPE *); 265130803Smarcel 266130803Smarcel 267130803Smarcel/* Line 214 of yacc.c. */ 268130803Smarcel 269130803Smarcel#if ! defined (yyoverflow) || YYERROR_VERBOSE 270130803Smarcel 271130803Smarcel/* The parser invokes alloca or xmalloc; define the necessary symbols. */ 272130803Smarcel 273130803Smarcel# if YYSTACK_USE_ALLOCA 274130803Smarcel# define YYSTACK_ALLOC alloca 275130803Smarcel# else 276130803Smarcel# ifndef YYSTACK_USE_ALLOCA 277130803Smarcel# if defined (alloca) || defined (_ALLOCA_H) 278130803Smarcel# define YYSTACK_ALLOC alloca 279130803Smarcel# else 280130803Smarcel# ifdef __GNUC__ 281130803Smarcel# define YYSTACK_ALLOC __builtin_alloca 282130803Smarcel# endif 283130803Smarcel# endif 284130803Smarcel# endif 285130803Smarcel# endif 286130803Smarcel 287130803Smarcel# ifdef YYSTACK_ALLOC 288130803Smarcel /* Pacify GCC's `empty if-body' warning. */ 289130803Smarcel# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) 290130803Smarcel# else 291130803Smarcel# if defined (__STDC__) || defined (__cplusplus) 292130803Smarcel# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 293130803Smarcel# define YYSIZE_T size_t 294130803Smarcel# endif 295130803Smarcel# define YYSTACK_ALLOC xmalloc 296130803Smarcel# define YYSTACK_FREE free 297130803Smarcel# endif 298130803Smarcel#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ 299130803Smarcel 300130803Smarcel 301130803Smarcel#if (! defined (yyoverflow) \ 302130803Smarcel && (! defined (__cplusplus) \ 303130803Smarcel || (YYSTYPE_IS_TRIVIAL))) 304130803Smarcel 305130803Smarcel/* A type that is properly aligned for any stack member. */ 306130803Smarcelunion yyalloc 307130803Smarcel{ 308130803Smarcel short yyss; 309130803Smarcel YYSTYPE yyvs; 310130803Smarcel }; 311130803Smarcel 312130803Smarcel/* The size of the maximum gap between one aligned stack and the next. */ 313130803Smarcel# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) 314130803Smarcel 315130803Smarcel/* The size of an array large to enough to hold all stacks, each with 316130803Smarcel N elements. */ 317130803Smarcel# define YYSTACK_BYTES(N) \ 318130803Smarcel ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ 319130803Smarcel + YYSTACK_GAP_MAXIMUM) 320130803Smarcel 321130803Smarcel/* Copy COUNT objects from FROM to TO. The source and destination do 322130803Smarcel not overlap. */ 323130803Smarcel# ifndef YYCOPY 324130803Smarcel# if 1 < __GNUC__ 325130803Smarcel# define YYCOPY(To, From, Count) \ 326130803Smarcel __builtin_memcpy (To, From, (Count) * sizeof (*(From))) 327130803Smarcel# else 328130803Smarcel# define YYCOPY(To, From, Count) \ 329130803Smarcel do \ 330130803Smarcel { \ 331130803Smarcel register YYSIZE_T yyi; \ 332130803Smarcel for (yyi = 0; yyi < (Count); yyi++) \ 333130803Smarcel (To)[yyi] = (From)[yyi]; \ 334130803Smarcel } \ 335130803Smarcel while (0) 336130803Smarcel# endif 337130803Smarcel# endif 338130803Smarcel 339130803Smarcel/* Relocate STACK from its old location to the new one. The 340130803Smarcel local variables YYSIZE and YYSTACKSIZE give the old and new number of 341130803Smarcel elements in the stack, and YYPTR gives the new location of the 342130803Smarcel stack. Advance YYPTR to a properly aligned location for the next 343130803Smarcel stack. */ 344130803Smarcel# define YYSTACK_RELOCATE(Stack) \ 345130803Smarcel do \ 346130803Smarcel { \ 347130803Smarcel YYSIZE_T yynewbytes; \ 348130803Smarcel YYCOPY (&yyptr->Stack, Stack, yysize); \ 349130803Smarcel Stack = &yyptr->Stack; \ 350130803Smarcel yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ 351130803Smarcel yyptr += yynewbytes / sizeof (*yyptr); \ 352130803Smarcel } \ 353130803Smarcel while (0) 354130803Smarcel 355130803Smarcel#endif 356130803Smarcel 357130803Smarcel#if defined (__STDC__) || defined (__cplusplus) 358130803Smarcel typedef signed char yysigned_char; 359130803Smarcel#else 360130803Smarcel typedef short yysigned_char; 361130803Smarcel#endif 362130803Smarcel 363130803Smarcel/* YYFINAL -- State number of the termination state. */ 364130803Smarcel#define YYFINAL 46 365130803Smarcel/* YYLAST -- Last index in YYTABLE. */ 366130803Smarcel#define YYLAST 460 367130803Smarcel 368130803Smarcel/* YYNTOKENS -- Number of terminals. */ 369130803Smarcel#define YYNTOKENS 55 370130803Smarcel/* YYNNTS -- Number of nonterminals. */ 371130803Smarcel#define YYNNTS 17 372130803Smarcel/* YYNRULES -- Number of rules. */ 373130803Smarcel#define YYNRULES 80 374130803Smarcel/* YYNRULES -- Number of states. */ 375130803Smarcel#define YYNSTATES 125 376130803Smarcel 377130803Smarcel/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ 378130803Smarcel#define YYUNDEFTOK 2 379130803Smarcel#define YYMAXUTOK 293 380130803Smarcel 381130803Smarcel#define YYTRANSLATE(YYX) \ 382130803Smarcel ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) 383130803Smarcel 384130803Smarcel/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ 385130803Smarcelstatic const unsigned char yytranslate[] = 386130803Smarcel{ 387130803Smarcel 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 388130803Smarcel 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 389130803Smarcel 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 390130803Smarcel 2, 2, 2, 2, 2, 2, 2, 49, 35, 2, 391130803Smarcel 51, 52, 47, 45, 29, 46, 2, 48, 2, 2, 392130803Smarcel 2, 2, 2, 2, 2, 2, 2, 2, 54, 2, 393130803Smarcel 2, 31, 2, 32, 44, 2, 2, 2, 2, 2, 394130803Smarcel 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 395130803Smarcel 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 396130803Smarcel 2, 2, 2, 2, 34, 2, 2, 2, 2, 2, 397130803Smarcel 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 398130803Smarcel 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 399130803Smarcel 2, 2, 2, 2, 33, 2, 53, 2, 2, 2, 400130803Smarcel 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 401130803Smarcel 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 402130803Smarcel 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 403130803Smarcel 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 404130803Smarcel 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 405130803Smarcel 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 406130803Smarcel 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 407130803Smarcel 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 408130803Smarcel 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 409130803Smarcel 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 410130803Smarcel 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 411130803Smarcel 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 412130803Smarcel 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 413130803Smarcel 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 414130803Smarcel 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 415130803Smarcel 25, 26, 27, 28, 30, 36, 37, 38, 39, 40, 416130803Smarcel 41, 42, 43, 50 417130803Smarcel}; 418130803Smarcel 419130803Smarcel#if YYDEBUG 420130803Smarcel/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in 421130803Smarcel YYRHS. */ 422130803Smarcelstatic const unsigned char yyprhs[] = 423130803Smarcel{ 424130803Smarcel 0, 0, 3, 5, 7, 9, 13, 16, 19, 22, 425130803Smarcel 25, 28, 31, 32, 38, 39, 41, 43, 47, 51, 426130803Smarcel 55, 59, 64, 68, 72, 76, 80, 84, 88, 92, 427130803Smarcel 96, 100, 104, 108, 112, 116, 120, 124, 128, 132, 428130803Smarcel 136, 140, 144, 148, 150, 152, 154, 156, 158, 163, 429130803Smarcel 165, 167, 169, 171, 173, 176, 178, 181, 183, 186, 430130803Smarcel 188, 192, 195, 197, 200, 204, 206, 208, 210, 212, 431130803Smarcel 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 432130803Smarcel 236 433130803Smarcel}; 434130803Smarcel 435130803Smarcel/* YYRHS -- A `-1'-separated list of the rules' RHS. */ 436130803Smarcelstatic const yysigned_char yyrhs[] = 437130803Smarcel{ 438130803Smarcel 56, 0, -1, 58, -1, 57, -1, 64, -1, 51, 439130803Smarcel 58, 52, -1, 47, 58, -1, 35, 58, -1, 46, 440130803Smarcel 58, -1, 25, 58, -1, 53, 58, -1, 10, 58, 441130803Smarcel -1, -1, 58, 51, 59, 60, 52, -1, -1, 58, 442130803Smarcel -1, 61, -1, 60, 29, 58, -1, 58, 54, 58, 443130803Smarcel -1, 58, 29, 58, -1, 51, 62, 52, -1, 51, 444130803Smarcel 64, 52, 58, -1, 58, 44, 58, -1, 58, 47, 445130803Smarcel 58, -1, 58, 48, 58, -1, 58, 49, 58, -1, 446130803Smarcel 58, 45, 58, -1, 58, 46, 58, -1, 58, 43, 447130803Smarcel 58, -1, 58, 42, 58, -1, 58, 37, 58, -1, 448130803Smarcel 58, 36, 58, -1, 58, 39, 58, -1, 58, 38, 449130803Smarcel 58, -1, 58, 41, 58, -1, 58, 40, 58, -1, 450130803Smarcel 58, 35, 58, -1, 58, 34, 58, -1, 58, 33, 451130803Smarcel 58, -1, 58, 23, 58, -1, 58, 24, 58, -1, 452130803Smarcel 58, 31, 58, -1, 58, 28, 58, -1, 3, -1, 453130803Smarcel 9, -1, 4, -1, 63, -1, 27, -1, 10, 51, 454130803Smarcel 64, 52, -1, 6, -1, 5, -1, 71, -1, 65, 455130803Smarcel -1, 69, -1, 69, 66, -1, 47, -1, 47, 66, 456130803Smarcel -1, 35, -1, 35, 66, -1, 67, -1, 51, 66, 457130803Smarcel 52, -1, 67, 68, -1, 68, -1, 51, 52, -1, 458130803Smarcel 51, 70, 52, -1, 8, -1, 12, -1, 13, -1, 459130803Smarcel 26, -1, 16, -1, 15, -1, 14, -1, 17, -1, 460130803Smarcel 18, -1, 19, -1, 20, -1, 21, -1, 22, -1, 461130803Smarcel 64, -1, 70, 29, 64, -1, 7, -1 462130803Smarcel}; 463130803Smarcel 464130803Smarcel/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 465130803Smarcelstatic const unsigned short yyrline[] = 466130803Smarcel{ 467130803Smarcel 0, 228, 228, 229, 232, 238, 243, 247, 251, 255, 468130803Smarcel 259, 263, 273, 272, 280, 283, 287, 291, 295, 300, 469130803Smarcel 304, 308, 316, 320, 324, 328, 332, 336, 340, 344, 470130803Smarcel 348, 352, 356, 360, 364, 368, 372, 376, 380, 384, 471130803Smarcel 389, 393, 397, 403, 410, 419, 426, 429, 432, 440, 472130803Smarcel 447, 455, 499, 502, 503, 546, 548, 550, 552, 554, 473130803Smarcel 557, 559, 561, 565, 567, 572, 574, 576, 578, 580, 474130803Smarcel 582, 584, 586, 588, 590, 592, 594, 596, 604, 609, 475130803Smarcel 624 476130803Smarcel}; 477130803Smarcel#endif 478130803Smarcel 479130803Smarcel#if YYDEBUG || YYERROR_VERBOSE 480130803Smarcel/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. 481130803Smarcel First, the terminals, then, starting at YYNTOKENS, nonterminals. */ 482130803Smarcelstatic const char *const yytname[] = 483130803Smarcel{ 484130803Smarcel "$end", "error", "$undefined", "INT", "FLOAT", "STRING_LITERAL", 485130803Smarcel "BOOLEAN_LITERAL", "NAME", "TYPENAME", "NAME_OR_INT", "SIZEOF", "ERROR", 486130803Smarcel "INT_KEYWORD", "INT_S2_KEYWORD", "LOGICAL_S1_KEYWORD", 487130803Smarcel "LOGICAL_S2_KEYWORD", "LOGICAL_KEYWORD", "REAL_KEYWORD", 488130803Smarcel "REAL_S8_KEYWORD", "REAL_S16_KEYWORD", "COMPLEX_S8_KEYWORD", 489130803Smarcel "COMPLEX_S16_KEYWORD", "COMPLEX_S32_KEYWORD", "BOOL_AND", "BOOL_OR", 490130803Smarcel "BOOL_NOT", "CHARACTER", "VARIABLE", "ASSIGN_MODIFY", "','", 491130803Smarcel "ABOVE_COMMA", "'='", "'?'", "'|'", "'^'", "'&'", "NOTEQUAL", "EQUAL", 492130803Smarcel "GEQ", "LEQ", "GREATERTHAN", "LESSTHAN", "RSH", "LSH", "'@'", "'+'", 493130803Smarcel "'-'", "'*'", "'/'", "'%'", "UNARY", "'('", "')'", "'~'", "':'", 494130803Smarcel "$accept", "start", "type_exp", "exp", "@1", "arglist", "substring", 495130803Smarcel "complexnum", "variable", "type", "ptype", "abs_decl", 496130803Smarcel "direct_abs_decl", "func_mod", "typebase", "nonempty_typelist", 497130803Smarcel "name_not_typename", 0 498130803Smarcel}; 499130803Smarcel#endif 500130803Smarcel 501130803Smarcel# ifdef YYPRINT 502130803Smarcel/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to 503130803Smarcel token YYLEX-NUM. */ 504130803Smarcelstatic const unsigned short yytoknum[] = 505130803Smarcel{ 506130803Smarcel 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 507130803Smarcel 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 508130803Smarcel 275, 276, 277, 278, 279, 280, 281, 282, 283, 44, 509130803Smarcel 284, 61, 63, 124, 94, 38, 285, 286, 287, 288, 510130803Smarcel 289, 290, 291, 292, 64, 43, 45, 42, 47, 37, 511130803Smarcel 293, 40, 41, 126, 58 512130803Smarcel}; 513130803Smarcel# endif 514130803Smarcel 515130803Smarcel/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ 516130803Smarcelstatic const unsigned char yyr1[] = 517130803Smarcel{ 518130803Smarcel 0, 55, 56, 56, 57, 58, 58, 58, 58, 58, 519130803Smarcel 58, 58, 59, 58, 60, 60, 60, 60, 61, 62, 520130803Smarcel 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 521130803Smarcel 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 522130803Smarcel 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 523130803Smarcel 58, 63, 64, 65, 65, 66, 66, 66, 66, 66, 524130803Smarcel 67, 67, 67, 68, 68, 69, 69, 69, 69, 69, 525130803Smarcel 69, 69, 69, 69, 69, 69, 69, 69, 70, 70, 526130803Smarcel 71 527130803Smarcel}; 528130803Smarcel 529130803Smarcel/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 530130803Smarcelstatic const unsigned char yyr2[] = 531130803Smarcel{ 532130803Smarcel 0, 2, 1, 1, 1, 3, 2, 2, 2, 2, 533130803Smarcel 2, 2, 0, 5, 0, 1, 1, 3, 3, 3, 534130803Smarcel 3, 4, 3, 3, 3, 3, 3, 3, 3, 3, 535130803Smarcel 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 536130803Smarcel 3, 3, 3, 1, 1, 1, 1, 1, 4, 1, 537130803Smarcel 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 538130803Smarcel 3, 2, 1, 2, 3, 1, 1, 1, 1, 1, 539130803Smarcel 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 540130803Smarcel 1 541130803Smarcel}; 542130803Smarcel 543130803Smarcel/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state 544130803Smarcel STATE-NUM when YYTABLE doesn't specify something else to do. Zero 545130803Smarcel means the default is an error. */ 546130803Smarcelstatic const unsigned char yydefact[] = 547130803Smarcel{ 548130803Smarcel 0, 43, 45, 50, 49, 80, 65, 44, 0, 66, 549130803Smarcel 67, 71, 70, 69, 72, 73, 74, 75, 76, 77, 550130803Smarcel 0, 68, 47, 0, 0, 0, 0, 0, 0, 3, 551130803Smarcel 2, 46, 4, 52, 53, 51, 0, 11, 9, 7, 552130803Smarcel 8, 6, 0, 0, 0, 10, 1, 0, 0, 0, 553130803Smarcel 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 554130803Smarcel 0, 0, 0, 0, 0, 0, 0, 0, 12, 57, 555130803Smarcel 55, 0, 54, 59, 62, 0, 0, 5, 20, 0, 556130803Smarcel 39, 40, 42, 41, 38, 37, 36, 31, 30, 33, 557130803Smarcel 32, 35, 34, 29, 28, 22, 26, 27, 23, 24, 558130803Smarcel 25, 14, 58, 56, 63, 78, 0, 0, 0, 61, 559130803Smarcel 48, 19, 21, 15, 0, 16, 60, 0, 64, 0, 560130803Smarcel 0, 13, 79, 18, 17 561130803Smarcel}; 562130803Smarcel 563130803Smarcel/* YYDEFGOTO[NTERM-NUM]. */ 564130803Smarcelstatic const yysigned_char yydefgoto[] = 565130803Smarcel{ 566130803Smarcel -1, 28, 29, 42, 101, 114, 115, 43, 31, 105, 567130803Smarcel 33, 72, 73, 74, 34, 107, 35 568130803Smarcel}; 569130803Smarcel 570130803Smarcel/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 571130803Smarcel STATE-NUM. */ 572130803Smarcel#define YYPACT_NINF -59 573130803Smarcelstatic const short yypact[] = 574130803Smarcel{ 575130803Smarcel 77, -59, -59, -59, -59, -59, -59, -59, 128, -59, 576130803Smarcel -59, -59, -59, -59, -59, -59, -59, -59, -59, -59, 577130803Smarcel 137, -59, -59, 137, 137, 137, 77, 137, 2, -59, 578130803Smarcel 311, -59, -59, -59, -34, -59, 77, -45, -45, -45, 579130803Smarcel -45, -45, 281, -43, -36, -45, -59, 137, 137, 137, 580130803Smarcel 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 581130803Smarcel 137, 137, 137, 137, 137, 137, 137, 137, -59, -34, 582130803Smarcel -34, 208, -59, -44, -59, -33, 137, -59, -59, 137, 583130803Smarcel 357, 338, 311, 311, 392, 409, 163, 223, 223, -10, 584130803Smarcel -10, -10, -10, 24, 24, 60, -37, -37, -45, -45, 585130803Smarcel -45, 137, -59, -59, -59, -59, -31, -26, 232, -59, 586130803Smarcel 188, 311, -45, 252, -24, -59, -59, 399, -59, 137, 587130803Smarcel 137, -59, -59, 311, 311 588130803Smarcel}; 589130803Smarcel 590130803Smarcel/* YYPGOTO[NTERM-NUM]. */ 591130803Smarcelstatic const yysigned_char yypgoto[] = 592130803Smarcel{ 593130803Smarcel -59, -59, -59, 0, -59, -59, -59, -59, -59, 4, 594130803Smarcel -59, -27, -59, -58, -59, -59, -59 595130803Smarcel}; 596130803Smarcel 597130803Smarcel/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If 598130803Smarcel positive, shift that token. If negative, reduce the rule which 599130803Smarcel number is the opposite. If zero, do what YYDEFACT says. 600130803Smarcel If YYTABLE_NINF, syntax error. */ 601130803Smarcel#define YYTABLE_NINF -1 602130803Smarcelstatic const unsigned char yytable[] = 603130803Smarcel{ 604130803Smarcel 30, 69, 46, 117, 32, 120, 68, 108, 37, 78, 605130803Smarcel 65, 66, 67, 70, 68, 109, 79, 71, 0, 110, 606130803Smarcel 38, 116, 0, 39, 40, 41, 118, 45, 121, 0, 607130803Smarcel 44, 0, 60, 61, 62, 63, 64, 65, 66, 67, 608130803Smarcel 75, 68, 102, 103, 106, 0, 0, 80, 81, 82, 609130803Smarcel 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 610130803Smarcel 93, 94, 95, 96, 97, 98, 99, 100, 62, 63, 611130803Smarcel 64, 65, 66, 67, 0, 68, 111, 0, 0, 112, 612130803Smarcel 1, 2, 3, 4, 5, 6, 7, 8, 0, 9, 613130803Smarcel 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 614130803Smarcel 0, 113, 20, 21, 22, 63, 64, 65, 66, 67, 615130803Smarcel 112, 68, 23, 0, 0, 0, 0, 0, 0, 123, 616130803Smarcel 124, 122, 0, 24, 25, 0, 0, 0, 26, 0, 617130803Smarcel 27, 1, 2, 3, 4, 5, 0, 7, 8, 0, 618130803Smarcel 1, 2, 3, 4, 5, 0, 7, 8, 0, 0, 619130803Smarcel 0, 0, 0, 20, 0, 22, 0, 0, 0, 0, 620130803Smarcel 0, 0, 20, 23, 22, 0, 0, 0, 0, 0, 621130803Smarcel 0, 0, 23, 0, 24, 25, 0, 0, 0, 36, 622130803Smarcel 0, 27, 0, 24, 25, 0, 0, 0, 26, 0, 623130803Smarcel 27, 1, 2, 3, 4, 5, 0, 7, 8, 54, 624130803Smarcel 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 625130803Smarcel 65, 66, 67, 20, 68, 22, 6, 0, 0, 0, 626130803Smarcel 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 627130803Smarcel 19, 0, 0, 0, 21, 0, 0, 0, 0, 26, 628130803Smarcel 6, 27, 0, 69, 9, 10, 11, 12, 13, 14, 629130803Smarcel 15, 16, 17, 18, 19, 70, 0, 0, 21, 71, 630130803Smarcel 104, 56, 57, 58, 59, 60, 61, 62, 63, 64, 631130803Smarcel 65, 66, 67, 0, 68, 47, 48, 0, 0, 0, 632130803Smarcel 49, 0, 0, 50, 104, 51, 52, 53, 54, 55, 633130803Smarcel 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 634130803Smarcel 66, 67, 0, 68, 47, 48, 119, 0, 0, 49, 635130803Smarcel 76, 0, 50, 0, 51, 52, 53, 54, 55, 56, 636130803Smarcel 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 637130803Smarcel 67, 0, 68, 77, 47, 48, 0, 0, 0, 49, 638130803Smarcel 0, 0, 50, 0, 51, 52, 53, 54, 55, 56, 639130803Smarcel 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 640130803Smarcel 67, 47, 68, 0, 0, 0, 0, 0, 0, 0, 641130803Smarcel 0, 51, 52, 53, 54, 55, 56, 57, 58, 59, 642130803Smarcel 60, 61, 62, 63, 64, 65, 66, 67, 0, 68, 643130803Smarcel 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 644130803Smarcel 61, 62, 63, 64, 65, 66, 67, 6, 68, 0, 645130803Smarcel 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 646130803Smarcel 18, 19, 0, 0, 0, 21, 52, 53, 54, 55, 647130803Smarcel 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 648130803Smarcel 66, 67, 0, 68, 53, 54, 55, 56, 57, 58, 649130803Smarcel 59, 60, 61, 62, 63, 64, 65, 66, 67, 0, 650130803Smarcel 68 651130803Smarcel}; 652130803Smarcel 653130803Smarcelstatic const yysigned_char yycheck[] = 654130803Smarcel{ 655130803Smarcel 0, 35, 0, 29, 0, 29, 51, 51, 8, 52, 656130803Smarcel 47, 48, 49, 47, 51, 73, 52, 51, -1, 52, 657130803Smarcel 20, 52, -1, 23, 24, 25, 52, 27, 52, -1, 658130803Smarcel 26, -1, 42, 43, 44, 45, 46, 47, 48, 49, 659130803Smarcel 36, 51, 69, 70, 71, -1, -1, 47, 48, 49, 660130803Smarcel 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 661130803Smarcel 60, 61, 62, 63, 64, 65, 66, 67, 44, 45, 662130803Smarcel 46, 47, 48, 49, -1, 51, 76, -1, -1, 79, 663130803Smarcel 3, 4, 5, 6, 7, 8, 9, 10, -1, 12, 664130803Smarcel 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 665130803Smarcel -1, 101, 25, 26, 27, 45, 46, 47, 48, 49, 666130803Smarcel 110, 51, 35, -1, -1, -1, -1, -1, -1, 119, 667130803Smarcel 120, 117, -1, 46, 47, -1, -1, -1, 51, -1, 668130803Smarcel 53, 3, 4, 5, 6, 7, -1, 9, 10, -1, 669130803Smarcel 3, 4, 5, 6, 7, -1, 9, 10, -1, -1, 670130803Smarcel -1, -1, -1, 25, -1, 27, -1, -1, -1, -1, 671130803Smarcel -1, -1, 25, 35, 27, -1, -1, -1, -1, -1, 672130803Smarcel -1, -1, 35, -1, 46, 47, -1, -1, -1, 51, 673130803Smarcel -1, 53, -1, 46, 47, -1, -1, -1, 51, -1, 674130803Smarcel 53, 3, 4, 5, 6, 7, -1, 9, 10, 36, 675130803Smarcel 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 676130803Smarcel 47, 48, 49, 25, 51, 27, 8, -1, -1, -1, 677130803Smarcel 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 678130803Smarcel 22, -1, -1, -1, 26, -1, -1, -1, -1, 51, 679130803Smarcel 8, 53, -1, 35, 12, 13, 14, 15, 16, 17, 680130803Smarcel 18, 19, 20, 21, 22, 47, -1, -1, 26, 51, 681130803Smarcel 52, 38, 39, 40, 41, 42, 43, 44, 45, 46, 682130803Smarcel 47, 48, 49, -1, 51, 23, 24, -1, -1, -1, 683130803Smarcel 28, -1, -1, 31, 52, 33, 34, 35, 36, 37, 684130803Smarcel 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 685130803Smarcel 48, 49, -1, 51, 23, 24, 54, -1, -1, 28, 686130803Smarcel 29, -1, 31, -1, 33, 34, 35, 36, 37, 38, 687130803Smarcel 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 688130803Smarcel 49, -1, 51, 52, 23, 24, -1, -1, -1, 28, 689130803Smarcel -1, -1, 31, -1, 33, 34, 35, 36, 37, 38, 690130803Smarcel 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 691130803Smarcel 49, 23, 51, -1, -1, -1, -1, -1, -1, -1, 692130803Smarcel -1, 33, 34, 35, 36, 37, 38, 39, 40, 41, 693130803Smarcel 42, 43, 44, 45, 46, 47, 48, 49, -1, 51, 694130803Smarcel 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 695130803Smarcel 43, 44, 45, 46, 47, 48, 49, 8, 51, -1, 696130803Smarcel -1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 697130803Smarcel 21, 22, -1, -1, -1, 26, 34, 35, 36, 37, 698130803Smarcel 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 699130803Smarcel 48, 49, -1, 51, 35, 36, 37, 38, 39, 40, 700130803Smarcel 41, 42, 43, 44, 45, 46, 47, 48, 49, -1, 701130803Smarcel 51 702130803Smarcel}; 703130803Smarcel 704130803Smarcel/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing 705130803Smarcel symbol of state STATE-NUM. */ 706130803Smarcelstatic const unsigned char yystos[] = 707130803Smarcel{ 708130803Smarcel 0, 3, 4, 5, 6, 7, 8, 9, 10, 12, 709130803Smarcel 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 710130803Smarcel 25, 26, 27, 35, 46, 47, 51, 53, 56, 57, 711130803Smarcel 58, 63, 64, 65, 69, 71, 51, 58, 58, 58, 712130803Smarcel 58, 58, 58, 62, 64, 58, 0, 23, 24, 28, 713130803Smarcel 31, 33, 34, 35, 36, 37, 38, 39, 40, 41, 714130803Smarcel 42, 43, 44, 45, 46, 47, 48, 49, 51, 35, 715130803Smarcel 47, 51, 66, 67, 68, 64, 29, 52, 52, 52, 716130803Smarcel 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 717130803Smarcel 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 718130803Smarcel 58, 59, 66, 66, 52, 64, 66, 70, 51, 68, 719130803Smarcel 52, 58, 58, 58, 60, 61, 52, 29, 52, 54, 720130803Smarcel 29, 52, 64, 58, 58 721130803Smarcel}; 722130803Smarcel 723130803Smarcel#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) 724130803Smarcel# define YYSIZE_T __SIZE_TYPE__ 725130803Smarcel#endif 726130803Smarcel#if ! defined (YYSIZE_T) && defined (size_t) 727130803Smarcel# define YYSIZE_T size_t 728130803Smarcel#endif 729130803Smarcel#if ! defined (YYSIZE_T) 730130803Smarcel# if defined (__STDC__) || defined (__cplusplus) 731130803Smarcel# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ 732130803Smarcel# define YYSIZE_T size_t 733130803Smarcel# endif 734130803Smarcel#endif 735130803Smarcel#if ! defined (YYSIZE_T) 736130803Smarcel# define YYSIZE_T unsigned int 737130803Smarcel#endif 738130803Smarcel 739130803Smarcel#define yyerrok (yyerrstatus = 0) 740130803Smarcel#define yyclearin (yychar = YYEMPTY) 741130803Smarcel#define YYEMPTY (-2) 742130803Smarcel#define YYEOF 0 743130803Smarcel 744130803Smarcel#define YYACCEPT goto yyacceptlab 745130803Smarcel#define YYABORT goto yyabortlab 746130803Smarcel#define YYERROR goto yyerrlab1 747130803Smarcel 748130803Smarcel/* Like YYERROR except do call yyerror. This remains here temporarily 749130803Smarcel to ease the transition to the new meaning of YYERROR, for GCC. 750130803Smarcel Once GCC version 2 has supplanted version 1, this can go. */ 751130803Smarcel 752130803Smarcel#define YYFAIL goto yyerrlab 753130803Smarcel 754130803Smarcel#define YYRECOVERING() (!!yyerrstatus) 755130803Smarcel 756130803Smarcel#define YYBACKUP(Token, Value) \ 757130803Smarceldo \ 758130803Smarcel if (yychar == YYEMPTY && yylen == 1) \ 759130803Smarcel { \ 760130803Smarcel yychar = (Token); \ 761130803Smarcel yylval = (Value); \ 762130803Smarcel yytoken = YYTRANSLATE (yychar); \ 763130803Smarcel YYPOPSTACK; \ 764130803Smarcel goto yybackup; \ 765130803Smarcel } \ 766130803Smarcel else \ 767130803Smarcel { \ 768130803Smarcel yyerror ("syntax error: cannot back up");\ 769130803Smarcel YYERROR; \ 770130803Smarcel } \ 771130803Smarcelwhile (0) 772130803Smarcel 773130803Smarcel#define YYTERROR 1 774130803Smarcel#define YYERRCODE 256 775130803Smarcel 776130803Smarcel/* YYLLOC_DEFAULT -- Compute the default location (before the actions 777130803Smarcel are run). */ 778130803Smarcel 779130803Smarcel#ifndef YYLLOC_DEFAULT 780130803Smarcel# define YYLLOC_DEFAULT(Current, Rhs, N) \ 781130803Smarcel Current.first_line = Rhs[1].first_line; \ 782130803Smarcel Current.first_column = Rhs[1].first_column; \ 783130803Smarcel Current.last_line = Rhs[N].last_line; \ 784130803Smarcel Current.last_column = Rhs[N].last_column; 785130803Smarcel#endif 786130803Smarcel 787130803Smarcel/* YYLEX -- calling `yylex' with the right arguments. */ 788130803Smarcel 789130803Smarcel#ifdef YYLEX_PARAM 790130803Smarcel# define YYLEX yylex (YYLEX_PARAM) 791130803Smarcel#else 792130803Smarcel# define YYLEX yylex () 793130803Smarcel#endif 794130803Smarcel 795130803Smarcel/* Enable debugging if requested. */ 796130803Smarcel#if YYDEBUG 797130803Smarcel 798130803Smarcel# ifndef YYFPRINTF 799130803Smarcel# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ 800130803Smarcel# define YYFPRINTF fprintf 801130803Smarcel# endif 802130803Smarcel 803130803Smarcel# define YYDPRINTF(Args) \ 804130803Smarceldo { \ 805130803Smarcel if (yydebug) \ 806130803Smarcel YYFPRINTF Args; \ 807130803Smarcel} while (0) 808130803Smarcel 809130803Smarcel# define YYDSYMPRINT(Args) \ 810130803Smarceldo { \ 811130803Smarcel if (yydebug) \ 812130803Smarcel yysymprint Args; \ 813130803Smarcel} while (0) 814130803Smarcel 815130803Smarcel# define YYDSYMPRINTF(Title, Token, Value, Location) \ 816130803Smarceldo { \ 817130803Smarcel if (yydebug) \ 818130803Smarcel { \ 819130803Smarcel YYFPRINTF (stderr, "%s ", Title); \ 820130803Smarcel yysymprint (stderr, \ 821130803Smarcel Token, Value); \ 822130803Smarcel YYFPRINTF (stderr, "\n"); \ 823130803Smarcel } \ 824130803Smarcel} while (0) 825130803Smarcel 826130803Smarcel/*------------------------------------------------------------------. 827130803Smarcel| yy_stack_print -- Print the state stack from its BOTTOM up to its | 828130803Smarcel| TOP (cinluded). | 829130803Smarcel`------------------------------------------------------------------*/ 830130803Smarcel 831130803Smarcel#if defined (__STDC__) || defined (__cplusplus) 832130803Smarcelstatic void 833130803Smarcelyy_stack_print (short *bottom, short *top) 834130803Smarcel#else 835130803Smarcelstatic void 836130803Smarcelyy_stack_print (bottom, top) 837130803Smarcel short *bottom; 838130803Smarcel short *top; 839130803Smarcel#endif 840130803Smarcel{ 841130803Smarcel YYFPRINTF (stderr, "Stack now"); 842130803Smarcel for (/* Nothing. */; bottom <= top; ++bottom) 843130803Smarcel YYFPRINTF (stderr, " %d", *bottom); 844130803Smarcel YYFPRINTF (stderr, "\n"); 845130803Smarcel} 846130803Smarcel 847130803Smarcel# define YY_STACK_PRINT(Bottom, Top) \ 848130803Smarceldo { \ 849130803Smarcel if (yydebug) \ 850130803Smarcel yy_stack_print ((Bottom), (Top)); \ 851130803Smarcel} while (0) 852130803Smarcel 853130803Smarcel 854130803Smarcel/*------------------------------------------------. 855130803Smarcel| Report that the YYRULE is going to be reduced. | 856130803Smarcel`------------------------------------------------*/ 857130803Smarcel 858130803Smarcel#if defined (__STDC__) || defined (__cplusplus) 859130803Smarcelstatic void 860130803Smarcelyy_reduce_print (int yyrule) 861130803Smarcel#else 862130803Smarcelstatic void 863130803Smarcelyy_reduce_print (yyrule) 864130803Smarcel int yyrule; 865130803Smarcel#endif 866130803Smarcel{ 867130803Smarcel int yyi; 868130803Smarcel unsigned int yylineno = yyrline[yyrule]; 869130803Smarcel YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", 870130803Smarcel yyrule - 1, yylineno); 871130803Smarcel /* Print the symbols being reduced, and their result. */ 872130803Smarcel for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) 873130803Smarcel YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); 874130803Smarcel YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); 875130803Smarcel} 876130803Smarcel 877130803Smarcel# define YY_REDUCE_PRINT(Rule) \ 878130803Smarceldo { \ 879130803Smarcel if (yydebug) \ 880130803Smarcel yy_reduce_print (Rule); \ 881130803Smarcel} while (0) 882130803Smarcel 883130803Smarcel/* Nonzero means print parse trace. It is left uninitialized so that 884130803Smarcel multiple parsers can coexist. */ 885130803Smarcelint yydebug; 886130803Smarcel#else /* !YYDEBUG */ 887130803Smarcel# define YYDPRINTF(Args) 888130803Smarcel# define YYDSYMPRINT(Args) 889130803Smarcel# define YYDSYMPRINTF(Title, Token, Value, Location) 890130803Smarcel# define YY_STACK_PRINT(Bottom, Top) 891130803Smarcel# define YY_REDUCE_PRINT(Rule) 892130803Smarcel#endif /* !YYDEBUG */ 893130803Smarcel 894130803Smarcel 895130803Smarcel/* YYINITDEPTH -- initial size of the parser's stacks. */ 896130803Smarcel#ifndef YYINITDEPTH 897130803Smarcel# define YYINITDEPTH 200 898130803Smarcel#endif 899130803Smarcel 900130803Smarcel/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only 901130803Smarcel if the built-in stack extension method is used). 902130803Smarcel 903130803Smarcel Do not make this value too large; the results are undefined if 904130803Smarcel SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) 905130803Smarcel evaluated with infinite-precision integer arithmetic. */ 906130803Smarcel 907130803Smarcel#if YYMAXDEPTH == 0 908130803Smarcel# undef YYMAXDEPTH 909130803Smarcel#endif 910130803Smarcel 911130803Smarcel#ifndef YYMAXDEPTH 912130803Smarcel# define YYMAXDEPTH 10000 913130803Smarcel#endif 914130803Smarcel 915130803Smarcel 916130803Smarcel 917130803Smarcel#if YYERROR_VERBOSE 918130803Smarcel 919130803Smarcel# ifndef yystrlen 920130803Smarcel# if defined (__GLIBC__) && defined (_STRING_H) 921130803Smarcel# define yystrlen strlen 922130803Smarcel# else 923130803Smarcel/* Return the length of YYSTR. */ 924130803Smarcelstatic YYSIZE_T 925130803Smarcel# if defined (__STDC__) || defined (__cplusplus) 926130803Smarcelyystrlen (const char *yystr) 927130803Smarcel# else 928130803Smarcelyystrlen (yystr) 929130803Smarcel const char *yystr; 930130803Smarcel# endif 931130803Smarcel{ 932130803Smarcel register const char *yys = yystr; 933130803Smarcel 934130803Smarcel while (*yys++ != '\0') 935130803Smarcel continue; 936130803Smarcel 937130803Smarcel return yys - yystr - 1; 938130803Smarcel} 939130803Smarcel# endif 940130803Smarcel# endif 941130803Smarcel 942130803Smarcel# ifndef yystpcpy 943130803Smarcel# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) 944130803Smarcel# define yystpcpy stpcpy 945130803Smarcel# else 946130803Smarcel/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in 947130803Smarcel YYDEST. */ 948130803Smarcelstatic char * 949130803Smarcel# if defined (__STDC__) || defined (__cplusplus) 950130803Smarcelyystpcpy (char *yydest, const char *yysrc) 951130803Smarcel# else 952130803Smarcelyystpcpy (yydest, yysrc) 953130803Smarcel char *yydest; 954130803Smarcel const char *yysrc; 955130803Smarcel# endif 956130803Smarcel{ 957130803Smarcel register char *yyd = yydest; 958130803Smarcel register const char *yys = yysrc; 959130803Smarcel 960130803Smarcel while ((*yyd++ = *yys++) != '\0') 961130803Smarcel continue; 962130803Smarcel 963130803Smarcel return yyd - 1; 964130803Smarcel} 965130803Smarcel# endif 966130803Smarcel# endif 967130803Smarcel 968130803Smarcel#endif /* !YYERROR_VERBOSE */ 969130803Smarcel 970130803Smarcel 971130803Smarcel 972130803Smarcel#if YYDEBUG 973130803Smarcel/*--------------------------------. 974130803Smarcel| Print this symbol on YYOUTPUT. | 975130803Smarcel`--------------------------------*/ 976130803Smarcel 977130803Smarcel#if defined (__STDC__) || defined (__cplusplus) 978130803Smarcelstatic void 979130803Smarcelyysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) 980130803Smarcel#else 981130803Smarcelstatic void 982130803Smarcelyysymprint (yyoutput, yytype, yyvaluep) 983130803Smarcel FILE *yyoutput; 984130803Smarcel int yytype; 985130803Smarcel YYSTYPE *yyvaluep; 986130803Smarcel#endif 987130803Smarcel{ 988130803Smarcel /* Pacify ``unused variable'' warnings. */ 989130803Smarcel (void) yyvaluep; 990130803Smarcel 991130803Smarcel if (yytype < YYNTOKENS) 992130803Smarcel { 993130803Smarcel YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); 994130803Smarcel# ifdef YYPRINT 995130803Smarcel YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); 996130803Smarcel# endif 997130803Smarcel } 998130803Smarcel else 999130803Smarcel YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); 1000130803Smarcel 1001130803Smarcel switch (yytype) 1002130803Smarcel { 1003130803Smarcel default: 1004130803Smarcel break; 1005130803Smarcel } 1006130803Smarcel YYFPRINTF (yyoutput, ")"); 1007130803Smarcel} 1008130803Smarcel 1009130803Smarcel#endif /* ! YYDEBUG */ 1010130803Smarcel/*-----------------------------------------------. 1011130803Smarcel| Release the memory associated to this symbol. | 1012130803Smarcel`-----------------------------------------------*/ 1013130803Smarcel 1014130803Smarcel#if defined (__STDC__) || defined (__cplusplus) 1015130803Smarcelstatic void 1016130803Smarcelyydestruct (int yytype, YYSTYPE *yyvaluep) 1017130803Smarcel#else 1018130803Smarcelstatic void 1019130803Smarcelyydestruct (yytype, yyvaluep) 1020130803Smarcel int yytype; 1021130803Smarcel YYSTYPE *yyvaluep; 1022130803Smarcel#endif 1023130803Smarcel{ 1024130803Smarcel /* Pacify ``unused variable'' warnings. */ 1025130803Smarcel (void) yyvaluep; 1026130803Smarcel 1027130803Smarcel switch (yytype) 1028130803Smarcel { 1029130803Smarcel 1030130803Smarcel default: 1031130803Smarcel break; 1032130803Smarcel } 1033130803Smarcel} 1034130803Smarcel 1035130803Smarcel 1036130803Smarcel/* Prevent warnings from -Wmissing-prototypes. */ 1037130803Smarcel 1038130803Smarcel#ifdef YYPARSE_PARAM 1039130803Smarcel# if defined (__STDC__) || defined (__cplusplus) 1040130803Smarcelint yyparse (void *YYPARSE_PARAM); 1041130803Smarcel# else 1042130803Smarcelint yyparse (); 1043130803Smarcel# endif 1044130803Smarcel#else /* ! YYPARSE_PARAM */ 1045130803Smarcel#if defined (__STDC__) || defined (__cplusplus) 1046130803Smarcelint yyparse (void); 1047130803Smarcel#else 1048130803Smarcelint yyparse (); 1049130803Smarcel#endif 1050130803Smarcel#endif /* ! YYPARSE_PARAM */ 1051130803Smarcel 1052130803Smarcel 1053130803Smarcel 1054130803Smarcel/* The lookahead symbol. */ 1055130803Smarcelint yychar; 1056130803Smarcel 1057130803Smarcel/* The semantic value of the lookahead symbol. */ 1058130803SmarcelYYSTYPE yylval; 1059130803Smarcel 1060130803Smarcel/* Number of syntax errors so far. */ 1061130803Smarcelint yynerrs; 1062130803Smarcel 1063130803Smarcel 1064130803Smarcel 1065130803Smarcel/*----------. 1066130803Smarcel| yyparse. | 1067130803Smarcel`----------*/ 1068130803Smarcel 1069130803Smarcel#ifdef YYPARSE_PARAM 1070130803Smarcel# if defined (__STDC__) || defined (__cplusplus) 1071130803Smarcelint yyparse (void *YYPARSE_PARAM) 1072130803Smarcel# else 1073130803Smarcelint yyparse (YYPARSE_PARAM) 1074130803Smarcel void *YYPARSE_PARAM; 1075130803Smarcel# endif 1076130803Smarcel#else /* ! YYPARSE_PARAM */ 1077130803Smarcel#if defined (__STDC__) || defined (__cplusplus) 1078130803Smarcelint 1079130803Smarcelyyparse (void) 1080130803Smarcel#else 1081130803Smarcelint 1082130803Smarcelyyparse () 1083130803Smarcel 1084130803Smarcel#endif 1085130803Smarcel#endif 1086130803Smarcel{ 1087130803Smarcel 1088130803Smarcel register int yystate; 1089130803Smarcel register int yyn; 1090130803Smarcel int yyresult; 1091130803Smarcel /* Number of tokens to shift before error messages enabled. */ 1092130803Smarcel int yyerrstatus; 1093130803Smarcel /* Lookahead token as an internal (translated) token number. */ 1094130803Smarcel int yytoken = 0; 1095130803Smarcel 1096130803Smarcel /* Three stacks and their tools: 1097130803Smarcel `yyss': related to states, 1098130803Smarcel `yyvs': related to semantic values, 1099130803Smarcel `yyls': related to locations. 1100130803Smarcel 1101130803Smarcel Refer to the stacks thru separate pointers, to allow yyoverflow 1102130803Smarcel to xreallocate them elsewhere. */ 1103130803Smarcel 1104130803Smarcel /* The state stack. */ 1105130803Smarcel short yyssa[YYINITDEPTH]; 1106130803Smarcel short *yyss = yyssa; 1107130803Smarcel register short *yyssp; 1108130803Smarcel 1109130803Smarcel /* The semantic value stack. */ 1110130803Smarcel YYSTYPE yyvsa[YYINITDEPTH]; 1111130803Smarcel YYSTYPE *yyvs = yyvsa; 1112130803Smarcel register YYSTYPE *yyvsp; 1113130803Smarcel 1114130803Smarcel 1115130803Smarcel 1116130803Smarcel#define YYPOPSTACK (yyvsp--, yyssp--) 1117130803Smarcel 1118130803Smarcel YYSIZE_T yystacksize = YYINITDEPTH; 1119130803Smarcel 1120130803Smarcel /* The variables used to return semantic value and location from the 1121130803Smarcel action routines. */ 1122130803Smarcel YYSTYPE yyval; 1123130803Smarcel 1124130803Smarcel 1125130803Smarcel /* When reducing, the number of symbols on the RHS of the reduced 1126130803Smarcel rule. */ 1127130803Smarcel int yylen; 1128130803Smarcel 1129130803Smarcel YYDPRINTF ((stderr, "Starting parse\n")); 1130130803Smarcel 1131130803Smarcel yystate = 0; 1132130803Smarcel yyerrstatus = 0; 1133130803Smarcel yynerrs = 0; 1134130803Smarcel yychar = YYEMPTY; /* Cause a token to be read. */ 1135130803Smarcel 1136130803Smarcel /* Initialize stack pointers. 1137130803Smarcel Waste one element of value and location stack 1138130803Smarcel so that they stay on the same level as the state stack. 1139130803Smarcel The wasted elements are never initialized. */ 1140130803Smarcel 1141130803Smarcel yyssp = yyss; 1142130803Smarcel yyvsp = yyvs; 1143130803Smarcel 1144130803Smarcel goto yysetstate; 1145130803Smarcel 1146130803Smarcel/*------------------------------------------------------------. 1147130803Smarcel| yynewstate -- Push a new state, which is found in yystate. | 1148130803Smarcel`------------------------------------------------------------*/ 1149130803Smarcel yynewstate: 1150130803Smarcel /* In all cases, when you get here, the value and location stacks 1151130803Smarcel have just been pushed. so pushing a state here evens the stacks. 1152130803Smarcel */ 1153130803Smarcel yyssp++; 1154130803Smarcel 1155130803Smarcel yysetstate: 1156130803Smarcel *yyssp = yystate; 1157130803Smarcel 1158130803Smarcel if (yyss + yystacksize - 1 <= yyssp) 1159130803Smarcel { 1160130803Smarcel /* Get the current used size of the three stacks, in elements. */ 1161130803Smarcel YYSIZE_T yysize = yyssp - yyss + 1; 1162130803Smarcel 1163130803Smarcel#ifdef yyoverflow 1164130803Smarcel { 1165130803Smarcel /* Give user a chance to xreallocate the stack. Use copies of 1166130803Smarcel these so that the &'s don't force the real ones into 1167130803Smarcel memory. */ 1168130803Smarcel YYSTYPE *yyvs1 = yyvs; 1169130803Smarcel short *yyss1 = yyss; 1170130803Smarcel 1171130803Smarcel 1172130803Smarcel /* Each stack pointer address is followed by the size of the 1173130803Smarcel data in use in that stack, in bytes. This used to be a 1174130803Smarcel conditional around just the two extra args, but that might 1175130803Smarcel be undefined if yyoverflow is a macro. */ 1176130803Smarcel yyoverflow ("parser stack overflow", 1177130803Smarcel &yyss1, yysize * sizeof (*yyssp), 1178130803Smarcel &yyvs1, yysize * sizeof (*yyvsp), 1179130803Smarcel 1180130803Smarcel &yystacksize); 1181130803Smarcel 1182130803Smarcel yyss = yyss1; 1183130803Smarcel yyvs = yyvs1; 1184130803Smarcel } 1185130803Smarcel#else /* no yyoverflow */ 1186130803Smarcel# ifndef YYSTACK_RELOCATE 1187130803Smarcel goto yyoverflowlab; 1188130803Smarcel# else 1189130803Smarcel /* Extend the stack our own way. */ 1190130803Smarcel if (YYMAXDEPTH <= yystacksize) 1191130803Smarcel goto yyoverflowlab; 1192130803Smarcel yystacksize *= 2; 1193130803Smarcel if (YYMAXDEPTH < yystacksize) 1194130803Smarcel yystacksize = YYMAXDEPTH; 1195130803Smarcel 1196130803Smarcel { 1197130803Smarcel short *yyss1 = yyss; 1198130803Smarcel union yyalloc *yyptr = 1199130803Smarcel (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 1200130803Smarcel if (! yyptr) 1201130803Smarcel goto yyoverflowlab; 1202130803Smarcel YYSTACK_RELOCATE (yyss); 1203130803Smarcel YYSTACK_RELOCATE (yyvs); 1204130803Smarcel 1205130803Smarcel# undef YYSTACK_RELOCATE 1206130803Smarcel if (yyss1 != yyssa) 1207130803Smarcel YYSTACK_FREE (yyss1); 1208130803Smarcel } 1209130803Smarcel# endif 1210130803Smarcel#endif /* no yyoverflow */ 1211130803Smarcel 1212130803Smarcel yyssp = yyss + yysize - 1; 1213130803Smarcel yyvsp = yyvs + yysize - 1; 1214130803Smarcel 1215130803Smarcel 1216130803Smarcel YYDPRINTF ((stderr, "Stack size increased to %lu\n", 1217130803Smarcel (unsigned long int) yystacksize)); 1218130803Smarcel 1219130803Smarcel if (yyss + yystacksize - 1 <= yyssp) 1220130803Smarcel YYABORT; 1221130803Smarcel } 1222130803Smarcel 1223130803Smarcel YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 1224130803Smarcel 1225130803Smarcel goto yybackup; 1226130803Smarcel 1227130803Smarcel/*-----------. 1228130803Smarcel| yybackup. | 1229130803Smarcel`-----------*/ 1230130803Smarcelyybackup: 1231130803Smarcel 1232130803Smarcel/* Do appropriate processing given the current state. */ 1233130803Smarcel/* Read a lookahead token if we need one and don't already have one. */ 1234130803Smarcel/* yyresume: */ 1235130803Smarcel 1236130803Smarcel /* First try to decide what to do without reference to lookahead token. */ 1237130803Smarcel 1238130803Smarcel yyn = yypact[yystate]; 1239130803Smarcel if (yyn == YYPACT_NINF) 1240130803Smarcel goto yydefault; 1241130803Smarcel 1242130803Smarcel /* Not known => get a lookahead token if don't already have one. */ 1243130803Smarcel 1244130803Smarcel /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ 1245130803Smarcel if (yychar == YYEMPTY) 1246130803Smarcel { 1247130803Smarcel YYDPRINTF ((stderr, "Reading a token: ")); 1248130803Smarcel yychar = YYLEX; 1249130803Smarcel } 1250130803Smarcel 1251130803Smarcel if (yychar <= YYEOF) 1252130803Smarcel { 1253130803Smarcel yychar = yytoken = YYEOF; 1254130803Smarcel YYDPRINTF ((stderr, "Now at end of input.\n")); 1255130803Smarcel } 1256130803Smarcel else 1257130803Smarcel { 1258130803Smarcel yytoken = YYTRANSLATE (yychar); 1259130803Smarcel YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); 1260130803Smarcel } 1261130803Smarcel 1262130803Smarcel /* If the proper action on seeing token YYTOKEN is to reduce or to 1263130803Smarcel detect an error, take that action. */ 1264130803Smarcel yyn += yytoken; 1265130803Smarcel if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) 1266130803Smarcel goto yydefault; 1267130803Smarcel yyn = yytable[yyn]; 1268130803Smarcel if (yyn <= 0) 1269130803Smarcel { 1270130803Smarcel if (yyn == 0 || yyn == YYTABLE_NINF) 1271130803Smarcel goto yyerrlab; 1272130803Smarcel yyn = -yyn; 1273130803Smarcel goto yyreduce; 1274130803Smarcel } 1275130803Smarcel 1276130803Smarcel if (yyn == YYFINAL) 1277130803Smarcel YYACCEPT; 1278130803Smarcel 1279130803Smarcel /* Shift the lookahead token. */ 1280130803Smarcel YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); 1281130803Smarcel 1282130803Smarcel /* Discard the token being shifted unless it is eof. */ 1283130803Smarcel if (yychar != YYEOF) 1284130803Smarcel yychar = YYEMPTY; 1285130803Smarcel 1286130803Smarcel *++yyvsp = yylval; 1287130803Smarcel 1288130803Smarcel 1289130803Smarcel /* Count tokens shifted since error; after three, turn off error 1290130803Smarcel status. */ 1291130803Smarcel if (yyerrstatus) 1292130803Smarcel yyerrstatus--; 1293130803Smarcel 1294130803Smarcel yystate = yyn; 1295130803Smarcel goto yynewstate; 1296130803Smarcel 1297130803Smarcel 1298130803Smarcel/*-----------------------------------------------------------. 1299130803Smarcel| yydefault -- do the default action for the current state. | 1300130803Smarcel`-----------------------------------------------------------*/ 1301130803Smarcelyydefault: 1302130803Smarcel yyn = yydefact[yystate]; 1303130803Smarcel if (yyn == 0) 1304130803Smarcel goto yyerrlab; 1305130803Smarcel goto yyreduce; 1306130803Smarcel 1307130803Smarcel 1308130803Smarcel/*-----------------------------. 1309130803Smarcel| yyreduce -- Do a reduction. | 1310130803Smarcel`-----------------------------*/ 1311130803Smarcelyyreduce: 1312130803Smarcel /* yyn is the number of a rule to reduce with. */ 1313130803Smarcel yylen = yyr2[yyn]; 1314130803Smarcel 1315130803Smarcel /* If YYLEN is nonzero, implement the default value of the action: 1316130803Smarcel `$$ = $1'. 1317130803Smarcel 1318130803Smarcel Otherwise, the following line sets YYVAL to garbage. 1319130803Smarcel This behavior is undocumented and Bison 1320130803Smarcel users should not rely upon it. Assigning to YYVAL 1321130803Smarcel unconditionally makes the parser a bit smaller, and it avoids a 1322130803Smarcel GCC warning that YYVAL may be used uninitialized. */ 1323130803Smarcel yyval = yyvsp[1-yylen]; 1324130803Smarcel 1325130803Smarcel 1326130803Smarcel YY_REDUCE_PRINT (yyn); 1327130803Smarcel switch (yyn) 1328130803Smarcel { 1329130803Smarcel case 4: 1330130803Smarcel#line 233 "f-exp.y" 1331130803Smarcel { write_exp_elt_opcode(OP_TYPE); 1332130803Smarcel write_exp_elt_type(yyvsp[0].tval); 1333130803Smarcel write_exp_elt_opcode(OP_TYPE); } 1334130803Smarcel break; 1335130803Smarcel 1336130803Smarcel case 5: 1337130803Smarcel#line 239 "f-exp.y" 1338130803Smarcel { } 1339130803Smarcel break; 1340130803Smarcel 1341130803Smarcel case 6: 1342130803Smarcel#line 244 "f-exp.y" 1343130803Smarcel { write_exp_elt_opcode (UNOP_IND); } 1344130803Smarcel break; 1345130803Smarcel 1346130803Smarcel case 7: 1347130803Smarcel#line 248 "f-exp.y" 1348130803Smarcel { write_exp_elt_opcode (UNOP_ADDR); } 1349130803Smarcel break; 1350130803Smarcel 1351130803Smarcel case 8: 1352130803Smarcel#line 252 "f-exp.y" 1353130803Smarcel { write_exp_elt_opcode (UNOP_NEG); } 1354130803Smarcel break; 1355130803Smarcel 1356130803Smarcel case 9: 1357130803Smarcel#line 256 "f-exp.y" 1358130803Smarcel { write_exp_elt_opcode (UNOP_LOGICAL_NOT); } 1359130803Smarcel break; 1360130803Smarcel 1361130803Smarcel case 10: 1362130803Smarcel#line 260 "f-exp.y" 1363130803Smarcel { write_exp_elt_opcode (UNOP_COMPLEMENT); } 1364130803Smarcel break; 1365130803Smarcel 1366130803Smarcel case 11: 1367130803Smarcel#line 264 "f-exp.y" 1368130803Smarcel { write_exp_elt_opcode (UNOP_SIZEOF); } 1369130803Smarcel break; 1370130803Smarcel 1371130803Smarcel case 12: 1372130803Smarcel#line 273 "f-exp.y" 1373130803Smarcel { start_arglist (); } 1374130803Smarcel break; 1375130803Smarcel 1376130803Smarcel case 13: 1377130803Smarcel#line 275 "f-exp.y" 1378130803Smarcel { write_exp_elt_opcode (OP_F77_UNDETERMINED_ARGLIST); 1379130803Smarcel write_exp_elt_longcst ((LONGEST) end_arglist ()); 1380130803Smarcel write_exp_elt_opcode (OP_F77_UNDETERMINED_ARGLIST); } 1381130803Smarcel break; 1382130803Smarcel 1383130803Smarcel case 15: 1384130803Smarcel#line 284 "f-exp.y" 1385130803Smarcel { arglist_len = 1; } 1386130803Smarcel break; 1387130803Smarcel 1388130803Smarcel case 16: 1389130803Smarcel#line 288 "f-exp.y" 1390130803Smarcel { arglist_len = 2;} 1391130803Smarcel break; 1392130803Smarcel 1393130803Smarcel case 17: 1394130803Smarcel#line 292 "f-exp.y" 1395130803Smarcel { arglist_len++; } 1396130803Smarcel break; 1397130803Smarcel 1398130803Smarcel case 18: 1399130803Smarcel#line 296 "f-exp.y" 1400130803Smarcel { } 1401130803Smarcel break; 1402130803Smarcel 1403130803Smarcel case 19: 1404130803Smarcel#line 301 "f-exp.y" 1405130803Smarcel { } 1406130803Smarcel break; 1407130803Smarcel 1408130803Smarcel case 20: 1409130803Smarcel#line 305 "f-exp.y" 1410130803Smarcel { write_exp_elt_opcode(OP_COMPLEX); } 1411130803Smarcel break; 1412130803Smarcel 1413130803Smarcel case 21: 1414130803Smarcel#line 309 "f-exp.y" 1415130803Smarcel { write_exp_elt_opcode (UNOP_CAST); 1416130803Smarcel write_exp_elt_type (yyvsp[-2].tval); 1417130803Smarcel write_exp_elt_opcode (UNOP_CAST); } 1418130803Smarcel break; 1419130803Smarcel 1420130803Smarcel case 22: 1421130803Smarcel#line 317 "f-exp.y" 1422130803Smarcel { write_exp_elt_opcode (BINOP_REPEAT); } 1423130803Smarcel break; 1424130803Smarcel 1425130803Smarcel case 23: 1426130803Smarcel#line 321 "f-exp.y" 1427130803Smarcel { write_exp_elt_opcode (BINOP_MUL); } 1428130803Smarcel break; 1429130803Smarcel 1430130803Smarcel case 24: 1431130803Smarcel#line 325 "f-exp.y" 1432130803Smarcel { write_exp_elt_opcode (BINOP_DIV); } 1433130803Smarcel break; 1434130803Smarcel 1435130803Smarcel case 25: 1436130803Smarcel#line 329 "f-exp.y" 1437130803Smarcel { write_exp_elt_opcode (BINOP_REM); } 1438130803Smarcel break; 1439130803Smarcel 1440130803Smarcel case 26: 1441130803Smarcel#line 333 "f-exp.y" 1442130803Smarcel { write_exp_elt_opcode (BINOP_ADD); } 1443130803Smarcel break; 1444130803Smarcel 1445130803Smarcel case 27: 1446130803Smarcel#line 337 "f-exp.y" 1447130803Smarcel { write_exp_elt_opcode (BINOP_SUB); } 1448130803Smarcel break; 1449130803Smarcel 1450130803Smarcel case 28: 1451130803Smarcel#line 341 "f-exp.y" 1452130803Smarcel { write_exp_elt_opcode (BINOP_LSH); } 1453130803Smarcel break; 1454130803Smarcel 1455130803Smarcel case 29: 1456130803Smarcel#line 345 "f-exp.y" 1457130803Smarcel { write_exp_elt_opcode (BINOP_RSH); } 1458130803Smarcel break; 1459130803Smarcel 1460130803Smarcel case 30: 1461130803Smarcel#line 349 "f-exp.y" 1462130803Smarcel { write_exp_elt_opcode (BINOP_EQUAL); } 1463130803Smarcel break; 1464130803Smarcel 1465130803Smarcel case 31: 1466130803Smarcel#line 353 "f-exp.y" 1467130803Smarcel { write_exp_elt_opcode (BINOP_NOTEQUAL); } 1468130803Smarcel break; 1469130803Smarcel 1470130803Smarcel case 32: 1471130803Smarcel#line 357 "f-exp.y" 1472130803Smarcel { write_exp_elt_opcode (BINOP_LEQ); } 1473130803Smarcel break; 1474130803Smarcel 1475130803Smarcel case 33: 1476130803Smarcel#line 361 "f-exp.y" 1477130803Smarcel { write_exp_elt_opcode (BINOP_GEQ); } 1478130803Smarcel break; 1479130803Smarcel 1480130803Smarcel case 34: 1481130803Smarcel#line 365 "f-exp.y" 1482130803Smarcel { write_exp_elt_opcode (BINOP_LESS); } 1483130803Smarcel break; 1484130803Smarcel 1485130803Smarcel case 35: 1486130803Smarcel#line 369 "f-exp.y" 1487130803Smarcel { write_exp_elt_opcode (BINOP_GTR); } 1488130803Smarcel break; 1489130803Smarcel 1490130803Smarcel case 36: 1491130803Smarcel#line 373 "f-exp.y" 1492130803Smarcel { write_exp_elt_opcode (BINOP_BITWISE_AND); } 1493130803Smarcel break; 1494130803Smarcel 1495130803Smarcel case 37: 1496130803Smarcel#line 377 "f-exp.y" 1497130803Smarcel { write_exp_elt_opcode (BINOP_BITWISE_XOR); } 1498130803Smarcel break; 1499130803Smarcel 1500130803Smarcel case 38: 1501130803Smarcel#line 381 "f-exp.y" 1502130803Smarcel { write_exp_elt_opcode (BINOP_BITWISE_IOR); } 1503130803Smarcel break; 1504130803Smarcel 1505130803Smarcel case 39: 1506130803Smarcel#line 385 "f-exp.y" 1507130803Smarcel { write_exp_elt_opcode (BINOP_LOGICAL_AND); } 1508130803Smarcel break; 1509130803Smarcel 1510130803Smarcel case 40: 1511130803Smarcel#line 390 "f-exp.y" 1512130803Smarcel { write_exp_elt_opcode (BINOP_LOGICAL_OR); } 1513130803Smarcel break; 1514130803Smarcel 1515130803Smarcel case 41: 1516130803Smarcel#line 394 "f-exp.y" 1517130803Smarcel { write_exp_elt_opcode (BINOP_ASSIGN); } 1518130803Smarcel break; 1519130803Smarcel 1520130803Smarcel case 42: 1521130803Smarcel#line 398 "f-exp.y" 1522130803Smarcel { write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); 1523130803Smarcel write_exp_elt_opcode (yyvsp[-1].opcode); 1524130803Smarcel write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); } 1525130803Smarcel break; 1526130803Smarcel 1527130803Smarcel case 43: 1528130803Smarcel#line 404 "f-exp.y" 1529130803Smarcel { write_exp_elt_opcode (OP_LONG); 1530130803Smarcel write_exp_elt_type (yyvsp[0].typed_val.type); 1531130803Smarcel write_exp_elt_longcst ((LONGEST)(yyvsp[0].typed_val.val)); 1532130803Smarcel write_exp_elt_opcode (OP_LONG); } 1533130803Smarcel break; 1534130803Smarcel 1535130803Smarcel case 44: 1536130803Smarcel#line 411 "f-exp.y" 1537130803Smarcel { YYSTYPE val; 1538130803Smarcel parse_number (yyvsp[0].ssym.stoken.ptr, yyvsp[0].ssym.stoken.length, 0, &val); 1539130803Smarcel write_exp_elt_opcode (OP_LONG); 1540130803Smarcel write_exp_elt_type (val.typed_val.type); 1541130803Smarcel write_exp_elt_longcst ((LONGEST)val.typed_val.val); 1542130803Smarcel write_exp_elt_opcode (OP_LONG); } 1543130803Smarcel break; 1544130803Smarcel 1545130803Smarcel case 45: 1546130803Smarcel#line 420 "f-exp.y" 1547130803Smarcel { write_exp_elt_opcode (OP_DOUBLE); 1548130803Smarcel write_exp_elt_type (builtin_type_f_real_s8); 1549130803Smarcel write_exp_elt_dblcst (yyvsp[0].dval); 1550130803Smarcel write_exp_elt_opcode (OP_DOUBLE); } 1551130803Smarcel break; 1552130803Smarcel 1553130803Smarcel case 48: 1554130803Smarcel#line 433 "f-exp.y" 1555130803Smarcel { write_exp_elt_opcode (OP_LONG); 1556130803Smarcel write_exp_elt_type (builtin_type_f_integer); 1557130803Smarcel CHECK_TYPEDEF (yyvsp[-1].tval); 1558130803Smarcel write_exp_elt_longcst ((LONGEST) TYPE_LENGTH (yyvsp[-1].tval)); 1559130803Smarcel write_exp_elt_opcode (OP_LONG); } 1560130803Smarcel break; 1561130803Smarcel 1562130803Smarcel case 49: 1563130803Smarcel#line 441 "f-exp.y" 1564130803Smarcel { write_exp_elt_opcode (OP_BOOL); 1565130803Smarcel write_exp_elt_longcst ((LONGEST) yyvsp[0].lval); 1566130803Smarcel write_exp_elt_opcode (OP_BOOL); 1567130803Smarcel } 1568130803Smarcel break; 1569130803Smarcel 1570130803Smarcel case 50: 1571130803Smarcel#line 448 "f-exp.y" 1572130803Smarcel { 1573130803Smarcel write_exp_elt_opcode (OP_STRING); 1574130803Smarcel write_exp_string (yyvsp[0].sval); 1575130803Smarcel write_exp_elt_opcode (OP_STRING); 1576130803Smarcel } 1577130803Smarcel break; 1578130803Smarcel 1579130803Smarcel case 51: 1580130803Smarcel#line 456 "f-exp.y" 1581130803Smarcel { struct symbol *sym = yyvsp[0].ssym.sym; 1582130803Smarcel 1583130803Smarcel if (sym) 1584130803Smarcel { 1585130803Smarcel if (symbol_read_needs_frame (sym)) 1586130803Smarcel { 1587130803Smarcel if (innermost_block == 0 || 1588130803Smarcel contained_in (block_found, 1589130803Smarcel innermost_block)) 1590130803Smarcel innermost_block = block_found; 1591130803Smarcel } 1592130803Smarcel write_exp_elt_opcode (OP_VAR_VALUE); 1593130803Smarcel /* We want to use the selected frame, not 1594130803Smarcel another more inner frame which happens to 1595130803Smarcel be in the same block. */ 1596130803Smarcel write_exp_elt_block (NULL); 1597130803Smarcel write_exp_elt_sym (sym); 1598130803Smarcel write_exp_elt_opcode (OP_VAR_VALUE); 1599130803Smarcel break; 1600130803Smarcel } 1601130803Smarcel else 1602130803Smarcel { 1603130803Smarcel struct minimal_symbol *msymbol; 1604130803Smarcel char *arg = copy_name (yyvsp[0].ssym.stoken); 1605130803Smarcel 1606130803Smarcel msymbol = 1607130803Smarcel lookup_minimal_symbol (arg, NULL, NULL); 1608130803Smarcel if (msymbol != NULL) 1609130803Smarcel { 1610130803Smarcel write_exp_msymbol (msymbol, 1611130803Smarcel lookup_function_type (builtin_type_int), 1612130803Smarcel builtin_type_int); 1613130803Smarcel } 1614130803Smarcel else if (!have_full_symbols () && !have_partial_symbols ()) 1615130803Smarcel error ("No symbol table is loaded. Use the \"file\" command."); 1616130803Smarcel else 1617130803Smarcel error ("No symbol \"%s\" in current context.", 1618130803Smarcel copy_name (yyvsp[0].ssym.stoken)); 1619130803Smarcel } 1620130803Smarcel } 1621130803Smarcel break; 1622130803Smarcel 1623130803Smarcel case 54: 1624130803Smarcel#line 504 "f-exp.y" 1625130803Smarcel { 1626130803Smarcel /* This is where the interesting stuff happens. */ 1627130803Smarcel int done = 0; 1628130803Smarcel int array_size; 1629130803Smarcel struct type *follow_type = yyvsp[-1].tval; 1630130803Smarcel struct type *range_type; 1631130803Smarcel 1632130803Smarcel while (!done) 1633130803Smarcel switch (pop_type ()) 1634130803Smarcel { 1635130803Smarcel case tp_end: 1636130803Smarcel done = 1; 1637130803Smarcel break; 1638130803Smarcel case tp_pointer: 1639130803Smarcel follow_type = lookup_pointer_type (follow_type); 1640130803Smarcel break; 1641130803Smarcel case tp_reference: 1642130803Smarcel follow_type = lookup_reference_type (follow_type); 1643130803Smarcel break; 1644130803Smarcel case tp_array: 1645130803Smarcel array_size = pop_type_int (); 1646130803Smarcel if (array_size != -1) 1647130803Smarcel { 1648130803Smarcel range_type = 1649130803Smarcel create_range_type ((struct type *) NULL, 1650130803Smarcel builtin_type_f_integer, 0, 1651130803Smarcel array_size - 1); 1652130803Smarcel follow_type = 1653130803Smarcel create_array_type ((struct type *) NULL, 1654130803Smarcel follow_type, range_type); 1655130803Smarcel } 1656130803Smarcel else 1657130803Smarcel follow_type = lookup_pointer_type (follow_type); 1658130803Smarcel break; 1659130803Smarcel case tp_function: 1660130803Smarcel follow_type = lookup_function_type (follow_type); 1661130803Smarcel break; 1662130803Smarcel } 1663130803Smarcel yyval.tval = follow_type; 1664130803Smarcel } 1665130803Smarcel break; 1666130803Smarcel 1667130803Smarcel case 55: 1668130803Smarcel#line 547 "f-exp.y" 1669130803Smarcel { push_type (tp_pointer); yyval.voidval = 0; } 1670130803Smarcel break; 1671130803Smarcel 1672130803Smarcel case 56: 1673130803Smarcel#line 549 "f-exp.y" 1674130803Smarcel { push_type (tp_pointer); yyval.voidval = yyvsp[0].voidval; } 1675130803Smarcel break; 1676130803Smarcel 1677130803Smarcel case 57: 1678130803Smarcel#line 551 "f-exp.y" 1679130803Smarcel { push_type (tp_reference); yyval.voidval = 0; } 1680130803Smarcel break; 1681130803Smarcel 1682130803Smarcel case 58: 1683130803Smarcel#line 553 "f-exp.y" 1684130803Smarcel { push_type (tp_reference); yyval.voidval = yyvsp[0].voidval; } 1685130803Smarcel break; 1686130803Smarcel 1687130803Smarcel case 60: 1688130803Smarcel#line 558 "f-exp.y" 1689130803Smarcel { yyval.voidval = yyvsp[-1].voidval; } 1690130803Smarcel break; 1691130803Smarcel 1692130803Smarcel case 61: 1693130803Smarcel#line 560 "f-exp.y" 1694130803Smarcel { push_type (tp_function); } 1695130803Smarcel break; 1696130803Smarcel 1697130803Smarcel case 62: 1698130803Smarcel#line 562 "f-exp.y" 1699130803Smarcel { push_type (tp_function); } 1700130803Smarcel break; 1701130803Smarcel 1702130803Smarcel case 63: 1703130803Smarcel#line 566 "f-exp.y" 1704130803Smarcel { yyval.voidval = 0; } 1705130803Smarcel break; 1706130803Smarcel 1707130803Smarcel case 64: 1708130803Smarcel#line 568 "f-exp.y" 1709130803Smarcel { free (yyvsp[-1].tvec); yyval.voidval = 0; } 1710130803Smarcel break; 1711130803Smarcel 1712130803Smarcel case 65: 1713130803Smarcel#line 573 "f-exp.y" 1714130803Smarcel { yyval.tval = yyvsp[0].tsym.type; } 1715130803Smarcel break; 1716130803Smarcel 1717130803Smarcel case 66: 1718130803Smarcel#line 575 "f-exp.y" 1719130803Smarcel { yyval.tval = builtin_type_f_integer; } 1720130803Smarcel break; 1721130803Smarcel 1722130803Smarcel case 67: 1723130803Smarcel#line 577 "f-exp.y" 1724130803Smarcel { yyval.tval = builtin_type_f_integer_s2; } 1725130803Smarcel break; 1726130803Smarcel 1727130803Smarcel case 68: 1728130803Smarcel#line 579 "f-exp.y" 1729130803Smarcel { yyval.tval = builtin_type_f_character; } 1730130803Smarcel break; 1731130803Smarcel 1732130803Smarcel case 69: 1733130803Smarcel#line 581 "f-exp.y" 1734130803Smarcel { yyval.tval = builtin_type_f_logical;} 1735130803Smarcel break; 1736130803Smarcel 1737130803Smarcel case 70: 1738130803Smarcel#line 583 "f-exp.y" 1739130803Smarcel { yyval.tval = builtin_type_f_logical_s2;} 1740130803Smarcel break; 1741130803Smarcel 1742130803Smarcel case 71: 1743130803Smarcel#line 585 "f-exp.y" 1744130803Smarcel { yyval.tval = builtin_type_f_logical_s1;} 1745130803Smarcel break; 1746130803Smarcel 1747130803Smarcel case 72: 1748130803Smarcel#line 587 "f-exp.y" 1749130803Smarcel { yyval.tval = builtin_type_f_real;} 1750130803Smarcel break; 1751130803Smarcel 1752130803Smarcel case 73: 1753130803Smarcel#line 589 "f-exp.y" 1754130803Smarcel { yyval.tval = builtin_type_f_real_s8;} 1755130803Smarcel break; 1756130803Smarcel 1757130803Smarcel case 74: 1758130803Smarcel#line 591 "f-exp.y" 1759130803Smarcel { yyval.tval = builtin_type_f_real_s16;} 1760130803Smarcel break; 1761130803Smarcel 1762130803Smarcel case 75: 1763130803Smarcel#line 593 "f-exp.y" 1764130803Smarcel { yyval.tval = builtin_type_f_complex_s8;} 1765130803Smarcel break; 1766130803Smarcel 1767130803Smarcel case 76: 1768130803Smarcel#line 595 "f-exp.y" 1769130803Smarcel { yyval.tval = builtin_type_f_complex_s16;} 1770130803Smarcel break; 1771130803Smarcel 1772130803Smarcel case 77: 1773130803Smarcel#line 597 "f-exp.y" 1774130803Smarcel { yyval.tval = builtin_type_f_complex_s32;} 1775130803Smarcel break; 1776130803Smarcel 1777130803Smarcel case 78: 1778130803Smarcel#line 605 "f-exp.y" 1779130803Smarcel { yyval.tvec = (struct type **) xmalloc (sizeof (struct type *) * 2); 1780130803Smarcel yyval.ivec[0] = 1; /* Number of types in vector */ 1781130803Smarcel yyval.tvec[1] = yyvsp[0].tval; 1782130803Smarcel } 1783130803Smarcel break; 1784130803Smarcel 1785130803Smarcel case 79: 1786130803Smarcel#line 610 "f-exp.y" 1787130803Smarcel { int len = sizeof (struct type *) * (++(yyvsp[-2].ivec[0]) + 1); 1788130803Smarcel yyval.tvec = (struct type **) xrealloc ((char *) yyvsp[-2].tvec, len); 1789130803Smarcel yyval.tvec[yyval.ivec[0]] = yyvsp[0].tval; 1790130803Smarcel } 1791130803Smarcel break; 1792130803Smarcel 1793130803Smarcel 1794130803Smarcel } 1795130803Smarcel 1796130803Smarcel/* Line 991 of yacc.c. */ 1797130803Smarcel 1798130803Smarcel yyvsp -= yylen; 1799130803Smarcel yyssp -= yylen; 1800130803Smarcel 1801130803Smarcel 1802130803Smarcel YY_STACK_PRINT (yyss, yyssp); 1803130803Smarcel 1804130803Smarcel *++yyvsp = yyval; 1805130803Smarcel 1806130803Smarcel 1807130803Smarcel /* Now `shift' the result of the reduction. Determine what state 1808130803Smarcel that goes to, based on the state we popped back to and the rule 1809130803Smarcel number reduced by. */ 1810130803Smarcel 1811130803Smarcel yyn = yyr1[yyn]; 1812130803Smarcel 1813130803Smarcel yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; 1814130803Smarcel if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) 1815130803Smarcel yystate = yytable[yystate]; 1816130803Smarcel else 1817130803Smarcel yystate = yydefgoto[yyn - YYNTOKENS]; 1818130803Smarcel 1819130803Smarcel goto yynewstate; 1820130803Smarcel 1821130803Smarcel 1822130803Smarcel/*------------------------------------. 1823130803Smarcel| yyerrlab -- here on detecting error | 1824130803Smarcel`------------------------------------*/ 1825130803Smarcelyyerrlab: 1826130803Smarcel /* If not already recovering from an error, report this error. */ 1827130803Smarcel if (!yyerrstatus) 1828130803Smarcel { 1829130803Smarcel ++yynerrs; 1830130803Smarcel#if YYERROR_VERBOSE 1831130803Smarcel yyn = yypact[yystate]; 1832130803Smarcel 1833130803Smarcel if (YYPACT_NINF < yyn && yyn < YYLAST) 1834130803Smarcel { 1835130803Smarcel YYSIZE_T yysize = 0; 1836130803Smarcel int yytype = YYTRANSLATE (yychar); 1837130803Smarcel char *yymsg; 1838130803Smarcel int yyx, yycount; 1839130803Smarcel 1840130803Smarcel yycount = 0; 1841130803Smarcel /* Start YYX at -YYN if negative to avoid negative indexes in 1842130803Smarcel YYCHECK. */ 1843130803Smarcel for (yyx = yyn < 0 ? -yyn : 0; 1844130803Smarcel yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) 1845130803Smarcel if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) 1846130803Smarcel yysize += yystrlen (yytname[yyx]) + 15, yycount++; 1847130803Smarcel yysize += yystrlen ("syntax error, unexpected ") + 1; 1848130803Smarcel yysize += yystrlen (yytname[yytype]); 1849130803Smarcel yymsg = (char *) YYSTACK_ALLOC (yysize); 1850130803Smarcel if (yymsg != 0) 1851130803Smarcel { 1852130803Smarcel char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); 1853130803Smarcel yyp = yystpcpy (yyp, yytname[yytype]); 1854130803Smarcel 1855130803Smarcel if (yycount < 5) 1856130803Smarcel { 1857130803Smarcel yycount = 0; 1858130803Smarcel for (yyx = yyn < 0 ? -yyn : 0; 1859130803Smarcel yyx < (int) (sizeof (yytname) / sizeof (char *)); 1860130803Smarcel yyx++) 1861130803Smarcel if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) 1862130803Smarcel { 1863130803Smarcel const char *yyq = ! yycount ? ", expecting " : " or "; 1864130803Smarcel yyp = yystpcpy (yyp, yyq); 1865130803Smarcel yyp = yystpcpy (yyp, yytname[yyx]); 1866130803Smarcel yycount++; 1867130803Smarcel } 1868130803Smarcel } 1869130803Smarcel yyerror (yymsg); 1870130803Smarcel YYSTACK_FREE (yymsg); 1871130803Smarcel } 1872130803Smarcel else 1873130803Smarcel yyerror ("syntax error; also virtual memory exhausted"); 1874130803Smarcel } 1875130803Smarcel else 1876130803Smarcel#endif /* YYERROR_VERBOSE */ 1877130803Smarcel yyerror ("syntax error"); 1878130803Smarcel } 1879130803Smarcel 1880130803Smarcel 1881130803Smarcel 1882130803Smarcel if (yyerrstatus == 3) 1883130803Smarcel { 1884130803Smarcel /* If just tried and failed to reuse lookahead token after an 1885130803Smarcel error, discard it. */ 1886130803Smarcel 1887130803Smarcel /* Return failure if at end of input. */ 1888130803Smarcel if (yychar == YYEOF) 1889130803Smarcel { 1890130803Smarcel /* Pop the error token. */ 1891130803Smarcel YYPOPSTACK; 1892130803Smarcel /* Pop the rest of the stack. */ 1893130803Smarcel while (yyss < yyssp) 1894130803Smarcel { 1895130803Smarcel YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); 1896130803Smarcel yydestruct (yystos[*yyssp], yyvsp); 1897130803Smarcel YYPOPSTACK; 1898130803Smarcel } 1899130803Smarcel YYABORT; 1900130803Smarcel } 1901130803Smarcel 1902130803Smarcel YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); 1903130803Smarcel yydestruct (yytoken, &yylval); 1904130803Smarcel yychar = YYEMPTY; 1905130803Smarcel 1906130803Smarcel } 1907130803Smarcel 1908130803Smarcel /* Else will try to reuse lookahead token after shifting the error 1909130803Smarcel token. */ 1910130803Smarcel goto yyerrlab2; 1911130803Smarcel 1912130803Smarcel 1913130803Smarcel/*----------------------------------------------------. 1914130803Smarcel| yyerrlab1 -- error raised explicitly by an action. | 1915130803Smarcel`----------------------------------------------------*/ 1916130803Smarcelyyerrlab1: 1917130803Smarcel 1918130803Smarcel /* Suppress GCC warning that yyerrlab1 is unused when no action 1919130803Smarcel invokes YYERROR. Doesn't work in C++ */ 1920130803Smarcel#ifndef __cplusplus 1921130803Smarcel#if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__) 1922130803Smarcel __attribute__ ((__unused__)) 1923130803Smarcel#endif 1924130803Smarcel#endif 1925130803Smarcel 1926130803Smarcel 1927130803Smarcel goto yyerrlab2; 1928130803Smarcel 1929130803Smarcel 1930130803Smarcel/*---------------------------------------------------------------. 1931130803Smarcel| yyerrlab2 -- pop states until the error token can be shifted. | 1932130803Smarcel`---------------------------------------------------------------*/ 1933130803Smarcelyyerrlab2: 1934130803Smarcel yyerrstatus = 3; /* Each real token shifted decrements this. */ 1935130803Smarcel 1936130803Smarcel for (;;) 1937130803Smarcel { 1938130803Smarcel yyn = yypact[yystate]; 1939130803Smarcel if (yyn != YYPACT_NINF) 1940130803Smarcel { 1941130803Smarcel yyn += YYTERROR; 1942130803Smarcel if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) 1943130803Smarcel { 1944130803Smarcel yyn = yytable[yyn]; 1945130803Smarcel if (0 < yyn) 1946130803Smarcel break; 1947130803Smarcel } 1948130803Smarcel } 1949130803Smarcel 1950130803Smarcel /* Pop the current state because it cannot handle the error token. */ 1951130803Smarcel if (yyssp == yyss) 1952130803Smarcel YYABORT; 1953130803Smarcel 1954130803Smarcel YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); 1955130803Smarcel yydestruct (yystos[yystate], yyvsp); 1956130803Smarcel yyvsp--; 1957130803Smarcel yystate = *--yyssp; 1958130803Smarcel 1959130803Smarcel YY_STACK_PRINT (yyss, yyssp); 1960130803Smarcel } 1961130803Smarcel 1962130803Smarcel if (yyn == YYFINAL) 1963130803Smarcel YYACCEPT; 1964130803Smarcel 1965130803Smarcel YYDPRINTF ((stderr, "Shifting error token, ")); 1966130803Smarcel 1967130803Smarcel *++yyvsp = yylval; 1968130803Smarcel 1969130803Smarcel 1970130803Smarcel yystate = yyn; 1971130803Smarcel goto yynewstate; 1972130803Smarcel 1973130803Smarcel 1974130803Smarcel/*-------------------------------------. 1975130803Smarcel| yyacceptlab -- YYACCEPT comes here. | 1976130803Smarcel`-------------------------------------*/ 1977130803Smarcelyyacceptlab: 1978130803Smarcel yyresult = 0; 1979130803Smarcel goto yyreturn; 1980130803Smarcel 1981130803Smarcel/*-----------------------------------. 1982130803Smarcel| yyabortlab -- YYABORT comes here. | 1983130803Smarcel`-----------------------------------*/ 1984130803Smarcelyyabortlab: 1985130803Smarcel yyresult = 1; 1986130803Smarcel goto yyreturn; 1987130803Smarcel 1988130803Smarcel#ifndef yyoverflow 1989130803Smarcel/*----------------------------------------------. 1990130803Smarcel| yyoverflowlab -- parser overflow comes here. | 1991130803Smarcel`----------------------------------------------*/ 1992130803Smarcelyyoverflowlab: 1993130803Smarcel yyerror ("parser stack overflow"); 1994130803Smarcel yyresult = 2; 1995130803Smarcel /* Fall through. */ 1996130803Smarcel#endif 1997130803Smarcel 1998130803Smarcelyyreturn: 1999130803Smarcel#ifndef yyoverflow 2000130803Smarcel if (yyss != yyssa) 2001130803Smarcel YYSTACK_FREE (yyss); 2002130803Smarcel#endif 2003130803Smarcel return yyresult; 2004130803Smarcel} 2005130803Smarcel 2006130803Smarcel 2007130803Smarcel#line 634 "f-exp.y" 2008130803Smarcel 2009130803Smarcel 2010130803Smarcel/* Take care of parsing a number (anything that starts with a digit). 2011130803Smarcel Set yylval and return the token type; update lexptr. 2012130803Smarcel LEN is the number of characters in it. */ 2013130803Smarcel 2014130803Smarcel/*** Needs some error checking for the float case ***/ 2015130803Smarcel 2016130803Smarcelstatic int 2017130803Smarcelparse_number (p, len, parsed_float, putithere) 2018130803Smarcel char *p; 2019130803Smarcel int len; 2020130803Smarcel int parsed_float; 2021130803Smarcel YYSTYPE *putithere; 2022130803Smarcel{ 2023130803Smarcel LONGEST n = 0; 2024130803Smarcel LONGEST prevn = 0; 2025130803Smarcel int c; 2026130803Smarcel int base = input_radix; 2027130803Smarcel int unsigned_p = 0; 2028130803Smarcel int long_p = 0; 2029130803Smarcel ULONGEST high_bit; 2030130803Smarcel struct type *signed_type; 2031130803Smarcel struct type *unsigned_type; 2032130803Smarcel 2033130803Smarcel if (parsed_float) 2034130803Smarcel { 2035130803Smarcel /* It's a float since it contains a point or an exponent. */ 2036130803Smarcel /* [dD] is not understood as an exponent by atof, change it to 'e'. */ 2037130803Smarcel char *tmp, *tmp2; 2038130803Smarcel 2039130803Smarcel tmp = xstrdup (p); 2040130803Smarcel for (tmp2 = tmp; *tmp2; ++tmp2) 2041130803Smarcel if (*tmp2 == 'd' || *tmp2 == 'D') 2042130803Smarcel *tmp2 = 'e'; 2043130803Smarcel putithere->dval = atof (tmp); 2044130803Smarcel free (tmp); 2045130803Smarcel return FLOAT; 2046130803Smarcel } 2047130803Smarcel 2048130803Smarcel /* Handle base-switching prefixes 0x, 0t, 0d, 0 */ 2049130803Smarcel if (p[0] == '0') 2050130803Smarcel switch (p[1]) 2051130803Smarcel { 2052130803Smarcel case 'x': 2053130803Smarcel case 'X': 2054130803Smarcel if (len >= 3) 2055130803Smarcel { 2056130803Smarcel p += 2; 2057130803Smarcel base = 16; 2058130803Smarcel len -= 2; 2059130803Smarcel } 2060130803Smarcel break; 2061130803Smarcel 2062130803Smarcel case 't': 2063130803Smarcel case 'T': 2064130803Smarcel case 'd': 2065130803Smarcel case 'D': 2066130803Smarcel if (len >= 3) 2067130803Smarcel { 2068130803Smarcel p += 2; 2069130803Smarcel base = 10; 2070130803Smarcel len -= 2; 2071130803Smarcel } 2072130803Smarcel break; 2073130803Smarcel 2074130803Smarcel default: 2075130803Smarcel base = 8; 2076130803Smarcel break; 2077130803Smarcel } 2078130803Smarcel 2079130803Smarcel while (len-- > 0) 2080130803Smarcel { 2081130803Smarcel c = *p++; 2082130803Smarcel if (isupper (c)) 2083130803Smarcel c = tolower (c); 2084130803Smarcel if (len == 0 && c == 'l') 2085130803Smarcel long_p = 1; 2086130803Smarcel else if (len == 0 && c == 'u') 2087130803Smarcel unsigned_p = 1; 2088130803Smarcel else 2089130803Smarcel { 2090130803Smarcel int i; 2091130803Smarcel if (c >= '0' && c <= '9') 2092130803Smarcel i = c - '0'; 2093130803Smarcel else if (c >= 'a' && c <= 'f') 2094130803Smarcel i = c - 'a' + 10; 2095130803Smarcel else 2096130803Smarcel return ERROR; /* Char not a digit */ 2097130803Smarcel if (i >= base) 2098130803Smarcel return ERROR; /* Invalid digit in this base */ 2099130803Smarcel n *= base; 2100130803Smarcel n += i; 2101130803Smarcel } 2102130803Smarcel /* Portably test for overflow (only works for nonzero values, so make 2103130803Smarcel a second check for zero). */ 2104130803Smarcel if ((prevn >= n) && n != 0) 2105130803Smarcel unsigned_p=1; /* Try something unsigned */ 2106130803Smarcel /* If range checking enabled, portably test for unsigned overflow. */ 2107130803Smarcel if (RANGE_CHECK && n != 0) 2108130803Smarcel { 2109130803Smarcel if ((unsigned_p && (unsigned)prevn >= (unsigned)n)) 2110130803Smarcel range_error("Overflow on numeric constant."); 2111130803Smarcel } 2112130803Smarcel prevn = n; 2113130803Smarcel } 2114130803Smarcel 2115130803Smarcel /* If the number is too big to be an int, or it's got an l suffix 2116130803Smarcel then it's a long. Work out if this has to be a long by 2117130803Smarcel shifting right and and seeing if anything remains, and the 2118130803Smarcel target int size is different to the target long size. 2119130803Smarcel 2120130803Smarcel In the expression below, we could have tested 2121130803Smarcel (n >> TARGET_INT_BIT) 2122130803Smarcel to see if it was zero, 2123130803Smarcel but too many compilers warn about that, when ints and longs 2124130803Smarcel are the same size. So we shift it twice, with fewer bits 2125130803Smarcel each time, for the same result. */ 2126130803Smarcel 2127130803Smarcel if ((TARGET_INT_BIT != TARGET_LONG_BIT 2128130803Smarcel && ((n >> 2) >> (TARGET_INT_BIT-2))) /* Avoid shift warning */ 2129130803Smarcel || long_p) 2130130803Smarcel { 2131130803Smarcel high_bit = ((ULONGEST)1) << (TARGET_LONG_BIT-1); 2132130803Smarcel unsigned_type = builtin_type_unsigned_long; 2133130803Smarcel signed_type = builtin_type_long; 2134130803Smarcel } 2135130803Smarcel else 2136130803Smarcel { 2137130803Smarcel high_bit = ((ULONGEST)1) << (TARGET_INT_BIT-1); 2138130803Smarcel unsigned_type = builtin_type_unsigned_int; 2139130803Smarcel signed_type = builtin_type_int; 2140130803Smarcel } 2141130803Smarcel 2142130803Smarcel putithere->typed_val.val = n; 2143130803Smarcel 2144130803Smarcel /* If the high bit of the worked out type is set then this number 2145130803Smarcel has to be unsigned. */ 2146130803Smarcel 2147130803Smarcel if (unsigned_p || (n & high_bit)) 2148130803Smarcel putithere->typed_val.type = unsigned_type; 2149130803Smarcel else 2150130803Smarcel putithere->typed_val.type = signed_type; 2151130803Smarcel 2152130803Smarcel return INT; 2153130803Smarcel} 2154130803Smarcel 2155130803Smarcelstruct token 2156130803Smarcel{ 2157130803Smarcel char *operator; 2158130803Smarcel int token; 2159130803Smarcel enum exp_opcode opcode; 2160130803Smarcel}; 2161130803Smarcel 2162130803Smarcelstatic const struct token dot_ops[] = 2163130803Smarcel{ 2164130803Smarcel { ".and.", BOOL_AND, BINOP_END }, 2165130803Smarcel { ".AND.", BOOL_AND, BINOP_END }, 2166130803Smarcel { ".or.", BOOL_OR, BINOP_END }, 2167130803Smarcel { ".OR.", BOOL_OR, BINOP_END }, 2168130803Smarcel { ".not.", BOOL_NOT, BINOP_END }, 2169130803Smarcel { ".NOT.", BOOL_NOT, BINOP_END }, 2170130803Smarcel { ".eq.", EQUAL, BINOP_END }, 2171130803Smarcel { ".EQ.", EQUAL, BINOP_END }, 2172130803Smarcel { ".eqv.", EQUAL, BINOP_END }, 2173130803Smarcel { ".NEQV.", NOTEQUAL, BINOP_END }, 2174130803Smarcel { ".neqv.", NOTEQUAL, BINOP_END }, 2175130803Smarcel { ".EQV.", EQUAL, BINOP_END }, 2176130803Smarcel { ".ne.", NOTEQUAL, BINOP_END }, 2177130803Smarcel { ".NE.", NOTEQUAL, BINOP_END }, 2178130803Smarcel { ".le.", LEQ, BINOP_END }, 2179130803Smarcel { ".LE.", LEQ, BINOP_END }, 2180130803Smarcel { ".ge.", GEQ, BINOP_END }, 2181130803Smarcel { ".GE.", GEQ, BINOP_END }, 2182130803Smarcel { ".gt.", GREATERTHAN, BINOP_END }, 2183130803Smarcel { ".GT.", GREATERTHAN, BINOP_END }, 2184130803Smarcel { ".lt.", LESSTHAN, BINOP_END }, 2185130803Smarcel { ".LT.", LESSTHAN, BINOP_END }, 2186130803Smarcel { NULL, 0, 0 } 2187130803Smarcel}; 2188130803Smarcel 2189130803Smarcelstruct f77_boolean_val 2190130803Smarcel{ 2191130803Smarcel char *name; 2192130803Smarcel int value; 2193130803Smarcel}; 2194130803Smarcel 2195130803Smarcelstatic const struct f77_boolean_val boolean_values[] = 2196130803Smarcel{ 2197130803Smarcel { ".true.", 1 }, 2198130803Smarcel { ".TRUE.", 1 }, 2199130803Smarcel { ".false.", 0 }, 2200130803Smarcel { ".FALSE.", 0 }, 2201130803Smarcel { NULL, 0 } 2202130803Smarcel}; 2203130803Smarcel 2204130803Smarcelstatic const struct token f77_keywords[] = 2205130803Smarcel{ 2206130803Smarcel { "complex_16", COMPLEX_S16_KEYWORD, BINOP_END }, 2207130803Smarcel { "complex_32", COMPLEX_S32_KEYWORD, BINOP_END }, 2208130803Smarcel { "character", CHARACTER, BINOP_END }, 2209130803Smarcel { "integer_2", INT_S2_KEYWORD, BINOP_END }, 2210130803Smarcel { "logical_1", LOGICAL_S1_KEYWORD, BINOP_END }, 2211130803Smarcel { "logical_2", LOGICAL_S2_KEYWORD, BINOP_END }, 2212130803Smarcel { "complex_8", COMPLEX_S8_KEYWORD, BINOP_END }, 2213130803Smarcel { "integer", INT_KEYWORD, BINOP_END }, 2214130803Smarcel { "logical", LOGICAL_KEYWORD, BINOP_END }, 2215130803Smarcel { "real_16", REAL_S16_KEYWORD, BINOP_END }, 2216130803Smarcel { "complex", COMPLEX_S8_KEYWORD, BINOP_END }, 2217130803Smarcel { "sizeof", SIZEOF, BINOP_END }, 2218130803Smarcel { "real_8", REAL_S8_KEYWORD, BINOP_END }, 2219130803Smarcel { "real", REAL_KEYWORD, BINOP_END }, 2220130803Smarcel { NULL, 0, 0 } 2221130803Smarcel}; 2222130803Smarcel 2223130803Smarcel/* Implementation of a dynamically expandable buffer for processing input 2224130803Smarcel characters acquired through lexptr and building a value to return in 2225130803Smarcel yylval. Ripped off from ch-exp.y */ 2226130803Smarcel 2227130803Smarcelstatic char *tempbuf; /* Current buffer contents */ 2228130803Smarcelstatic int tempbufsize; /* Size of allocated buffer */ 2229130803Smarcelstatic int tempbufindex; /* Current index into buffer */ 2230130803Smarcel 2231130803Smarcel#define GROWBY_MIN_SIZE 64 /* Minimum amount to grow buffer by */ 2232130803Smarcel 2233130803Smarcel#define CHECKBUF(size) \ 2234130803Smarcel do { \ 2235130803Smarcel if (tempbufindex + (size) >= tempbufsize) \ 2236130803Smarcel { \ 2237130803Smarcel growbuf_by_size (size); \ 2238130803Smarcel } \ 2239130803Smarcel } while (0); 2240130803Smarcel 2241130803Smarcel 2242130803Smarcel/* Grow the static temp buffer if necessary, including allocating the first one 2243130803Smarcel on demand. */ 2244130803Smarcel 2245130803Smarcelstatic void 2246130803Smarcelgrowbuf_by_size (count) 2247130803Smarcel int count; 2248130803Smarcel{ 2249130803Smarcel int growby; 2250130803Smarcel 2251130803Smarcel growby = max (count, GROWBY_MIN_SIZE); 2252130803Smarcel tempbufsize += growby; 2253130803Smarcel if (tempbuf == NULL) 2254130803Smarcel tempbuf = (char *) xmalloc (tempbufsize); 2255130803Smarcel else 2256130803Smarcel tempbuf = (char *) xrealloc (tempbuf, tempbufsize); 2257130803Smarcel} 2258130803Smarcel 2259130803Smarcel/* Blatantly ripped off from ch-exp.y. This routine recognizes F77 2260130803Smarcel string-literals. 2261130803Smarcel 2262130803Smarcel Recognize a string literal. A string literal is a nonzero sequence 2263130803Smarcel of characters enclosed in matching single quotes, except that 2264130803Smarcel a single character inside single quotes is a character literal, which 2265130803Smarcel we reject as a string literal. To embed the terminator character inside 2266130803Smarcel a string, it is simply doubled (I.E. 'this''is''one''string') */ 2267130803Smarcel 2268130803Smarcelstatic int 2269130803Smarcelmatch_string_literal () 2270130803Smarcel{ 2271130803Smarcel char *tokptr = lexptr; 2272130803Smarcel 2273130803Smarcel for (tempbufindex = 0, tokptr++; *tokptr != '\0'; tokptr++) 2274130803Smarcel { 2275130803Smarcel CHECKBUF (1); 2276130803Smarcel if (*tokptr == *lexptr) 2277130803Smarcel { 2278130803Smarcel if (*(tokptr + 1) == *lexptr) 2279130803Smarcel tokptr++; 2280130803Smarcel else 2281130803Smarcel break; 2282130803Smarcel } 2283130803Smarcel tempbuf[tempbufindex++] = *tokptr; 2284130803Smarcel } 2285130803Smarcel if (*tokptr == '\0' /* no terminator */ 2286130803Smarcel || tempbufindex == 0) /* no string */ 2287130803Smarcel return 0; 2288130803Smarcel else 2289130803Smarcel { 2290130803Smarcel tempbuf[tempbufindex] = '\0'; 2291130803Smarcel yylval.sval.ptr = tempbuf; 2292130803Smarcel yylval.sval.length = tempbufindex; 2293130803Smarcel lexptr = ++tokptr; 2294130803Smarcel return STRING_LITERAL; 2295130803Smarcel } 2296130803Smarcel} 2297130803Smarcel 2298130803Smarcel/* Read one token, getting characters through lexptr. */ 2299130803Smarcel 2300130803Smarcelstatic int 2301130803Smarcelyylex () 2302130803Smarcel{ 2303130803Smarcel int c; 2304130803Smarcel int namelen; 2305130803Smarcel unsigned int i,token; 2306130803Smarcel char *tokstart; 2307130803Smarcel 2308130803Smarcel retry: 2309130803Smarcel 2310130803Smarcel prev_lexptr = lexptr; 2311130803Smarcel 2312130803Smarcel tokstart = lexptr; 2313130803Smarcel 2314130803Smarcel /* First of all, let us make sure we are not dealing with the 2315130803Smarcel special tokens .true. and .false. which evaluate to 1 and 0. */ 2316130803Smarcel 2317130803Smarcel if (*lexptr == '.') 2318130803Smarcel { 2319130803Smarcel for (i = 0; boolean_values[i].name != NULL; i++) 2320130803Smarcel { 2321130803Smarcel if (strncmp (tokstart, boolean_values[i].name, 2322130803Smarcel strlen (boolean_values[i].name)) == 0) 2323130803Smarcel { 2324130803Smarcel lexptr += strlen (boolean_values[i].name); 2325130803Smarcel yylval.lval = boolean_values[i].value; 2326130803Smarcel return BOOLEAN_LITERAL; 2327130803Smarcel } 2328130803Smarcel } 2329130803Smarcel } 2330130803Smarcel 2331130803Smarcel /* See if it is a special .foo. operator */ 2332130803Smarcel 2333130803Smarcel for (i = 0; dot_ops[i].operator != NULL; i++) 2334130803Smarcel if (strncmp (tokstart, dot_ops[i].operator, strlen (dot_ops[i].operator)) == 0) 2335130803Smarcel { 2336130803Smarcel lexptr += strlen (dot_ops[i].operator); 2337130803Smarcel yylval.opcode = dot_ops[i].opcode; 2338130803Smarcel return dot_ops[i].token; 2339130803Smarcel } 2340130803Smarcel 2341130803Smarcel switch (c = *tokstart) 2342130803Smarcel { 2343130803Smarcel case 0: 2344130803Smarcel return 0; 2345130803Smarcel 2346130803Smarcel case ' ': 2347130803Smarcel case '\t': 2348130803Smarcel case '\n': 2349130803Smarcel lexptr++; 2350130803Smarcel goto retry; 2351130803Smarcel 2352130803Smarcel case '\'': 2353130803Smarcel token = match_string_literal (); 2354130803Smarcel if (token != 0) 2355130803Smarcel return (token); 2356130803Smarcel break; 2357130803Smarcel 2358130803Smarcel case '(': 2359130803Smarcel paren_depth++; 2360130803Smarcel lexptr++; 2361130803Smarcel return c; 2362130803Smarcel 2363130803Smarcel case ')': 2364130803Smarcel if (paren_depth == 0) 2365130803Smarcel return 0; 2366130803Smarcel paren_depth--; 2367130803Smarcel lexptr++; 2368130803Smarcel return c; 2369130803Smarcel 2370130803Smarcel case ',': 2371130803Smarcel if (comma_terminates && paren_depth == 0) 2372130803Smarcel return 0; 2373130803Smarcel lexptr++; 2374130803Smarcel return c; 2375130803Smarcel 2376130803Smarcel case '.': 2377130803Smarcel /* Might be a floating point number. */ 2378130803Smarcel if (lexptr[1] < '0' || lexptr[1] > '9') 2379130803Smarcel goto symbol; /* Nope, must be a symbol. */ 2380130803Smarcel /* FALL THRU into number case. */ 2381130803Smarcel 2382130803Smarcel case '0': 2383130803Smarcel case '1': 2384130803Smarcel case '2': 2385130803Smarcel case '3': 2386130803Smarcel case '4': 2387130803Smarcel case '5': 2388130803Smarcel case '6': 2389130803Smarcel case '7': 2390130803Smarcel case '8': 2391130803Smarcel case '9': 2392130803Smarcel { 2393130803Smarcel /* It's a number. */ 2394130803Smarcel int got_dot = 0, got_e = 0, got_d = 0, toktype; 2395130803Smarcel char *p = tokstart; 2396130803Smarcel int hex = input_radix > 10; 2397130803Smarcel 2398130803Smarcel if (c == '0' && (p[1] == 'x' || p[1] == 'X')) 2399130803Smarcel { 2400130803Smarcel p += 2; 2401130803Smarcel hex = 1; 2402130803Smarcel } 2403130803Smarcel else if (c == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D')) 2404130803Smarcel { 2405130803Smarcel p += 2; 2406130803Smarcel hex = 0; 2407130803Smarcel } 2408130803Smarcel 2409130803Smarcel for (;; ++p) 2410130803Smarcel { 2411130803Smarcel if (!hex && !got_e && (*p == 'e' || *p == 'E')) 2412130803Smarcel got_dot = got_e = 1; 2413130803Smarcel else if (!hex && !got_d && (*p == 'd' || *p == 'D')) 2414130803Smarcel got_dot = got_d = 1; 2415130803Smarcel else if (!hex && !got_dot && *p == '.') 2416130803Smarcel got_dot = 1; 2417130803Smarcel else if (((got_e && (p[-1] == 'e' || p[-1] == 'E')) 2418130803Smarcel || (got_d && (p[-1] == 'd' || p[-1] == 'D'))) 2419130803Smarcel && (*p == '-' || *p == '+')) 2420130803Smarcel /* This is the sign of the exponent, not the end of the 2421130803Smarcel number. */ 2422130803Smarcel continue; 2423130803Smarcel /* We will take any letters or digits. parse_number will 2424130803Smarcel complain if past the radix, or if L or U are not final. */ 2425130803Smarcel else if ((*p < '0' || *p > '9') 2426130803Smarcel && ((*p < 'a' || *p > 'z') 2427130803Smarcel && (*p < 'A' || *p > 'Z'))) 2428130803Smarcel break; 2429130803Smarcel } 2430130803Smarcel toktype = parse_number (tokstart, p - tokstart, got_dot|got_e|got_d, 2431130803Smarcel &yylval); 2432130803Smarcel if (toktype == ERROR) 2433130803Smarcel { 2434130803Smarcel char *err_copy = (char *) alloca (p - tokstart + 1); 2435130803Smarcel 2436130803Smarcel memcpy (err_copy, tokstart, p - tokstart); 2437130803Smarcel err_copy[p - tokstart] = 0; 2438130803Smarcel error ("Invalid number \"%s\".", err_copy); 2439130803Smarcel } 2440130803Smarcel lexptr = p; 2441130803Smarcel return toktype; 2442130803Smarcel } 2443130803Smarcel 2444130803Smarcel case '+': 2445130803Smarcel case '-': 2446130803Smarcel case '*': 2447130803Smarcel case '/': 2448130803Smarcel case '%': 2449130803Smarcel case '|': 2450130803Smarcel case '&': 2451130803Smarcel case '^': 2452130803Smarcel case '~': 2453130803Smarcel case '!': 2454130803Smarcel case '@': 2455130803Smarcel case '<': 2456130803Smarcel case '>': 2457130803Smarcel case '[': 2458130803Smarcel case ']': 2459130803Smarcel case '?': 2460130803Smarcel case ':': 2461130803Smarcel case '=': 2462130803Smarcel case '{': 2463130803Smarcel case '}': 2464130803Smarcel symbol: 2465130803Smarcel lexptr++; 2466130803Smarcel return c; 2467130803Smarcel } 2468130803Smarcel 2469130803Smarcel if (!(c == '_' || c == '$' 2470130803Smarcel || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))) 2471130803Smarcel /* We must have come across a bad character (e.g. ';'). */ 2472130803Smarcel error ("Invalid character '%c' in expression.", c); 2473130803Smarcel 2474130803Smarcel namelen = 0; 2475130803Smarcel for (c = tokstart[namelen]; 2476130803Smarcel (c == '_' || c == '$' || (c >= '0' && c <= '9') 2477130803Smarcel || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); 2478130803Smarcel c = tokstart[++namelen]); 2479130803Smarcel 2480130803Smarcel /* The token "if" terminates the expression and is NOT 2481130803Smarcel removed from the input stream. */ 2482130803Smarcel 2483130803Smarcel if (namelen == 2 && tokstart[0] == 'i' && tokstart[1] == 'f') 2484130803Smarcel return 0; 2485130803Smarcel 2486130803Smarcel lexptr += namelen; 2487130803Smarcel 2488130803Smarcel /* Catch specific keywords. */ 2489130803Smarcel 2490130803Smarcel for (i = 0; f77_keywords[i].operator != NULL; i++) 2491130803Smarcel if (strncmp (tokstart, f77_keywords[i].operator, 2492130803Smarcel strlen(f77_keywords[i].operator)) == 0) 2493130803Smarcel { 2494130803Smarcel /* lexptr += strlen(f77_keywords[i].operator); */ 2495130803Smarcel yylval.opcode = f77_keywords[i].opcode; 2496130803Smarcel return f77_keywords[i].token; 2497130803Smarcel } 2498130803Smarcel 2499130803Smarcel yylval.sval.ptr = tokstart; 2500130803Smarcel yylval.sval.length = namelen; 2501130803Smarcel 2502130803Smarcel if (*tokstart == '$') 2503130803Smarcel { 2504130803Smarcel write_dollar_variable (yylval.sval); 2505130803Smarcel return VARIABLE; 2506130803Smarcel } 2507130803Smarcel 2508130803Smarcel /* Use token-type TYPENAME for symbols that happen to be defined 2509130803Smarcel currently as names of types; NAME for other symbols. 2510130803Smarcel The caller is not constrained to care about the distinction. */ 2511130803Smarcel { 2512130803Smarcel char *tmp = copy_name (yylval.sval); 2513130803Smarcel struct symbol *sym; 2514130803Smarcel int is_a_field_of_this = 0; 2515130803Smarcel int hextype; 2516130803Smarcel 2517130803Smarcel sym = lookup_symbol (tmp, expression_context_block, 2518130803Smarcel VAR_DOMAIN, 2519130803Smarcel current_language->la_language == language_cplus 2520130803Smarcel ? &is_a_field_of_this : NULL, 2521130803Smarcel NULL); 2522130803Smarcel if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF) 2523130803Smarcel { 2524130803Smarcel yylval.tsym.type = SYMBOL_TYPE (sym); 2525130803Smarcel return TYPENAME; 2526130803Smarcel } 2527130803Smarcel if ((yylval.tsym.type = lookup_primitive_typename (tmp)) != 0) 2528130803Smarcel return TYPENAME; 2529130803Smarcel 2530130803Smarcel /* Input names that aren't symbols but ARE valid hex numbers, 2531130803Smarcel when the input radix permits them, can be names or numbers 2532130803Smarcel depending on the parse. Note we support radixes > 16 here. */ 2533130803Smarcel if (!sym 2534130803Smarcel && ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10) 2535130803Smarcel || (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10))) 2536130803Smarcel { 2537130803Smarcel YYSTYPE newlval; /* Its value is ignored. */ 2538130803Smarcel hextype = parse_number (tokstart, namelen, 0, &newlval); 2539130803Smarcel if (hextype == INT) 2540130803Smarcel { 2541130803Smarcel yylval.ssym.sym = sym; 2542130803Smarcel yylval.ssym.is_a_field_of_this = is_a_field_of_this; 2543130803Smarcel return NAME_OR_INT; 2544130803Smarcel } 2545130803Smarcel } 2546130803Smarcel 2547130803Smarcel /* Any other kind of symbol */ 2548130803Smarcel yylval.ssym.sym = sym; 2549130803Smarcel yylval.ssym.is_a_field_of_this = is_a_field_of_this; 2550130803Smarcel return NAME; 2551130803Smarcel } 2552130803Smarcel} 2553130803Smarcel 2554130803Smarcelvoid 2555130803Smarcelyyerror (msg) 2556130803Smarcel char *msg; 2557130803Smarcel{ 2558130803Smarcel if (prev_lexptr) 2559130803Smarcel lexptr = prev_lexptr; 2560130803Smarcel 2561130803Smarcel error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr); 2562130803Smarcel} 2563130803Smarcel 2564130803Smarcel 2565