| OLD | NEW |
| 1 /* FLEX lexer for Ada expressions, for GDB. | 1 /* FLEX lexer for Ada expressions, for GDB. |
| 2 Copyright (C) 1994, 1997-1998, 2000-2003, 2007-2012 Free Software | 2 Copyright (C) 1994, 1997-1998, 2000-2003, 2007-2012 Free Software |
| 3 Foundation, Inc. | 3 Foundation, Inc. |
| 4 | 4 |
| 5 This file is part of GDB. | 5 This file is part of GDB. |
| 6 | 6 |
| 7 This program is free software; you can redistribute it and/or modify | 7 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 | 8 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 | 9 the Free Software Foundation; either version 3 of the License, or |
| 10 (at your option) any later version. | 10 (at your option) any later version. |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 /* CATCH-ALL ERROR CASE */ | 286 /* CATCH-ALL ERROR CASE */ |
| 287 | 287 |
| 288 . { error (_("Invalid character '%s' in expression."), yytext); } | 288 . { error (_("Invalid character '%s' in expression."), yytext); } |
| 289 %% | 289 %% |
| 290 | 290 |
| 291 #include <ctype.h> | 291 #include <ctype.h> |
| 292 #include "gdb_string.h" | 292 #include "gdb_string.h" |
| 293 | 293 |
| 294 /* Initialize the lexer for processing new expression. */ | 294 /* Initialize the lexer for processing new expression. */ |
| 295 | 295 |
| 296 void | 296 static void |
| 297 lexer_init (FILE *inp) | 297 lexer_init (FILE *inp) |
| 298 { | 298 { |
| 299 BEGIN INITIAL; | 299 BEGIN INITIAL; |
| 300 yyrestart (inp); | 300 yyrestart (inp); |
| 301 } | 301 } |
| 302 | 302 |
| 303 | 303 |
| 304 /* Copy S2 to S1, removing all underscores, and downcasing all letters. */ | 304 /* Copy S2 to S1, removing all underscores, and downcasing all letters. */ |
| 305 | 305 |
| 306 static void | 306 static void |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 yylval.typed_val_float.type = type_double (); | 403 yylval.typed_val_float.type = type_double (); |
| 404 if (sizeof(DOUBLEST) >= gdbarch_long_double_bit (parse_gdbarch) | 404 if (sizeof(DOUBLEST) >= gdbarch_long_double_bit (parse_gdbarch) |
| 405 / TARGET_CHAR_BIT) | 405 / TARGET_CHAR_BIT) |
| 406 yylval.typed_val_float.type = type_long_double (); | 406 yylval.typed_val_float.type = type_long_double (); |
| 407 | 407 |
| 408 return FLOAT; | 408 return FLOAT; |
| 409 } | 409 } |
| 410 | 410 |
| 411 | 411 |
| 412 /* Store a canonicalized version of NAME0[0..LEN-1] in yylval.ssym. The | 412 /* Store a canonicalized version of NAME0[0..LEN-1] in yylval.ssym. The |
| 413 resulting string is valid until the next call to ada_parse. It differs | 413 resulting string is valid until the next call to ada_parse. If |
| 414 NAME0 contains the substring "___", it is assumed to be already |
| 415 encoded and the resulting name is equal to it. Otherwise, it differs |
| 414 from NAME0 in that: | 416 from NAME0 in that: |
| 415 + Characters between '...' or <...> are transfered verbatim to | 417 + Characters between '...' or <...> are transfered verbatim to |
| 416 yylval.ssym. | 418 yylval.ssym. |
| 417 + <, >, and trailing "'" characters in quoted sequences are removed | 419 + <, >, and trailing "'" characters in quoted sequences are removed |
| 418 (a leading quote is preserved to indicate that the name is not to be | 420 (a leading quote is preserved to indicate that the name is not to be |
| 419 GNAT-encoded). | 421 GNAT-encoded). |
| 420 + Unquoted whitespace is removed. | 422 + Unquoted whitespace is removed. |
| 421 + Unquoted alphabetic characters are mapped to lower case. | 423 + Unquoted alphabetic characters are mapped to lower case. |
| 422 Result is returned as a struct stoken, but for convenience, the string | 424 Result is returned as a struct stoken, but for convenience, the string |
| 423 is also null-terminated. Result string valid until the next call of | 425 is also null-terminated. Result string valid until the next call of |
| 424 ada_parse. | 426 ada_parse. |
| 425 */ | 427 */ |
| 426 static struct stoken | 428 static struct stoken |
| 427 processId (const char *name0, int len) | 429 processId (const char *name0, int len) |
| 428 { | 430 { |
| 429 char *name = obstack_alloc (&temp_parse_space, len + 11); | 431 char *name = obstack_alloc (&temp_parse_space, len + 11); |
| 430 int i0, i; | 432 int i0, i; |
| 431 struct stoken result; | 433 struct stoken result; |
| 432 | 434 |
| 435 result.ptr = name; |
| 433 while (len > 0 && isspace (name0[len-1])) | 436 while (len > 0 && isspace (name0[len-1])) |
| 434 len -= 1; | 437 len -= 1; |
| 438 |
| 439 if (strstr (name0, "___") != NULL) |
| 440 { |
| 441 strncpy (name, name0, len); |
| 442 name[len] = '\000'; |
| 443 result.length = len; |
| 444 return result; |
| 445 } |
| 446 |
| 435 i = i0 = 0; | 447 i = i0 = 0; |
| 436 while (i0 < len) | 448 while (i0 < len) |
| 437 { | 449 { |
| 438 if (isalnum (name0[i0])) | 450 if (isalnum (name0[i0])) |
| 439 { | 451 { |
| 440 name[i] = tolower (name0[i0]); | 452 name[i] = tolower (name0[i0]); |
| 441 i += 1; i0 += 1; | 453 i += 1; i0 += 1; |
| 442 } | 454 } |
| 443 else switch (name0[i0]) | 455 else switch (name0[i0]) |
| 444 { | 456 { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 464 { | 476 { |
| 465 name[i] = name0[i0]; | 477 name[i] = name0[i0]; |
| 466 i += 1; i0 += 1; | 478 i += 1; i0 += 1; |
| 467 } | 479 } |
| 468 i0 += 1; | 480 i0 += 1; |
| 469 break; | 481 break; |
| 470 } | 482 } |
| 471 } | 483 } |
| 472 name[i] = '\000'; | 484 name[i] = '\000'; |
| 473 | 485 |
| 474 result.ptr = name; | |
| 475 result.length = i; | 486 result.length = i; |
| 476 return result; | 487 return result; |
| 477 } | 488 } |
| 478 | 489 |
| 479 /* Return TEXT[0..LEN-1], a string literal without surrounding quotes, | 490 /* Return TEXT[0..LEN-1], a string literal without surrounding quotes, |
| 480 with special hex character notations replaced with characters. | 491 with special hex character notations replaced with characters. |
| 481 Result valid until the next call to ada_parse. */ | 492 Result valid until the next call to ada_parse. */ |
| 482 | 493 |
| 483 static struct stoken | 494 static struct stoken |
| 484 processString (const char *text, int len) | 495 processString (const char *text, int len) |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 { | 622 { |
| 612 return 1; | 623 return 1; |
| 613 } | 624 } |
| 614 | 625 |
| 615 /* Dummy definition to suppress warnings about unused static definitions. */ | 626 /* Dummy definition to suppress warnings about unused static definitions. */ |
| 616 typedef void (*dummy_function) (); | 627 typedef void (*dummy_function) (); |
| 617 dummy_function ada_flex_use[] = | 628 dummy_function ada_flex_use[] = |
| 618 { | 629 { |
| 619 (dummy_function) yyunput | 630 (dummy_function) yyunput |
| 620 }; | 631 }; |
| OLD | NEW |