1 /* YACC grammar for Chill expressions, for GDB.
2 Copyright (C) 1992 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20 /* Parse a Chill expression from text in a string,
21 and return the result as a struct expression pointer.
22 That structure contains arithmetic operations in reverse polish,
23 with constants represented by operations that are followed by special data.
24 See expression.h for the details of the format.
25 What is important here is that it can be built up sequentially
26 during the process of parsing; the lower levels of the tree always
27 come first in the result.
29 Note that malloc's and realloc's in this file are transformed to
30 xmalloc and xrealloc respectively by the same sed command in the
31 makefile that remaps any other malloc/realloc inserted by the parser
32 generator. Doing this with #defines and trying to control the interaction
33 with include files (<malloc.h> and <stdlib.h> for example) just became
34 too messy, particularly when such includes can be inserted at random
35 times by the parser generator.
37 Also note that the language accepted by this parser is more liberal
38 than the one accepted by an actual Chill compiler. For example, the
39 language rule that a simple name string can not be one of the reserved
40 simple name strings is not enforced (e.g "case" is not treated as a
41 reserved name). Another example is that Chill is a strongly typed
42 language, and certain expressions that violate the type constraints
43 may still be evaluated if gdb can do so in a meaningful manner, while
44 such expressions would be rejected by the compiler. The reason for
45 this more liberal behavior is the philosophy that the debugger
46 is intended to be a tool that is used by the programmer when things
47 go wrong, and as such, it should provide as few artificial barriers
48 to it's use as possible. If it can do something meaningful, even
49 something that violates language contraints that are enforced by the
50 compiler, it should do so without complaint.
57 #include "expression.h"
60 #include "parser-defs.h"
63 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
64 as well as gratuitiously global symbol names, so we can have multiple
65 yacc generated parsers in gdb. Note that these are only the variables
66 produced by yacc. If other parser generators (bison, byacc, etc) produce
67 additional global names that conflict at link time, then those parser
68 generators need to be fixed instead of adding those names to this list. */
70 #define yymaxdepth chill_maxdepth
71 #define yyparse chill_parse
72 #define yylex chill_lex
73 #define yyerror chill_error
74 #define yylval chill_lval
75 #define yychar chill_char
76 #define yydebug chill_debug
77 #define yypact chill_pact
80 #define yydef chill_def
81 #define yychk chill_chk
82 #define yypgo chill_pgo
83 #define yyact chill_act
84 #define yyexca chill_exca
85 #define yyerrflag chill_errflag
86 #define yynerrs chill_nerrs
90 #define yy_yys chill_yys
91 #define yystate chill_state
92 #define yytmp chill_tmp
94 #define yy_yyv chill_yyv
95 #define yyval chill_val
96 #define yylloc chill_lloc
97 #define yyreds chill_reds /* With YYDEBUG defined */
98 #define yytoks chill_toks /* With YYDEBUG defined */
101 #define YYDEBUG 0 /* Default to no yydebug support */
105 yyparse PARAMS ((void));
108 yylex PARAMS ((void));
111 yyerror PARAMS ((char *));
115 /* Although the yacc "value" of an expression is not used,
116 since the result is stored in the structure being created,
117 other node types do have values. */
122 unsigned LONGEST ulval;
132 struct symtoken ssym;
135 enum exp_opcode opcode;
136 struct internalvar *ivar;
142 %token <voidval> FIXME
144 %token <typed_val> INTEGER_LITERAL
145 %token <ulval> BOOLEAN_LITERAL
146 %token <typed_val> CHARACTER_LITERAL
147 %token <ssym> GENERAL_PROCEDURE_NAME
148 %token <ssym> LOCATION_NAME
149 %token <voidval> SET_LITERAL
150 %token <voidval> EMPTINESS_LITERAL
151 %token <voidval> CHARACTER_STRING_LITERAL
152 %token <voidval> BIT_STRING_LITERAL
154 %token <voidval> STRING
155 %token <voidval> CONSTANT
159 %token <voidval> CASE
161 %token <voidval> ESAC
162 %token <voidval> LOGIOR
163 %token <voidval> ORIF
164 %token <voidval> LOGXOR
165 %token <voidval> LOGAND
166 %token <voidval> ANDIF
168 %token <voidval> NOTEQUAL
178 %token <voidval> SLASH_SLASH
182 %token <voidval> POINTER
183 %token <voidval> RECEIVE
191 %token <voidval> THEN
192 %token <voidval> ELSE
194 %token <voidval> ELSIF
195 %token <voidval> ILLEGAL_TOKEN
197 /* Tokens which are not Chill tokens used in expressions, but rather GDB
198 specific things that we recognize in the same context as Chill tokens
199 (register names for example). */
201 %token <lval> GDB_REGNAME /* Machine register name */
202 %token <lval> GDB_LAST /* Value history */
203 %token <ivar> GDB_VARIABLE /* Convenience variable */
204 %token <voidval> GDB_ASSIGNMENT /* Assign value to somewhere */
206 %type <voidval> location
207 %type <voidval> access_name
208 %type <voidval> primitive_value
209 %type <voidval> location_contents
210 %type <voidval> value_name
211 %type <voidval> literal
212 %type <voidval> tuple
213 %type <voidval> value_string_element
214 %type <voidval> value_string_slice
215 %type <voidval> value_array_element
216 %type <voidval> value_array_slice
217 %type <voidval> value_structure_field
218 %type <voidval> expression_conversion
219 %type <voidval> value_procedure_call
220 %type <voidval> value_built_in_routine_call
221 %type <voidval> start_expression
222 %type <voidval> zero_adic_operator
223 %type <voidval> parenthesised_expression
224 %type <voidval> value
225 %type <voidval> undefined_value
226 %type <voidval> expression
227 %type <voidval> conditional_expression
228 %type <voidval> then_alternative
229 %type <voidval> else_alternative
230 %type <voidval> sub_expression
231 %type <voidval> value_case_alternative
232 %type <voidval> operand_0
233 %type <voidval> operand_1
234 %type <voidval> operand_2
235 %type <voidval> operand_3
236 %type <voidval> operand_4
237 %type <voidval> operand_5
238 %type <voidval> operand_6
239 %type <voidval> integer_literal_expression
240 %type <voidval> synonym_name
241 %type <voidval> value_enumeration_name
242 %type <voidval> value_do_with_name
243 %type <voidval> value_receive_name
244 %type <voidval> string_primitive_value
245 %type <voidval> start_element
246 %type <voidval> left_element
247 %type <voidval> right_element
248 %type <voidval> slice_size
249 %type <voidval> array_primitive_value
250 %type <voidval> expression_list
251 %type <voidval> lower_element
252 %type <voidval> upper_element
253 %type <voidval> first_element
254 %type <voidval> structure_primitive_value
255 %type <voidval> field_name
256 %type <voidval> mode_name
257 %type <voidval> boolean_expression
258 %type <voidval> case_selector_list
259 %type <voidval> subexpression
260 %type <voidval> case_label_specification
261 %type <voidval> buffer_location
263 %type <voidval> single_assignment_action
279 undefined_value : FIXME
287 location : access_name
299 access_name : LOCATION_NAME
301 write_exp_elt_opcode (OP_VAR_VALUE);
302 write_exp_elt_sym ($1.sym);
303 write_exp_elt_opcode (OP_VAR_VALUE);
305 | GDB_LAST /* gdb specific */
307 write_exp_elt_opcode (OP_LAST);
308 write_exp_elt_longcst ($1);
309 write_exp_elt_opcode (OP_LAST);
311 | GDB_REGNAME /* gdb specific */
313 write_exp_elt_opcode (OP_REGISTER);
314 write_exp_elt_longcst ($1);
315 write_exp_elt_opcode (OP_REGISTER);
317 | GDB_VARIABLE /* gdb specific */
319 write_exp_elt_opcode (OP_INTERNALVAR);
320 write_exp_elt_intern ($1);
321 write_exp_elt_opcode (OP_INTERNALVAR);
331 primitive_value : location_contents
347 | value_string_element
355 | value_array_element
363 | value_structure_field
367 | expression_conversion
371 | value_procedure_call
375 | value_built_in_routine_call
387 | parenthesised_expression
395 location_contents: location
403 value_name : synonym_name
407 | value_enumeration_name
419 | GENERAL_PROCEDURE_NAME
421 write_exp_elt_opcode (OP_VAR_VALUE);
422 write_exp_elt_sym ($1.sym);
423 write_exp_elt_opcode (OP_VAR_VALUE);
429 literal : INTEGER_LITERAL
431 write_exp_elt_opcode (OP_LONG);
432 write_exp_elt_type ($1.type);
433 write_exp_elt_longcst ((LONGEST) ($1.val));
434 write_exp_elt_opcode (OP_LONG);
438 write_exp_elt_opcode (OP_BOOL);
439 write_exp_elt_longcst ((LONGEST) $1);
440 write_exp_elt_opcode (OP_BOOL);
444 write_exp_elt_opcode (OP_LONG);
445 write_exp_elt_type ($1.type);
446 write_exp_elt_longcst ((LONGEST) ($1.val));
447 write_exp_elt_opcode (OP_LONG);
457 | CHARACTER_STRING_LITERAL
478 value_string_element: string_primitive_value '(' start_element ')'
486 value_string_slice: string_primitive_value '(' left_element ':' right_element ')'
490 | string_primitive_value '(' start_element UP slice_size ')'
498 value_array_element: array_primitive_value '(' expression_list ')'
506 value_array_slice: array_primitive_value '(' lower_element ':' upper_element ')'
510 | array_primitive_value '(' first_element UP slice_size ')'
518 value_structure_field: structure_primitive_value '.' field_name
526 expression_conversion: mode_name '(' expression ')'
534 value_procedure_call: FIXME
542 value_built_in_routine_call: FIXME
550 start_expression: FIXME
553 } /* Not in GNU-Chill */
558 zero_adic_operator: FIXME
566 parenthesised_expression: '(' expression ')'
574 expression : operand_0
578 | conditional_expression
584 conditional_expression : IF boolean_expression then_alternative else_alternative FI
588 | CASE case_selector_list OF value_case_alternative '[' ELSE sub_expression ']' ESAC
594 then_alternative: THEN subexpression
600 else_alternative: ELSE subexpression
604 | ELSIF boolean_expression then_alternative else_alternative
610 sub_expression : expression
616 value_case_alternative: case_label_specification ':' sub_expression ';'
624 operand_0 : operand_1
628 | operand_0 LOGIOR operand_1
630 write_exp_elt_opcode (BINOP_BITWISE_IOR);
632 | operand_0 ORIF operand_1
636 | operand_0 LOGXOR operand_1
638 write_exp_elt_opcode (BINOP_BITWISE_XOR);
640 | single_assignment_action
648 operand_1 : operand_2
652 | operand_1 LOGAND operand_2
654 write_exp_elt_opcode (BINOP_BITWISE_AND);
656 | operand_1 ANDIF operand_2
664 operand_2 : operand_3
668 | operand_2 '=' operand_3
670 write_exp_elt_opcode (BINOP_EQUAL);
672 | operand_2 NOTEQUAL operand_3
674 write_exp_elt_opcode (BINOP_NOTEQUAL);
676 | operand_2 '>' operand_3
678 write_exp_elt_opcode (BINOP_GTR);
680 | operand_2 GTR operand_3
682 write_exp_elt_opcode (BINOP_GEQ);
684 | operand_2 '<' operand_3
686 write_exp_elt_opcode (BINOP_LESS);
688 | operand_2 LEQ operand_3
690 write_exp_elt_opcode (BINOP_LEQ);
692 | operand_2 IN operand_3
701 operand_3 : operand_4
705 | operand_3 '+' operand_4
707 write_exp_elt_opcode (BINOP_ADD);
709 | operand_3 '-' operand_4
711 write_exp_elt_opcode (BINOP_SUB);
713 | operand_3 SLASH_SLASH operand_4
721 operand_4 : operand_5
725 | operand_4 '*' operand_5
727 write_exp_elt_opcode (BINOP_MUL);
729 | operand_4 '/' operand_5
731 write_exp_elt_opcode (BINOP_DIV);
733 | operand_4 MOD operand_5
737 | operand_4 REM operand_5
745 operand_5 : operand_6
751 write_exp_elt_opcode (UNOP_NEG);
755 write_exp_elt_opcode (UNOP_LOGICAL_NOT);
757 | '(' integer_literal_expression ')' operand_6
765 operand_6 : POINTER location
769 | RECEIVE buffer_location
782 single_assignment_action : location GDB_ASSIGNMENT value
784 write_exp_elt_opcode (BINOP_ASSIGN);
788 /* FIXME: For now we just accept only a single integer literal. */
790 integer_literal_expression:
796 /* Things which still need productions... */
797 synonym_name : FIXME { $$ = 0; }
798 value_enumeration_name : FIXME { $$ = 0; }
799 value_do_with_name : FIXME { $$ = 0; }
800 value_receive_name : FIXME { $$ = 0; }
801 string_primitive_value : FIXME { $$ = 0; }
802 start_element : FIXME { $$ = 0; }
803 left_element : FIXME { $$ = 0; }
804 right_element : FIXME { $$ = 0; }
805 slice_size : FIXME { $$ = 0; }
806 array_primitive_value : FIXME { $$ = 0; }
807 expression_list : FIXME { $$ = 0; }
808 lower_element : FIXME { $$ = 0; }
809 upper_element : FIXME { $$ = 0; }
810 first_element : FIXME { $$ = 0; }
811 structure_primitive_value: FIXME { $$ = 0; }
812 field_name : FIXME { $$ = 0; }
813 mode_name : FIXME { $$ = 0; }
814 boolean_expression : FIXME { $$ = 0; }
815 case_selector_list : FIXME { $$ = 0; }
816 subexpression : FIXME { $$ = 0; }
817 case_label_specification: FIXME { $$ = 0; }
818 buffer_location : FIXME { $$ = 0; }
822 /* Try to consume a simple name string token. If successful, returns
823 a pointer to a nullbyte terminated copy of the name that can be used
824 in symbol table lookups. If not successful, returns NULL. */
827 match_simple_name_string ()
829 char *tokptr = lexptr;
831 if (isalpha (*tokptr))
835 } while (isalpha (*tokptr) || isdigit (*tokptr) || (*tokptr == '_'));
836 yylval.sval.ptr = lexptr;
837 yylval.sval.length = tokptr - lexptr;
839 return (copy_name (yylval.sval));
844 /* Start looking for a value composed of valid digits as set by the base
845 in use. Note that '_' characters are valid anywhere, in any quantity,
846 and are simply ignored. Since we must find at least one valid digit,
847 or reject this token as an integer literal, we keep track of how many
848 digits we have encountered. */
851 decode_integer_value (base, tokptrptr, ivalptr)
856 char *tokptr = *tokptrptr;
860 while (*tokptr != '\0')
862 temp = tolower (*tokptr);
868 case '0': case '1': case '2': case '3': case '4':
869 case '5': case '6': case '7': case '8': case '9':
872 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
888 /* Found something not in domain for current base. */
889 tokptr--; /* Unconsume what gave us indigestion. */
894 /* If we didn't find any digits, then we don't have a valid integer
895 value, so reject the entire token. Otherwise, update the lexical
896 scan pointer, and return non-zero for success. */
910 decode_integer_literal (valptr, tokptrptr)
914 char *tokptr = *tokptrptr;
917 int explicit_base = 0;
919 /* Look for an explicit base specifier, which is optional. */
952 /* If we found an explicit base ensure that the character after the
953 explicit base is a single quote. */
955 if (explicit_base && (*tokptr++ != '\''))
960 /* Attempt to decode whatever follows as an integer value in the
961 indicated base, updating the token pointer in the process and
962 computing the value into ival. Also, if we have an explicit
963 base, then the next character must not be a single quote, or we
964 have a bitstring literal, so reject the entire token in this case.
965 Otherwise, update the lexical scan pointer, and return non-zero
968 if (!decode_integer_value (base, &tokptr, &ival))
972 else if (explicit_base && (*tokptr == '\''))
984 /* Recognize a character literal. A character literal is single character
985 or a control sequence, enclosed in single quotes. A control sequence
986 is a comma separated list of one or more integer literals, enclosed
987 in parenthesis and introduced with a circumflex character.
989 EX: 'a' '^(7)' '^(7,8)'
991 As a GNU chill extension, the syntax C'xx' is also recognized as a
992 character literal, where xx is a hex value for the character.
994 Returns CHARACTER_LITERAL if a match is found.
998 match_character_literal ()
1000 char *tokptr = lexptr;
1003 if ((tolower (*tokptr) == 'c') && (*(tokptr + 1) == '\''))
1005 /* We have a GNU chill extension form, so skip the leading "C'",
1006 decode the hex value, and then ensure that we have a trailing
1007 single quote character. */
1009 if (!decode_integer_value (16, &tokptr, &ival) || (*tokptr != '\''))
1015 else if (*tokptr == '\'')
1019 /* Determine which form we have, either a control sequence or the
1020 single character form. */
1022 if ((*tokptr == '^') && (*(tokptr + 1) == '('))
1024 /* Match and decode a control sequence. Return zero if we don't
1025 find a valid integer literal, or if the next unconsumed character
1026 after the integer literal is not the trailing ')'.
1027 FIXME: We currently don't handle the multiple integer literal
1030 if (!decode_integer_literal (&ival, &tokptr) || (*tokptr++ != ')'))
1040 /* The trailing quote has not yet been consumed. If we don't find
1041 it, then we have no match. */
1043 if (*tokptr++ != '\'')
1050 /* Not a character literal. */
1053 yylval.typed_val.val = ival;
1054 yylval.typed_val.type = builtin_type_chill_char;
1056 return (CHARACTER_LITERAL);
1059 /* Recognize an integer literal, as specified in Z.200 sec 5.2.4.2.
1060 Note that according to 5.2.4.2, a single "_" is also a valid integer
1061 literal, however GNU-chill requires there to be at least one "digit"
1062 in any integer literal. */
1065 match_integer_literal ()
1067 char *tokptr = lexptr;
1070 if (!decode_integer_literal (&ival, &tokptr))
1076 yylval.typed_val.val = ival;
1077 yylval.typed_val.type = builtin_type_int;
1079 return (INTEGER_LITERAL);
1083 /* Recognize tokens that start with '$'. These include:
1085 $regname A native register name or a "standard
1087 Return token GDB_REGNAME.
1089 $variable A convenience variable with a name chosen
1091 Return token GDB_VARIABLE.
1093 $digits Value history with index <digits>, starting
1094 from the first value which has index 1.
1097 $$digits Value history with index <digits> relative
1098 to the last value. I.E. $$0 is the last
1099 value, $$1 is the one previous to that, $$2
1100 is the one previous to $$1, etc.
1101 Return token GDB_LAST.
1103 $ | $0 | $$0 The last value in the value history.
1104 Return token GDB_LAST.
1106 $$ An abbreviation for the second to the last
1107 value in the value history, I.E. $$1
1108 Return token GDB_LAST.
1110 Note that we currently assume that register names and convenience
1111 variables follow the convention of starting with a letter or '_'.
1116 match_dollar_tokens ()
1124 /* We will always have a successful match, even if it is just for
1125 a single '$', the abbreviation for $$0. So advance lexptr. */
1129 if (*tokptr == '_' || isalpha (*tokptr))
1131 /* Look for a match with a native register name, usually something
1132 like "r0" for example. */
1134 for (regno = 0; regno < NUM_REGS; regno++)
1136 namelength = strlen (reg_names[regno]);
1137 if (STREQN (tokptr, reg_names[regno], namelength)
1138 && !isalnum (tokptr[namelength]))
1140 yylval.lval = regno;
1141 lexptr += namelength + 1;
1142 return (GDB_REGNAME);
1146 /* Look for a match with a standard register name, usually something
1147 like "pc", which gdb always recognizes as the program counter
1148 regardless of what the native register name is. */
1150 for (regno = 0; regno < num_std_regs; regno++)
1152 namelength = strlen (std_regs[regno].name);
1153 if (STREQN (tokptr, std_regs[regno].name, namelength)
1154 && !isalnum (tokptr[namelength]))
1156 yylval.lval = std_regs[regno].regnum;
1157 lexptr += namelength;
1158 return (GDB_REGNAME);
1162 /* Attempt to match against a convenience variable. Note that
1163 this will always succeed, because if no variable of that name
1164 already exists, the lookup_internalvar will create one for us.
1165 Also note that both lexptr and tokptr currently point to the
1166 start of the input string we are trying to match, and that we
1167 have already tested the first character for non-numeric, so we
1168 don't have to treat it specially. */
1170 while (*tokptr == '_' || isalnum (*tokptr))
1174 yylval.sval.ptr = lexptr;
1175 yylval.sval.length = tokptr - lexptr;
1176 yylval.ivar = lookup_internalvar (copy_name (yylval.sval));
1178 return (GDB_VARIABLE);
1181 /* Since we didn't match against a register name or convenience
1182 variable, our only choice left is a history value. */
1196 /* Attempt to decode more characters as an integer value giving
1197 the index in the history list. If successful, the value will
1198 overwrite ival (currently 0 or 1), and if not, ival will be
1199 left alone, which is good since it is currently correct for
1200 the '$' or '$$' case. */
1202 decode_integer_literal (&ival, &tokptr);
1203 yylval.lval = negate ? -ival : ival;
1209 static void convert_float ()
1211 extern double strtod ();
1214 char *p = yytext, *p1 = tmp;
1234 d = strtod (tmp, &p1);
1237 /* add error handling here */
1244 /* Take care of parsing a number (anything that starts with a digit).
1245 Set yylval and return the token type; update lexptr.
1246 LEN is the number of characters in it. */
1248 /*** Needs some error checking for the float case ***/
1256 static const struct token tokentab5[] =
1261 static const struct token tokentab4[] =
1266 static const struct token tokentab3[] =
1273 static const struct token tokentab2[] =
1275 { ":=", GDB_ASSIGNMENT },
1276 { "//", SLASH_SLASH },
1284 /* Read one token, getting characters through lexptr. */
1285 /* This is where we will check to make sure that the language and the
1286 operators used are compatible. */
1296 /* Skip over any leading whitespace. */
1297 while (isspace (*lexptr))
1301 /* Look for special single character cases which can't be the first
1302 character of some other multicharacter token. */
1321 /* Look for characters which start a particular kind of multicharacter
1322 token, such as a character literal, register name, convenience
1323 variable name, etc. */
1329 token = match_character_literal ();
1336 token = match_dollar_tokens ();
1343 /* See if it is a special token of length 5. */
1344 for (i = 0; i < sizeof (tokentab5) / sizeof (tokentab5[0]); i++)
1346 if (STREQN (lexptr, tokentab5[i].operator, 5))
1349 return (tokentab5[i].token);
1352 /* See if it is a special token of length 4. */
1353 for (i = 0; i < sizeof (tokentab4) / sizeof (tokentab4[0]); i++)
1355 if (STREQN (lexptr, tokentab4[i].operator, 4))
1358 return (tokentab4[i].token);
1361 /* See if it is a special token of length 3. */
1362 for (i = 0; i < sizeof (tokentab3) / sizeof (tokentab3[0]); i++)
1364 if (STREQN (lexptr, tokentab3[i].operator, 3))
1367 return (tokentab3[i].token);
1370 /* See if it is a special token of length 2. */
1371 for (i = 0; i < sizeof (tokentab2) / sizeof (tokentab2[0]); i++)
1373 if (STREQN (lexptr, tokentab2[i].operator, 2))
1376 return (tokentab2[i].token);
1379 /* Look for single character cases which which could be the first
1380 character of some other multicharacter token, but aren't, or we
1381 would already have found it. */
1390 /* Look for other special tokens. */
1391 if (STREQN (lexptr, "TRUE", 4)) /* FIXME: What about lowercase? */
1395 return (BOOLEAN_LITERAL);
1397 if (STREQN (lexptr, "FALSE", 5)) /* FIXME: What about lowercase? */
1401 return (BOOLEAN_LITERAL);
1403 token = match_integer_literal ();
1409 /* Try to match a simple name string, and if a match is found, then
1410 further classify what sort of name it is and return an appropriate
1411 token. Note that attempting to match a simple name string consumes
1412 the token from lexptr, so we can't back out if we later find that
1413 we can't classify what sort of name it is. */
1415 simplename = match_simple_name_string ();
1416 if (simplename != NULL)
1418 sym = lookup_symbol (simplename, expression_context_block,
1419 VAR_NAMESPACE, (int *) NULL,
1420 (struct symtab **) NULL);
1423 yylval.ssym.stoken.ptr = NULL;
1424 yylval.ssym.stoken.length = 0;
1425 yylval.ssym.sym = sym;
1426 yylval.ssym.is_a_field_of_this = 0; /* FIXME, C++'ism */
1427 switch (SYMBOL_CLASS (sym))
1430 /* Found a procedure name. */
1431 return (GENERAL_PROCEDURE_NAME);
1433 /* Found a global or local static variable. */
1434 return (LOCATION_NAME);
1444 case LOC_CONST_BYTES:
1449 else if (!have_full_symbols () && !have_partial_symbols ())
1451 error ("No symbol table is loaded. Use the \"file\" command.");
1455 error ("No symbol \"%s\" in current context.", simplename);
1459 return (ILLEGAL_TOKEN);
1464 char *msg; /* unused */
1466 printf ("Parsing: %s\n", lexptr);
1469 error ("Invalid syntax in expression near character '%c'.", yychar);
1473 error ("Invalid syntax in expression");