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 expression_list : expression
335 | expression_list ',' expression
342 primitive_value : location_contents
358 | value_string_element
366 | value_array_element
374 | value_structure_field
378 | expression_conversion
382 | value_procedure_call
386 | value_built_in_routine_call
398 | parenthesised_expression
406 location_contents: location
414 value_name : synonym_name
418 | value_enumeration_name
430 | GENERAL_PROCEDURE_NAME
432 write_exp_elt_opcode (OP_VAR_VALUE);
433 write_exp_elt_sym ($1.sym);
434 write_exp_elt_opcode (OP_VAR_VALUE);
440 literal : INTEGER_LITERAL
442 write_exp_elt_opcode (OP_LONG);
443 write_exp_elt_type ($1.type);
444 write_exp_elt_longcst ((LONGEST) ($1.val));
445 write_exp_elt_opcode (OP_LONG);
449 write_exp_elt_opcode (OP_BOOL);
450 write_exp_elt_longcst ((LONGEST) $1);
451 write_exp_elt_opcode (OP_BOOL);
455 write_exp_elt_opcode (OP_LONG);
456 write_exp_elt_type ($1.type);
457 write_exp_elt_longcst ((LONGEST) ($1.val));
458 write_exp_elt_opcode (OP_LONG);
468 | CHARACTER_STRING_LITERAL
489 value_string_element: string_primitive_value '(' start_element ')'
497 value_string_slice: string_primitive_value '(' left_element ':' right_element ')'
501 | string_primitive_value '(' start_element UP slice_size ')'
509 value_array_element: array_primitive_value '('
510 /* This is to save the value of arglist_len
511 being accumulated for each dimension. */
512 { start_arglist (); }
515 write_exp_elt_opcode (MULTI_SUBSCRIPT);
516 write_exp_elt_longcst ((LONGEST) end_arglist ());
517 write_exp_elt_opcode (MULTI_SUBSCRIPT);
523 value_array_slice: array_primitive_value '(' lower_element ':' upper_element ')'
527 | array_primitive_value '(' first_element UP slice_size ')'
535 value_structure_field: structure_primitive_value '.' field_name
543 expression_conversion: mode_name '(' expression ')'
551 value_procedure_call: FIXME
559 value_built_in_routine_call: FIXME
567 start_expression: FIXME
570 } /* Not in GNU-Chill */
575 zero_adic_operator: FIXME
583 parenthesised_expression: '(' expression ')'
591 expression : operand_0
595 | conditional_expression
601 conditional_expression : IF boolean_expression then_alternative else_alternative FI
605 | CASE case_selector_list OF value_case_alternative '[' ELSE sub_expression ']' ESAC
611 then_alternative: THEN subexpression
617 else_alternative: ELSE subexpression
621 | ELSIF boolean_expression then_alternative else_alternative
627 sub_expression : expression
633 value_case_alternative: case_label_specification ':' sub_expression ';'
641 operand_0 : operand_1
645 | operand_0 LOGIOR operand_1
647 write_exp_elt_opcode (BINOP_BITWISE_IOR);
649 | operand_0 ORIF operand_1
653 | operand_0 LOGXOR operand_1
655 write_exp_elt_opcode (BINOP_BITWISE_XOR);
657 | single_assignment_action
665 operand_1 : operand_2
669 | operand_1 LOGAND operand_2
671 write_exp_elt_opcode (BINOP_BITWISE_AND);
673 | operand_1 ANDIF operand_2
681 operand_2 : operand_3
685 | operand_2 '=' operand_3
687 write_exp_elt_opcode (BINOP_EQUAL);
689 | operand_2 NOTEQUAL operand_3
691 write_exp_elt_opcode (BINOP_NOTEQUAL);
693 | operand_2 '>' operand_3
695 write_exp_elt_opcode (BINOP_GTR);
697 | operand_2 GTR operand_3
699 write_exp_elt_opcode (BINOP_GEQ);
701 | operand_2 '<' operand_3
703 write_exp_elt_opcode (BINOP_LESS);
705 | operand_2 LEQ operand_3
707 write_exp_elt_opcode (BINOP_LEQ);
709 | operand_2 IN operand_3
718 operand_3 : operand_4
722 | operand_3 '+' operand_4
724 write_exp_elt_opcode (BINOP_ADD);
726 | operand_3 '-' operand_4
728 write_exp_elt_opcode (BINOP_SUB);
730 | operand_3 SLASH_SLASH operand_4
738 operand_4 : operand_5
742 | operand_4 '*' operand_5
744 write_exp_elt_opcode (BINOP_MUL);
746 | operand_4 '/' operand_5
748 write_exp_elt_opcode (BINOP_DIV);
750 | operand_4 MOD operand_5
754 | operand_4 REM operand_5
762 operand_5 : operand_6
768 write_exp_elt_opcode (UNOP_NEG);
772 write_exp_elt_opcode (UNOP_LOGICAL_NOT);
774 | '(' integer_literal_expression ')' operand_6
782 operand_6 : POINTER location
786 | RECEIVE buffer_location
799 single_assignment_action : location GDB_ASSIGNMENT value
801 write_exp_elt_opcode (BINOP_ASSIGN);
805 /* FIXME: For now we just accept only a single integer literal. */
807 integer_literal_expression:
815 array_primitive_value : primitive_value
821 /* Things which still need productions... */
823 synonym_name : FIXME { $$ = 0; }
824 value_enumeration_name : FIXME { $$ = 0; }
825 value_do_with_name : FIXME { $$ = 0; }
826 value_receive_name : FIXME { $$ = 0; }
827 string_primitive_value : FIXME { $$ = 0; }
828 start_element : FIXME { $$ = 0; }
829 left_element : FIXME { $$ = 0; }
830 right_element : FIXME { $$ = 0; }
831 slice_size : FIXME { $$ = 0; }
832 lower_element : FIXME { $$ = 0; }
833 upper_element : FIXME { $$ = 0; }
834 first_element : FIXME { $$ = 0; }
835 structure_primitive_value: FIXME { $$ = 0; }
836 field_name : FIXME { $$ = 0; }
837 mode_name : FIXME { $$ = 0; }
838 boolean_expression : FIXME { $$ = 0; }
839 case_selector_list : FIXME { $$ = 0; }
840 subexpression : FIXME { $$ = 0; }
841 case_label_specification: FIXME { $$ = 0; }
842 buffer_location : FIXME { $$ = 0; }
846 /* Try to consume a simple name string token. If successful, returns
847 a pointer to a nullbyte terminated copy of the name that can be used
848 in symbol table lookups. If not successful, returns NULL. */
851 match_simple_name_string ()
853 char *tokptr = lexptr;
855 if (isalpha (*tokptr))
859 } while (isalpha (*tokptr) || isdigit (*tokptr) || (*tokptr == '_'));
860 yylval.sval.ptr = lexptr;
861 yylval.sval.length = tokptr - lexptr;
863 return (copy_name (yylval.sval));
868 /* Start looking for a value composed of valid digits as set by the base
869 in use. Note that '_' characters are valid anywhere, in any quantity,
870 and are simply ignored. Since we must find at least one valid digit,
871 or reject this token as an integer literal, we keep track of how many
872 digits we have encountered. */
875 decode_integer_value (base, tokptrptr, ivalptr)
880 char *tokptr = *tokptrptr;
884 while (*tokptr != '\0')
886 temp = tolower (*tokptr);
892 case '0': case '1': case '2': case '3': case '4':
893 case '5': case '6': case '7': case '8': case '9':
896 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
912 /* Found something not in domain for current base. */
913 tokptr--; /* Unconsume what gave us indigestion. */
918 /* If we didn't find any digits, then we don't have a valid integer
919 value, so reject the entire token. Otherwise, update the lexical
920 scan pointer, and return non-zero for success. */
934 decode_integer_literal (valptr, tokptrptr)
938 char *tokptr = *tokptrptr;
941 int explicit_base = 0;
943 /* Look for an explicit base specifier, which is optional. */
976 /* If we found an explicit base ensure that the character after the
977 explicit base is a single quote. */
979 if (explicit_base && (*tokptr++ != '\''))
984 /* Attempt to decode whatever follows as an integer value in the
985 indicated base, updating the token pointer in the process and
986 computing the value into ival. Also, if we have an explicit
987 base, then the next character must not be a single quote, or we
988 have a bitstring literal, so reject the entire token in this case.
989 Otherwise, update the lexical scan pointer, and return non-zero
992 if (!decode_integer_value (base, &tokptr, &ival))
996 else if (explicit_base && (*tokptr == '\''))
1003 *tokptrptr = tokptr;
1008 /* Recognize a character literal. A character literal is single character
1009 or a control sequence, enclosed in single quotes. A control sequence
1010 is a comma separated list of one or more integer literals, enclosed
1011 in parenthesis and introduced with a circumflex character.
1013 EX: 'a' '^(7)' '^(7,8)'
1015 As a GNU chill extension, the syntax C'xx' is also recognized as a
1016 character literal, where xx is a hex value for the character.
1018 Returns CHARACTER_LITERAL if a match is found.
1022 match_character_literal ()
1024 char *tokptr = lexptr;
1027 if ((tolower (*tokptr) == 'c') && (*(tokptr + 1) == '\''))
1029 /* We have a GNU chill extension form, so skip the leading "C'",
1030 decode the hex value, and then ensure that we have a trailing
1031 single quote character. */
1033 if (!decode_integer_value (16, &tokptr, &ival) || (*tokptr != '\''))
1039 else if (*tokptr == '\'')
1043 /* Determine which form we have, either a control sequence or the
1044 single character form. */
1046 if ((*tokptr == '^') && (*(tokptr + 1) == '('))
1048 /* Match and decode a control sequence. Return zero if we don't
1049 find a valid integer literal, or if the next unconsumed character
1050 after the integer literal is not the trailing ')'.
1051 FIXME: We currently don't handle the multiple integer literal
1054 if (!decode_integer_literal (&ival, &tokptr) || (*tokptr++ != ')'))
1064 /* The trailing quote has not yet been consumed. If we don't find
1065 it, then we have no match. */
1067 if (*tokptr++ != '\'')
1074 /* Not a character literal. */
1077 yylval.typed_val.val = ival;
1078 yylval.typed_val.type = builtin_type_chill_char;
1080 return (CHARACTER_LITERAL);
1083 /* Recognize an integer literal, as specified in Z.200 sec 5.2.4.2.
1084 Note that according to 5.2.4.2, a single "_" is also a valid integer
1085 literal, however GNU-chill requires there to be at least one "digit"
1086 in any integer literal. */
1089 match_integer_literal ()
1091 char *tokptr = lexptr;
1094 if (!decode_integer_literal (&ival, &tokptr))
1100 yylval.typed_val.val = ival;
1101 yylval.typed_val.type = builtin_type_int;
1103 return (INTEGER_LITERAL);
1107 /* Recognize tokens that start with '$'. These include:
1109 $regname A native register name or a "standard
1111 Return token GDB_REGNAME.
1113 $variable A convenience variable with a name chosen
1115 Return token GDB_VARIABLE.
1117 $digits Value history with index <digits>, starting
1118 from the first value which has index 1.
1121 $$digits Value history with index <digits> relative
1122 to the last value. I.E. $$0 is the last
1123 value, $$1 is the one previous to that, $$2
1124 is the one previous to $$1, etc.
1125 Return token GDB_LAST.
1127 $ | $0 | $$0 The last value in the value history.
1128 Return token GDB_LAST.
1130 $$ An abbreviation for the second to the last
1131 value in the value history, I.E. $$1
1132 Return token GDB_LAST.
1134 Note that we currently assume that register names and convenience
1135 variables follow the convention of starting with a letter or '_'.
1140 match_dollar_tokens ()
1148 /* We will always have a successful match, even if it is just for
1149 a single '$', the abbreviation for $$0. So advance lexptr. */
1153 if (*tokptr == '_' || isalpha (*tokptr))
1155 /* Look for a match with a native register name, usually something
1156 like "r0" for example. */
1158 for (regno = 0; regno < NUM_REGS; regno++)
1160 namelength = strlen (reg_names[regno]);
1161 if (STREQN (tokptr, reg_names[regno], namelength)
1162 && !isalnum (tokptr[namelength]))
1164 yylval.lval = regno;
1165 lexptr += namelength + 1;
1166 return (GDB_REGNAME);
1170 /* Look for a match with a standard register name, usually something
1171 like "pc", which gdb always recognizes as the program counter
1172 regardless of what the native register name is. */
1174 for (regno = 0; regno < num_std_regs; regno++)
1176 namelength = strlen (std_regs[regno].name);
1177 if (STREQN (tokptr, std_regs[regno].name, namelength)
1178 && !isalnum (tokptr[namelength]))
1180 yylval.lval = std_regs[regno].regnum;
1181 lexptr += namelength;
1182 return (GDB_REGNAME);
1186 /* Attempt to match against a convenience variable. Note that
1187 this will always succeed, because if no variable of that name
1188 already exists, the lookup_internalvar will create one for us.
1189 Also note that both lexptr and tokptr currently point to the
1190 start of the input string we are trying to match, and that we
1191 have already tested the first character for non-numeric, so we
1192 don't have to treat it specially. */
1194 while (*tokptr == '_' || isalnum (*tokptr))
1198 yylval.sval.ptr = lexptr;
1199 yylval.sval.length = tokptr - lexptr;
1200 yylval.ivar = lookup_internalvar (copy_name (yylval.sval));
1202 return (GDB_VARIABLE);
1205 /* Since we didn't match against a register name or convenience
1206 variable, our only choice left is a history value. */
1220 /* Attempt to decode more characters as an integer value giving
1221 the index in the history list. If successful, the value will
1222 overwrite ival (currently 0 or 1), and if not, ival will be
1223 left alone, which is good since it is currently correct for
1224 the '$' or '$$' case. */
1226 decode_integer_literal (&ival, &tokptr);
1227 yylval.lval = negate ? -ival : ival;
1233 static void convert_float ()
1235 extern double strtod ();
1238 char *p = yytext, *p1 = tmp;
1258 d = strtod (tmp, &p1);
1261 /* add error handling here */
1268 /* Take care of parsing a number (anything that starts with a digit).
1269 Set yylval and return the token type; update lexptr.
1270 LEN is the number of characters in it. */
1272 /*** Needs some error checking for the float case ***/
1280 static const struct token tokentab5[] =
1285 static const struct token tokentab4[] =
1290 static const struct token tokentab3[] =
1297 static const struct token tokentab2[] =
1299 { ":=", GDB_ASSIGNMENT },
1300 { "//", SLASH_SLASH },
1308 /* Read one token, getting characters through lexptr. */
1309 /* This is where we will check to make sure that the language and the
1310 operators used are compatible. */
1320 /* Skip over any leading whitespace. */
1321 while (isspace (*lexptr))
1325 /* Look for special single character cases which can't be the first
1326 character of some other multicharacter token. */
1346 /* Look for characters which start a particular kind of multicharacter
1347 token, such as a character literal, register name, convenience
1348 variable name, etc. */
1354 token = match_character_literal ();
1361 token = match_dollar_tokens ();
1368 /* See if it is a special token of length 5. */
1369 for (i = 0; i < sizeof (tokentab5) / sizeof (tokentab5[0]); i++)
1371 if (STREQN (lexptr, tokentab5[i].operator, 5))
1374 return (tokentab5[i].token);
1377 /* See if it is a special token of length 4. */
1378 for (i = 0; i < sizeof (tokentab4) / sizeof (tokentab4[0]); i++)
1380 if (STREQN (lexptr, tokentab4[i].operator, 4))
1383 return (tokentab4[i].token);
1386 /* See if it is a special token of length 3. */
1387 for (i = 0; i < sizeof (tokentab3) / sizeof (tokentab3[0]); i++)
1389 if (STREQN (lexptr, tokentab3[i].operator, 3))
1392 return (tokentab3[i].token);
1395 /* See if it is a special token of length 2. */
1396 for (i = 0; i < sizeof (tokentab2) / sizeof (tokentab2[0]); i++)
1398 if (STREQN (lexptr, tokentab2[i].operator, 2))
1401 return (tokentab2[i].token);
1404 /* Look for single character cases which which could be the first
1405 character of some other multicharacter token, but aren't, or we
1406 would already have found it. */
1415 /* Look for other special tokens. */
1416 if (STREQN (lexptr, "TRUE", 4)) /* FIXME: What about lowercase? */
1420 return (BOOLEAN_LITERAL);
1422 if (STREQN (lexptr, "FALSE", 5)) /* FIXME: What about lowercase? */
1426 return (BOOLEAN_LITERAL);
1428 token = match_integer_literal ();
1434 /* Try to match a simple name string, and if a match is found, then
1435 further classify what sort of name it is and return an appropriate
1436 token. Note that attempting to match a simple name string consumes
1437 the token from lexptr, so we can't back out if we later find that
1438 we can't classify what sort of name it is. */
1440 simplename = match_simple_name_string ();
1441 if (simplename != NULL)
1443 sym = lookup_symbol (simplename, expression_context_block,
1444 VAR_NAMESPACE, (int *) NULL,
1445 (struct symtab **) NULL);
1448 yylval.ssym.stoken.ptr = NULL;
1449 yylval.ssym.stoken.length = 0;
1450 yylval.ssym.sym = sym;
1451 yylval.ssym.is_a_field_of_this = 0; /* FIXME, C++'ism */
1452 switch (SYMBOL_CLASS (sym))
1455 /* Found a procedure name. */
1456 return (GENERAL_PROCEDURE_NAME);
1458 /* Found a global or local static variable. */
1459 return (LOCATION_NAME);
1469 case LOC_CONST_BYTES:
1474 else if (!have_full_symbols () && !have_partial_symbols ())
1476 error ("No symbol table is loaded. Use the \"file\" command.");
1480 error ("No symbol \"%s\" in current context.", simplename);
1484 return (ILLEGAL_TOKEN);
1489 char *msg; /* unused */
1491 printf ("Parsing: %s\n", lexptr);
1494 error ("Invalid syntax in expression near character '%c'.", yychar);
1498 error ("Invalid syntax in expression");