* ch-exp.y (GENERAL_PROCEDURE_NAME, LOCATION_NAME): New
authorFred Fish <fnf@specifix.com>
Sun, 29 Nov 1992 06:59:17 +0000 (06:59 +0000)
committerFred Fish <fnf@specifix.com>
Sun, 29 Nov 1992 06:59:17 +0000 (06:59 +0000)
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.

gdb/ChangeLog
gdb/ch-exp.y

index 37e4198408cb8479b6d2861100d6cacb5def142d..01512adbb6be0241725b206296382f09b312ac63 100644 (file)
@@ -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
index d9c985b052b084724326daae61b8cbd4a68fc82d..dc607298c80de0b314888040f7942ec4786a7ec5 100644 (file)
@@ -151,6 +151,8 @@ static int parse_number PARAMS ((void));
 %token <typed_val>     INTEGER_LITERAL
 %token <ulval>         BOOLEAN_LITERAL
 %token <typed_val>     CHARACTER_LITERAL
+%token <ssym>          GENERAL_PROCEDURE_NAME
+%token <ssym>          LOCATION_NAME
 %token <voidval>       SET_LITERAL
 %token <voidval>       EMPTINESS_LITERAL
 %token <voidval>       CHARACTER_STRING_LITERAL
@@ -200,6 +202,7 @@ static int parse_number PARAMS ((void));
 %token <voidval>       ILLEGAL_TOKEN
 
 %type <voidval>                location
+%type <voidval>                access_name
 %type <voidval>                primitive_value
 %type <voidval>                location_contents
 %type <voidval>                value_name
@@ -236,7 +239,6 @@ static int parse_number PARAMS ((void));
 %type <voidval>                value_enumeration_name
 %type <voidval>                value_do_with_name
 %type <voidval>                value_receive_name
-%type <voidval>                general_procedure_name
 %type <voidval>                string_primitive_value
 %type <voidval>                start_element
 %type <voidval>                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);
 }
 
This page took 0.030658 seconds and 4 git commands to generate.