15796c8dcSSimon Schubert /* YACC parser for Ada expressions, for GDB. 25796c8dcSSimon Schubert Copyright (C) 1986, 1989, 1990, 1991, 1993, 1994, 1997, 2000, 2003, 2004, 3*cf7f2e2dSJohn Marino 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 45796c8dcSSimon Schubert 55796c8dcSSimon Schubert This file is part of GDB. 65796c8dcSSimon Schubert 75796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify 85796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by 95796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or 105796c8dcSSimon Schubert (at your option) any later version. 115796c8dcSSimon Schubert 125796c8dcSSimon Schubert This program is distributed in the hope that it will be useful, 135796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of 145796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 155796c8dcSSimon Schubert GNU General Public License for more details. 165796c8dcSSimon Schubert 175796c8dcSSimon Schubert You should have received a copy of the GNU General Public License 185796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */ 195796c8dcSSimon Schubert 205796c8dcSSimon Schubert /* Parse an Ada expression from text in a string, 215796c8dcSSimon Schubert and return the result as a struct expression pointer. 225796c8dcSSimon Schubert That structure contains arithmetic operations in reverse polish, 235796c8dcSSimon Schubert with constants represented by operations that are followed by special data. 245796c8dcSSimon Schubert See expression.h for the details of the format. 255796c8dcSSimon Schubert What is important here is that it can be built up sequentially 265796c8dcSSimon Schubert during the process of parsing; the lower levels of the tree always 275796c8dcSSimon Schubert come first in the result. 285796c8dcSSimon Schubert 295796c8dcSSimon Schubert malloc's and realloc's in this file are transformed to 305796c8dcSSimon Schubert xmalloc and xrealloc respectively by the same sed command in the 315796c8dcSSimon Schubert makefile that remaps any other malloc/realloc inserted by the parser 325796c8dcSSimon Schubert generator. Doing this with #defines and trying to control the interaction 335796c8dcSSimon Schubert with include files (<malloc.h> and <stdlib.h> for example) just became 345796c8dcSSimon Schubert too messy, particularly when such includes can be inserted at random 355796c8dcSSimon Schubert times by the parser generator. */ 365796c8dcSSimon Schubert 375796c8dcSSimon Schubert %{ 385796c8dcSSimon Schubert 395796c8dcSSimon Schubert #include "defs.h" 405796c8dcSSimon Schubert #include "gdb_string.h" 415796c8dcSSimon Schubert #include <ctype.h> 425796c8dcSSimon Schubert #include "expression.h" 435796c8dcSSimon Schubert #include "value.h" 445796c8dcSSimon Schubert #include "parser-defs.h" 455796c8dcSSimon Schubert #include "language.h" 465796c8dcSSimon Schubert #include "ada-lang.h" 475796c8dcSSimon Schubert #include "bfd.h" /* Required by objfiles.h. */ 485796c8dcSSimon Schubert #include "symfile.h" /* Required by objfiles.h. */ 495796c8dcSSimon Schubert #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */ 505796c8dcSSimon Schubert #include "frame.h" 515796c8dcSSimon Schubert #include "block.h" 525796c8dcSSimon Schubert 535796c8dcSSimon Schubert #define parse_type builtin_type (parse_gdbarch) 545796c8dcSSimon Schubert 555796c8dcSSimon Schubert /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), 565796c8dcSSimon Schubert as well as gratuitiously global symbol names, so we can have multiple 575796c8dcSSimon Schubert yacc generated parsers in gdb. These are only the variables 585796c8dcSSimon Schubert produced by yacc. If other parser generators (bison, byacc, etc) produce 595796c8dcSSimon Schubert additional global names that conflict at link time, then those parser 605796c8dcSSimon Schubert generators need to be fixed instead of adding those names to this list. */ 615796c8dcSSimon Schubert 625796c8dcSSimon Schubert /* NOTE: This is clumsy, especially since BISON and FLEX provide --prefix 635796c8dcSSimon Schubert options. I presume we are maintaining it to accommodate systems 645796c8dcSSimon Schubert without BISON? (PNH) */ 655796c8dcSSimon Schubert 665796c8dcSSimon Schubert #define yymaxdepth ada_maxdepth 675796c8dcSSimon Schubert #define yyparse _ada_parse /* ada_parse calls this after initialization */ 685796c8dcSSimon Schubert #define yylex ada_lex 695796c8dcSSimon Schubert #define yyerror ada_error 705796c8dcSSimon Schubert #define yylval ada_lval 715796c8dcSSimon Schubert #define yychar ada_char 725796c8dcSSimon Schubert #define yydebug ada_debug 735796c8dcSSimon Schubert #define yypact ada_pact 745796c8dcSSimon Schubert #define yyr1 ada_r1 755796c8dcSSimon Schubert #define yyr2 ada_r2 765796c8dcSSimon Schubert #define yydef ada_def 775796c8dcSSimon Schubert #define yychk ada_chk 785796c8dcSSimon Schubert #define yypgo ada_pgo 795796c8dcSSimon Schubert #define yyact ada_act 805796c8dcSSimon Schubert #define yyexca ada_exca 815796c8dcSSimon Schubert #define yyerrflag ada_errflag 825796c8dcSSimon Schubert #define yynerrs ada_nerrs 835796c8dcSSimon Schubert #define yyps ada_ps 845796c8dcSSimon Schubert #define yypv ada_pv 855796c8dcSSimon Schubert #define yys ada_s 865796c8dcSSimon Schubert #define yy_yys ada_yys 875796c8dcSSimon Schubert #define yystate ada_state 885796c8dcSSimon Schubert #define yytmp ada_tmp 895796c8dcSSimon Schubert #define yyv ada_v 905796c8dcSSimon Schubert #define yy_yyv ada_yyv 915796c8dcSSimon Schubert #define yyval ada_val 925796c8dcSSimon Schubert #define yylloc ada_lloc 935796c8dcSSimon Schubert #define yyreds ada_reds /* With YYDEBUG defined */ 945796c8dcSSimon Schubert #define yytoks ada_toks /* With YYDEBUG defined */ 955796c8dcSSimon Schubert #define yyname ada_name /* With YYDEBUG defined */ 965796c8dcSSimon Schubert #define yyrule ada_rule /* With YYDEBUG defined */ 975796c8dcSSimon Schubert 985796c8dcSSimon Schubert #ifndef YYDEBUG 995796c8dcSSimon Schubert #define YYDEBUG 1 /* Default to yydebug support */ 1005796c8dcSSimon Schubert #endif 1015796c8dcSSimon Schubert 1025796c8dcSSimon Schubert #define YYFPRINTF parser_fprintf 1035796c8dcSSimon Schubert 1045796c8dcSSimon Schubert struct name_info { 1055796c8dcSSimon Schubert struct symbol *sym; 1065796c8dcSSimon Schubert struct minimal_symbol *msym; 1075796c8dcSSimon Schubert struct block *block; 1085796c8dcSSimon Schubert struct stoken stoken; 1095796c8dcSSimon Schubert }; 1105796c8dcSSimon Schubert 1115796c8dcSSimon Schubert static struct stoken empty_stoken = { "", 0 }; 1125796c8dcSSimon Schubert 1135796c8dcSSimon Schubert /* If expression is in the context of TYPE'(...), then TYPE, else 1145796c8dcSSimon Schubert * NULL. */ 1155796c8dcSSimon Schubert static struct type *type_qualifier; 1165796c8dcSSimon Schubert 1175796c8dcSSimon Schubert int yyparse (void); 1185796c8dcSSimon Schubert 1195796c8dcSSimon Schubert static int yylex (void); 1205796c8dcSSimon Schubert 1215796c8dcSSimon Schubert void yyerror (char *); 1225796c8dcSSimon Schubert 1235796c8dcSSimon Schubert static struct stoken string_to_operator (struct stoken); 1245796c8dcSSimon Schubert 1255796c8dcSSimon Schubert static void write_int (LONGEST, struct type *); 1265796c8dcSSimon Schubert 1275796c8dcSSimon Schubert static void write_object_renaming (struct block *, const char *, int, 1285796c8dcSSimon Schubert const char *, int); 1295796c8dcSSimon Schubert 1305796c8dcSSimon Schubert static struct type* write_var_or_type (struct block *, struct stoken); 1315796c8dcSSimon Schubert 1325796c8dcSSimon Schubert static void write_name_assoc (struct stoken); 1335796c8dcSSimon Schubert 1345796c8dcSSimon Schubert static void write_exp_op_with_string (enum exp_opcode, struct stoken); 1355796c8dcSSimon Schubert 1365796c8dcSSimon Schubert static struct block *block_lookup (struct block *, char *); 1375796c8dcSSimon Schubert 1385796c8dcSSimon Schubert static LONGEST convert_char_literal (struct type *, LONGEST); 1395796c8dcSSimon Schubert 1405796c8dcSSimon Schubert static void write_ambiguous_var (struct block *, char *, int); 1415796c8dcSSimon Schubert 1425796c8dcSSimon Schubert static struct type *type_int (void); 1435796c8dcSSimon Schubert 1445796c8dcSSimon Schubert static struct type *type_long (void); 1455796c8dcSSimon Schubert 1465796c8dcSSimon Schubert static struct type *type_long_long (void); 1475796c8dcSSimon Schubert 1485796c8dcSSimon Schubert static struct type *type_float (void); 1495796c8dcSSimon Schubert 1505796c8dcSSimon Schubert static struct type *type_double (void); 1515796c8dcSSimon Schubert 1525796c8dcSSimon Schubert static struct type *type_long_double (void); 1535796c8dcSSimon Schubert 1545796c8dcSSimon Schubert static struct type *type_char (void); 1555796c8dcSSimon Schubert 1565796c8dcSSimon Schubert static struct type *type_boolean (void); 1575796c8dcSSimon Schubert 1585796c8dcSSimon Schubert static struct type *type_system_address (void); 1595796c8dcSSimon Schubert 1605796c8dcSSimon Schubert %} 1615796c8dcSSimon Schubert 1625796c8dcSSimon Schubert %union 1635796c8dcSSimon Schubert { 1645796c8dcSSimon Schubert LONGEST lval; 1655796c8dcSSimon Schubert struct { 1665796c8dcSSimon Schubert LONGEST val; 1675796c8dcSSimon Schubert struct type *type; 1685796c8dcSSimon Schubert } typed_val; 1695796c8dcSSimon Schubert struct { 1705796c8dcSSimon Schubert DOUBLEST dval; 1715796c8dcSSimon Schubert struct type *type; 1725796c8dcSSimon Schubert } typed_val_float; 1735796c8dcSSimon Schubert struct type *tval; 1745796c8dcSSimon Schubert struct stoken sval; 1755796c8dcSSimon Schubert struct block *bval; 1765796c8dcSSimon Schubert struct internalvar *ivar; 1775796c8dcSSimon Schubert } 1785796c8dcSSimon Schubert 1795796c8dcSSimon Schubert %type <lval> positional_list component_groups component_associations 1805796c8dcSSimon Schubert %type <lval> aggregate_component_list 1815796c8dcSSimon Schubert %type <tval> var_or_type 1825796c8dcSSimon Schubert 1835796c8dcSSimon Schubert %token <typed_val> INT NULL_PTR CHARLIT 1845796c8dcSSimon Schubert %token <typed_val_float> FLOAT 1855796c8dcSSimon Schubert %token TRUEKEYWORD FALSEKEYWORD 1865796c8dcSSimon Schubert %token COLONCOLON 1875796c8dcSSimon Schubert %token <sval> STRING NAME DOT_ID 1885796c8dcSSimon Schubert %type <bval> block 1895796c8dcSSimon Schubert %type <lval> arglist tick_arglist 1905796c8dcSSimon Schubert 1915796c8dcSSimon Schubert %type <tval> save_qualifier 1925796c8dcSSimon Schubert 1935796c8dcSSimon Schubert %token DOT_ALL 1945796c8dcSSimon Schubert 1955796c8dcSSimon Schubert /* Special type cases, put in to allow the parser to distinguish different 1965796c8dcSSimon Schubert legal basetypes. */ 1975796c8dcSSimon Schubert %token <sval> SPECIAL_VARIABLE 1985796c8dcSSimon Schubert 1995796c8dcSSimon Schubert %nonassoc ASSIGN 2005796c8dcSSimon Schubert %left _AND_ OR XOR THEN ELSE 2015796c8dcSSimon Schubert %left '=' NOTEQUAL '<' '>' LEQ GEQ IN DOTDOT 2025796c8dcSSimon Schubert %left '@' 2035796c8dcSSimon Schubert %left '+' '-' '&' 2045796c8dcSSimon Schubert %left UNARY 2055796c8dcSSimon Schubert %left '*' '/' MOD REM 2065796c8dcSSimon Schubert %right STARSTAR ABS NOT 2075796c8dcSSimon Schubert 2085796c8dcSSimon Schubert /* Artificial token to give NAME => ... and NAME | priority over reducing 2095796c8dcSSimon Schubert NAME to <primary> and to give <primary>' priority over reducing <primary> 2105796c8dcSSimon Schubert to <simple_exp>. */ 2115796c8dcSSimon Schubert %nonassoc VAR 2125796c8dcSSimon Schubert 2135796c8dcSSimon Schubert %nonassoc ARROW '|' 2145796c8dcSSimon Schubert 2155796c8dcSSimon Schubert %right TICK_ACCESS TICK_ADDRESS TICK_FIRST TICK_LAST TICK_LENGTH 2165796c8dcSSimon Schubert %right TICK_MAX TICK_MIN TICK_MODULUS 2175796c8dcSSimon Schubert %right TICK_POS TICK_RANGE TICK_SIZE TICK_TAG TICK_VAL 2185796c8dcSSimon Schubert /* The following are right-associative only so that reductions at this 2195796c8dcSSimon Schubert precedence have lower precedence than '.' and '('. The syntax still 2205796c8dcSSimon Schubert forces a.b.c, e.g., to be LEFT-associated. */ 2215796c8dcSSimon Schubert %right '.' '(' '[' DOT_ID DOT_ALL 2225796c8dcSSimon Schubert 2235796c8dcSSimon Schubert %token NEW OTHERS 2245796c8dcSSimon Schubert 2255796c8dcSSimon Schubert 2265796c8dcSSimon Schubert %% 2275796c8dcSSimon Schubert 2285796c8dcSSimon Schubert start : exp1 2295796c8dcSSimon Schubert ; 2305796c8dcSSimon Schubert 2315796c8dcSSimon Schubert /* Expressions, including the sequencing operator. */ 2325796c8dcSSimon Schubert exp1 : exp 2335796c8dcSSimon Schubert | exp1 ';' exp 2345796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_COMMA); } 2355796c8dcSSimon Schubert | primary ASSIGN exp /* Extension for convenience */ 2365796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_ASSIGN); } 2375796c8dcSSimon Schubert ; 2385796c8dcSSimon Schubert 2395796c8dcSSimon Schubert /* Expressions, not including the sequencing operator. */ 2405796c8dcSSimon Schubert primary : primary DOT_ALL 2415796c8dcSSimon Schubert { write_exp_elt_opcode (UNOP_IND); } 2425796c8dcSSimon Schubert ; 2435796c8dcSSimon Schubert 2445796c8dcSSimon Schubert primary : primary DOT_ID 2455796c8dcSSimon Schubert { write_exp_op_with_string (STRUCTOP_STRUCT, $2); } 2465796c8dcSSimon Schubert ; 2475796c8dcSSimon Schubert 2485796c8dcSSimon Schubert primary : primary '(' arglist ')' 2495796c8dcSSimon Schubert { 2505796c8dcSSimon Schubert write_exp_elt_opcode (OP_FUNCALL); 2515796c8dcSSimon Schubert write_exp_elt_longcst ($3); 2525796c8dcSSimon Schubert write_exp_elt_opcode (OP_FUNCALL); 2535796c8dcSSimon Schubert } 2545796c8dcSSimon Schubert | var_or_type '(' arglist ')' 2555796c8dcSSimon Schubert { 2565796c8dcSSimon Schubert if ($1 != NULL) 2575796c8dcSSimon Schubert { 2585796c8dcSSimon Schubert if ($3 != 1) 2595796c8dcSSimon Schubert error (_("Invalid conversion")); 2605796c8dcSSimon Schubert write_exp_elt_opcode (UNOP_CAST); 2615796c8dcSSimon Schubert write_exp_elt_type ($1); 2625796c8dcSSimon Schubert write_exp_elt_opcode (UNOP_CAST); 2635796c8dcSSimon Schubert } 2645796c8dcSSimon Schubert else 2655796c8dcSSimon Schubert { 2665796c8dcSSimon Schubert write_exp_elt_opcode (OP_FUNCALL); 2675796c8dcSSimon Schubert write_exp_elt_longcst ($3); 2685796c8dcSSimon Schubert write_exp_elt_opcode (OP_FUNCALL); 2695796c8dcSSimon Schubert } 2705796c8dcSSimon Schubert } 2715796c8dcSSimon Schubert ; 2725796c8dcSSimon Schubert 2735796c8dcSSimon Schubert primary : var_or_type '\'' save_qualifier { type_qualifier = $1; } 2745796c8dcSSimon Schubert '(' exp ')' 2755796c8dcSSimon Schubert { 2765796c8dcSSimon Schubert if ($1 == NULL) 2775796c8dcSSimon Schubert error (_("Type required for qualification")); 2785796c8dcSSimon Schubert write_exp_elt_opcode (UNOP_QUAL); 2795796c8dcSSimon Schubert write_exp_elt_type ($1); 2805796c8dcSSimon Schubert write_exp_elt_opcode (UNOP_QUAL); 2815796c8dcSSimon Schubert type_qualifier = $3; 2825796c8dcSSimon Schubert } 2835796c8dcSSimon Schubert ; 2845796c8dcSSimon Schubert 2855796c8dcSSimon Schubert save_qualifier : { $$ = type_qualifier; } 2865796c8dcSSimon Schubert ; 2875796c8dcSSimon Schubert 2885796c8dcSSimon Schubert primary : 2895796c8dcSSimon Schubert primary '(' simple_exp DOTDOT simple_exp ')' 2905796c8dcSSimon Schubert { write_exp_elt_opcode (TERNOP_SLICE); } 2915796c8dcSSimon Schubert | var_or_type '(' simple_exp DOTDOT simple_exp ')' 2925796c8dcSSimon Schubert { if ($1 == NULL) 2935796c8dcSSimon Schubert write_exp_elt_opcode (TERNOP_SLICE); 2945796c8dcSSimon Schubert else 2955796c8dcSSimon Schubert error (_("Cannot slice a type")); 2965796c8dcSSimon Schubert } 2975796c8dcSSimon Schubert ; 2985796c8dcSSimon Schubert 2995796c8dcSSimon Schubert primary : '(' exp1 ')' { } 3005796c8dcSSimon Schubert ; 3015796c8dcSSimon Schubert 3025796c8dcSSimon Schubert /* The following rule causes a conflict with the type conversion 3035796c8dcSSimon Schubert var_or_type (exp) 3045796c8dcSSimon Schubert To get around it, we give '(' higher priority and add bridge rules for 3055796c8dcSSimon Schubert var_or_type (exp, exp, ...) 3065796c8dcSSimon Schubert var_or_type (exp .. exp) 3075796c8dcSSimon Schubert We also have the action for var_or_type(exp) generate a function call 3085796c8dcSSimon Schubert when the first symbol does not denote a type. */ 3095796c8dcSSimon Schubert 3105796c8dcSSimon Schubert primary : var_or_type %prec VAR 3115796c8dcSSimon Schubert { if ($1 != NULL) 3125796c8dcSSimon Schubert { 3135796c8dcSSimon Schubert write_exp_elt_opcode (OP_TYPE); 3145796c8dcSSimon Schubert write_exp_elt_type ($1); 3155796c8dcSSimon Schubert write_exp_elt_opcode (OP_TYPE); 3165796c8dcSSimon Schubert } 3175796c8dcSSimon Schubert } 3185796c8dcSSimon Schubert ; 3195796c8dcSSimon Schubert 3205796c8dcSSimon Schubert primary : SPECIAL_VARIABLE /* Various GDB extensions */ 3215796c8dcSSimon Schubert { write_dollar_variable ($1); } 3225796c8dcSSimon Schubert ; 3235796c8dcSSimon Schubert 3245796c8dcSSimon Schubert primary : aggregate 3255796c8dcSSimon Schubert ; 3265796c8dcSSimon Schubert 3275796c8dcSSimon Schubert simple_exp : primary 3285796c8dcSSimon Schubert ; 3295796c8dcSSimon Schubert 3305796c8dcSSimon Schubert simple_exp : '-' simple_exp %prec UNARY 3315796c8dcSSimon Schubert { write_exp_elt_opcode (UNOP_NEG); } 3325796c8dcSSimon Schubert ; 3335796c8dcSSimon Schubert 3345796c8dcSSimon Schubert simple_exp : '+' simple_exp %prec UNARY 3355796c8dcSSimon Schubert { write_exp_elt_opcode (UNOP_PLUS); } 3365796c8dcSSimon Schubert ; 3375796c8dcSSimon Schubert 3385796c8dcSSimon Schubert simple_exp : NOT simple_exp %prec UNARY 3395796c8dcSSimon Schubert { write_exp_elt_opcode (UNOP_LOGICAL_NOT); } 3405796c8dcSSimon Schubert ; 3415796c8dcSSimon Schubert 3425796c8dcSSimon Schubert simple_exp : ABS simple_exp %prec UNARY 3435796c8dcSSimon Schubert { write_exp_elt_opcode (UNOP_ABS); } 3445796c8dcSSimon Schubert ; 3455796c8dcSSimon Schubert 3465796c8dcSSimon Schubert arglist : { $$ = 0; } 3475796c8dcSSimon Schubert ; 3485796c8dcSSimon Schubert 3495796c8dcSSimon Schubert arglist : exp 3505796c8dcSSimon Schubert { $$ = 1; } 3515796c8dcSSimon Schubert | NAME ARROW exp 3525796c8dcSSimon Schubert { $$ = 1; } 3535796c8dcSSimon Schubert | arglist ',' exp 3545796c8dcSSimon Schubert { $$ = $1 + 1; } 3555796c8dcSSimon Schubert | arglist ',' NAME ARROW exp 3565796c8dcSSimon Schubert { $$ = $1 + 1; } 3575796c8dcSSimon Schubert ; 3585796c8dcSSimon Schubert 3595796c8dcSSimon Schubert primary : '{' var_or_type '}' primary %prec '.' 3605796c8dcSSimon Schubert /* GDB extension */ 3615796c8dcSSimon Schubert { 3625796c8dcSSimon Schubert if ($2 == NULL) 3635796c8dcSSimon Schubert error (_("Type required within braces in coercion")); 3645796c8dcSSimon Schubert write_exp_elt_opcode (UNOP_MEMVAL); 3655796c8dcSSimon Schubert write_exp_elt_type ($2); 3665796c8dcSSimon Schubert write_exp_elt_opcode (UNOP_MEMVAL); 3675796c8dcSSimon Schubert } 3685796c8dcSSimon Schubert ; 3695796c8dcSSimon Schubert 3705796c8dcSSimon Schubert /* Binary operators in order of decreasing precedence. */ 3715796c8dcSSimon Schubert 3725796c8dcSSimon Schubert simple_exp : simple_exp STARSTAR simple_exp 3735796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_EXP); } 3745796c8dcSSimon Schubert ; 3755796c8dcSSimon Schubert 3765796c8dcSSimon Schubert simple_exp : simple_exp '*' simple_exp 3775796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_MUL); } 3785796c8dcSSimon Schubert ; 3795796c8dcSSimon Schubert 3805796c8dcSSimon Schubert simple_exp : simple_exp '/' simple_exp 3815796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_DIV); } 3825796c8dcSSimon Schubert ; 3835796c8dcSSimon Schubert 3845796c8dcSSimon Schubert simple_exp : simple_exp REM simple_exp /* May need to be fixed to give correct Ada REM */ 3855796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_REM); } 3865796c8dcSSimon Schubert ; 3875796c8dcSSimon Schubert 3885796c8dcSSimon Schubert simple_exp : simple_exp MOD simple_exp 3895796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_MOD); } 3905796c8dcSSimon Schubert ; 3915796c8dcSSimon Schubert 3925796c8dcSSimon Schubert simple_exp : simple_exp '@' simple_exp /* GDB extension */ 3935796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_REPEAT); } 3945796c8dcSSimon Schubert ; 3955796c8dcSSimon Schubert 3965796c8dcSSimon Schubert simple_exp : simple_exp '+' simple_exp 3975796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_ADD); } 3985796c8dcSSimon Schubert ; 3995796c8dcSSimon Schubert 4005796c8dcSSimon Schubert simple_exp : simple_exp '&' simple_exp 4015796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_CONCAT); } 4025796c8dcSSimon Schubert ; 4035796c8dcSSimon Schubert 4045796c8dcSSimon Schubert simple_exp : simple_exp '-' simple_exp 4055796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_SUB); } 4065796c8dcSSimon Schubert ; 4075796c8dcSSimon Schubert 4085796c8dcSSimon Schubert relation : simple_exp 4095796c8dcSSimon Schubert ; 4105796c8dcSSimon Schubert 4115796c8dcSSimon Schubert relation : simple_exp '=' simple_exp 4125796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_EQUAL); } 4135796c8dcSSimon Schubert ; 4145796c8dcSSimon Schubert 4155796c8dcSSimon Schubert relation : simple_exp NOTEQUAL simple_exp 4165796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_NOTEQUAL); } 4175796c8dcSSimon Schubert ; 4185796c8dcSSimon Schubert 4195796c8dcSSimon Schubert relation : simple_exp LEQ simple_exp 4205796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_LEQ); } 4215796c8dcSSimon Schubert ; 4225796c8dcSSimon Schubert 4235796c8dcSSimon Schubert relation : simple_exp IN simple_exp DOTDOT simple_exp 4245796c8dcSSimon Schubert { write_exp_elt_opcode (TERNOP_IN_RANGE); } 4255796c8dcSSimon Schubert | simple_exp IN primary TICK_RANGE tick_arglist 4265796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_IN_BOUNDS); 4275796c8dcSSimon Schubert write_exp_elt_longcst ((LONGEST) $5); 4285796c8dcSSimon Schubert write_exp_elt_opcode (BINOP_IN_BOUNDS); 4295796c8dcSSimon Schubert } 4305796c8dcSSimon Schubert | simple_exp IN var_or_type %prec TICK_ACCESS 4315796c8dcSSimon Schubert { 4325796c8dcSSimon Schubert if ($3 == NULL) 4335796c8dcSSimon Schubert error (_("Right operand of 'in' must be type")); 4345796c8dcSSimon Schubert write_exp_elt_opcode (UNOP_IN_RANGE); 4355796c8dcSSimon Schubert write_exp_elt_type ($3); 4365796c8dcSSimon Schubert write_exp_elt_opcode (UNOP_IN_RANGE); 4375796c8dcSSimon Schubert } 4385796c8dcSSimon Schubert | simple_exp NOT IN simple_exp DOTDOT simple_exp 4395796c8dcSSimon Schubert { write_exp_elt_opcode (TERNOP_IN_RANGE); 4405796c8dcSSimon Schubert write_exp_elt_opcode (UNOP_LOGICAL_NOT); 4415796c8dcSSimon Schubert } 4425796c8dcSSimon Schubert | simple_exp NOT IN primary TICK_RANGE tick_arglist 4435796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_IN_BOUNDS); 4445796c8dcSSimon Schubert write_exp_elt_longcst ((LONGEST) $6); 4455796c8dcSSimon Schubert write_exp_elt_opcode (BINOP_IN_BOUNDS); 4465796c8dcSSimon Schubert write_exp_elt_opcode (UNOP_LOGICAL_NOT); 4475796c8dcSSimon Schubert } 4485796c8dcSSimon Schubert | simple_exp NOT IN var_or_type %prec TICK_ACCESS 4495796c8dcSSimon Schubert { 4505796c8dcSSimon Schubert if ($4 == NULL) 4515796c8dcSSimon Schubert error (_("Right operand of 'in' must be type")); 4525796c8dcSSimon Schubert write_exp_elt_opcode (UNOP_IN_RANGE); 4535796c8dcSSimon Schubert write_exp_elt_type ($4); 4545796c8dcSSimon Schubert write_exp_elt_opcode (UNOP_IN_RANGE); 4555796c8dcSSimon Schubert write_exp_elt_opcode (UNOP_LOGICAL_NOT); 4565796c8dcSSimon Schubert } 4575796c8dcSSimon Schubert ; 4585796c8dcSSimon Schubert 4595796c8dcSSimon Schubert relation : simple_exp GEQ simple_exp 4605796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_GEQ); } 4615796c8dcSSimon Schubert ; 4625796c8dcSSimon Schubert 4635796c8dcSSimon Schubert relation : simple_exp '<' simple_exp 4645796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_LESS); } 4655796c8dcSSimon Schubert ; 4665796c8dcSSimon Schubert 4675796c8dcSSimon Schubert relation : simple_exp '>' simple_exp 4685796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_GTR); } 4695796c8dcSSimon Schubert ; 4705796c8dcSSimon Schubert 4715796c8dcSSimon Schubert exp : relation 4725796c8dcSSimon Schubert | and_exp 4735796c8dcSSimon Schubert | and_then_exp 4745796c8dcSSimon Schubert | or_exp 4755796c8dcSSimon Schubert | or_else_exp 4765796c8dcSSimon Schubert | xor_exp 4775796c8dcSSimon Schubert ; 4785796c8dcSSimon Schubert 4795796c8dcSSimon Schubert and_exp : 4805796c8dcSSimon Schubert relation _AND_ relation 4815796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_BITWISE_AND); } 4825796c8dcSSimon Schubert | and_exp _AND_ relation 4835796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_BITWISE_AND); } 4845796c8dcSSimon Schubert ; 4855796c8dcSSimon Schubert 4865796c8dcSSimon Schubert and_then_exp : 4875796c8dcSSimon Schubert relation _AND_ THEN relation 4885796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_LOGICAL_AND); } 4895796c8dcSSimon Schubert | and_then_exp _AND_ THEN relation 4905796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_LOGICAL_AND); } 4915796c8dcSSimon Schubert ; 4925796c8dcSSimon Schubert 4935796c8dcSSimon Schubert or_exp : 4945796c8dcSSimon Schubert relation OR relation 4955796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_BITWISE_IOR); } 4965796c8dcSSimon Schubert | or_exp OR relation 4975796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_BITWISE_IOR); } 4985796c8dcSSimon Schubert ; 4995796c8dcSSimon Schubert 5005796c8dcSSimon Schubert or_else_exp : 5015796c8dcSSimon Schubert relation OR ELSE relation 5025796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_LOGICAL_OR); } 5035796c8dcSSimon Schubert | or_else_exp OR ELSE relation 5045796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_LOGICAL_OR); } 5055796c8dcSSimon Schubert ; 5065796c8dcSSimon Schubert 5075796c8dcSSimon Schubert xor_exp : relation XOR relation 5085796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_BITWISE_XOR); } 5095796c8dcSSimon Schubert | xor_exp XOR relation 5105796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_BITWISE_XOR); } 5115796c8dcSSimon Schubert ; 5125796c8dcSSimon Schubert 5135796c8dcSSimon Schubert /* Primaries can denote types (OP_TYPE). In cases such as 5145796c8dcSSimon Schubert primary TICK_ADDRESS, where a type would be invalid, it will be 5155796c8dcSSimon Schubert caught when evaluate_subexp in ada-lang.c tries to evaluate the 5165796c8dcSSimon Schubert primary, expecting a value. Precedence rules resolve the ambiguity 5175796c8dcSSimon Schubert in NAME TICK_ACCESS in favor of shifting to form a var_or_type. A 5185796c8dcSSimon Schubert construct such as aType'access'access will again cause an error when 5195796c8dcSSimon Schubert aType'access evaluates to a type that evaluate_subexp attempts to 5205796c8dcSSimon Schubert evaluate. */ 5215796c8dcSSimon Schubert primary : primary TICK_ACCESS 5225796c8dcSSimon Schubert { write_exp_elt_opcode (UNOP_ADDR); } 5235796c8dcSSimon Schubert | primary TICK_ADDRESS 5245796c8dcSSimon Schubert { write_exp_elt_opcode (UNOP_ADDR); 5255796c8dcSSimon Schubert write_exp_elt_opcode (UNOP_CAST); 5265796c8dcSSimon Schubert write_exp_elt_type (type_system_address ()); 5275796c8dcSSimon Schubert write_exp_elt_opcode (UNOP_CAST); 5285796c8dcSSimon Schubert } 5295796c8dcSSimon Schubert | primary TICK_FIRST tick_arglist 5305796c8dcSSimon Schubert { write_int ($3, type_int ()); 5315796c8dcSSimon Schubert write_exp_elt_opcode (OP_ATR_FIRST); } 5325796c8dcSSimon Schubert | primary TICK_LAST tick_arglist 5335796c8dcSSimon Schubert { write_int ($3, type_int ()); 5345796c8dcSSimon Schubert write_exp_elt_opcode (OP_ATR_LAST); } 5355796c8dcSSimon Schubert | primary TICK_LENGTH tick_arglist 5365796c8dcSSimon Schubert { write_int ($3, type_int ()); 5375796c8dcSSimon Schubert write_exp_elt_opcode (OP_ATR_LENGTH); } 5385796c8dcSSimon Schubert | primary TICK_SIZE 5395796c8dcSSimon Schubert { write_exp_elt_opcode (OP_ATR_SIZE); } 5405796c8dcSSimon Schubert | primary TICK_TAG 5415796c8dcSSimon Schubert { write_exp_elt_opcode (OP_ATR_TAG); } 5425796c8dcSSimon Schubert | opt_type_prefix TICK_MIN '(' exp ',' exp ')' 5435796c8dcSSimon Schubert { write_exp_elt_opcode (OP_ATR_MIN); } 5445796c8dcSSimon Schubert | opt_type_prefix TICK_MAX '(' exp ',' exp ')' 5455796c8dcSSimon Schubert { write_exp_elt_opcode (OP_ATR_MAX); } 5465796c8dcSSimon Schubert | opt_type_prefix TICK_POS '(' exp ')' 5475796c8dcSSimon Schubert { write_exp_elt_opcode (OP_ATR_POS); } 5485796c8dcSSimon Schubert | type_prefix TICK_VAL '(' exp ')' 5495796c8dcSSimon Schubert { write_exp_elt_opcode (OP_ATR_VAL); } 5505796c8dcSSimon Schubert | type_prefix TICK_MODULUS 5515796c8dcSSimon Schubert { write_exp_elt_opcode (OP_ATR_MODULUS); } 5525796c8dcSSimon Schubert ; 5535796c8dcSSimon Schubert 5545796c8dcSSimon Schubert tick_arglist : %prec '(' 5555796c8dcSSimon Schubert { $$ = 1; } 5565796c8dcSSimon Schubert | '(' INT ')' 5575796c8dcSSimon Schubert { $$ = $2.val; } 5585796c8dcSSimon Schubert ; 5595796c8dcSSimon Schubert 5605796c8dcSSimon Schubert type_prefix : 5615796c8dcSSimon Schubert var_or_type 5625796c8dcSSimon Schubert { 5635796c8dcSSimon Schubert if ($1 == NULL) 5645796c8dcSSimon Schubert error (_("Prefix must be type")); 5655796c8dcSSimon Schubert write_exp_elt_opcode (OP_TYPE); 5665796c8dcSSimon Schubert write_exp_elt_type ($1); 5675796c8dcSSimon Schubert write_exp_elt_opcode (OP_TYPE); } 5685796c8dcSSimon Schubert ; 5695796c8dcSSimon Schubert 5705796c8dcSSimon Schubert opt_type_prefix : 5715796c8dcSSimon Schubert type_prefix 5725796c8dcSSimon Schubert | /* EMPTY */ 5735796c8dcSSimon Schubert { write_exp_elt_opcode (OP_TYPE); 5745796c8dcSSimon Schubert write_exp_elt_type (parse_type->builtin_void); 5755796c8dcSSimon Schubert write_exp_elt_opcode (OP_TYPE); } 5765796c8dcSSimon Schubert ; 5775796c8dcSSimon Schubert 5785796c8dcSSimon Schubert 5795796c8dcSSimon Schubert primary : INT 5805796c8dcSSimon Schubert { write_int ((LONGEST) $1.val, $1.type); } 5815796c8dcSSimon Schubert ; 5825796c8dcSSimon Schubert 5835796c8dcSSimon Schubert primary : CHARLIT 5845796c8dcSSimon Schubert { write_int (convert_char_literal (type_qualifier, $1.val), 5855796c8dcSSimon Schubert (type_qualifier == NULL) 5865796c8dcSSimon Schubert ? $1.type : type_qualifier); 5875796c8dcSSimon Schubert } 5885796c8dcSSimon Schubert ; 5895796c8dcSSimon Schubert 5905796c8dcSSimon Schubert primary : FLOAT 5915796c8dcSSimon Schubert { write_exp_elt_opcode (OP_DOUBLE); 5925796c8dcSSimon Schubert write_exp_elt_type ($1.type); 5935796c8dcSSimon Schubert write_exp_elt_dblcst ($1.dval); 5945796c8dcSSimon Schubert write_exp_elt_opcode (OP_DOUBLE); 5955796c8dcSSimon Schubert } 5965796c8dcSSimon Schubert ; 5975796c8dcSSimon Schubert 5985796c8dcSSimon Schubert primary : NULL_PTR 5995796c8dcSSimon Schubert { write_int (0, type_int ()); } 6005796c8dcSSimon Schubert ; 6015796c8dcSSimon Schubert 6025796c8dcSSimon Schubert primary : STRING 6035796c8dcSSimon Schubert { 6045796c8dcSSimon Schubert write_exp_op_with_string (OP_STRING, $1); 6055796c8dcSSimon Schubert } 6065796c8dcSSimon Schubert ; 6075796c8dcSSimon Schubert 6085796c8dcSSimon Schubert primary : TRUEKEYWORD 6095796c8dcSSimon Schubert { write_int (1, type_boolean ()); } 6105796c8dcSSimon Schubert | FALSEKEYWORD 6115796c8dcSSimon Schubert { write_int (0, type_boolean ()); } 6125796c8dcSSimon Schubert ; 6135796c8dcSSimon Schubert 6145796c8dcSSimon Schubert primary : NEW NAME 6155796c8dcSSimon Schubert { error (_("NEW not implemented.")); } 6165796c8dcSSimon Schubert ; 6175796c8dcSSimon Schubert 6185796c8dcSSimon Schubert var_or_type: NAME %prec VAR 6195796c8dcSSimon Schubert { $$ = write_var_or_type (NULL, $1); } 6205796c8dcSSimon Schubert | block NAME %prec VAR 6215796c8dcSSimon Schubert { $$ = write_var_or_type ($1, $2); } 6225796c8dcSSimon Schubert | NAME TICK_ACCESS 6235796c8dcSSimon Schubert { 6245796c8dcSSimon Schubert $$ = write_var_or_type (NULL, $1); 6255796c8dcSSimon Schubert if ($$ == NULL) 6265796c8dcSSimon Schubert write_exp_elt_opcode (UNOP_ADDR); 6275796c8dcSSimon Schubert else 6285796c8dcSSimon Schubert $$ = lookup_pointer_type ($$); 6295796c8dcSSimon Schubert } 6305796c8dcSSimon Schubert | block NAME TICK_ACCESS 6315796c8dcSSimon Schubert { 6325796c8dcSSimon Schubert $$ = write_var_or_type ($1, $2); 6335796c8dcSSimon Schubert if ($$ == NULL) 6345796c8dcSSimon Schubert write_exp_elt_opcode (UNOP_ADDR); 6355796c8dcSSimon Schubert else 6365796c8dcSSimon Schubert $$ = lookup_pointer_type ($$); 6375796c8dcSSimon Schubert } 6385796c8dcSSimon Schubert ; 6395796c8dcSSimon Schubert 6405796c8dcSSimon Schubert /* GDB extension */ 6415796c8dcSSimon Schubert block : NAME COLONCOLON 6425796c8dcSSimon Schubert { $$ = block_lookup (NULL, $1.ptr); } 6435796c8dcSSimon Schubert | block NAME COLONCOLON 6445796c8dcSSimon Schubert { $$ = block_lookup ($1, $2.ptr); } 6455796c8dcSSimon Schubert ; 6465796c8dcSSimon Schubert 6475796c8dcSSimon Schubert aggregate : 6485796c8dcSSimon Schubert '(' aggregate_component_list ')' 6495796c8dcSSimon Schubert { 6505796c8dcSSimon Schubert write_exp_elt_opcode (OP_AGGREGATE); 6515796c8dcSSimon Schubert write_exp_elt_longcst ($2); 6525796c8dcSSimon Schubert write_exp_elt_opcode (OP_AGGREGATE); 6535796c8dcSSimon Schubert } 6545796c8dcSSimon Schubert ; 6555796c8dcSSimon Schubert 6565796c8dcSSimon Schubert aggregate_component_list : 6575796c8dcSSimon Schubert component_groups { $$ = $1; } 6585796c8dcSSimon Schubert | positional_list exp 6595796c8dcSSimon Schubert { write_exp_elt_opcode (OP_POSITIONAL); 6605796c8dcSSimon Schubert write_exp_elt_longcst ($1); 6615796c8dcSSimon Schubert write_exp_elt_opcode (OP_POSITIONAL); 6625796c8dcSSimon Schubert $$ = $1 + 1; 6635796c8dcSSimon Schubert } 6645796c8dcSSimon Schubert | positional_list component_groups 6655796c8dcSSimon Schubert { $$ = $1 + $2; } 6665796c8dcSSimon Schubert ; 6675796c8dcSSimon Schubert 6685796c8dcSSimon Schubert positional_list : 6695796c8dcSSimon Schubert exp ',' 6705796c8dcSSimon Schubert { write_exp_elt_opcode (OP_POSITIONAL); 6715796c8dcSSimon Schubert write_exp_elt_longcst (0); 6725796c8dcSSimon Schubert write_exp_elt_opcode (OP_POSITIONAL); 6735796c8dcSSimon Schubert $$ = 1; 6745796c8dcSSimon Schubert } 6755796c8dcSSimon Schubert | positional_list exp ',' 6765796c8dcSSimon Schubert { write_exp_elt_opcode (OP_POSITIONAL); 6775796c8dcSSimon Schubert write_exp_elt_longcst ($1); 6785796c8dcSSimon Schubert write_exp_elt_opcode (OP_POSITIONAL); 6795796c8dcSSimon Schubert $$ = $1 + 1; 6805796c8dcSSimon Schubert } 6815796c8dcSSimon Schubert ; 6825796c8dcSSimon Schubert 6835796c8dcSSimon Schubert component_groups: 6845796c8dcSSimon Schubert others { $$ = 1; } 6855796c8dcSSimon Schubert | component_group { $$ = 1; } 6865796c8dcSSimon Schubert | component_group ',' component_groups 6875796c8dcSSimon Schubert { $$ = $3 + 1; } 6885796c8dcSSimon Schubert ; 6895796c8dcSSimon Schubert 6905796c8dcSSimon Schubert others : OTHERS ARROW exp 6915796c8dcSSimon Schubert { write_exp_elt_opcode (OP_OTHERS); } 6925796c8dcSSimon Schubert ; 6935796c8dcSSimon Schubert 6945796c8dcSSimon Schubert component_group : 6955796c8dcSSimon Schubert component_associations 6965796c8dcSSimon Schubert { 6975796c8dcSSimon Schubert write_exp_elt_opcode (OP_CHOICES); 6985796c8dcSSimon Schubert write_exp_elt_longcst ($1); 6995796c8dcSSimon Schubert write_exp_elt_opcode (OP_CHOICES); 7005796c8dcSSimon Schubert } 7015796c8dcSSimon Schubert ; 7025796c8dcSSimon Schubert 7035796c8dcSSimon Schubert /* We use this somewhat obscure definition in order to handle NAME => and 7045796c8dcSSimon Schubert NAME | differently from exp => and exp |. ARROW and '|' have a precedence 7055796c8dcSSimon Schubert above that of the reduction of NAME to var_or_type. By delaying 7065796c8dcSSimon Schubert decisions until after the => or '|', we convert the ambiguity to a 7075796c8dcSSimon Schubert resolved shift/reduce conflict. */ 7085796c8dcSSimon Schubert component_associations : 7095796c8dcSSimon Schubert NAME ARROW 7105796c8dcSSimon Schubert { write_name_assoc ($1); } 7115796c8dcSSimon Schubert exp { $$ = 1; } 7125796c8dcSSimon Schubert | simple_exp ARROW exp 7135796c8dcSSimon Schubert { $$ = 1; } 7145796c8dcSSimon Schubert | simple_exp DOTDOT simple_exp ARROW 7155796c8dcSSimon Schubert { write_exp_elt_opcode (OP_DISCRETE_RANGE); 7165796c8dcSSimon Schubert write_exp_op_with_string (OP_NAME, empty_stoken); 7175796c8dcSSimon Schubert } 7185796c8dcSSimon Schubert exp { $$ = 1; } 7195796c8dcSSimon Schubert | NAME '|' 7205796c8dcSSimon Schubert { write_name_assoc ($1); } 7215796c8dcSSimon Schubert component_associations { $$ = $4 + 1; } 7225796c8dcSSimon Schubert | simple_exp '|' 7235796c8dcSSimon Schubert component_associations { $$ = $3 + 1; } 7245796c8dcSSimon Schubert | simple_exp DOTDOT simple_exp '|' 7255796c8dcSSimon Schubert { write_exp_elt_opcode (OP_DISCRETE_RANGE); } 7265796c8dcSSimon Schubert component_associations { $$ = $6 + 1; } 7275796c8dcSSimon Schubert ; 7285796c8dcSSimon Schubert 7295796c8dcSSimon Schubert /* Some extensions borrowed from C, for the benefit of those who find they 7305796c8dcSSimon Schubert can't get used to Ada notation in GDB. */ 7315796c8dcSSimon Schubert 7325796c8dcSSimon Schubert primary : '*' primary %prec '.' 7335796c8dcSSimon Schubert { write_exp_elt_opcode (UNOP_IND); } 7345796c8dcSSimon Schubert | '&' primary %prec '.' 7355796c8dcSSimon Schubert { write_exp_elt_opcode (UNOP_ADDR); } 7365796c8dcSSimon Schubert | primary '[' exp ']' 7375796c8dcSSimon Schubert { write_exp_elt_opcode (BINOP_SUBSCRIPT); } 7385796c8dcSSimon Schubert ; 7395796c8dcSSimon Schubert 7405796c8dcSSimon Schubert %% 7415796c8dcSSimon Schubert 7425796c8dcSSimon Schubert /* yylex defined in ada-lex.c: Reads one token, getting characters */ 7435796c8dcSSimon Schubert /* through lexptr. */ 7445796c8dcSSimon Schubert 7455796c8dcSSimon Schubert /* Remap normal flex interface names (yylex) as well as gratuitiously */ 7465796c8dcSSimon Schubert /* global symbol names, so we can have multiple flex-generated parsers */ 7475796c8dcSSimon Schubert /* in gdb. */ 7485796c8dcSSimon Schubert 7495796c8dcSSimon Schubert /* (See note above on previous definitions for YACC.) */ 7505796c8dcSSimon Schubert 7515796c8dcSSimon Schubert #define yy_create_buffer ada_yy_create_buffer 7525796c8dcSSimon Schubert #define yy_delete_buffer ada_yy_delete_buffer 7535796c8dcSSimon Schubert #define yy_init_buffer ada_yy_init_buffer 7545796c8dcSSimon Schubert #define yy_load_buffer_state ada_yy_load_buffer_state 7555796c8dcSSimon Schubert #define yy_switch_to_buffer ada_yy_switch_to_buffer 7565796c8dcSSimon Schubert #define yyrestart ada_yyrestart 7575796c8dcSSimon Schubert #define yytext ada_yytext 7585796c8dcSSimon Schubert #define yywrap ada_yywrap 7595796c8dcSSimon Schubert 7605796c8dcSSimon Schubert static struct obstack temp_parse_space; 7615796c8dcSSimon Schubert 7625796c8dcSSimon Schubert /* The following kludge was found necessary to prevent conflicts between */ 7635796c8dcSSimon Schubert /* defs.h and non-standard stdlib.h files. */ 7645796c8dcSSimon Schubert #define qsort __qsort__dummy 7655796c8dcSSimon Schubert #include "ada-lex.c" 7665796c8dcSSimon Schubert 7675796c8dcSSimon Schubert int 7685796c8dcSSimon Schubert ada_parse (void) 7695796c8dcSSimon Schubert { 7705796c8dcSSimon Schubert lexer_init (yyin); /* (Re-)initialize lexer. */ 7715796c8dcSSimon Schubert type_qualifier = NULL; 7725796c8dcSSimon Schubert obstack_free (&temp_parse_space, NULL); 7735796c8dcSSimon Schubert obstack_init (&temp_parse_space); 7745796c8dcSSimon Schubert 7755796c8dcSSimon Schubert return _ada_parse (); 7765796c8dcSSimon Schubert } 7775796c8dcSSimon Schubert 7785796c8dcSSimon Schubert void 7795796c8dcSSimon Schubert yyerror (char *msg) 7805796c8dcSSimon Schubert { 7815796c8dcSSimon Schubert error (_("Error in expression, near `%s'."), lexptr); 7825796c8dcSSimon Schubert } 7835796c8dcSSimon Schubert 7845796c8dcSSimon Schubert /* The operator name corresponding to operator symbol STRING (adds 7855796c8dcSSimon Schubert quotes and maps to lower-case). Destroys the previous contents of 7865796c8dcSSimon Schubert the array pointed to by STRING.ptr. Error if STRING does not match 7875796c8dcSSimon Schubert a valid Ada operator. Assumes that STRING.ptr points to a 7885796c8dcSSimon Schubert null-terminated string and that, if STRING is a valid operator 7895796c8dcSSimon Schubert symbol, the array pointed to by STRING.ptr contains at least 7905796c8dcSSimon Schubert STRING.length+3 characters. */ 7915796c8dcSSimon Schubert 7925796c8dcSSimon Schubert static struct stoken 7935796c8dcSSimon Schubert string_to_operator (struct stoken string) 7945796c8dcSSimon Schubert { 7955796c8dcSSimon Schubert int i; 7965796c8dcSSimon Schubert 7975796c8dcSSimon Schubert for (i = 0; ada_opname_table[i].encoded != NULL; i += 1) 7985796c8dcSSimon Schubert { 7995796c8dcSSimon Schubert if (string.length == strlen (ada_opname_table[i].decoded)-2 8005796c8dcSSimon Schubert && strncasecmp (string.ptr, ada_opname_table[i].decoded+1, 8015796c8dcSSimon Schubert string.length) == 0) 8025796c8dcSSimon Schubert { 8035796c8dcSSimon Schubert strncpy (string.ptr, ada_opname_table[i].decoded, 8045796c8dcSSimon Schubert string.length+2); 8055796c8dcSSimon Schubert string.length += 2; 8065796c8dcSSimon Schubert return string; 8075796c8dcSSimon Schubert } 8085796c8dcSSimon Schubert } 8095796c8dcSSimon Schubert error (_("Invalid operator symbol `%s'"), string.ptr); 8105796c8dcSSimon Schubert } 8115796c8dcSSimon Schubert 8125796c8dcSSimon Schubert /* Emit expression to access an instance of SYM, in block BLOCK (if 8135796c8dcSSimon Schubert * non-NULL), and with :: qualification ORIG_LEFT_CONTEXT. */ 8145796c8dcSSimon Schubert static void 8155796c8dcSSimon Schubert write_var_from_sym (struct block *orig_left_context, 8165796c8dcSSimon Schubert struct block *block, 8175796c8dcSSimon Schubert struct symbol *sym) 8185796c8dcSSimon Schubert { 8195796c8dcSSimon Schubert if (orig_left_context == NULL && symbol_read_needs_frame (sym)) 8205796c8dcSSimon Schubert { 8215796c8dcSSimon Schubert if (innermost_block == 0 8225796c8dcSSimon Schubert || contained_in (block, innermost_block)) 8235796c8dcSSimon Schubert innermost_block = block; 8245796c8dcSSimon Schubert } 8255796c8dcSSimon Schubert 8265796c8dcSSimon Schubert write_exp_elt_opcode (OP_VAR_VALUE); 8275796c8dcSSimon Schubert write_exp_elt_block (block); 8285796c8dcSSimon Schubert write_exp_elt_sym (sym); 8295796c8dcSSimon Schubert write_exp_elt_opcode (OP_VAR_VALUE); 8305796c8dcSSimon Schubert } 8315796c8dcSSimon Schubert 8325796c8dcSSimon Schubert /* Write integer or boolean constant ARG of type TYPE. */ 8335796c8dcSSimon Schubert 8345796c8dcSSimon Schubert static void 8355796c8dcSSimon Schubert write_int (LONGEST arg, struct type *type) 8365796c8dcSSimon Schubert { 8375796c8dcSSimon Schubert write_exp_elt_opcode (OP_LONG); 8385796c8dcSSimon Schubert write_exp_elt_type (type); 8395796c8dcSSimon Schubert write_exp_elt_longcst (arg); 8405796c8dcSSimon Schubert write_exp_elt_opcode (OP_LONG); 8415796c8dcSSimon Schubert } 8425796c8dcSSimon Schubert 8435796c8dcSSimon Schubert /* Write an OPCODE, string, OPCODE sequence to the current expression. */ 8445796c8dcSSimon Schubert static void 8455796c8dcSSimon Schubert write_exp_op_with_string (enum exp_opcode opcode, struct stoken token) 8465796c8dcSSimon Schubert { 8475796c8dcSSimon Schubert write_exp_elt_opcode (opcode); 8485796c8dcSSimon Schubert write_exp_string (token); 8495796c8dcSSimon Schubert write_exp_elt_opcode (opcode); 8505796c8dcSSimon Schubert } 8515796c8dcSSimon Schubert 8525796c8dcSSimon Schubert /* Emit expression corresponding to the renamed object named 8535796c8dcSSimon Schubert * designated by RENAMED_ENTITY[0 .. RENAMED_ENTITY_LEN-1] in the 8545796c8dcSSimon Schubert * context of ORIG_LEFT_CONTEXT, to which is applied the operations 8555796c8dcSSimon Schubert * encoded by RENAMING_EXPR. MAX_DEPTH is the maximum number of 8565796c8dcSSimon Schubert * cascaded renamings to allow. If ORIG_LEFT_CONTEXT is null, it 8575796c8dcSSimon Schubert * defaults to the currently selected block. ORIG_SYMBOL is the 8585796c8dcSSimon Schubert * symbol that originally encoded the renaming. It is needed only 8595796c8dcSSimon Schubert * because its prefix also qualifies any index variables used to index 8605796c8dcSSimon Schubert * or slice an array. It should not be necessary once we go to the 8615796c8dcSSimon Schubert * new encoding entirely (FIXME pnh 7/20/2007). */ 8625796c8dcSSimon Schubert 8635796c8dcSSimon Schubert static void 8645796c8dcSSimon Schubert write_object_renaming (struct block *orig_left_context, 8655796c8dcSSimon Schubert const char *renamed_entity, int renamed_entity_len, 8665796c8dcSSimon Schubert const char *renaming_expr, int max_depth) 8675796c8dcSSimon Schubert { 8685796c8dcSSimon Schubert char *name; 8695796c8dcSSimon Schubert enum { SIMPLE_INDEX, LOWER_BOUND, UPPER_BOUND } slice_state; 8705796c8dcSSimon Schubert struct symbol *sym; 8715796c8dcSSimon Schubert struct block *block; 8725796c8dcSSimon Schubert 8735796c8dcSSimon Schubert if (max_depth <= 0) 8745796c8dcSSimon Schubert error (_("Could not find renamed symbol")); 8755796c8dcSSimon Schubert 8765796c8dcSSimon Schubert if (orig_left_context == NULL) 8775796c8dcSSimon Schubert orig_left_context = get_selected_block (NULL); 8785796c8dcSSimon Schubert 8795796c8dcSSimon Schubert name = obsavestring (renamed_entity, renamed_entity_len, &temp_parse_space); 8805796c8dcSSimon Schubert sym = ada_lookup_encoded_symbol (name, orig_left_context, VAR_DOMAIN, 8815796c8dcSSimon Schubert &block); 8825796c8dcSSimon Schubert if (sym == NULL) 8835796c8dcSSimon Schubert error (_("Could not find renamed variable: %s"), ada_decode (name)); 8845796c8dcSSimon Schubert else if (SYMBOL_CLASS (sym) == LOC_TYPEDEF) 8855796c8dcSSimon Schubert /* We have a renaming of an old-style renaming symbol. Don't 8865796c8dcSSimon Schubert trust the block information. */ 8875796c8dcSSimon Schubert block = orig_left_context; 8885796c8dcSSimon Schubert 8895796c8dcSSimon Schubert { 8905796c8dcSSimon Schubert const char *inner_renamed_entity; 8915796c8dcSSimon Schubert int inner_renamed_entity_len; 8925796c8dcSSimon Schubert const char *inner_renaming_expr; 8935796c8dcSSimon Schubert 8945796c8dcSSimon Schubert switch (ada_parse_renaming (sym, &inner_renamed_entity, 8955796c8dcSSimon Schubert &inner_renamed_entity_len, 8965796c8dcSSimon Schubert &inner_renaming_expr)) 8975796c8dcSSimon Schubert { 8985796c8dcSSimon Schubert case ADA_NOT_RENAMING: 8995796c8dcSSimon Schubert write_var_from_sym (orig_left_context, block, sym); 9005796c8dcSSimon Schubert break; 9015796c8dcSSimon Schubert case ADA_OBJECT_RENAMING: 9025796c8dcSSimon Schubert write_object_renaming (block, 9035796c8dcSSimon Schubert inner_renamed_entity, inner_renamed_entity_len, 9045796c8dcSSimon Schubert inner_renaming_expr, max_depth - 1); 9055796c8dcSSimon Schubert break; 9065796c8dcSSimon Schubert default: 9075796c8dcSSimon Schubert goto BadEncoding; 9085796c8dcSSimon Schubert } 9095796c8dcSSimon Schubert } 9105796c8dcSSimon Schubert 9115796c8dcSSimon Schubert slice_state = SIMPLE_INDEX; 9125796c8dcSSimon Schubert while (*renaming_expr == 'X') 9135796c8dcSSimon Schubert { 9145796c8dcSSimon Schubert renaming_expr += 1; 9155796c8dcSSimon Schubert 9165796c8dcSSimon Schubert switch (*renaming_expr) { 9175796c8dcSSimon Schubert case 'A': 9185796c8dcSSimon Schubert renaming_expr += 1; 9195796c8dcSSimon Schubert write_exp_elt_opcode (UNOP_IND); 9205796c8dcSSimon Schubert break; 9215796c8dcSSimon Schubert case 'L': 9225796c8dcSSimon Schubert slice_state = LOWER_BOUND; 9235796c8dcSSimon Schubert case 'S': 9245796c8dcSSimon Schubert renaming_expr += 1; 9255796c8dcSSimon Schubert if (isdigit (*renaming_expr)) 9265796c8dcSSimon Schubert { 9275796c8dcSSimon Schubert char *next; 9285796c8dcSSimon Schubert long val = strtol (renaming_expr, &next, 10); 9295796c8dcSSimon Schubert if (next == renaming_expr) 9305796c8dcSSimon Schubert goto BadEncoding; 9315796c8dcSSimon Schubert renaming_expr = next; 9325796c8dcSSimon Schubert write_exp_elt_opcode (OP_LONG); 9335796c8dcSSimon Schubert write_exp_elt_type (type_int ()); 9345796c8dcSSimon Schubert write_exp_elt_longcst ((LONGEST) val); 9355796c8dcSSimon Schubert write_exp_elt_opcode (OP_LONG); 9365796c8dcSSimon Schubert } 9375796c8dcSSimon Schubert else 9385796c8dcSSimon Schubert { 9395796c8dcSSimon Schubert const char *end; 9405796c8dcSSimon Schubert char *index_name; 9415796c8dcSSimon Schubert struct symbol *index_sym; 9425796c8dcSSimon Schubert 9435796c8dcSSimon Schubert end = strchr (renaming_expr, 'X'); 9445796c8dcSSimon Schubert if (end == NULL) 9455796c8dcSSimon Schubert end = renaming_expr + strlen (renaming_expr); 9465796c8dcSSimon Schubert 9475796c8dcSSimon Schubert index_name = 9485796c8dcSSimon Schubert obsavestring (renaming_expr, end - renaming_expr, 9495796c8dcSSimon Schubert &temp_parse_space); 9505796c8dcSSimon Schubert renaming_expr = end; 9515796c8dcSSimon Schubert 9525796c8dcSSimon Schubert index_sym = ada_lookup_encoded_symbol (index_name, NULL, 9535796c8dcSSimon Schubert VAR_DOMAIN, &block); 9545796c8dcSSimon Schubert if (index_sym == NULL) 9555796c8dcSSimon Schubert error (_("Could not find %s"), index_name); 9565796c8dcSSimon Schubert else if (SYMBOL_CLASS (index_sym) == LOC_TYPEDEF) 9575796c8dcSSimon Schubert /* Index is an old-style renaming symbol. */ 9585796c8dcSSimon Schubert block = orig_left_context; 9595796c8dcSSimon Schubert write_var_from_sym (NULL, block, index_sym); 9605796c8dcSSimon Schubert } 9615796c8dcSSimon Schubert if (slice_state == SIMPLE_INDEX) 9625796c8dcSSimon Schubert { 9635796c8dcSSimon Schubert write_exp_elt_opcode (OP_FUNCALL); 9645796c8dcSSimon Schubert write_exp_elt_longcst ((LONGEST) 1); 9655796c8dcSSimon Schubert write_exp_elt_opcode (OP_FUNCALL); 9665796c8dcSSimon Schubert } 9675796c8dcSSimon Schubert else if (slice_state == LOWER_BOUND) 9685796c8dcSSimon Schubert slice_state = UPPER_BOUND; 9695796c8dcSSimon Schubert else if (slice_state == UPPER_BOUND) 9705796c8dcSSimon Schubert { 9715796c8dcSSimon Schubert write_exp_elt_opcode (TERNOP_SLICE); 9725796c8dcSSimon Schubert slice_state = SIMPLE_INDEX; 9735796c8dcSSimon Schubert } 9745796c8dcSSimon Schubert break; 9755796c8dcSSimon Schubert 9765796c8dcSSimon Schubert case 'R': 9775796c8dcSSimon Schubert { 9785796c8dcSSimon Schubert struct stoken field_name; 9795796c8dcSSimon Schubert const char *end; 9805796c8dcSSimon Schubert renaming_expr += 1; 9815796c8dcSSimon Schubert 9825796c8dcSSimon Schubert if (slice_state != SIMPLE_INDEX) 9835796c8dcSSimon Schubert goto BadEncoding; 9845796c8dcSSimon Schubert end = strchr (renaming_expr, 'X'); 9855796c8dcSSimon Schubert if (end == NULL) 9865796c8dcSSimon Schubert end = renaming_expr + strlen (renaming_expr); 9875796c8dcSSimon Schubert field_name.length = end - renaming_expr; 9885796c8dcSSimon Schubert field_name.ptr = malloc (end - renaming_expr + 1); 9895796c8dcSSimon Schubert strncpy (field_name.ptr, renaming_expr, end - renaming_expr); 9905796c8dcSSimon Schubert field_name.ptr[end - renaming_expr] = '\000'; 9915796c8dcSSimon Schubert renaming_expr = end; 9925796c8dcSSimon Schubert write_exp_op_with_string (STRUCTOP_STRUCT, field_name); 9935796c8dcSSimon Schubert break; 9945796c8dcSSimon Schubert } 9955796c8dcSSimon Schubert 9965796c8dcSSimon Schubert default: 9975796c8dcSSimon Schubert goto BadEncoding; 9985796c8dcSSimon Schubert } 9995796c8dcSSimon Schubert } 10005796c8dcSSimon Schubert if (slice_state == SIMPLE_INDEX) 10015796c8dcSSimon Schubert return; 10025796c8dcSSimon Schubert 10035796c8dcSSimon Schubert BadEncoding: 10045796c8dcSSimon Schubert error (_("Internal error in encoding of renaming declaration")); 10055796c8dcSSimon Schubert } 10065796c8dcSSimon Schubert 10075796c8dcSSimon Schubert static struct block* 10085796c8dcSSimon Schubert block_lookup (struct block *context, char *raw_name) 10095796c8dcSSimon Schubert { 10105796c8dcSSimon Schubert char *name; 10115796c8dcSSimon Schubert struct ada_symbol_info *syms; 10125796c8dcSSimon Schubert int nsyms; 10135796c8dcSSimon Schubert struct symtab *symtab; 10145796c8dcSSimon Schubert 10155796c8dcSSimon Schubert if (raw_name[0] == '\'') 10165796c8dcSSimon Schubert { 10175796c8dcSSimon Schubert raw_name += 1; 10185796c8dcSSimon Schubert name = raw_name; 10195796c8dcSSimon Schubert } 10205796c8dcSSimon Schubert else 10215796c8dcSSimon Schubert name = ada_encode (raw_name); 10225796c8dcSSimon Schubert 10235796c8dcSSimon Schubert nsyms = ada_lookup_symbol_list (name, context, VAR_DOMAIN, &syms); 1024*cf7f2e2dSJohn Marino if (context == NULL 1025*cf7f2e2dSJohn Marino && (nsyms == 0 || SYMBOL_CLASS (syms[0].sym) != LOC_BLOCK)) 10265796c8dcSSimon Schubert symtab = lookup_symtab (name); 10275796c8dcSSimon Schubert else 10285796c8dcSSimon Schubert symtab = NULL; 10295796c8dcSSimon Schubert 10305796c8dcSSimon Schubert if (symtab != NULL) 10315796c8dcSSimon Schubert return BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK); 10325796c8dcSSimon Schubert else if (nsyms == 0 || SYMBOL_CLASS (syms[0].sym) != LOC_BLOCK) 10335796c8dcSSimon Schubert { 10345796c8dcSSimon Schubert if (context == NULL) 10355796c8dcSSimon Schubert error (_("No file or function \"%s\"."), raw_name); 10365796c8dcSSimon Schubert else 10375796c8dcSSimon Schubert error (_("No function \"%s\" in specified context."), raw_name); 10385796c8dcSSimon Schubert } 10395796c8dcSSimon Schubert else 10405796c8dcSSimon Schubert { 10415796c8dcSSimon Schubert if (nsyms > 1) 10425796c8dcSSimon Schubert warning (_("Function name \"%s\" ambiguous here"), raw_name); 10435796c8dcSSimon Schubert return SYMBOL_BLOCK_VALUE (syms[0].sym); 10445796c8dcSSimon Schubert } 10455796c8dcSSimon Schubert } 10465796c8dcSSimon Schubert 10475796c8dcSSimon Schubert static struct symbol* 10485796c8dcSSimon Schubert select_possible_type_sym (struct ada_symbol_info *syms, int nsyms) 10495796c8dcSSimon Schubert { 10505796c8dcSSimon Schubert int i; 10515796c8dcSSimon Schubert int preferred_index; 10525796c8dcSSimon Schubert struct type *preferred_type; 10535796c8dcSSimon Schubert 10545796c8dcSSimon Schubert preferred_index = -1; preferred_type = NULL; 10555796c8dcSSimon Schubert for (i = 0; i < nsyms; i += 1) 10565796c8dcSSimon Schubert switch (SYMBOL_CLASS (syms[i].sym)) 10575796c8dcSSimon Schubert { 10585796c8dcSSimon Schubert case LOC_TYPEDEF: 10595796c8dcSSimon Schubert if (ada_prefer_type (SYMBOL_TYPE (syms[i].sym), preferred_type)) 10605796c8dcSSimon Schubert { 10615796c8dcSSimon Schubert preferred_index = i; 10625796c8dcSSimon Schubert preferred_type = SYMBOL_TYPE (syms[i].sym); 10635796c8dcSSimon Schubert } 10645796c8dcSSimon Schubert break; 10655796c8dcSSimon Schubert case LOC_REGISTER: 10665796c8dcSSimon Schubert case LOC_ARG: 10675796c8dcSSimon Schubert case LOC_REF_ARG: 10685796c8dcSSimon Schubert case LOC_REGPARM_ADDR: 10695796c8dcSSimon Schubert case LOC_LOCAL: 10705796c8dcSSimon Schubert case LOC_COMPUTED: 10715796c8dcSSimon Schubert return NULL; 10725796c8dcSSimon Schubert default: 10735796c8dcSSimon Schubert break; 10745796c8dcSSimon Schubert } 10755796c8dcSSimon Schubert if (preferred_type == NULL) 10765796c8dcSSimon Schubert return NULL; 10775796c8dcSSimon Schubert return syms[preferred_index].sym; 10785796c8dcSSimon Schubert } 10795796c8dcSSimon Schubert 10805796c8dcSSimon Schubert static struct type* 10815796c8dcSSimon Schubert find_primitive_type (char *name) 10825796c8dcSSimon Schubert { 10835796c8dcSSimon Schubert struct type *type; 10845796c8dcSSimon Schubert type = language_lookup_primitive_type_by_name (parse_language, 10855796c8dcSSimon Schubert parse_gdbarch, 10865796c8dcSSimon Schubert name); 10875796c8dcSSimon Schubert if (type == NULL && strcmp ("system__address", name) == 0) 10885796c8dcSSimon Schubert type = type_system_address (); 10895796c8dcSSimon Schubert 10905796c8dcSSimon Schubert if (type != NULL) 10915796c8dcSSimon Schubert { 10925796c8dcSSimon Schubert /* Check to see if we have a regular definition of this 10935796c8dcSSimon Schubert type that just didn't happen to have been read yet. */ 10945796c8dcSSimon Schubert struct symbol *sym; 10955796c8dcSSimon Schubert char *expanded_name = 10965796c8dcSSimon Schubert (char *) alloca (strlen (name) + sizeof ("standard__")); 10975796c8dcSSimon Schubert strcpy (expanded_name, "standard__"); 10985796c8dcSSimon Schubert strcat (expanded_name, name); 10995796c8dcSSimon Schubert sym = ada_lookup_symbol (expanded_name, NULL, VAR_DOMAIN, NULL); 11005796c8dcSSimon Schubert if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF) 11015796c8dcSSimon Schubert type = SYMBOL_TYPE (sym); 11025796c8dcSSimon Schubert } 11035796c8dcSSimon Schubert 11045796c8dcSSimon Schubert return type; 11055796c8dcSSimon Schubert } 11065796c8dcSSimon Schubert 11075796c8dcSSimon Schubert static int 11085796c8dcSSimon Schubert chop_selector (char *name, int end) 11095796c8dcSSimon Schubert { 11105796c8dcSSimon Schubert int i; 11115796c8dcSSimon Schubert for (i = end - 1; i > 0; i -= 1) 11125796c8dcSSimon Schubert if (name[i] == '.' || (name[i] == '_' && name[i+1] == '_')) 11135796c8dcSSimon Schubert return i; 11145796c8dcSSimon Schubert return -1; 11155796c8dcSSimon Schubert } 11165796c8dcSSimon Schubert 11175796c8dcSSimon Schubert /* If NAME is a string beginning with a separator (either '__', or 11185796c8dcSSimon Schubert '.'), chop this separator and return the result; else, return 11195796c8dcSSimon Schubert NAME. */ 11205796c8dcSSimon Schubert 11215796c8dcSSimon Schubert static char * 11225796c8dcSSimon Schubert chop_separator (char *name) 11235796c8dcSSimon Schubert { 11245796c8dcSSimon Schubert if (*name == '.') 11255796c8dcSSimon Schubert return name + 1; 11265796c8dcSSimon Schubert 11275796c8dcSSimon Schubert if (name[0] == '_' && name[1] == '_') 11285796c8dcSSimon Schubert return name + 2; 11295796c8dcSSimon Schubert 11305796c8dcSSimon Schubert return name; 11315796c8dcSSimon Schubert } 11325796c8dcSSimon Schubert 11335796c8dcSSimon Schubert /* Given that SELS is a string of the form (<sep><identifier>)*, where 11345796c8dcSSimon Schubert <sep> is '__' or '.', write the indicated sequence of 11355796c8dcSSimon Schubert STRUCTOP_STRUCT expression operators. */ 11365796c8dcSSimon Schubert static void 11375796c8dcSSimon Schubert write_selectors (char *sels) 11385796c8dcSSimon Schubert { 11395796c8dcSSimon Schubert while (*sels != '\0') 11405796c8dcSSimon Schubert { 11415796c8dcSSimon Schubert struct stoken field_name; 11425796c8dcSSimon Schubert char *p = chop_separator (sels); 11435796c8dcSSimon Schubert sels = p; 11445796c8dcSSimon Schubert while (*sels != '\0' && *sels != '.' 11455796c8dcSSimon Schubert && (sels[0] != '_' || sels[1] != '_')) 11465796c8dcSSimon Schubert sels += 1; 11475796c8dcSSimon Schubert field_name.length = sels - p; 11485796c8dcSSimon Schubert field_name.ptr = p; 11495796c8dcSSimon Schubert write_exp_op_with_string (STRUCTOP_STRUCT, field_name); 11505796c8dcSSimon Schubert } 11515796c8dcSSimon Schubert } 11525796c8dcSSimon Schubert 11535796c8dcSSimon Schubert /* Write a variable access (OP_VAR_VALUE) to ambiguous encoded name 11545796c8dcSSimon Schubert NAME[0..LEN-1], in block context BLOCK, to be resolved later. Writes 11555796c8dcSSimon Schubert a temporary symbol that is valid until the next call to ada_parse. 11565796c8dcSSimon Schubert */ 11575796c8dcSSimon Schubert static void 11585796c8dcSSimon Schubert write_ambiguous_var (struct block *block, char *name, int len) 11595796c8dcSSimon Schubert { 11605796c8dcSSimon Schubert struct symbol *sym = 11615796c8dcSSimon Schubert obstack_alloc (&temp_parse_space, sizeof (struct symbol)); 11625796c8dcSSimon Schubert memset (sym, 0, sizeof (struct symbol)); 11635796c8dcSSimon Schubert SYMBOL_DOMAIN (sym) = UNDEF_DOMAIN; 11645796c8dcSSimon Schubert SYMBOL_LINKAGE_NAME (sym) = obsavestring (name, len, &temp_parse_space); 11655796c8dcSSimon Schubert SYMBOL_LANGUAGE (sym) = language_ada; 11665796c8dcSSimon Schubert 11675796c8dcSSimon Schubert write_exp_elt_opcode (OP_VAR_VALUE); 11685796c8dcSSimon Schubert write_exp_elt_block (block); 11695796c8dcSSimon Schubert write_exp_elt_sym (sym); 11705796c8dcSSimon Schubert write_exp_elt_opcode (OP_VAR_VALUE); 11715796c8dcSSimon Schubert } 11725796c8dcSSimon Schubert 11735796c8dcSSimon Schubert /* A convenient wrapper around ada_get_field_index that takes 11745796c8dcSSimon Schubert a non NUL-terminated FIELD_NAME0 and a FIELD_NAME_LEN instead 11755796c8dcSSimon Schubert of a NUL-terminated field name. */ 11765796c8dcSSimon Schubert 11775796c8dcSSimon Schubert static int 11785796c8dcSSimon Schubert ada_nget_field_index (const struct type *type, const char *field_name0, 11795796c8dcSSimon Schubert int field_name_len, int maybe_missing) 11805796c8dcSSimon Schubert { 11815796c8dcSSimon Schubert char *field_name = alloca ((field_name_len + 1) * sizeof (char)); 11825796c8dcSSimon Schubert 11835796c8dcSSimon Schubert strncpy (field_name, field_name0, field_name_len); 11845796c8dcSSimon Schubert field_name[field_name_len] = '\0'; 11855796c8dcSSimon Schubert return ada_get_field_index (type, field_name, maybe_missing); 11865796c8dcSSimon Schubert } 11875796c8dcSSimon Schubert 11885796c8dcSSimon Schubert /* If encoded_field_name is the name of a field inside symbol SYM, 11895796c8dcSSimon Schubert then return the type of that field. Otherwise, return NULL. 11905796c8dcSSimon Schubert 11915796c8dcSSimon Schubert This function is actually recursive, so if ENCODED_FIELD_NAME 11925796c8dcSSimon Schubert doesn't match one of the fields of our symbol, then try to see 11935796c8dcSSimon Schubert if ENCODED_FIELD_NAME could not be a succession of field names 11945796c8dcSSimon Schubert (in other words, the user entered an expression of the form 11955796c8dcSSimon Schubert TYPE_NAME.FIELD1.FIELD2.FIELD3), in which case we evaluate 11965796c8dcSSimon Schubert each field name sequentially to obtain the desired field type. 11975796c8dcSSimon Schubert In case of failure, we return NULL. */ 11985796c8dcSSimon Schubert 11995796c8dcSSimon Schubert static struct type * 12005796c8dcSSimon Schubert get_symbol_field_type (struct symbol *sym, char *encoded_field_name) 12015796c8dcSSimon Schubert { 12025796c8dcSSimon Schubert char *field_name = encoded_field_name; 12035796c8dcSSimon Schubert char *subfield_name; 12045796c8dcSSimon Schubert struct type *type = SYMBOL_TYPE (sym); 12055796c8dcSSimon Schubert int fieldno; 12065796c8dcSSimon Schubert 12075796c8dcSSimon Schubert if (type == NULL || field_name == NULL) 12085796c8dcSSimon Schubert return NULL; 12095796c8dcSSimon Schubert type = check_typedef (type); 12105796c8dcSSimon Schubert 12115796c8dcSSimon Schubert while (field_name[0] != '\0') 12125796c8dcSSimon Schubert { 12135796c8dcSSimon Schubert field_name = chop_separator (field_name); 12145796c8dcSSimon Schubert 12155796c8dcSSimon Schubert fieldno = ada_get_field_index (type, field_name, 1); 12165796c8dcSSimon Schubert if (fieldno >= 0) 12175796c8dcSSimon Schubert return TYPE_FIELD_TYPE (type, fieldno); 12185796c8dcSSimon Schubert 12195796c8dcSSimon Schubert subfield_name = field_name; 12205796c8dcSSimon Schubert while (*subfield_name != '\0' && *subfield_name != '.' 12215796c8dcSSimon Schubert && (subfield_name[0] != '_' || subfield_name[1] != '_')) 12225796c8dcSSimon Schubert subfield_name += 1; 12235796c8dcSSimon Schubert 12245796c8dcSSimon Schubert if (subfield_name[0] == '\0') 12255796c8dcSSimon Schubert return NULL; 12265796c8dcSSimon Schubert 12275796c8dcSSimon Schubert fieldno = ada_nget_field_index (type, field_name, 12285796c8dcSSimon Schubert subfield_name - field_name, 1); 12295796c8dcSSimon Schubert if (fieldno < 0) 12305796c8dcSSimon Schubert return NULL; 12315796c8dcSSimon Schubert 12325796c8dcSSimon Schubert type = TYPE_FIELD_TYPE (type, fieldno); 12335796c8dcSSimon Schubert field_name = subfield_name; 12345796c8dcSSimon Schubert } 12355796c8dcSSimon Schubert 12365796c8dcSSimon Schubert return NULL; 12375796c8dcSSimon Schubert } 12385796c8dcSSimon Schubert 12395796c8dcSSimon Schubert /* Look up NAME0 (an unencoded identifier or dotted name) in BLOCK (or 12405796c8dcSSimon Schubert expression_block_context if NULL). If it denotes a type, return 12415796c8dcSSimon Schubert that type. Otherwise, write expression code to evaluate it as an 12425796c8dcSSimon Schubert object and return NULL. In this second case, NAME0 will, in general, 12435796c8dcSSimon Schubert have the form <name>(.<selector_name>)*, where <name> is an object 12445796c8dcSSimon Schubert or renaming encoded in the debugging data. Calls error if no 12455796c8dcSSimon Schubert prefix <name> matches a name in the debugging data (i.e., matches 12465796c8dcSSimon Schubert either a complete name or, as a wild-card match, the final 12475796c8dcSSimon Schubert identifier). */ 12485796c8dcSSimon Schubert 12495796c8dcSSimon Schubert static struct type* 12505796c8dcSSimon Schubert write_var_or_type (struct block *block, struct stoken name0) 12515796c8dcSSimon Schubert { 12525796c8dcSSimon Schubert int depth; 12535796c8dcSSimon Schubert char *encoded_name; 12545796c8dcSSimon Schubert int name_len; 12555796c8dcSSimon Schubert 12565796c8dcSSimon Schubert if (block == NULL) 12575796c8dcSSimon Schubert block = expression_context_block; 12585796c8dcSSimon Schubert 12595796c8dcSSimon Schubert encoded_name = ada_encode (name0.ptr); 12605796c8dcSSimon Schubert name_len = strlen (encoded_name); 12615796c8dcSSimon Schubert encoded_name = obsavestring (encoded_name, name_len, &temp_parse_space); 12625796c8dcSSimon Schubert for (depth = 0; depth < MAX_RENAMING_CHAIN_LENGTH; depth += 1) 12635796c8dcSSimon Schubert { 12645796c8dcSSimon Schubert int tail_index; 12655796c8dcSSimon Schubert 12665796c8dcSSimon Schubert tail_index = name_len; 12675796c8dcSSimon Schubert while (tail_index > 0) 12685796c8dcSSimon Schubert { 12695796c8dcSSimon Schubert int nsyms; 12705796c8dcSSimon Schubert struct ada_symbol_info *syms; 12715796c8dcSSimon Schubert struct symbol *type_sym; 12725796c8dcSSimon Schubert struct symbol *renaming_sym; 12735796c8dcSSimon Schubert const char* renaming; 12745796c8dcSSimon Schubert int renaming_len; 12755796c8dcSSimon Schubert const char* renaming_expr; 12765796c8dcSSimon Schubert int terminator = encoded_name[tail_index]; 12775796c8dcSSimon Schubert 12785796c8dcSSimon Schubert encoded_name[tail_index] = '\0'; 12795796c8dcSSimon Schubert nsyms = ada_lookup_symbol_list (encoded_name, block, 12805796c8dcSSimon Schubert VAR_DOMAIN, &syms); 12815796c8dcSSimon Schubert encoded_name[tail_index] = terminator; 12825796c8dcSSimon Schubert 12835796c8dcSSimon Schubert /* A single symbol may rename a package or object. */ 12845796c8dcSSimon Schubert 12855796c8dcSSimon Schubert /* This should go away when we move entirely to new version. 12865796c8dcSSimon Schubert FIXME pnh 7/20/2007. */ 12875796c8dcSSimon Schubert if (nsyms == 1) 12885796c8dcSSimon Schubert { 12895796c8dcSSimon Schubert struct symbol *renaming = 12905796c8dcSSimon Schubert ada_find_renaming_symbol (SYMBOL_LINKAGE_NAME (syms[0].sym), 12915796c8dcSSimon Schubert syms[0].block); 12925796c8dcSSimon Schubert 12935796c8dcSSimon Schubert if (renaming != NULL) 12945796c8dcSSimon Schubert syms[0].sym = renaming; 12955796c8dcSSimon Schubert } 12965796c8dcSSimon Schubert 12975796c8dcSSimon Schubert type_sym = select_possible_type_sym (syms, nsyms); 12985796c8dcSSimon Schubert 12995796c8dcSSimon Schubert if (type_sym != NULL) 13005796c8dcSSimon Schubert renaming_sym = type_sym; 13015796c8dcSSimon Schubert else if (nsyms == 1) 13025796c8dcSSimon Schubert renaming_sym = syms[0].sym; 13035796c8dcSSimon Schubert else 13045796c8dcSSimon Schubert renaming_sym = NULL; 13055796c8dcSSimon Schubert 13065796c8dcSSimon Schubert switch (ada_parse_renaming (renaming_sym, &renaming, 13075796c8dcSSimon Schubert &renaming_len, &renaming_expr)) 13085796c8dcSSimon Schubert { 13095796c8dcSSimon Schubert case ADA_NOT_RENAMING: 13105796c8dcSSimon Schubert break; 13115796c8dcSSimon Schubert case ADA_PACKAGE_RENAMING: 13125796c8dcSSimon Schubert case ADA_EXCEPTION_RENAMING: 13135796c8dcSSimon Schubert case ADA_SUBPROGRAM_RENAMING: 13145796c8dcSSimon Schubert { 13155796c8dcSSimon Schubert char *new_name 13165796c8dcSSimon Schubert = obstack_alloc (&temp_parse_space, 13175796c8dcSSimon Schubert renaming_len + name_len - tail_index + 1); 13185796c8dcSSimon Schubert strncpy (new_name, renaming, renaming_len); 13195796c8dcSSimon Schubert strcpy (new_name + renaming_len, encoded_name + tail_index); 13205796c8dcSSimon Schubert encoded_name = new_name; 13215796c8dcSSimon Schubert name_len = renaming_len + name_len - tail_index; 13225796c8dcSSimon Schubert goto TryAfterRenaming; 13235796c8dcSSimon Schubert } 13245796c8dcSSimon Schubert case ADA_OBJECT_RENAMING: 13255796c8dcSSimon Schubert write_object_renaming (block, renaming, renaming_len, 13265796c8dcSSimon Schubert renaming_expr, MAX_RENAMING_CHAIN_LENGTH); 13275796c8dcSSimon Schubert write_selectors (encoded_name + tail_index); 13285796c8dcSSimon Schubert return NULL; 13295796c8dcSSimon Schubert default: 13305796c8dcSSimon Schubert internal_error (__FILE__, __LINE__, 13315796c8dcSSimon Schubert _("impossible value from ada_parse_renaming")); 13325796c8dcSSimon Schubert } 13335796c8dcSSimon Schubert 13345796c8dcSSimon Schubert if (type_sym != NULL) 13355796c8dcSSimon Schubert { 13365796c8dcSSimon Schubert struct type *field_type; 13375796c8dcSSimon Schubert 13385796c8dcSSimon Schubert if (tail_index == name_len) 13395796c8dcSSimon Schubert return SYMBOL_TYPE (type_sym); 13405796c8dcSSimon Schubert 13415796c8dcSSimon Schubert /* We have some extraneous characters after the type name. 13425796c8dcSSimon Schubert If this is an expression "TYPE_NAME.FIELD0.[...].FIELDN", 13435796c8dcSSimon Schubert then try to get the type of FIELDN. */ 13445796c8dcSSimon Schubert field_type 13455796c8dcSSimon Schubert = get_symbol_field_type (type_sym, encoded_name + tail_index); 13465796c8dcSSimon Schubert if (field_type != NULL) 13475796c8dcSSimon Schubert return field_type; 13485796c8dcSSimon Schubert else 13495796c8dcSSimon Schubert error (_("Invalid attempt to select from type: \"%s\"."), 13505796c8dcSSimon Schubert name0.ptr); 13515796c8dcSSimon Schubert } 13525796c8dcSSimon Schubert else if (tail_index == name_len && nsyms == 0) 13535796c8dcSSimon Schubert { 13545796c8dcSSimon Schubert struct type *type = find_primitive_type (encoded_name); 13555796c8dcSSimon Schubert 13565796c8dcSSimon Schubert if (type != NULL) 13575796c8dcSSimon Schubert return type; 13585796c8dcSSimon Schubert } 13595796c8dcSSimon Schubert 13605796c8dcSSimon Schubert if (nsyms == 1) 13615796c8dcSSimon Schubert { 13625796c8dcSSimon Schubert write_var_from_sym (block, syms[0].block, syms[0].sym); 13635796c8dcSSimon Schubert write_selectors (encoded_name + tail_index); 13645796c8dcSSimon Schubert return NULL; 13655796c8dcSSimon Schubert } 13665796c8dcSSimon Schubert else if (nsyms == 0) 13675796c8dcSSimon Schubert { 13685796c8dcSSimon Schubert struct minimal_symbol *msym 13695796c8dcSSimon Schubert = ada_lookup_simple_minsym (encoded_name); 13705796c8dcSSimon Schubert if (msym != NULL) 13715796c8dcSSimon Schubert { 13725796c8dcSSimon Schubert write_exp_msymbol (msym); 13735796c8dcSSimon Schubert /* Maybe cause error here rather than later? FIXME? */ 13745796c8dcSSimon Schubert write_selectors (encoded_name + tail_index); 13755796c8dcSSimon Schubert return NULL; 13765796c8dcSSimon Schubert } 13775796c8dcSSimon Schubert 13785796c8dcSSimon Schubert if (tail_index == name_len 13795796c8dcSSimon Schubert && strncmp (encoded_name, "standard__", 13805796c8dcSSimon Schubert sizeof ("standard__") - 1) == 0) 13815796c8dcSSimon Schubert error (_("No definition of \"%s\" found."), name0.ptr); 13825796c8dcSSimon Schubert 13835796c8dcSSimon Schubert tail_index = chop_selector (encoded_name, tail_index); 13845796c8dcSSimon Schubert } 13855796c8dcSSimon Schubert else 13865796c8dcSSimon Schubert { 13875796c8dcSSimon Schubert write_ambiguous_var (block, encoded_name, tail_index); 13885796c8dcSSimon Schubert write_selectors (encoded_name + tail_index); 13895796c8dcSSimon Schubert return NULL; 13905796c8dcSSimon Schubert } 13915796c8dcSSimon Schubert } 13925796c8dcSSimon Schubert 13935796c8dcSSimon Schubert if (!have_full_symbols () && !have_partial_symbols () && block == NULL) 13945796c8dcSSimon Schubert error (_("No symbol table is loaded. Use the \"file\" command.")); 13955796c8dcSSimon Schubert if (block == expression_context_block) 13965796c8dcSSimon Schubert error (_("No definition of \"%s\" in current context."), name0.ptr); 13975796c8dcSSimon Schubert else 13985796c8dcSSimon Schubert error (_("No definition of \"%s\" in specified context."), name0.ptr); 13995796c8dcSSimon Schubert 14005796c8dcSSimon Schubert TryAfterRenaming: ; 14015796c8dcSSimon Schubert } 14025796c8dcSSimon Schubert 14035796c8dcSSimon Schubert error (_("Could not find renamed symbol \"%s\""), name0.ptr); 14045796c8dcSSimon Schubert 14055796c8dcSSimon Schubert } 14065796c8dcSSimon Schubert 14075796c8dcSSimon Schubert /* Write a left side of a component association (e.g., NAME in NAME => 14085796c8dcSSimon Schubert exp). If NAME has the form of a selected component, write it as an 14095796c8dcSSimon Schubert ordinary expression. If it is a simple variable that unambiguously 14105796c8dcSSimon Schubert corresponds to exactly one symbol that does not denote a type or an 14115796c8dcSSimon Schubert object renaming, also write it normally as an OP_VAR_VALUE. 14125796c8dcSSimon Schubert Otherwise, write it as an OP_NAME. 14135796c8dcSSimon Schubert 14145796c8dcSSimon Schubert Unfortunately, we don't know at this point whether NAME is supposed 14155796c8dcSSimon Schubert to denote a record component name or the value of an array index. 14165796c8dcSSimon Schubert Therefore, it is not appropriate to disambiguate an ambiguous name 14175796c8dcSSimon Schubert as we normally would, nor to replace a renaming with its referent. 14185796c8dcSSimon Schubert As a result, in the (one hopes) rare case that one writes an 14195796c8dcSSimon Schubert aggregate such as (R => 42) where R renames an object or is an 14205796c8dcSSimon Schubert ambiguous name, one must write instead ((R) => 42). */ 14215796c8dcSSimon Schubert 14225796c8dcSSimon Schubert static void 14235796c8dcSSimon Schubert write_name_assoc (struct stoken name) 14245796c8dcSSimon Schubert { 14255796c8dcSSimon Schubert if (strchr (name.ptr, '.') == NULL) 14265796c8dcSSimon Schubert { 14275796c8dcSSimon Schubert struct ada_symbol_info *syms; 14285796c8dcSSimon Schubert int nsyms = ada_lookup_symbol_list (name.ptr, expression_context_block, 14295796c8dcSSimon Schubert VAR_DOMAIN, &syms); 14305796c8dcSSimon Schubert if (nsyms != 1 || SYMBOL_CLASS (syms[0].sym) == LOC_TYPEDEF) 14315796c8dcSSimon Schubert write_exp_op_with_string (OP_NAME, name); 14325796c8dcSSimon Schubert else 14335796c8dcSSimon Schubert write_var_from_sym (NULL, syms[0].block, syms[0].sym); 14345796c8dcSSimon Schubert } 14355796c8dcSSimon Schubert else 14365796c8dcSSimon Schubert if (write_var_or_type (NULL, name) != NULL) 14375796c8dcSSimon Schubert error (_("Invalid use of type.")); 14385796c8dcSSimon Schubert } 14395796c8dcSSimon Schubert 14405796c8dcSSimon Schubert /* Convert the character literal whose ASCII value would be VAL to the 14415796c8dcSSimon Schubert appropriate value of type TYPE, if there is a translation. 14425796c8dcSSimon Schubert Otherwise return VAL. Hence, in an enumeration type ('A', 'B'), 14435796c8dcSSimon Schubert the literal 'A' (VAL == 65), returns 0. */ 14445796c8dcSSimon Schubert 14455796c8dcSSimon Schubert static LONGEST 14465796c8dcSSimon Schubert convert_char_literal (struct type *type, LONGEST val) 14475796c8dcSSimon Schubert { 14485796c8dcSSimon Schubert char name[7]; 14495796c8dcSSimon Schubert int f; 14505796c8dcSSimon Schubert 14515796c8dcSSimon Schubert if (type == NULL || TYPE_CODE (type) != TYPE_CODE_ENUM) 14525796c8dcSSimon Schubert return val; 14535796c8dcSSimon Schubert xsnprintf (name, sizeof (name), "QU%02x", (int) val); 14545796c8dcSSimon Schubert for (f = 0; f < TYPE_NFIELDS (type); f += 1) 14555796c8dcSSimon Schubert { 14565796c8dcSSimon Schubert if (strcmp (name, TYPE_FIELD_NAME (type, f)) == 0) 14575796c8dcSSimon Schubert return TYPE_FIELD_BITPOS (type, f); 14585796c8dcSSimon Schubert } 14595796c8dcSSimon Schubert return val; 14605796c8dcSSimon Schubert } 14615796c8dcSSimon Schubert 14625796c8dcSSimon Schubert static struct type * 14635796c8dcSSimon Schubert type_int (void) 14645796c8dcSSimon Schubert { 14655796c8dcSSimon Schubert return parse_type->builtin_int; 14665796c8dcSSimon Schubert } 14675796c8dcSSimon Schubert 14685796c8dcSSimon Schubert static struct type * 14695796c8dcSSimon Schubert type_long (void) 14705796c8dcSSimon Schubert { 14715796c8dcSSimon Schubert return parse_type->builtin_long; 14725796c8dcSSimon Schubert } 14735796c8dcSSimon Schubert 14745796c8dcSSimon Schubert static struct type * 14755796c8dcSSimon Schubert type_long_long (void) 14765796c8dcSSimon Schubert { 14775796c8dcSSimon Schubert return parse_type->builtin_long_long; 14785796c8dcSSimon Schubert } 14795796c8dcSSimon Schubert 14805796c8dcSSimon Schubert static struct type * 14815796c8dcSSimon Schubert type_float (void) 14825796c8dcSSimon Schubert { 14835796c8dcSSimon Schubert return parse_type->builtin_float; 14845796c8dcSSimon Schubert } 14855796c8dcSSimon Schubert 14865796c8dcSSimon Schubert static struct type * 14875796c8dcSSimon Schubert type_double (void) 14885796c8dcSSimon Schubert { 14895796c8dcSSimon Schubert return parse_type->builtin_double; 14905796c8dcSSimon Schubert } 14915796c8dcSSimon Schubert 14925796c8dcSSimon Schubert static struct type * 14935796c8dcSSimon Schubert type_long_double (void) 14945796c8dcSSimon Schubert { 14955796c8dcSSimon Schubert return parse_type->builtin_long_double; 14965796c8dcSSimon Schubert } 14975796c8dcSSimon Schubert 14985796c8dcSSimon Schubert static struct type * 14995796c8dcSSimon Schubert type_char (void) 15005796c8dcSSimon Schubert { 15015796c8dcSSimon Schubert return language_string_char_type (parse_language, parse_gdbarch); 15025796c8dcSSimon Schubert } 15035796c8dcSSimon Schubert 15045796c8dcSSimon Schubert static struct type * 15055796c8dcSSimon Schubert type_boolean (void) 15065796c8dcSSimon Schubert { 15075796c8dcSSimon Schubert return parse_type->builtin_bool; 15085796c8dcSSimon Schubert } 15095796c8dcSSimon Schubert 15105796c8dcSSimon Schubert static struct type * 15115796c8dcSSimon Schubert type_system_address (void) 15125796c8dcSSimon Schubert { 15135796c8dcSSimon Schubert struct type *type 15145796c8dcSSimon Schubert = language_lookup_primitive_type_by_name (parse_language, 15155796c8dcSSimon Schubert parse_gdbarch, 15165796c8dcSSimon Schubert "system__address"); 15175796c8dcSSimon Schubert return type != NULL ? type : parse_type->builtin_data_ptr; 15185796c8dcSSimon Schubert } 15195796c8dcSSimon Schubert 15205796c8dcSSimon Schubert /* Provide a prototype to silence -Wmissing-prototypes. */ 15215796c8dcSSimon Schubert extern initialize_file_ftype _initialize_ada_exp; 15225796c8dcSSimon Schubert 15235796c8dcSSimon Schubert void 15245796c8dcSSimon Schubert _initialize_ada_exp (void) 15255796c8dcSSimon Schubert { 15265796c8dcSSimon Schubert obstack_init (&temp_parse_space); 15275796c8dcSSimon Schubert } 15285796c8dcSSimon Schubert 15295796c8dcSSimon Schubert /* FIXME: hilfingr/2004-10-05: Hack to remove warning. The function 15305796c8dcSSimon Schubert string_to_operator is supposed to be used for cases where one 15315796c8dcSSimon Schubert calls an operator function with prefix notation, as in 15325796c8dcSSimon Schubert "+" (a, b), but at some point, this code seems to have gone 15335796c8dcSSimon Schubert missing. */ 15345796c8dcSSimon Schubert 15355796c8dcSSimon Schubert struct stoken (*dummy_string_to_ada_operator) (struct stoken) 15365796c8dcSSimon Schubert = string_to_operator; 1537