From: Fred Fish Date: Sun, 29 Nov 1992 06:59:17 +0000 (+0000) Subject: * ch-exp.y (GENERAL_PROCEDURE_NAME, LOCATION_NAME): New X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cbd1bdc3facc87ac2aa85108a721daf66e26a1a8;p=binutils-gdb.git * ch-exp.y (GENERAL_PROCEDURE_NAME, LOCATION_NAME): New terminal tokens. * ch-exp.y (access_name): New non-terminal token and production. * ch-exp.y (general_procedure_name): Now a terminal token. * ch-exp.y (location): Expand production. * ch-exp.y (match_simple_name_string): New function. * ch-exp.y (yylex): Call match_simple_name_string and return GENERAL_PROCEDURE_NAME or LOCATION_NAME as appropriate. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 37e4198408c..01512adbb6b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,17 @@ + **** start-sanitize-chill **** +Sat Nov 28 22:45:04 1992 Fred Fish (fnf@cygnus.com) + + * ch-exp.y (GENERAL_PROCEDURE_NAME, LOCATION_NAME): New + terminal tokens. + * ch-exp.y (access_name): New non-terminal token and + production. + * ch-exp.y (general_procedure_name): Now a terminal token. + * ch-exp.y (location): Expand production. + * ch-exp.y (match_simple_name_string): New function. + * ch-exp.y (yylex): Call match_simple_name_string and return + GENERAL_PROCEDURE_NAME or LOCATION_NAME as appropriate. + **** end-sanitize-chill **** + Wed Nov 25 07:17:13 1992 Fred Fish (fnf@cygnus.com) * munch: Backslash escape vertical bar characters inside diff --git a/gdb/ch-exp.y b/gdb/ch-exp.y index d9c985b052b..dc607298c80 100644 --- a/gdb/ch-exp.y +++ b/gdb/ch-exp.y @@ -151,6 +151,8 @@ static int parse_number PARAMS ((void)); %token INTEGER_LITERAL %token BOOLEAN_LITERAL %token CHARACTER_LITERAL +%token GENERAL_PROCEDURE_NAME +%token LOCATION_NAME %token SET_LITERAL %token EMPTINESS_LITERAL %token CHARACTER_STRING_LITERAL @@ -200,6 +202,7 @@ static int parse_number PARAMS ((void)); %token ILLEGAL_TOKEN %type location +%type access_name %type primitive_value %type location_contents %type value_name @@ -236,7 +239,6 @@ static int parse_number PARAMS ((void)); %type value_enumeration_name %type value_do_with_name %type value_receive_name -%type general_procedure_name %type string_primitive_value %type start_element %type left_element @@ -278,7 +280,25 @@ undefined_value : FIXME /* Z.200, 4.2.1 */ -location : FIXME +location : access_name + { + $$ = 0; /* FIXME */ + } + | FIXME + { + $$ = 0; /* FIXME */ + } + ; + +/* Z.200, 4.2.2 */ + +access_name : LOCATION_NAME + { + write_exp_elt_opcode (OP_VAR_VALUE); + write_exp_elt_sym ($1.sym); + write_exp_elt_opcode (OP_VAR_VALUE); + } + | FIXME { $$ = 0; /* FIXME */ } @@ -374,9 +394,11 @@ value_name : synonym_name { $$ = 0; /* FIXME */ } - | general_procedure_name + | GENERAL_PROCEDURE_NAME { - $$ = 0; /* FIXME */ + write_exp_elt_opcode (OP_VAR_VALUE); + write_exp_elt_sym ($1.sym); + write_exp_elt_opcode (OP_VAR_VALUE); } ; @@ -743,7 +765,6 @@ synonym_name : FIXME { $$ = 0; } value_enumeration_name : FIXME { $$ = 0; } value_do_with_name : FIXME { $$ = 0; } value_receive_name : FIXME { $$ = 0; } -general_procedure_name : FIXME { $$ = 0; } string_primitive_value : FIXME { $$ = 0; } start_element : FIXME { $$ = 0; } left_element : FIXME { $$ = 0; } @@ -765,6 +786,28 @@ buffer_location : FIXME { $$ = 0; } %% +/* Try to consume a simple name string token. If successful, returns + a pointer to a nullbyte terminated copy of the name that can be used + in symbol table lookups. If not successful, returns NULL. */ + +static char * +match_simple_name_string () +{ + char *tokptr = lexptr; + + if (isalpha (*tokptr)) + { + do { + tokptr++; + } while (isalpha (*tokptr) || isdigit (*tokptr) || (*tokptr == '_')); + yylval.sval.ptr = lexptr; + yylval.sval.length = tokptr - lexptr; + lexptr = tokptr; + return (copy_name (yylval.sval)); + } + return (NULL); +} + /* Start looking for a value composed of valid digits as set by the base in use. Note that '_' characters are valid anywhere, in any quantity, and are simply ignored. Since we must find at least one valid digit, @@ -1090,6 +1133,8 @@ yylex () { unsigned int i; int token; + char *simplename; + struct symbol *sym; /* Skip over any leading whitespace. */ while (isspace (*lexptr)) @@ -1191,10 +1236,49 @@ yylex () return (BOOLEAN_LITERAL); } token = match_integer_literal (); - if (token != 0); + if (token != 0) { return (token); } + + /* Try to match a simple name string, and if a match is found, then + further classify what sort of name it is and return an appropriate + token. Note that attempting to match a simple name string consumes + the token from lexptr, so we can't back out if we later find that + we can't classify what sort of name it is. */ + + simplename = match_simple_name_string (); + if (simplename != NULL) + { + sym = lookup_symbol (simplename, expression_context_block, + VAR_NAMESPACE, (int *) NULL, + (struct symtab **) NULL); + if (sym != NULL) + { + yylval.ssym.stoken.ptr = NULL; + yylval.ssym.stoken.length = 0; + yylval.ssym.sym = sym; + yylval.ssym.is_a_field_of_this = 0; /* FIXME, C++'ism */ + switch (SYMBOL_CLASS (sym)) + { + case LOC_BLOCK: + /* Found a procedure name. */ + return (GENERAL_PROCEDURE_NAME); + case LOC_STATIC: + /* Found a global or local static variable. */ + return (LOCATION_NAME); + } + } + else if (!have_full_symbols () && !have_partial_symbols ()) + { + error ("No symbol table is loaded. Use the \"file\" command."); + } + else + { + error ("No symbol \"%s\" in current context.", simplename); + } + } + return (ILLEGAL_TOKEN); }