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