| OLD | NEW |
| 1 /* YACC parser for C expressions, for GDB. | 1 /* YACC parser for C expressions, for GDB. |
| 2 Copyright (C) 1986, 1989-2000, 2003-2004, 2006-2012 Free Software | 2 Copyright (C) 1986-2013 Free Software Foundation, Inc. |
| 3 Foundation, Inc. | |
| 4 | 3 |
| 5 This file is part of GDB. | 4 This file is part of GDB. |
| 6 | 5 |
| 7 This program is free software; you can redistribute it and/or modify | 6 This program is free software; you can redistribute it and/or modify |
| 8 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
| 9 the Free Software Foundation; either version 3 of the License, or | 8 the Free Software Foundation; either version 3 of the License, or |
| 10 (at your option) any later version. | 9 (at your option) any later version. |
| 11 | 10 |
| 12 This program is distributed in the hope that it will be useful, | 11 This program is distributed in the hope that it will be useful, |
| 13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 16 matching lines...) Expand all Loading... |
| 30 xmalloc and xrealloc respectively by the same sed command in the | 29 xmalloc and xrealloc respectively by the same sed command in the |
| 31 makefile that remaps any other malloc/realloc inserted by the parser | 30 makefile that remaps any other malloc/realloc inserted by the parser |
| 32 generator. Doing this with #defines and trying to control the interaction | 31 generator. Doing this with #defines and trying to control the interaction |
| 33 with include files (<malloc.h> and <stdlib.h> for example) just became | 32 with include files (<malloc.h> and <stdlib.h> for example) just became |
| 34 too messy, particularly when such includes can be inserted at random | 33 too messy, particularly when such includes can be inserted at random |
| 35 times by the parser generator. */ | 34 times by the parser generator. */ |
| 36 | 35 |
| 37 %{ | 36 %{ |
| 38 | 37 |
| 39 #include "defs.h" | 38 #include "defs.h" |
| 40 #include "gdb_string.h" | 39 #include <string.h> |
| 41 #include <ctype.h> | 40 #include <ctype.h> |
| 42 #include "expression.h" | 41 #include "expression.h" |
| 43 #include "value.h" | 42 #include "value.h" |
| 44 #include "parser-defs.h" | 43 #include "parser-defs.h" |
| 45 #include "language.h" | 44 #include "language.h" |
| 46 #include "c-lang.h" | 45 #include "c-lang.h" |
| 47 #include "bfd.h" /* Required by objfiles.h. */ | 46 #include "bfd.h" /* Required by objfiles.h. */ |
| 48 #include "symfile.h" /* Required by objfiles.h. */ | 47 #include "symfile.h" /* Required by objfiles.h. */ |
| 49 #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */ | 48 #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */ |
| 50 #include "charset.h" | 49 #include "charset.h" |
| 51 #include "block.h" | 50 #include "block.h" |
| 52 #include "cp-support.h" | 51 #include "cp-support.h" |
| 53 #include "dfp.h" | 52 #include "dfp.h" |
| 54 #include "gdb_assert.h" | 53 #include "gdb_assert.h" |
| 55 #include "macroscope.h" | 54 #include "macroscope.h" |
| 55 #include "objc-lang.h" |
| 56 #include "typeprint.h" |
| 57 #include "cp-abi.h" |
| 56 | 58 |
| 57 #define parse_type builtin_type (parse_gdbarch) | 59 #define parse_type builtin_type (parse_gdbarch) |
| 58 | 60 |
| 59 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), | 61 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), |
| 60 as well as gratuitiously global symbol names, so we can have multiple | 62 as well as gratuitiously global symbol names, so we can have multiple |
| 61 yacc generated parsers in gdb. Note that these are only the variables | 63 yacc generated parsers in gdb. Note that these are only the variables |
| 62 produced by yacc. If other parser generators (bison, byacc, etc) produce | 64 produced by yacc. If other parser generators (bison, byacc, etc) produce |
| 63 additional global names that conflict at link time, then those parser | 65 additional global names that conflict at link time, then those parser |
| 64 generators need to be fixed instead of adding those names to this list. */ | 66 generators need to be fixed instead of adding those names to this list. */ |
| 65 | 67 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 struct type *type; | 138 struct type *type; |
| 137 } typed_val_int; | 139 } typed_val_int; |
| 138 struct { | 140 struct { |
| 139 DOUBLEST dval; | 141 DOUBLEST dval; |
| 140 struct type *type; | 142 struct type *type; |
| 141 } typed_val_float; | 143 } typed_val_float; |
| 142 struct { | 144 struct { |
| 143 gdb_byte val[16]; | 145 gdb_byte val[16]; |
| 144 struct type *type; | 146 struct type *type; |
| 145 } typed_val_decfloat; | 147 } typed_val_decfloat; |
| 146 struct symbol *sym; | |
| 147 struct type *tval; | 148 struct type *tval; |
| 148 struct stoken sval; | 149 struct stoken sval; |
| 149 struct typed_stoken tsval; | 150 struct typed_stoken tsval; |
| 150 struct ttype tsym; | 151 struct ttype tsym; |
| 151 struct symtoken ssym; | 152 struct symtoken ssym; |
| 152 int voidval; | 153 int voidval; |
| 153 struct block *bval; | 154 struct block *bval; |
| 154 enum exp_opcode opcode; | 155 enum exp_opcode opcode; |
| 155 struct internalvar *ivar; | |
| 156 | 156 |
| 157 struct stoken_vector svec; | 157 struct stoken_vector svec; |
| 158 VEC (type_ptr) *tvec; | 158 VEC (type_ptr) *tvec; |
| 159 int *ivec; | |
| 160 | 159 |
| 161 struct type_stack *type_stack; | 160 struct type_stack *type_stack; |
| 161 |
| 162 struct objc_class_str class; |
| 162 } | 163 } |
| 163 | 164 |
| 164 %{ | 165 %{ |
| 165 /* YYSTYPE gets defined by %union */ | 166 /* YYSTYPE gets defined by %union */ |
| 166 static int parse_number (char *, int, int, YYSTYPE *); | 167 static int parse_number (const char *, int, int, YYSTYPE *); |
| 167 static struct stoken operator_stoken (const char *); | 168 static struct stoken operator_stoken (const char *); |
| 168 static void check_parameter_typelist (VEC (type_ptr) *); | 169 static void check_parameter_typelist (VEC (type_ptr) *); |
| 170 static void write_destructor_name (struct stoken); |
| 171 |
| 172 static void c_print_token (FILE *file, int type, YYSTYPE value); |
| 173 #define YYPRINT(FILE, TYPE, VALUE) c_print_token (FILE, TYPE, VALUE) |
| 169 %} | 174 %} |
| 170 | 175 |
| 171 %type <voidval> exp exp1 type_exp start variable qualified_name lcurly | 176 %type <voidval> exp exp1 type_exp start variable qualified_name lcurly |
| 172 %type <lval> rcurly | 177 %type <lval> rcurly |
| 173 %type <tval> type typebase | 178 %type <tval> type typebase |
| 174 %type <tvec> nonempty_typelist func_mod parameter_typelist | 179 %type <tvec> nonempty_typelist func_mod parameter_typelist |
| 175 /* %type <bval> block */ | 180 /* %type <bval> block */ |
| 176 | 181 |
| 177 /* Fancy type parsing. */ | 182 /* Fancy type parsing. */ |
| 178 %type <tval> ptype | 183 %type <tval> ptype |
| 179 %type <lval> array_mod | 184 %type <lval> array_mod |
| 180 %type <tval> conversion_type_id | 185 %type <tval> conversion_type_id |
| 181 | 186 |
| 182 %type <type_stack> ptr_operator_ts abs_decl direct_abs_decl | 187 %type <type_stack> ptr_operator_ts abs_decl direct_abs_decl |
| 183 | 188 |
| 184 %token <typed_val_int> INT | 189 %token <typed_val_int> INT |
| 185 %token <typed_val_float> FLOAT | 190 %token <typed_val_float> FLOAT |
| 186 %token <typed_val_decfloat> DECFLOAT | 191 %token <typed_val_decfloat> DECFLOAT |
| 187 | 192 |
| 188 /* Both NAME and TYPENAME tokens represent symbols in the input, | 193 /* Both NAME and TYPENAME tokens represent symbols in the input, |
| 189 and both convey their data as strings. | 194 and both convey their data as strings. |
| 190 But a TYPENAME is a string that happens to be defined as a typedef | 195 But a TYPENAME is a string that happens to be defined as a typedef |
| 191 or builtin type name (such as int or char) | 196 or builtin type name (such as int or char) |
| 192 and a NAME is any other symbol. | 197 and a NAME is any other symbol. |
| 193 Contexts where this distinction is not important can use the | 198 Contexts where this distinction is not important can use the |
| 194 nonterminal "name", which matches either NAME or TYPENAME. */ | 199 nonterminal "name", which matches either NAME or TYPENAME. */ |
| 195 | 200 |
| 196 %token <tsval> STRING | 201 %token <tsval> STRING |
| 202 %token <sval> NSSTRING /* ObjC Foundation "NSString" literal */ |
| 203 %token SELECTOR /* ObjC "@selector" pseudo-operator */ |
| 197 %token <tsval> CHAR | 204 %token <tsval> CHAR |
| 198 %token <ssym> NAME /* BLOCKNAME defined below to give it higher precedence. */ | 205 %token <ssym> NAME /* BLOCKNAME defined below to give it higher precedence. */ |
| 199 %token <ssym> UNKNOWN_CPP_NAME | 206 %token <ssym> UNKNOWN_CPP_NAME |
| 200 %token <voidval> COMPLETE | 207 %token <voidval> COMPLETE |
| 201 %token <tsym> TYPENAME | 208 %token <tsym> TYPENAME |
| 209 %token <class> CLASSNAME /* ObjC Class name */ |
| 202 %type <sval> name | 210 %type <sval> name |
| 203 %type <svec> string_exp | 211 %type <svec> string_exp |
| 204 %type <ssym> name_not_typename | 212 %type <ssym> name_not_typename |
| 205 %type <tsym> typename | 213 %type <tsym> typename |
| 206 | 214 |
| 215 /* This is like a '[' token, but is only generated when parsing |
| 216 Objective C. This lets us reuse the same parser without |
| 217 erroneously parsing ObjC-specific expressions in C. */ |
| 218 %token OBJC_LBRAC |
| 219 |
| 207 /* A NAME_OR_INT is a symbol which is not known in the symbol table, | 220 /* A NAME_OR_INT is a symbol which is not known in the symbol table, |
| 208 but which would parse as a valid number in the current input radix. | 221 but which would parse as a valid number in the current input radix. |
| 209 E.g. "c" when input_radix==16. Depending on the parse, it will be | 222 E.g. "c" when input_radix==16. Depending on the parse, it will be |
| 210 turned into a name or into a number. */ | 223 turned into a name or into a number. */ |
| 211 | 224 |
| 212 %token <ssym> NAME_OR_INT | 225 %token <ssym> NAME_OR_INT |
| 213 | 226 |
| 214 %token OPERATOR | 227 %token OPERATOR |
| 215 %token STRUCT CLASS UNION ENUM SIZEOF UNSIGNED COLONCOLON | 228 %token STRUCT CLASS UNION ENUM SIZEOF UNSIGNED COLONCOLON |
| 216 %token TEMPLATE | 229 %token TEMPLATE |
| 217 %token ERROR | 230 %token ERROR |
| 218 %token NEW DELETE | 231 %token NEW DELETE |
| 219 %type <sval> operator | 232 %type <sval> operator |
| 220 %token REINTERPRET_CAST DYNAMIC_CAST STATIC_CAST CONST_CAST | 233 %token REINTERPRET_CAST DYNAMIC_CAST STATIC_CAST CONST_CAST |
| 221 %token ENTRY | 234 %token ENTRY |
| 235 %token TYPEOF |
| 236 %token DECLTYPE |
| 237 %token TYPEID |
| 222 | 238 |
| 223 /* Special type cases, put in to allow the parser to distinguish different | 239 /* Special type cases, put in to allow the parser to distinguish different |
| 224 legal basetypes. */ | 240 legal basetypes. */ |
| 225 %token SIGNED_KEYWORD LONG SHORT INT_KEYWORD CONST_KEYWORD VOLATILE_KEYWORD DOUB
LE_KEYWORD | 241 %token SIGNED_KEYWORD LONG SHORT INT_KEYWORD CONST_KEYWORD VOLATILE_KEYWORD DOUB
LE_KEYWORD |
| 226 | 242 |
| 227 %token <sval> VARIABLE | 243 %token <sval> VARIABLE |
| 228 | 244 |
| 229 %token <opcode> ASSIGN_MODIFY | 245 %token <opcode> ASSIGN_MODIFY |
| 230 | 246 |
| 231 /* C++ */ | 247 /* C++ */ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 242 %left '|' | 258 %left '|' |
| 243 %left '^' | 259 %left '^' |
| 244 %left '&' | 260 %left '&' |
| 245 %left EQUAL NOTEQUAL | 261 %left EQUAL NOTEQUAL |
| 246 %left '<' '>' LEQ GEQ | 262 %left '<' '>' LEQ GEQ |
| 247 %left LSH RSH | 263 %left LSH RSH |
| 248 %left '@' | 264 %left '@' |
| 249 %left '+' '-' | 265 %left '+' '-' |
| 250 %left '*' '/' '%' | 266 %left '*' '/' '%' |
| 251 %right UNARY INCREMENT DECREMENT | 267 %right UNARY INCREMENT DECREMENT |
| 252 %right ARROW ARROW_STAR '.' DOT_STAR '[' '(' | 268 %right ARROW ARROW_STAR '.' DOT_STAR '[' OBJC_LBRAC '(' |
| 253 %token <ssym> BLOCKNAME | 269 %token <ssym> BLOCKNAME |
| 254 %token <bval> FILENAME | 270 %token <bval> FILENAME |
| 255 %type <bval> block | 271 %type <bval> block |
| 256 %left COLONCOLON | 272 %left COLONCOLON |
| 257 | 273 |
| 258 %token DOTDOTDOT | 274 %token DOTDOTDOT |
| 259 | 275 |
| 260 | 276 |
| 261 | 277 |
| 262 %% | 278 %% |
| 263 | 279 |
| 264 start : exp1 | 280 start : exp1 |
| 265 | type_exp | 281 | type_exp |
| 266 ; | 282 ; |
| 267 | 283 |
error: old chunk mismatch |
None
| OLD | NEW |