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 /* These MUST be included in any grammar file!!!! Please choose unique names!
64 Note that this are a combined list of variables that can be produced
65 by any one of bison, byacc, or yacc. */
66 #define yymaxdepth chill_maxdepth
67 #define yyparse chill_parse
68 #define yylex chill_lex
69 #define yyerror chill_error
70 #define yylval chill_lval
71 #define yychar chill_char
72 #define yydebug chill_debug
73 #define yypact chill_pact
76 #define yydef chill_def
77 #define yychk chill_chk
78 #define yypgo chill_pgo
79 #define yyact chill_act
80 #define yyexca chill_exca
81 #define yyerrflag chill_errflag
82 #define yynerrs chill_nerrs
86 #define yy_yys chill_yys
87 #define yystate chill_state
88 #define yytmp chill_tmp
90 #define yy_yyv chill_yyv
91 #define yyval chill_val
92 #define yylloc chill_lloc
93 #define yyrule chill_rule /* With YYDEBUG defined, byacc */
94 #define yyname chill_name /* With YYDEBUG defined, byacc */
95 #define yyreds chill_reds /* With YYDEBUG defined */
96 #define yytoks chill_toks /* With YYDEBUG defined */
97 #define yyss chill_yyss /* byacc */
98 #define yyssp chill_yysp /* byacc */
99 #define yyvs chill_yyvs /* byacc */
100 #define yyvsp chill_yyvsp /* byacc */
103 yylex PARAMS ((void));
106 yyerror PARAMS ((char *));
109 yyparse PARAMS ((void));
117 /* Although the yacc "value" of an expression is not used,
118 since the result is stored in the structure being created,
119 other node types do have values. */
124 unsigned LONGEST ulval;
134 struct symtoken ssym;
137 enum exp_opcode opcode;
138 struct internalvar *ivar;
144 %token <voidval> FIXME
146 %token <typed_val> INTEGER_LITERAL
147 %token <ulval> BOOLEAN_LITERAL
148 %token <typed_val> CHARACTER_LITERAL
149 %token <ssym> GENERAL_PROCEDURE_NAME
150 %token <ssym> LOCATION_NAME
151 %token <voidval> SET_LITERAL
152 %token <voidval> EMPTINESS_LITERAL
153 %token <voidval> CHARACTER_STRING_LITERAL
154 %token <voidval> BIT_STRING_LITERAL
156 %token <voidval> STRING
157 %token <voidval> CONSTANT
161 %token <voidval> CASE
163 %token <voidval> ESAC
164 %token <voidval> LOGIOR
165 %token <voidval> ORIF
166 %token <voidval> LOGXOR
167 %token <voidval> LOGAND
168 %token <voidval> ANDIF
170 %token <voidval> NOTEQUAL
180 %token <voidval> SLASH_SLASH
184 %token <voidval> POINTER
185 %token <voidval> RECEIVE
193 %token <voidval> THEN
194 %token <voidval> ELSE
196 %token <voidval> ELSIF
197 %token <voidval> ILLEGAL_TOKEN
199 /* Tokens which are not Chill tokens used in expressions, but rather GDB
200 specific things that we recognize in the same context as Chill tokens
201 (register names for example). */
203 %token <lval> GDB_REGNAME /* Machine register name */
204 %token <lval> GDB_LAST /* Value history */
205 %token <ivar> GDB_VARIABLE /* Convenience variable */
206 %token <voidval> GDB_ASSIGNMENT /* Assign value to somewhere */
208 %type <voidval> location
209 %type <voidval> access_name
210 %type <voidval> primitive_value
211 %type <voidval> location_contents
212 %type <voidval> value_name
213 %type <voidval> literal
214 %type <voidval> tuple
215 %type <voidval> value_string_element
216 %type <voidval> value_string_slice
217 %type <voidval> value_array_element
218 %type <voidval> value_array_slice
219 %type <voidval> value_structure_field
220 %type <voidval> expression_conversion
221 %type <voidval> value_procedure_call
222 %type <voidval> value_built_in_routine_call
223 %type <voidval> start_expression
224 %type <voidval> zero_adic_operator
225 %type <voidval> parenthesised_expression
226 %type <voidval> value
227 %type <voidval> undefined_value
228 %type <voidval> expression
229 %type <voidval> conditional_expression
230 %type <voidval> then_alternative
231 %type <voidval> else_alternative
232 %type <voidval> sub_expression
233 %type <voidval> value_case_alternative
234 %type <voidval> operand_0
235 %type <voidval> operand_1
236 %type <voidval> operand_2
237 %type <voidval> operand_3
238 %type <voidval> operand_4
239 %type <voidval> operand_5
240 %type <voidval> operand_6
241 %type <voidval> integer_literal_expression
242 %type <voidval> synonym_name
243 %type <voidval> value_enumeration_name
244 %type <voidval> value_do_with_name
245 %type <voidval> value_receive_name
246 %type <voidval> string_primitive_value
247 %type <voidval> start_element
248 %type <voidval> left_element
249 %type <voidval> right_element
250 %type <voidval> slice_size
251 %type <voidval> array_primitive_value
252 %type <voidval> expression_list
253 %type <voidval> lower_element
254 %type <voidval> upper_element
255 %type <voidval> first_element
256 %type <voidval> structure_primitive_value
257 %type <voidval> field_name
258 %type <voidval> mode_name
259 %type <voidval> boolean_expression
260 %type <voidval> case_selector_list
261 %type <voidval> subexpression
262 %type <voidval> case_label_specification
263 %type <voidval> buffer_location
265 %type <voidval> single_assignment_action
281 undefined_value : FIXME
289 location : access_name
301 access_name : LOCATION_NAME
303 write_exp_elt_opcode (OP_VAR_VALUE);
304 write_exp_elt_sym ($1.sym);
305 write_exp_elt_opcode (OP_VAR_VALUE);
307 | GDB_LAST /* gdb specific */
309 write_exp_elt_opcode (OP_LAST);
310 write_exp_elt_longcst ($1);
311 write_exp_elt_opcode (OP_LAST);
313 | GDB_REGNAME /* gdb specific */
315 write_exp_elt_opcode (OP_REGISTER);
316 write_exp_elt_longcst ($1);
317 write_exp_elt_opcode (OP_REGISTER);
319 | GDB_VARIABLE /* gdb specific */
321 write_exp_elt_opcode (OP_INTERNALVAR);
322 write_exp_elt_intern ($1);
323 write_exp_elt_opcode (OP_INTERNALVAR);
333 primitive_value : location_contents
349 | value_string_element
357 | value_array_element
365 | value_structure_field
369 | expression_conversion
373 | value_procedure_call
377 | value_built_in_routine_call
389 | parenthesised_expression
397 location_contents: location
405 value_name : synonym_name
409 | value_enumeration_name
421 | GENERAL_PROCEDURE_NAME
423 write_exp_elt_opcode (OP_VAR_VALUE);
424 write_exp_elt_sym ($1.sym);
425 write_exp_elt_opcode (OP_VAR_VALUE);
431 literal : INTEGER_LITERAL
433 write_exp_elt_opcode (OP_LONG);
434 write_exp_elt_type ($1.type);
435 write_exp_elt_longcst ((LONGEST) ($1.val));
436 write_exp_elt_opcode (OP_LONG);
440 write_exp_elt_opcode (OP_BOOL);
441 write_exp_elt_longcst ((LONGEST) $1);
442 write_exp_elt_opcode (OP_BOOL);
446 write_exp_elt_opcode (OP_LONG);
447 write_exp_elt_type ($1.type);
448 write_exp_elt_longcst ((LONGEST) ($1.val));
449 write_exp_elt_opcode (OP_LONG);
459 | CHARACTER_STRING_LITERAL
480 value_string_element: string_primitive_value '(' start_element ')'
488 value_string_slice: string_primitive_value '(' left_element ':' right_element ')'
492 | string_primitive_value '(' start_element UP slice_size ')'
500 value_array_element: array_primitive_value '(' expression_list ')'
508 value_array_slice: array_primitive_value '(' lower_element ':' upper_element ')'
512 | array_primitive_value '(' first_element UP slice_size ')'
520 value_structure_field: structure_primitive_value '.' field_name
528 expression_conversion: mode_name '(' expression ')'
536 value_procedure_call: FIXME
544 value_built_in_routine_call: FIXME
552 start_expression: FIXME
555 } /* Not in GNU-Chill */
560 zero_adic_operator: FIXME
568 parenthesised_expression: '(' expression ')'
576 expression : operand_0
580 | conditional_expression
586 conditional_expression : IF boolean_expression then_alternative else_alternative FI
590 | CASE case_selector_list OF value_case_alternative '[' ELSE sub_expression ']' ESAC
596 then_alternative: THEN subexpression
602 else_alternative: ELSE subexpression
606 | ELSIF boolean_expression then_alternative else_alternative
612 sub_expression : expression
618 value_case_alternative: case_label_specification ':' sub_expression ';'
626 operand_0 : operand_1
630 | operand_0 LOGIOR operand_1
632 write_exp_elt_opcode (BINOP_BITWISE_IOR);
634 | operand_0 ORIF operand_1
638 | operand_0 LOGXOR operand_1
640 write_exp_elt_opcode (BINOP_BITWISE_XOR);
642 | single_assignment_action
650 operand_1 : operand_2
654 | operand_1 LOGAND operand_2
656 write_exp_elt_opcode (BINOP_BITWISE_AND);
658 | operand_1 ANDIF operand_2
666 operand_2 : operand_3
670 | operand_2 '=' operand_3
672 write_exp_elt_opcode (BINOP_EQUAL);
674 | operand_2 NOTEQUAL operand_3
676 write_exp_elt_opcode (BINOP_NOTEQUAL);
678 | operand_2 '>' operand_3
680 write_exp_elt_opcode (BINOP_GTR);
682 | operand_2 GTR operand_3
684 write_exp_elt_opcode (BINOP_GEQ);
686 | operand_2 '<' operand_3
688 write_exp_elt_opcode (BINOP_LESS);
690 | operand_2 LEQ operand_3
692 write_exp_elt_opcode (BINOP_LEQ);
694 | operand_2 IN operand_3
703 operand_3 : operand_4
707 | operand_3 '+' operand_4
709 write_exp_elt_opcode (BINOP_ADD);
711 | operand_3 '-' operand_4
713 write_exp_elt_opcode (BINOP_SUB);
715 | operand_3 SLASH_SLASH operand_4
723 operand_4 : operand_5
727 | operand_4 '*' operand_5
729 write_exp_elt_opcode (BINOP_MUL);
731 | operand_4 '/' operand_5
733 write_exp_elt_opcode (BINOP_DIV);
735 | operand_4 MOD operand_5
739 | operand_4 REM operand_5
747 operand_5 : operand_6
753 write_exp_elt_opcode (UNOP_NEG);
757 write_exp_elt_opcode (UNOP_LOGICAL_NOT);
759 | '(' integer_literal_expression ')' operand_6
767 operand_6 : POINTER location
771 | RECEIVE buffer_location
784 single_assignment_action : location GDB_ASSIGNMENT value
786 write_exp_elt_opcode (BINOP_ASSIGN);
790 /* FIXME: For now we just accept only a single integer literal. */
792 integer_literal_expression:
798 /* Things which still need productions... */
799 synonym_name : FIXME { $$ = 0; }
800 value_enumeration_name : FIXME { $$ = 0; }
801 value_do_with_name : FIXME { $$ = 0; }
802 value_receive_name : FIXME { $$ = 0; }
803 string_primitive_value : FIXME { $$ = 0; }
804 start_element : FIXME { $$ = 0; }
805 left_element : FIXME { $$ = 0; }
806 right_element : FIXME { $$ = 0; }
807 slice_size : FIXME { $$ = 0; }
808 array_primitive_value : FIXME { $$ = 0; }
809 expression_list : FIXME { $$ = 0; }
810 lower_element : FIXME { $$ = 0; }
811 upper_element : FIXME { $$ = 0; }
812 first_element : FIXME { $$ = 0; }
813 structure_primitive_value: FIXME { $$ = 0; }
814 field_name : FIXME { $$ = 0; }
815 mode_name : FIXME { $$ = 0; }
816 boolean_expression : FIXME { $$ = 0; }
817 case_selector_list : FIXME { $$ = 0; }
818 subexpression : FIXME { $$ = 0; }
819 case_label_specification: FIXME { $$ = 0; }
820 buffer_location : FIXME { $$ = 0; }
824 /* Try to consume a simple name string token. If successful, returns
825 a pointer to a nullbyte terminated copy of the name that can be used
826 in symbol table lookups. If not successful, returns NULL. */
829 match_simple_name_string ()
831 char *tokptr = lexptr;
833 if (isalpha (*tokptr))
837 } while (isalpha (*tokptr) || isdigit (*tokptr) || (*tokptr == '_'));
838 yylval.sval.ptr = lexptr;
839 yylval.sval.length = tokptr - lexptr;
841 return (copy_name (yylval.sval));
846 /* Start looking for a value composed of valid digits as set by the base
847 in use. Note that '_' characters are valid anywhere, in any quantity,
848 and are simply ignored. Since we must find at least one valid digit,
849 or reject this token as an integer literal, we keep track of how many
850 digits we have encountered. */
853 decode_integer_value (base, tokptrptr, ivalptr)
858 char *tokptr = *tokptrptr;
862 while (*tokptr != '\0')
864 temp = tolower (*tokptr);
870 case '0': case '1': case '2': case '3': case '4':
871 case '5': case '6': case '7': case '8': case '9':
874 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
890 /* Found something not in domain for current base. */
891 tokptr--; /* Unconsume what gave us indigestion. */
896 /* If we didn't find any digits, then we don't have a valid integer
897 value, so reject the entire token. Otherwise, update the lexical
898 scan pointer, and return non-zero for success. */
912 decode_integer_literal (valptr, tokptrptr)
916 char *tokptr = *tokptrptr;
919 int explicit_base = 0;
921 /* Look for an explicit base specifier, which is optional. */
954 /* If we found an explicit base ensure that the character after the
955 explicit base is a single quote. */
957 if (explicit_base && (*tokptr++ != '\''))
962 /* Attempt to decode whatever follows as an integer value in the
963 indicated base, updating the token pointer in the process and
964 computing the value into ival. Also, if we have an explicit
965 base, then the next character must not be a single quote, or we
966 have a bitstring literal, so reject the entire token in this case.
967 Otherwise, update the lexical scan pointer, and return non-zero
970 if (!decode_integer_value (base, &tokptr, &ival))
974 else if (explicit_base && (*tokptr == '\''))
986 /* Recognize a character literal. A character literal is single character
987 or a control sequence, enclosed in single quotes. A control sequence
988 is a comma separated list of one or more integer literals, enclosed
989 in parenthesis and introduced with a circumflex character.
991 EX: 'a' '^(7)' '^(7,8)'
993 As a GNU chill extension, the syntax C'xx' is also recognized as a
994 character literal, where xx is a hex value for the character.
996 Returns CHARACTER_LITERAL if a match is found.
1000 match_character_literal ()
1002 char *tokptr = lexptr;
1005 if ((tolower (*tokptr) == 'c') && (*(tokptr + 1) == '\''))
1007 /* We have a GNU chill extension form, so skip the leading "C'",
1008 decode the hex value, and then ensure that we have a trailing
1009 single quote character. */
1011 if (!decode_integer_value (16, &tokptr, &ival) || (*tokptr != '\''))
1017 else if (*tokptr == '\'')
1021 /* Determine which form we have, either a control sequence or the
1022 single character form. */
1024 if ((*tokptr == '^') && (*(tokptr + 1) == '('))
1026 /* Match and decode a control sequence. Return zero if we don't
1027 find a valid integer literal, or if the next unconsumed character
1028 after the integer literal is not the trailing ')'.
1029 FIXME: We currently don't handle the multiple integer literal
1032 if (!decode_integer_literal (&ival, &tokptr) || (*tokptr++ != ')'))
1042 /* The trailing quote has not yet been consumed. If we don't find
1043 it, then we have no match. */
1045 if (*tokptr++ != '\'')
1052 /* Not a character literal. */
1055 yylval.typed_val.val = ival;
1056 yylval.typed_val.type = builtin_type_chill_char;
1058 return (CHARACTER_LITERAL);
1061 /* Recognize an integer literal, as specified in Z.200 sec 5.2.4.2.
1062 Note that according to 5.2.4.2, a single "_" is also a valid integer
1063 literal, however GNU-chill requires there to be at least one "digit"
1064 in any integer literal. */
1067 match_integer_literal ()
1069 char *tokptr = lexptr;
1072 if (!decode_integer_literal (&ival, &tokptr))
1078 yylval.typed_val.val = ival;
1079 yylval.typed_val.type = builtin_type_int;
1081 return (INTEGER_LITERAL);
1085 /* Recognize tokens that start with '$'. These include:
1087 $regname A native register name or a "standard
1089 Return token GDB_REGNAME.
1091 $variable A convenience variable with a name chosen
1093 Return token GDB_VARIABLE.
1095 $digits Value history with index <digits>, starting
1096 from the first value which has index 1.
1099 $$digits Value history with index <digits> relative
1100 to the last value. I.E. $$0 is the last
1101 value, $$1 is the one previous to that, $$2
1102 is the one previous to $$1, etc.
1103 Return token GDB_LAST.
1105 $ | $0 | $$0 The last value in the value history.
1106 Return token GDB_LAST.
1108 $$ An abbreviation for the second to the last
1109 value in the value history, I.E. $$1
1110 Return token GDB_LAST.
1112 Note that we currently assume that register names and convenience
1113 variables follow the convention of starting with a letter or '_'.
1118 match_dollar_tokens ()
1126 /* We will always have a successful match, even if it is just for
1127 a single '$', the abbreviation for $$0. So advance lexptr. */
1131 if (*tokptr == '_' || isalpha (*tokptr))
1133 /* Look for a match with a native register name, usually something
1134 like "r0" for example. */
1136 for (regno = 0; regno < NUM_REGS; regno++)
1138 namelength = strlen (reg_names[regno]);
1139 if (STREQN (tokptr, reg_names[regno], namelength)
1140 && !isalnum (tokptr[namelength]))
1142 yylval.lval = regno;
1143 lexptr += namelength + 1;
1144 return (GDB_REGNAME);
1148 /* Look for a match with a standard register name, usually something
1149 like "pc", which gdb always recognizes as the program counter
1150 regardless of what the native register name is. */
1152 for (regno = 0; regno < num_std_regs; regno++)
1154 namelength = strlen (std_regs[regno].name);
1155 if (STREQN (tokptr, std_regs[regno].name, namelength)
1156 && !isalnum (tokptr[namelength]))
1158 yylval.lval = std_regs[regno].regnum;
1159 lexptr += namelength;
1160 return (GDB_REGNAME);
1164 /* Attempt to match against a convenience variable. Note that
1165 this will always succeed, because if no variable of that name
1166 already exists, the lookup_internalvar will create one for us.
1167 Also note that both lexptr and tokptr currently point to the
1168 start of the input string we are trying to match, and that we
1169 have already tested the first character for non-numeric, so we
1170 don't have to treat it specially. */
1172 while (*tokptr == '_' || isalnum (*tokptr))
1176 yylval.sval.ptr = lexptr;
1177 yylval.sval.length = tokptr - lexptr;
1178 yylval.ivar = lookup_internalvar (copy_name (yylval.sval));
1180 return (GDB_VARIABLE);
1183 /* Since we didn't match against a register name or convenience
1184 variable, our only choice left is a history value. */
1198 /* Attempt to decode more characters as an integer value giving
1199 the index in the history list. If successful, the value will
1200 overwrite ival (currently 0 or 1), and if not, ival will be
1201 left alone, which is good since it is currently correct for
1202 the '$' or '$$' case. */
1204 decode_integer_literal (&ival, &tokptr);
1205 yylval.lval = negate ? -ival : ival;
1211 static void convert_float ()
1213 extern double strtod ();
1216 char *p = yytext, *p1 = tmp;
1236 d = strtod (tmp, &p1);
1239 /* add error handling here */
1246 /* Take care of parsing a number (anything that starts with a digit).
1247 Set yylval and return the token type; update lexptr.
1248 LEN is the number of characters in it. */
1250 /*** Needs some error checking for the float case ***/
1258 static const struct token tokentab5[] =
1263 static const struct token tokentab4[] =
1268 static const struct token tokentab3[] =
1275 static const struct token tokentab2[] =
1277 { ":=", GDB_ASSIGNMENT },
1278 { "//", SLASH_SLASH },
1286 /* Read one token, getting characters through lexptr. */
1287 /* This is where we will check to make sure that the language and the
1288 operators used are compatible. */
1298 /* Skip over any leading whitespace. */
1299 while (isspace (*lexptr))
1303 /* Look for special single character cases which can't be the first
1304 character of some other multicharacter token. */
1323 /* Look for characters which start a particular kind of multicharacter
1324 token, such as a character literal, register name, convenience
1325 variable name, etc. */
1331 token = match_character_literal ();
1338 token = match_dollar_tokens ();
1345 /* See if it is a special token of length 5. */
1346 for (i = 0; i < sizeof (tokentab5) / sizeof (tokentab5[0]); i++)
1348 if (STREQN (lexptr, tokentab5[i].operator, 5))
1351 return (tokentab5[i].token);
1354 /* See if it is a special token of length 4. */
1355 for (i = 0; i < sizeof (tokentab4) / sizeof (tokentab4[0]); i++)
1357 if (STREQN (lexptr, tokentab4[i].operator, 4))
1360 return (tokentab4[i].token);
1363 /* See if it is a special token of length 3. */
1364 for (i = 0; i < sizeof (tokentab3) / sizeof (tokentab3[0]); i++)
1366 if (STREQN (lexptr, tokentab3[i].operator, 3))
1369 return (tokentab3[i].token);
1372 /* See if it is a special token of length 2. */
1373 for (i = 0; i < sizeof (tokentab2) / sizeof (tokentab2[0]); i++)
1375 if (STREQN (lexptr, tokentab2[i].operator, 2))
1378 return (tokentab2[i].token);
1381 /* Look for single character cases which which could be the first
1382 character of some other multicharacter token, but aren't, or we
1383 would already have found it. */
1392 /* Look for other special tokens. */
1393 if (STREQN (lexptr, "TRUE", 4)) /* FIXME: What about lowercase? */
1397 return (BOOLEAN_LITERAL);
1399 if (STREQN (lexptr, "FALSE", 5)) /* FIXME: What about lowercase? */
1403 return (BOOLEAN_LITERAL);
1405 token = match_integer_literal ();
1411 /* Try to match a simple name string, and if a match is found, then
1412 further classify what sort of name it is and return an appropriate
1413 token. Note that attempting to match a simple name string consumes
1414 the token from lexptr, so we can't back out if we later find that
1415 we can't classify what sort of name it is. */
1417 simplename = match_simple_name_string ();
1418 if (simplename != NULL)
1420 sym = lookup_symbol (simplename, expression_context_block,
1421 VAR_NAMESPACE, (int *) NULL,
1422 (struct symtab **) NULL);
1425 yylval.ssym.stoken.ptr = NULL;
1426 yylval.ssym.stoken.length = 0;
1427 yylval.ssym.sym = sym;
1428 yylval.ssym.is_a_field_of_this = 0; /* FIXME, C++'ism */
1429 switch (SYMBOL_CLASS (sym))
1432 /* Found a procedure name. */
1433 return (GENERAL_PROCEDURE_NAME);
1435 /* Found a global or local static variable. */
1436 return (LOCATION_NAME);
1446 case LOC_CONST_BYTES:
1451 else if (!have_full_symbols () && !have_partial_symbols ())
1453 error ("No symbol table is loaded. Use the \"file\" command.");
1457 error ("No symbol \"%s\" in current context.", simplename);
1461 return (ILLEGAL_TOKEN);
1466 char *msg; /* unused */
1468 printf ("Parsing: %s\n", lexptr);
1471 error ("Invalid syntax in expression near character '%c'.", yychar);
1475 error ("Invalid syntax in expression");