e66bbec0a8c54a1e775331e0d9" /* YACC grammar for Modula-2 expressions, for GDB. Copyright (C) 1986-2016 Free Software Foundation, Inc. Generated from expread.y (now c-exp.y) and contributed by the Department of Computer Science at the State University of New York at Buffalo, 1991. This file is part of GDB. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* Parse a Modula-2 expression from text in a string, and return the result as a struct expression pointer. That structure contains arithmetic operations in reverse polish, with constants represented by operations that are followed by special data. See expression.h for the details of the format. What is important here is that it can be built up sequentially during the process of parsing; the lower levels of the tree always come first in the result. Note that malloc's and realloc's in this file are transformed to xmalloc and xrealloc respectively by the same sed command in the makefile that remaps any other malloc/realloc inserted by the parser generator. Doing this with #defines and trying to control the interaction with include files ( and for example) just became too messy, particularly when such includes can be inserted at random times by the parser generator. */ %{ #include "defs.h" #include "expression.h" #include "language.h" #include "value.h" #include "parser-defs.h" #include "m2-lang.h" #include "bfd.h" /* Required by objfiles.h. */ #include "symfile.h" /* Required by objfiles.h. */ #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */ #include "block.h" #define parse_type(ps) builtin_type (parse_gdbarch (ps)) #define parse_m2_type(ps) builtin_m2_type (parse_gdbarch (ps)) /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc). */ #define GDB_YY_REMAP_PREFIX m2_ #include "yy-remap.h" /* The state of the parser, used internally when we are parsing the expression. */ static struct parser_state *pstate = NULL; int yyparse (void); static int yylex (void); void yyerror (char *); static int parse_number (int); /* The sign of the number being parsed. */ static int number_sign = 1; %} /* Although the yacc "value" of an expression is not used, since the result is stored in the structure being created, other node types do have values. */ %union { LONGEST lval; ULONGEST ulval; DOUBLEST dval; struct symbol *sym; struct type *tval; struct stoken sval; int voidval; const struct block *bval; enum exp_opcode opcode; struct internalvar *ivar; struct type **tvec; int *ivec; } %type exp type_exp start set %type variable %type type %type block %type fblock %token INT HEX ERROR %token UINT M2_TRUE M2_FALSE CHAR %token FLOAT /* Both NAME and TYPENAME tokens represent symbols in the input, and both convey their data as strings. But a TYPENAME is a string that happens to be defined as a typedef or builtin type name (such as int or char) and