1 // OBSOLETE /* Parser for GNU CHILL (CCITT High-Level Language) -*- C -*-
2 // OBSOLETE Copyright 1992, 1993, 1995, 1996, 1997, 1999, 2000, 2001
3 // OBSOLETE Free Software Foundation, Inc.
5 // OBSOLETE This file is part of GDB.
7 // OBSOLETE This program is free software; you can redistribute it and/or modify
8 // OBSOLETE it under the terms of the GNU General Public License as published by
9 // OBSOLETE the Free Software Foundation; either version 2 of the License, or
10 // OBSOLETE (at your option) any later version.
12 // OBSOLETE This program is distributed in the hope that it will be useful,
13 // OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // OBSOLETE GNU General Public License for more details.
17 // OBSOLETE You should have received a copy of the GNU General Public License
18 // OBSOLETE along with this program; if not, write to the Free Software
19 // OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330,
20 // OBSOLETE Boston, MA 02111-1307, USA. */
22 // OBSOLETE /* Parse a Chill expression from text in a string,
23 // OBSOLETE and return the result as a struct expression pointer.
24 // OBSOLETE That structure contains arithmetic operations in reverse polish,
25 // OBSOLETE with constants represented by operations that are followed by special data.
26 // OBSOLETE See expression.h for the details of the format.
27 // OBSOLETE What is important here is that it can be built up sequentially
28 // OBSOLETE during the process of parsing; the lower levels of the tree always
29 // OBSOLETE come first in the result.
31 // OBSOLETE Note that the language accepted by this parser is more liberal
32 // OBSOLETE than the one accepted by an actual Chill compiler. For example, the
33 // OBSOLETE language rule that a simple name string can not be one of the reserved
34 // OBSOLETE simple name strings is not enforced (e.g "case" is not treated as a
35 // OBSOLETE reserved name). Another example is that Chill is a strongly typed
36 // OBSOLETE language, and certain expressions that violate the type constraints
37 // OBSOLETE may still be evaluated if gdb can do so in a meaningful manner, while
38 // OBSOLETE such expressions would be rejected by the compiler. The reason for
39 // OBSOLETE this more liberal behavior is the philosophy that the debugger
40 // OBSOLETE is intended to be a tool that is used by the programmer when things
41 // OBSOLETE go wrong, and as such, it should provide as few artificial barriers
42 // OBSOLETE to it's use as possible. If it can do something meaningful, even
43 // OBSOLETE something that violates language contraints that are enforced by the
44 // OBSOLETE compiler, it should do so without complaint.
48 // OBSOLETE #include "defs.h"
49 // OBSOLETE #include "gdb_string.h"
50 // OBSOLETE #include <ctype.h>
51 // OBSOLETE #include "expression.h"
52 // OBSOLETE #include "language.h"
53 // OBSOLETE #include "value.h"
54 // OBSOLETE #include "parser-defs.h"
55 // OBSOLETE #include "ch-lang.h"
56 // OBSOLETE #include "bfd.h" /* Required by objfiles.h. */
57 // OBSOLETE #include "symfile.h" /* Required by objfiles.h. */
58 // OBSOLETE #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
60 // OBSOLETE #ifdef __GNUC__
61 // OBSOLETE #define INLINE __inline__
64 // OBSOLETE typedef union
67 // OBSOLETE LONGEST lval;
68 // OBSOLETE ULONGEST ulval;
71 // OBSOLETE LONGEST val;
72 // OBSOLETE struct type *type;
74 // OBSOLETE typed_val;
75 // OBSOLETE double dval;
76 // OBSOLETE struct symbol *sym;
77 // OBSOLETE struct type *tval;
78 // OBSOLETE struct stoken sval;
79 // OBSOLETE struct ttype tsym;
80 // OBSOLETE struct symtoken ssym;
84 // OBSOLETE enum ch_terminal
86 // OBSOLETE END_TOKEN = 0,
87 // OBSOLETE /* '\001' ... '\xff' come first. */
88 // OBSOLETE OPEN_PAREN = '(',
89 // OBSOLETE TOKEN_NOT_READ = 999,
90 // OBSOLETE INTEGER_LITERAL,
91 // OBSOLETE BOOLEAN_LITERAL,
92 // OBSOLETE CHARACTER_LITERAL,
93 // OBSOLETE FLOAT_LITERAL,
94 // OBSOLETE GENERAL_PROCEDURE_NAME,
95 // OBSOLETE LOCATION_NAME,
96 // OBSOLETE EMPTINESS_LITERAL,
97 // OBSOLETE CHARACTER_STRING_LITERAL,
98 // OBSOLETE BIT_STRING_LITERAL,
100 // OBSOLETE DOT_FIELD_NAME, /* '.' followed by <field name> */
109 // OBSOLETE NOTEQUAL,
113 // OBSOLETE SLASH_SLASH,
125 // OBSOLETE ILLEGAL_TOKEN,
131 // OBSOLETE MAX_TOKEN,
132 // OBSOLETE MIN_TOKEN,
133 // OBSOLETE ADDR_TOKEN,
139 // OBSOLETE GDB_VARIABLE,
140 // OBSOLETE GDB_ASSIGNMENT
143 // OBSOLETE /* Forward declarations. */
145 // OBSOLETE static void write_lower_upper_value (enum exp_opcode, struct type *);
146 // OBSOLETE static enum ch_terminal match_bitstring_literal (void);
147 // OBSOLETE static enum ch_terminal match_integer_literal (void);
148 // OBSOLETE static enum ch_terminal match_character_literal (void);
149 // OBSOLETE static enum ch_terminal match_string_literal (void);
150 // OBSOLETE static enum ch_terminal match_float_literal (void);
151 // OBSOLETE static int decode_integer_literal (LONGEST *, char **);
152 // OBSOLETE static int decode_integer_value (int, char **, LONGEST *);
153 // OBSOLETE static char *match_simple_name_string (void);
154 // OBSOLETE static void growbuf_by_size (int);
155 // OBSOLETE static void parse_case_label (void);
156 // OBSOLETE static void parse_untyped_expr (void);
157 // OBSOLETE static void parse_if_expression (void);
158 // OBSOLETE static void parse_if_expression_body (void);
159 // OBSOLETE static void parse_else_alternative (void);
160 // OBSOLETE static void parse_then_alternative (void);
161 // OBSOLETE static void parse_expr (void);
162 // OBSOLETE static void parse_operand0 (void);
163 // OBSOLETE static void parse_operand1 (void);
164 // OBSOLETE static void parse_operand2 (void);
165 // OBSOLETE static void parse_operand3 (void);
166 // OBSOLETE static void parse_operand4 (void);
167 // OBSOLETE static void parse_operand5 (void);
168 // OBSOLETE static void parse_operand6 (void);
169 // OBSOLETE static void parse_primval (void);
170 // OBSOLETE static void parse_tuple (struct type *);
171 // OBSOLETE static void parse_opt_element_list (struct type *);
172 // OBSOLETE static void parse_tuple_element (struct type *);
173 // OBSOLETE static void parse_named_record_element (void);
174 // OBSOLETE static void parse_call (void);
175 // OBSOLETE static struct type *parse_mode_or_normal_call (void);
177 // OBSOLETE static struct type *parse_mode_call (void);
179 // OBSOLETE static void parse_unary_call (void);
180 // OBSOLETE static int parse_opt_untyped_expr (void);
181 // OBSOLETE static int expect (enum ch_terminal, char *);
182 // OBSOLETE static enum ch_terminal ch_lex (void);
183 // OBSOLETE INLINE static enum ch_terminal PEEK_TOKEN (void);
184 // OBSOLETE static enum ch_terminal peek_token_ (int);
185 // OBSOLETE static void forward_token_ (void);
186 // OBSOLETE static void require (enum ch_terminal);
187 // OBSOLETE static int check_token (enum ch_terminal);
189 // OBSOLETE #define MAX_LOOK_AHEAD 2
190 // OBSOLETE static enum ch_terminal terminal_buffer[MAX_LOOK_AHEAD + 1] =
192 // OBSOLETE TOKEN_NOT_READ, TOKEN_NOT_READ, TOKEN_NOT_READ};
193 // OBSOLETE static YYSTYPE yylval;
194 // OBSOLETE static YYSTYPE val_buffer[MAX_LOOK_AHEAD + 1];
196 // OBSOLETE /*int current_token, lookahead_token; */
198 // OBSOLETE INLINE static enum ch_terminal
199 // OBSOLETE PEEK_TOKEN (void)
201 // OBSOLETE if (terminal_buffer[0] == TOKEN_NOT_READ)
203 // OBSOLETE terminal_buffer[0] = ch_lex ();
204 // OBSOLETE val_buffer[0] = yylval;
206 // OBSOLETE return terminal_buffer[0];
208 // OBSOLETE #define PEEK_LVAL() val_buffer[0]
209 // OBSOLETE #define PEEK_TOKEN1() peek_token_(1)
210 // OBSOLETE #define PEEK_TOKEN2() peek_token_(2)
211 // OBSOLETE static enum ch_terminal
212 // OBSOLETE peek_token_ (int i)
214 // OBSOLETE if (i > MAX_LOOK_AHEAD)
215 // OBSOLETE internal_error (__FILE__, __LINE__,
216 // OBSOLETE "too much lookahead");
217 // OBSOLETE if (terminal_buffer[i] == TOKEN_NOT_READ)
219 // OBSOLETE terminal_buffer[i] = ch_lex ();
220 // OBSOLETE val_buffer[i] = yylval;
222 // OBSOLETE return terminal_buffer[i];
227 // OBSOLETE static void
228 // OBSOLETE pushback_token (enum ch_terminal code, YYSTYPE node)
231 // OBSOLETE if (terminal_buffer[MAX_LOOK_AHEAD] != TOKEN_NOT_READ)
232 // OBSOLETE internal_error (__FILE__, __LINE__,
233 // OBSOLETE "cannot pushback token");
234 // OBSOLETE for (i = MAX_LOOK_AHEAD; i > 0; i--)
236 // OBSOLETE terminal_buffer[i] = terminal_buffer[i - 1];
237 // OBSOLETE val_buffer[i] = val_buffer[i - 1];
239 // OBSOLETE terminal_buffer[0] = code;
240 // OBSOLETE val_buffer[0] = node;
245 // OBSOLETE static void
246 // OBSOLETE forward_token_ (void)
249 // OBSOLETE for (i = 0; i < MAX_LOOK_AHEAD; i++)
251 // OBSOLETE terminal_buffer[i] = terminal_buffer[i + 1];
252 // OBSOLETE val_buffer[i] = val_buffer[i + 1];
254 // OBSOLETE terminal_buffer[MAX_LOOK_AHEAD] = TOKEN_NOT_READ;
256 // OBSOLETE #define FORWARD_TOKEN() forward_token_()
258 // OBSOLETE /* Skip the next token.
259 // OBSOLETE if it isn't TOKEN, the parser is broken. */
261 // OBSOLETE static void
262 // OBSOLETE require (enum ch_terminal token)
264 // OBSOLETE if (PEEK_TOKEN () != token)
266 // OBSOLETE internal_error (__FILE__, __LINE__,
267 // OBSOLETE "expected token %d", (int) token);
269 // OBSOLETE FORWARD_TOKEN ();
272 // OBSOLETE static int
273 // OBSOLETE check_token (enum ch_terminal token)
275 // OBSOLETE if (PEEK_TOKEN () != token)
276 // OBSOLETE return 0;
277 // OBSOLETE FORWARD_TOKEN ();
278 // OBSOLETE return 1;
281 // OBSOLETE /* return 0 if expected token was not found,
282 // OBSOLETE else return 1.
284 // OBSOLETE static int
285 // OBSOLETE expect (enum ch_terminal token, char *message)
287 // OBSOLETE if (PEEK_TOKEN () != token)
289 // OBSOLETE if (message)
290 // OBSOLETE error (message);
291 // OBSOLETE else if (token < 256)
292 // OBSOLETE error ("syntax error - expected a '%c' here \"%s\"", token, lexptr);
294 // OBSOLETE error ("syntax error");
295 // OBSOLETE return 0;
298 // OBSOLETE FORWARD_TOKEN ();
299 // OBSOLETE return 1;
303 // OBSOLETE /* Parse a name string. If ALLOW_ALL is 1, ALL is allowed as a postfix. */
305 // OBSOLETE static tree
306 // OBSOLETE parse_opt_name_string (int allow_all)
308 // OBSOLETE int token = PEEK_TOKEN ();
309 // OBSOLETE tree name;
310 // OBSOLETE if (token != NAME)
312 // OBSOLETE if (token == ALL && allow_all)
314 // OBSOLETE FORWARD_TOKEN ();
315 // OBSOLETE return ALL_POSTFIX;
317 // OBSOLETE return NULL_TREE;
319 // OBSOLETE name = PEEK_LVAL ();
322 // OBSOLETE FORWARD_TOKEN ();
323 // OBSOLETE token = PEEK_TOKEN ();
324 // OBSOLETE if (token != '!')
325 // OBSOLETE return name;
326 // OBSOLETE FORWARD_TOKEN ();
327 // OBSOLETE token = PEEK_TOKEN ();
328 // OBSOLETE if (token == ALL && allow_all)
329 // OBSOLETE return get_identifier3 (IDENTIFIER_POINTER (name), "!", "*");
330 // OBSOLETE if (token != NAME)
332 // OBSOLETE if (pass == 1)
333 // OBSOLETE error ("'%s!' is not followed by an identifier",
334 // OBSOLETE IDENTIFIER_POINTER (name));
335 // OBSOLETE return name;
337 // OBSOLETE name = get_identifier3 (IDENTIFIER_POINTER (name),
338 // OBSOLETE "!", IDENTIFIER_POINTER (PEEK_LVAL ()));
342 // OBSOLETE static tree
343 // OBSOLETE parse_simple_name_string (void)
345 // OBSOLETE int token = PEEK_TOKEN ();
346 // OBSOLETE tree name;
347 // OBSOLETE if (token != NAME)
349 // OBSOLETE error ("expected a name here");
350 // OBSOLETE return error_mark_node;
352 // OBSOLETE name = PEEK_LVAL ();
353 // OBSOLETE FORWARD_TOKEN ();
354 // OBSOLETE return name;
357 // OBSOLETE static tree
358 // OBSOLETE parse_name_string (void)
360 // OBSOLETE tree name = parse_opt_name_string (0);
361 // OBSOLETE if (name)
362 // OBSOLETE return name;
363 // OBSOLETE if (pass == 1)
364 // OBSOLETE error ("expected a name string here");
365 // OBSOLETE return error_mark_node;
368 // OBSOLETE /* Matches: <name_string>
369 // OBSOLETE Returns if pass 1: the identifier.
370 // OBSOLETE Returns if pass 2: a decl or value for identifier. */
372 // OBSOLETE static tree
373 // OBSOLETE parse_name (void)
375 // OBSOLETE tree name = parse_name_string ();
376 // OBSOLETE if (pass == 1 || ignoring)
377 // OBSOLETE return name;
380 // OBSOLETE tree decl = lookup_name (name);
381 // OBSOLETE if (decl == NULL_TREE)
383 // OBSOLETE error ("`%s' undeclared", IDENTIFIER_POINTER (name));
384 // OBSOLETE return error_mark_node;
386 // OBSOLETE else if (TREE_CODE (TREE_TYPE (decl)) == ERROR_MARK)
387 // OBSOLETE return error_mark_node;
388 // OBSOLETE else if (TREE_CODE (decl) == CONST_DECL)
389 // OBSOLETE return DECL_INITIAL (decl);
390 // OBSOLETE else if (TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE)
391 // OBSOLETE return convert_from_reference (decl);
393 // OBSOLETE return decl;
399 // OBSOLETE static void
400 // OBSOLETE pushback_paren_expr (tree expr)
402 // OBSOLETE if (pass == 1 && !ignoring)
403 // OBSOLETE expr = build1 (PAREN_EXPR, NULL_TREE, expr);
404 // OBSOLETE pushback_token (EXPR, expr);
408 // OBSOLETE /* Matches: <case label> */
410 // OBSOLETE static void
411 // OBSOLETE parse_case_label (void)
413 // OBSOLETE if (check_token (ELSE))
414 // OBSOLETE error ("ELSE in tuples labels not implemented");
415 // OBSOLETE /* Does not handle the case of a mode name. FIXME */
416 // OBSOLETE parse_expr ();
417 // OBSOLETE if (check_token (':'))
419 // OBSOLETE parse_expr ();
420 // OBSOLETE write_exp_elt_opcode (BINOP_RANGE);
424 // OBSOLETE static int
425 // OBSOLETE parse_opt_untyped_expr (void)
427 // OBSOLETE switch (PEEK_TOKEN ())
429 // OBSOLETE case ',':
430 // OBSOLETE case ':':
431 // OBSOLETE case ')':
432 // OBSOLETE return 0;
434 // OBSOLETE parse_untyped_expr ();
435 // OBSOLETE return 1;
439 // OBSOLETE static void
440 // OBSOLETE parse_unary_call (void)
442 // OBSOLETE FORWARD_TOKEN ();
443 // OBSOLETE expect ('(', NULL);
444 // OBSOLETE parse_expr ();
445 // OBSOLETE expect (')', NULL);
448 // OBSOLETE /* Parse NAME '(' MODENAME ')'. */
452 // OBSOLETE static struct type *
453 // OBSOLETE parse_mode_call (void)
455 // OBSOLETE struct type *type;
456 // OBSOLETE FORWARD_TOKEN ();
457 // OBSOLETE expect ('(', NULL);
458 // OBSOLETE if (PEEK_TOKEN () != TYPENAME)
459 // OBSOLETE error ("expect MODENAME here `%s'", lexptr);
460 // OBSOLETE type = PEEK_LVAL ().tsym.type;
461 // OBSOLETE FORWARD_TOKEN ();
462 // OBSOLETE expect (')', NULL);
463 // OBSOLETE return type;
468 // OBSOLETE static struct type *
469 // OBSOLETE parse_mode_or_normal_call (void)
471 // OBSOLETE struct type *type;
472 // OBSOLETE FORWARD_TOKEN ();
473 // OBSOLETE expect ('(', NULL);
474 // OBSOLETE if (PEEK_TOKEN () == TYPENAME)
476 // OBSOLETE type = PEEK_LVAL ().tsym.type;
477 // OBSOLETE FORWARD_TOKEN ();
481 // OBSOLETE parse_expr ();
482 // OBSOLETE type = NULL;
484 // OBSOLETE expect (')', NULL);
485 // OBSOLETE return type;
488 // OBSOLETE /* Parse something that looks like a function call.
489 // OBSOLETE Assume we have parsed the function, and are at the '('. */
491 // OBSOLETE static void
492 // OBSOLETE parse_call (void)
494 // OBSOLETE int arg_count;
495 // OBSOLETE require ('(');
496 // OBSOLETE /* This is to save the value of arglist_len
497 // OBSOLETE being accumulated for each dimension. */
498 // OBSOLETE start_arglist ();
499 // OBSOLETE if (parse_opt_untyped_expr ())
501 // OBSOLETE int tok = PEEK_TOKEN ();
502 // OBSOLETE arglist_len = 1;
503 // OBSOLETE if (tok == UP || tok == ':')
505 // OBSOLETE FORWARD_TOKEN ();
506 // OBSOLETE parse_expr ();
507 // OBSOLETE expect (')', "expected ')' to terminate slice");
508 // OBSOLETE end_arglist ();
509 // OBSOLETE write_exp_elt_opcode (tok == UP ? TERNOP_SLICE_COUNT
510 // OBSOLETE : TERNOP_SLICE);
513 // OBSOLETE while (check_token (','))
515 // OBSOLETE parse_untyped_expr ();
516 // OBSOLETE arglist_len++;
520 // OBSOLETE arglist_len = 0;
521 // OBSOLETE expect (')', NULL);
522 // OBSOLETE arg_count = end_arglist ();
523 // OBSOLETE write_exp_elt_opcode (MULTI_SUBSCRIPT);
524 // OBSOLETE write_exp_elt_longcst (arg_count);
525 // OBSOLETE write_exp_elt_opcode (MULTI_SUBSCRIPT);
528 // OBSOLETE static void
529 // OBSOLETE parse_named_record_element (void)
531 // OBSOLETE struct stoken label;
532 // OBSOLETE char buf[256];
534 // OBSOLETE label = PEEK_LVAL ().sval;
535 // OBSOLETE sprintf (buf, "expected a field name here `%s'", lexptr);
536 // OBSOLETE expect (DOT_FIELD_NAME, buf);
537 // OBSOLETE if (check_token (','))
538 // OBSOLETE parse_named_record_element ();
539 // OBSOLETE else if (check_token (':'))
540 // OBSOLETE parse_expr ();
542 // OBSOLETE error ("syntax error near `%s' in named record tuple element", lexptr);
543 // OBSOLETE write_exp_elt_opcode (OP_LABELED);
544 // OBSOLETE write_exp_string (label);
545 // OBSOLETE write_exp_elt_opcode (OP_LABELED);
548 // OBSOLETE /* Returns one or more TREE_LIST nodes, in reverse order. */
550 // OBSOLETE static void
551 // OBSOLETE parse_tuple_element (struct type *type)
553 // OBSOLETE if (PEEK_TOKEN () == DOT_FIELD_NAME)
555 // OBSOLETE /* Parse a labelled structure tuple. */
556 // OBSOLETE parse_named_record_element ();
560 // OBSOLETE if (check_token ('('))
562 // OBSOLETE if (check_token ('*'))
564 // OBSOLETE expect (')', "missing ')' after '*' case label list");
565 // OBSOLETE if (type)
567 // OBSOLETE if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
569 // OBSOLETE /* do this as a range from low to high */
570 // OBSOLETE struct type *range_type = TYPE_FIELD_TYPE (type, 0);
571 // OBSOLETE LONGEST low_bound, high_bound;
572 // OBSOLETE if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
573 // OBSOLETE error ("cannot determine bounds for (*)");
574 // OBSOLETE /* lower bound */
575 // OBSOLETE write_exp_elt_opcode (OP_LONG);
576 // OBSOLETE write_exp_elt_type (range_type);
577 // OBSOLETE write_exp_elt_longcst (low_bound);
578 // OBSOLETE write_exp_elt_opcode (OP_LONG);
579 // OBSOLETE /* upper bound */
580 // OBSOLETE write_exp_elt_opcode (OP_LONG);
581 // OBSOLETE write_exp_elt_type (range_type);
582 // OBSOLETE write_exp_elt_longcst (high_bound);
583 // OBSOLETE write_exp_elt_opcode (OP_LONG);
584 // OBSOLETE write_exp_elt_opcode (BINOP_RANGE);
587 // OBSOLETE error ("(*) in invalid context");
590 // OBSOLETE error ("(*) only possible with modename in front of tuple (mode[..])");
594 // OBSOLETE parse_case_label ();
595 // OBSOLETE while (check_token (','))
597 // OBSOLETE parse_case_label ();
598 // OBSOLETE write_exp_elt_opcode (BINOP_COMMA);
600 // OBSOLETE expect (')', NULL);
604 // OBSOLETE parse_untyped_expr ();
605 // OBSOLETE if (check_token (':'))
607 // OBSOLETE /* A powerset range or a labeled Array. */
608 // OBSOLETE parse_untyped_expr ();
609 // OBSOLETE write_exp_elt_opcode (BINOP_RANGE);
613 // OBSOLETE /* Matches: a COMMA-separated list of tuple elements.
614 // OBSOLETE Returns a list (of TREE_LIST nodes). */
615 // OBSOLETE static void
616 // OBSOLETE parse_opt_element_list (struct type *type)
618 // OBSOLETE arglist_len = 0;
619 // OBSOLETE if (PEEK_TOKEN () == ']')
623 // OBSOLETE parse_tuple_element (type);
624 // OBSOLETE arglist_len++;
625 // OBSOLETE if (PEEK_TOKEN () == ']')
627 // OBSOLETE if (!check_token (','))
628 // OBSOLETE error ("bad syntax in tuple");
632 // OBSOLETE /* Parses: '[' elements ']'
633 // OBSOLETE If modename is non-NULL it prefixed the tuple. */
635 // OBSOLETE static void
636 // OBSOLETE parse_tuple (struct type *mode)
638 // OBSOLETE struct type *type;
639 // OBSOLETE if (mode)
640 // OBSOLETE type = check_typedef (mode);
642 // OBSOLETE type = 0;
643 // OBSOLETE require ('[');
644 // OBSOLETE start_arglist ();
645 // OBSOLETE parse_opt_element_list (type);
646 // OBSOLETE expect (']', "missing ']' after tuple");
647 // OBSOLETE write_exp_elt_opcode (OP_ARRAY);
648 // OBSOLETE write_exp_elt_longcst ((LONGEST) 0);
649 // OBSOLETE write_exp_elt_longcst ((LONGEST) end_arglist () - 1);
650 // OBSOLETE write_exp_elt_opcode (OP_ARRAY);
651 // OBSOLETE if (type)
653 // OBSOLETE if (TYPE_CODE (type) != TYPE_CODE_ARRAY
654 // OBSOLETE && TYPE_CODE (type) != TYPE_CODE_STRUCT
655 // OBSOLETE && TYPE_CODE (type) != TYPE_CODE_SET)
656 // OBSOLETE error ("invalid tuple mode");
657 // OBSOLETE write_exp_elt_opcode (UNOP_CAST);
658 // OBSOLETE write_exp_elt_type (mode);
659 // OBSOLETE write_exp_elt_opcode (UNOP_CAST);
663 // OBSOLETE static void
664 // OBSOLETE parse_primval (void)
666 // OBSOLETE struct type *type;
667 // OBSOLETE enum exp_opcode op;
668 // OBSOLETE char *op_name;
669 // OBSOLETE switch (PEEK_TOKEN ())
671 // OBSOLETE case INTEGER_LITERAL:
672 // OBSOLETE case CHARACTER_LITERAL:
673 // OBSOLETE write_exp_elt_opcode (OP_LONG);
674 // OBSOLETE write_exp_elt_type (PEEK_LVAL ().typed_val.type);
675 // OBSOLETE write_exp_elt_longcst (PEEK_LVAL ().typed_val.val);
676 // OBSOLETE write_exp_elt_opcode (OP_LONG);
677 // OBSOLETE FORWARD_TOKEN ();
679 // OBSOLETE case BOOLEAN_LITERAL:
680 // OBSOLETE write_exp_elt_opcode (OP_BOOL);
681 // OBSOLETE write_exp_elt_longcst ((LONGEST) PEEK_LVAL ().ulval);
682 // OBSOLETE write_exp_elt_opcode (OP_BOOL);
683 // OBSOLETE FORWARD_TOKEN ();
685 // OBSOLETE case FLOAT_LITERAL:
686 // OBSOLETE write_exp_elt_opcode (OP_DOUBLE);
687 // OBSOLETE write_exp_elt_type (builtin_type_double);
688 // OBSOLETE write_exp_elt_dblcst (PEEK_LVAL ().dval);
689 // OBSOLETE write_exp_elt_opcode (OP_DOUBLE);
690 // OBSOLETE FORWARD_TOKEN ();
692 // OBSOLETE case EMPTINESS_LITERAL:
693 // OBSOLETE write_exp_elt_opcode (OP_LONG);
694 // OBSOLETE write_exp_elt_type (lookup_pointer_type (builtin_type_void));
695 // OBSOLETE write_exp_elt_longcst (0);
696 // OBSOLETE write_exp_elt_opcode (OP_LONG);
697 // OBSOLETE FORWARD_TOKEN ();
699 // OBSOLETE case CHARACTER_STRING_LITERAL:
700 // OBSOLETE write_exp_elt_opcode (OP_STRING);
701 // OBSOLETE write_exp_string (PEEK_LVAL ().sval);
702 // OBSOLETE write_exp_elt_opcode (OP_STRING);
703 // OBSOLETE FORWARD_TOKEN ();
705 // OBSOLETE case BIT_STRING_LITERAL:
706 // OBSOLETE write_exp_elt_opcode (OP_BITSTRING);
707 // OBSOLETE write_exp_bitstring (PEEK_LVAL ().sval);
708 // OBSOLETE write_exp_elt_opcode (OP_BITSTRING);
709 // OBSOLETE FORWARD_TOKEN ();
711 // OBSOLETE case ARRAY:
712 // OBSOLETE FORWARD_TOKEN ();
713 // OBSOLETE /* This is pseudo-Chill, similar to C's '(TYPE[])EXPR'
714 // OBSOLETE which casts to an artificial array. */
715 // OBSOLETE expect ('(', NULL);
716 // OBSOLETE expect (')', NULL);
717 // OBSOLETE if (PEEK_TOKEN () != TYPENAME)
718 // OBSOLETE error ("missing MODENAME after ARRAY()");
719 // OBSOLETE type = PEEK_LVAL ().tsym.type;
720 // OBSOLETE FORWARD_TOKEN ();
721 // OBSOLETE expect ('(', NULL);
722 // OBSOLETE parse_expr ();
723 // OBSOLETE expect (')', "missing right parenthesis");
724 // OBSOLETE type = create_array_type ((struct type *) NULL, type,
725 // OBSOLETE create_range_type ((struct type *) NULL,
726 // OBSOLETE builtin_type_int, 0, 0));
727 // OBSOLETE TYPE_ARRAY_UPPER_BOUND_TYPE (type) = BOUND_CANNOT_BE_DETERMINED;
728 // OBSOLETE write_exp_elt_opcode (UNOP_CAST);
729 // OBSOLETE write_exp_elt_type (type);
730 // OBSOLETE write_exp_elt_opcode (UNOP_CAST);
733 // OBSOLETE case CONST:
734 // OBSOLETE case EXPR:
735 // OBSOLETE val = PEEK_LVAL ();
736 // OBSOLETE FORWARD_TOKEN ();
739 // OBSOLETE case '(':
740 // OBSOLETE FORWARD_TOKEN ();
741 // OBSOLETE parse_expr ();
742 // OBSOLETE expect (')', "missing right parenthesis");
744 // OBSOLETE case '[':
745 // OBSOLETE parse_tuple (NULL);
747 // OBSOLETE case GENERAL_PROCEDURE_NAME:
748 // OBSOLETE case LOCATION_NAME:
749 // OBSOLETE write_exp_elt_opcode (OP_VAR_VALUE);
750 // OBSOLETE write_exp_elt_block (NULL);
751 // OBSOLETE write_exp_elt_sym (PEEK_LVAL ().ssym.sym);
752 // OBSOLETE write_exp_elt_opcode (OP_VAR_VALUE);
753 // OBSOLETE FORWARD_TOKEN ();
755 // OBSOLETE case GDB_VARIABLE: /* gdb specific */
756 // OBSOLETE FORWARD_TOKEN ();
758 // OBSOLETE case NUM:
759 // OBSOLETE parse_unary_call ();
760 // OBSOLETE write_exp_elt_opcode (UNOP_CAST);
761 // OBSOLETE write_exp_elt_type (builtin_type_int);
762 // OBSOLETE write_exp_elt_opcode (UNOP_CAST);
764 // OBSOLETE case CARD:
765 // OBSOLETE parse_unary_call ();
766 // OBSOLETE write_exp_elt_opcode (UNOP_CARD);
768 // OBSOLETE case MAX_TOKEN:
769 // OBSOLETE parse_unary_call ();
770 // OBSOLETE write_exp_elt_opcode (UNOP_CHMAX);
772 // OBSOLETE case MIN_TOKEN:
773 // OBSOLETE parse_unary_call ();
774 // OBSOLETE write_exp_elt_opcode (UNOP_CHMIN);
776 // OBSOLETE case PRED:
777 // OBSOLETE op_name = "PRED";
778 // OBSOLETE goto unimplemented_unary_builtin;
779 // OBSOLETE case SUCC:
780 // OBSOLETE op_name = "SUCC";
781 // OBSOLETE goto unimplemented_unary_builtin;
782 // OBSOLETE case ABS:
783 // OBSOLETE op_name = "ABS";
784 // OBSOLETE goto unimplemented_unary_builtin;
785 // OBSOLETE unimplemented_unary_builtin:
786 // OBSOLETE parse_unary_call ();
787 // OBSOLETE error ("not implemented: %s builtin function", op_name);
789 // OBSOLETE case ADDR_TOKEN:
790 // OBSOLETE parse_unary_call ();
791 // OBSOLETE write_exp_elt_opcode (UNOP_ADDR);
793 // OBSOLETE case SIZE:
794 // OBSOLETE type = parse_mode_or_normal_call ();
795 // OBSOLETE if (type)
797 // OBSOLETE write_exp_elt_opcode (OP_LONG);
798 // OBSOLETE write_exp_elt_type (builtin_type_int);
799 // OBSOLETE CHECK_TYPEDEF (type);
800 // OBSOLETE write_exp_elt_longcst ((LONGEST) TYPE_LENGTH (type));
801 // OBSOLETE write_exp_elt_opcode (OP_LONG);
804 // OBSOLETE write_exp_elt_opcode (UNOP_SIZEOF);
806 // OBSOLETE case LOWER:
807 // OBSOLETE op = UNOP_LOWER;
808 // OBSOLETE goto lower_upper;
809 // OBSOLETE case UPPER:
810 // OBSOLETE op = UNOP_UPPER;
811 // OBSOLETE goto lower_upper;
812 // OBSOLETE lower_upper:
813 // OBSOLETE type = parse_mode_or_normal_call ();
814 // OBSOLETE write_lower_upper_value (op, type);
816 // OBSOLETE case LENGTH:
817 // OBSOLETE parse_unary_call ();
818 // OBSOLETE write_exp_elt_opcode (UNOP_LENGTH);
820 // OBSOLETE case TYPENAME:
821 // OBSOLETE type = PEEK_LVAL ().tsym.type;
822 // OBSOLETE FORWARD_TOKEN ();
823 // OBSOLETE switch (PEEK_TOKEN ())
825 // OBSOLETE case '[':
826 // OBSOLETE parse_tuple (type);
828 // OBSOLETE case '(':
829 // OBSOLETE FORWARD_TOKEN ();
830 // OBSOLETE parse_expr ();
831 // OBSOLETE expect (')', "missing right parenthesis");
832 // OBSOLETE write_exp_elt_opcode (UNOP_CAST);
833 // OBSOLETE write_exp_elt_type (type);
834 // OBSOLETE write_exp_elt_opcode (UNOP_CAST);
837 // OBSOLETE error ("typename in invalid context");
842 // OBSOLETE error ("invalid expression syntax at `%s'", lexptr);
846 // OBSOLETE switch (PEEK_TOKEN ())
848 // OBSOLETE case DOT_FIELD_NAME:
849 // OBSOLETE write_exp_elt_opcode (STRUCTOP_STRUCT);
850 // OBSOLETE write_exp_string (PEEK_LVAL ().sval);
851 // OBSOLETE write_exp_elt_opcode (STRUCTOP_STRUCT);
852 // OBSOLETE FORWARD_TOKEN ();
853 // OBSOLETE continue;
854 // OBSOLETE case POINTER:
855 // OBSOLETE FORWARD_TOKEN ();
856 // OBSOLETE if (PEEK_TOKEN () == TYPENAME)
858 // OBSOLETE type = PEEK_LVAL ().tsym.type;
859 // OBSOLETE write_exp_elt_opcode (UNOP_CAST);
860 // OBSOLETE write_exp_elt_type (lookup_pointer_type (type));
861 // OBSOLETE write_exp_elt_opcode (UNOP_CAST);
862 // OBSOLETE FORWARD_TOKEN ();
864 // OBSOLETE write_exp_elt_opcode (UNOP_IND);
865 // OBSOLETE continue;
866 // OBSOLETE case OPEN_PAREN:
867 // OBSOLETE parse_call ();
868 // OBSOLETE continue;
869 // OBSOLETE case CHARACTER_STRING_LITERAL:
870 // OBSOLETE case CHARACTER_LITERAL:
871 // OBSOLETE case BIT_STRING_LITERAL:
872 // OBSOLETE /* Handle string repetition. (See comment in parse_operand5.) */
873 // OBSOLETE parse_primval ();
874 // OBSOLETE write_exp_elt_opcode (MULTI_SUBSCRIPT);
875 // OBSOLETE write_exp_elt_longcst (1);
876 // OBSOLETE write_exp_elt_opcode (MULTI_SUBSCRIPT);
877 // OBSOLETE continue;
878 // OBSOLETE case END_TOKEN:
879 // OBSOLETE case TOKEN_NOT_READ:
880 // OBSOLETE case INTEGER_LITERAL:
881 // OBSOLETE case BOOLEAN_LITERAL:
882 // OBSOLETE case FLOAT_LITERAL:
883 // OBSOLETE case GENERAL_PROCEDURE_NAME:
884 // OBSOLETE case LOCATION_NAME:
885 // OBSOLETE case EMPTINESS_LITERAL:
886 // OBSOLETE case TYPENAME:
887 // OBSOLETE case CASE:
889 // OBSOLETE case ESAC:
890 // OBSOLETE case LOGIOR:
891 // OBSOLETE case ORIF:
892 // OBSOLETE case LOGXOR:
893 // OBSOLETE case LOGAND:
894 // OBSOLETE case ANDIF:
895 // OBSOLETE case NOTEQUAL:
896 // OBSOLETE case GEQ:
897 // OBSOLETE case LEQ:
899 // OBSOLETE case SLASH_SLASH:
900 // OBSOLETE case MOD:
901 // OBSOLETE case REM:
902 // OBSOLETE case NOT:
903 // OBSOLETE case RECEIVE:
906 // OBSOLETE case THEN:
907 // OBSOLETE case ELSE:
909 // OBSOLETE case ELSIF:
910 // OBSOLETE case ILLEGAL_TOKEN:
911 // OBSOLETE case NUM:
912 // OBSOLETE case PRED:
913 // OBSOLETE case SUCC:
914 // OBSOLETE case ABS:
915 // OBSOLETE case CARD:
916 // OBSOLETE case MAX_TOKEN:
917 // OBSOLETE case MIN_TOKEN:
918 // OBSOLETE case ADDR_TOKEN:
919 // OBSOLETE case SIZE:
920 // OBSOLETE case UPPER:
921 // OBSOLETE case LOWER:
922 // OBSOLETE case LENGTH:
923 // OBSOLETE case ARRAY:
924 // OBSOLETE case GDB_VARIABLE:
925 // OBSOLETE case GDB_ASSIGNMENT:
933 // OBSOLETE static void
934 // OBSOLETE parse_operand6 (void)
936 // OBSOLETE if (check_token (RECEIVE))
938 // OBSOLETE parse_primval ();
939 // OBSOLETE error ("not implemented: RECEIVE expression");
941 // OBSOLETE else if (check_token (POINTER))
943 // OBSOLETE parse_primval ();
944 // OBSOLETE write_exp_elt_opcode (UNOP_ADDR);
947 // OBSOLETE parse_primval ();
950 // OBSOLETE static void
951 // OBSOLETE parse_operand5 (void)
953 // OBSOLETE enum exp_opcode op;
954 // OBSOLETE /* We are supposed to be looking for a <string repetition operator>,
955 // OBSOLETE but in general we can't distinguish that from a parenthesized
956 // OBSOLETE expression. This is especially difficult if we allow the
957 // OBSOLETE string operand to be a constant expression (as requested by
958 // OBSOLETE some users), and not just a string literal.
959 // OBSOLETE Consider: LPRN expr RPRN LPRN expr RPRN
960 // OBSOLETE Is that a function call or string repetition?
961 // OBSOLETE Instead, we handle string repetition in parse_primval,
962 // OBSOLETE and build_generalized_call. */
963 // OBSOLETE switch (PEEK_TOKEN ())
965 // OBSOLETE case NOT:
966 // OBSOLETE op = UNOP_LOGICAL_NOT;
968 // OBSOLETE case '-':
969 // OBSOLETE op = UNOP_NEG;
972 // OBSOLETE op = OP_NULL;
974 // OBSOLETE if (op != OP_NULL)
975 // OBSOLETE FORWARD_TOKEN ();
976 // OBSOLETE parse_operand6 ();
977 // OBSOLETE if (op != OP_NULL)
978 // OBSOLETE write_exp_elt_opcode (op);
981 // OBSOLETE static void
982 // OBSOLETE parse_operand4 (void)
984 // OBSOLETE enum exp_opcode op;
985 // OBSOLETE parse_operand5 ();
988 // OBSOLETE switch (PEEK_TOKEN ())
990 // OBSOLETE case '*':
991 // OBSOLETE op = BINOP_MUL;
993 // OBSOLETE case '/':
994 // OBSOLETE op = BINOP_DIV;
996 // OBSOLETE case MOD:
997 // OBSOLETE op = BINOP_MOD;
999 // OBSOLETE case REM:
1000 // OBSOLETE op = BINOP_REM;
1002 // OBSOLETE default:
1005 // OBSOLETE FORWARD_TOKEN ();
1006 // OBSOLETE parse_operand5 ();
1007 // OBSOLETE write_exp_elt_opcode (op);
1011 // OBSOLETE static void
1012 // OBSOLETE parse_operand3 (void)
1014 // OBSOLETE enum exp_opcode op;
1015 // OBSOLETE parse_operand4 ();
1016 // OBSOLETE for (;;)
1018 // OBSOLETE switch (PEEK_TOKEN ())
1020 // OBSOLETE case '+':
1021 // OBSOLETE op = BINOP_ADD;
1023 // OBSOLETE case '-':
1024 // OBSOLETE op = BINOP_SUB;
1026 // OBSOLETE case SLASH_SLASH:
1027 // OBSOLETE op = BINOP_CONCAT;
1029 // OBSOLETE default:
1032 // OBSOLETE FORWARD_TOKEN ();
1033 // OBSOLETE parse_operand4 ();
1034 // OBSOLETE write_exp_elt_opcode (op);
1038 // OBSOLETE static void
1039 // OBSOLETE parse_operand2 (void)
1041 // OBSOLETE enum exp_opcode op;
1042 // OBSOLETE parse_operand3 ();
1043 // OBSOLETE for (;;)
1045 // OBSOLETE if (check_token (IN))
1047 // OBSOLETE parse_operand3 ();
1048 // OBSOLETE write_exp_elt_opcode (BINOP_IN);
1052 // OBSOLETE switch (PEEK_TOKEN ())
1054 // OBSOLETE case '>':
1055 // OBSOLETE op = BINOP_GTR;
1057 // OBSOLETE case GEQ:
1058 // OBSOLETE op = BINOP_GEQ;
1060 // OBSOLETE case '<':
1061 // OBSOLETE op = BINOP_LESS;
1063 // OBSOLETE case LEQ:
1064 // OBSOLETE op = BINOP_LEQ;
1066 // OBSOLETE case '=':
1067 // OBSOLETE op = BINOP_EQUAL;
1069 // OBSOLETE case NOTEQUAL:
1070 // OBSOLETE op = BINOP_NOTEQUAL;
1072 // OBSOLETE default:
1075 // OBSOLETE FORWARD_TOKEN ();
1076 // OBSOLETE parse_operand3 ();
1077 // OBSOLETE write_exp_elt_opcode (op);
1082 // OBSOLETE static void
1083 // OBSOLETE parse_operand1 (void)
1085 // OBSOLETE enum exp_opcode op;
1086 // OBSOLETE parse_operand2 ();
1087 // OBSOLETE for (;;)
1089 // OBSOLETE switch (PEEK_TOKEN ())
1091 // OBSOLETE case LOGAND:
1092 // OBSOLETE op = BINOP_BITWISE_AND;
1094 // OBSOLETE case ANDIF:
1095 // OBSOLETE op = BINOP_LOGICAL_AND;
1097 // OBSOLETE default:
1100 // OBSOLETE FORWARD_TOKEN ();
1101 // OBSOLETE parse_operand2 ();
1102 // OBSOLETE write_exp_elt_opcode (op);
1106 // OBSOLETE static void
1107 // OBSOLETE parse_operand0 (void)
1109 // OBSOLETE enum exp_opcode op;
1110 // OBSOLETE parse_operand1 ();
1111 // OBSOLETE for (;;)
1113 // OBSOLETE switch (PEEK_TOKEN ())
1115 // OBSOLETE case LOGIOR:
1116 // OBSOLETE op = BINOP_BITWISE_IOR;
1118 // OBSOLETE case LOGXOR:
1119 // OBSOLETE op = BINOP_BITWISE_XOR;
1121 // OBSOLETE case ORIF:
1122 // OBSOLETE op = BINOP_LOGICAL_OR;
1124 // OBSOLETE default:
1127 // OBSOLETE FORWARD_TOKEN ();
1128 // OBSOLETE parse_operand1 ();
1129 // OBSOLETE write_exp_elt_opcode (op);
1133 // OBSOLETE static void
1134 // OBSOLETE parse_expr (void)
1136 // OBSOLETE parse_operand0 ();
1137 // OBSOLETE if (check_token (GDB_ASSIGNMENT))
1139 // OBSOLETE parse_expr ();
1140 // OBSOLETE write_exp_elt_opcode (BINOP_ASSIGN);
1144 // OBSOLETE static void
1145 // OBSOLETE parse_then_alternative (void)
1147 // OBSOLETE expect (THEN, "missing 'THEN' in 'IF' expression");
1148 // OBSOLETE parse_expr ();
1151 // OBSOLETE static void
1152 // OBSOLETE parse_else_alternative (void)
1154 // OBSOLETE if (check_token (ELSIF))
1155 // OBSOLETE parse_if_expression_body ();
1156 // OBSOLETE else if (check_token (ELSE))
1157 // OBSOLETE parse_expr ();
1159 // OBSOLETE error ("missing ELSE/ELSIF in IF expression");
1162 // OBSOLETE /* Matches: <boolean expression> <then alternative> <else alternative> */
1164 // OBSOLETE static void
1165 // OBSOLETE parse_if_expression_body (void)
1167 // OBSOLETE parse_expr ();
1168 // OBSOLETE parse_then_alternative ();
1169 // OBSOLETE parse_else_alternative ();
1170 // OBSOLETE write_exp_elt_opcode (TERNOP_COND);
1173 // OBSOLETE static void
1174 // OBSOLETE parse_if_expression (void)
1176 // OBSOLETE require (IF);
1177 // OBSOLETE parse_if_expression_body ();
1178 // OBSOLETE expect (FI, "missing 'FI' at end of conditional expression");
1181 // OBSOLETE /* An <untyped_expr> is a superset of <expr>. It also includes
1182 // OBSOLETE <conditional expressions> and untyped <tuples>, whose types
1183 // OBSOLETE are not given by their constituents. Hence, these are only
1184 // OBSOLETE allowed in certain contexts that expect a certain type.
1185 // OBSOLETE You should call convert() to fix up the <untyped_expr>. */
1187 // OBSOLETE static void
1188 // OBSOLETE parse_untyped_expr (void)
1190 // OBSOLETE switch (PEEK_TOKEN ())
1192 // OBSOLETE case IF:
1193 // OBSOLETE parse_if_expression ();
1195 // OBSOLETE case CASE:
1196 // OBSOLETE error ("not implemented: CASE expression");
1197 // OBSOLETE case '(':
1198 // OBSOLETE switch (PEEK_TOKEN1 ())
1200 // OBSOLETE case IF:
1201 // OBSOLETE case CASE:
1202 // OBSOLETE goto skip_lprn;
1203 // OBSOLETE case '[':
1204 // OBSOLETE skip_lprn:
1205 // OBSOLETE FORWARD_TOKEN ();
1206 // OBSOLETE parse_untyped_expr ();
1207 // OBSOLETE expect (')', "missing ')'");
1209 // OBSOLETE default:;
1210 // OBSOLETE /* fall through */
1212 // OBSOLETE default:
1213 // OBSOLETE parse_operand0 ();
1218 // OBSOLETE chill_parse (void)
1220 // OBSOLETE terminal_buffer[0] = TOKEN_NOT_READ;
1221 // OBSOLETE if (PEEK_TOKEN () == TYPENAME && PEEK_TOKEN1 () == END_TOKEN)
1223 // OBSOLETE write_exp_elt_opcode (OP_TYPE);
1224 // OBSOLETE write_exp_elt_type (PEEK_LVAL ().tsym.type);
1225 // OBSOLETE write_exp_elt_opcode (OP_TYPE);
1226 // OBSOLETE FORWARD_TOKEN ();
1229 // OBSOLETE parse_expr ();
1230 // OBSOLETE if (terminal_buffer[0] != END_TOKEN)
1232 // OBSOLETE if (comma_terminates && terminal_buffer[0] == ',')
1233 // OBSOLETE lexptr--; /* Put the comma back. */
1235 // OBSOLETE error ("Junk after end of expression.");
1237 // OBSOLETE return 0;
1241 // OBSOLETE /* Implementation of a dynamically expandable buffer for processing input
1242 // OBSOLETE characters acquired through lexptr and building a value to return in
1243 // OBSOLETE yylval. */
1245 // OBSOLETE static char *tempbuf; /* Current buffer contents */
1246 // OBSOLETE static int tempbufsize; /* Size of allocated buffer */
1247 // OBSOLETE static int tempbufindex; /* Current index into buffer */
1249 // OBSOLETE #define GROWBY_MIN_SIZE 64 /* Minimum amount to grow buffer by */
1251 // OBSOLETE #define CHECKBUF(size) \
1253 // OBSOLETE if (tempbufindex + (size) >= tempbufsize) \
1255 // OBSOLETE growbuf_by_size (size); \
1257 // OBSOLETE } while (0);
1259 // OBSOLETE /* Grow the static temp buffer if necessary, including allocating the first one
1260 // OBSOLETE on demand. */
1262 // OBSOLETE static void
1263 // OBSOLETE growbuf_by_size (int count)
1265 // OBSOLETE int growby;
1267 // OBSOLETE growby = max (count, GROWBY_MIN_SIZE);
1268 // OBSOLETE tempbufsize += growby;
1269 // OBSOLETE if (tempbuf == NULL)
1271 // OBSOLETE tempbuf = (char *) xmalloc (tempbufsize);
1275 // OBSOLETE tempbuf = (char *) xrealloc (tempbuf, tempbufsize);
1279 // OBSOLETE /* Try to consume a simple name string token. If successful, returns
1280 // OBSOLETE a pointer to a nullbyte terminated copy of the name that can be used
1281 // OBSOLETE in symbol table lookups. If not successful, returns NULL. */
1283 // OBSOLETE static char *
1284 // OBSOLETE match_simple_name_string (void)
1286 // OBSOLETE char *tokptr = lexptr;
1288 // OBSOLETE if (isalpha (*tokptr) || *tokptr == '_')
1290 // OBSOLETE char *result;
1293 // OBSOLETE tokptr++;
1295 // OBSOLETE while (isalnum (*tokptr) || (*tokptr == '_'));
1296 // OBSOLETE yylval.sval.ptr = lexptr;
1297 // OBSOLETE yylval.sval.length = tokptr - lexptr;
1298 // OBSOLETE lexptr = tokptr;
1299 // OBSOLETE result = copy_name (yylval.sval);
1300 // OBSOLETE return result;
1302 // OBSOLETE return (NULL);
1305 // OBSOLETE /* Start looking for a value composed of valid digits as set by the base
1306 // OBSOLETE in use. Note that '_' characters are valid anywhere, in any quantity,
1307 // OBSOLETE and are simply ignored. Since we must find at least one valid digit,
1308 // OBSOLETE or reject this token as an integer literal, we keep track of how many
1309 // OBSOLETE digits we have encountered. */
1311 // OBSOLETE static int
1312 // OBSOLETE decode_integer_value (int base, char **tokptrptr, LONGEST *ivalptr)
1314 // OBSOLETE char *tokptr = *tokptrptr;
1315 // OBSOLETE int temp;
1316 // OBSOLETE int digits = 0;
1318 // OBSOLETE while (*tokptr != '\0')
1320 // OBSOLETE temp = *tokptr;
1321 // OBSOLETE if (isupper (temp))
1322 // OBSOLETE temp = tolower (temp);
1323 // OBSOLETE tokptr++;
1324 // OBSOLETE switch (temp)
1326 // OBSOLETE case '_':
1327 // OBSOLETE continue;
1328 // OBSOLETE case '0':
1329 // OBSOLETE case '1':
1330 // OBSOLETE case '2':
1331 // OBSOLETE case '3':
1332 // OBSOLETE case '4':
1333 // OBSOLETE case '5':
1334 // OBSOLETE case '6':
1335 // OBSOLETE case '7':
1336 // OBSOLETE case '8':
1337 // OBSOLETE case '9':
1338 // OBSOLETE temp -= '0';
1340 // OBSOLETE case 'a':
1341 // OBSOLETE case 'b':
1342 // OBSOLETE case 'c':
1343 // OBSOLETE case 'd':
1344 // OBSOLETE case 'e':
1345 // OBSOLETE case 'f':
1346 // OBSOLETE temp -= 'a';
1347 // OBSOLETE temp += 10;
1349 // OBSOLETE default:
1350 // OBSOLETE temp = base;
1353 // OBSOLETE if (temp < base)
1355 // OBSOLETE digits++;
1356 // OBSOLETE *ivalptr *= base;
1357 // OBSOLETE *ivalptr += temp;
1361 // OBSOLETE /* Found something not in domain for current base. */
1362 // OBSOLETE tokptr--; /* Unconsume what gave us indigestion. */
1367 // OBSOLETE /* If we didn't find any digits, then we don't have a valid integer
1368 // OBSOLETE value, so reject the entire token. Otherwise, update the lexical
1369 // OBSOLETE scan pointer, and return non-zero for success. */
1371 // OBSOLETE if (digits == 0)
1373 // OBSOLETE return (0);
1377 // OBSOLETE *tokptrptr = tokptr;
1378 // OBSOLETE return (1);
1382 // OBSOLETE static int
1383 // OBSOLETE decode_integer_literal (LONGEST *valptr, char **tokptrptr)
1385 // OBSOLETE char *tokptr = *tokptrptr;
1386 // OBSOLETE int base = 0;
1387 // OBSOLETE LONGEST ival = 0;
1388 // OBSOLETE int explicit_base = 0;
1390 // OBSOLETE /* Look for an explicit base specifier, which is optional. */
1392 // OBSOLETE switch (*tokptr)
1394 // OBSOLETE case 'd':
1395 // OBSOLETE case 'D':
1396 // OBSOLETE explicit_base++;
1397 // OBSOLETE base = 10;
1398 // OBSOLETE tokptr++;
1400 // OBSOLETE case 'b':
1401 // OBSOLETE case 'B':
1402 // OBSOLETE explicit_base++;
1403 // OBSOLETE base = 2;
1404 // OBSOLETE tokptr++;
1406 // OBSOLETE case 'h':
1407 // OBSOLETE case 'H':
1408 // OBSOLETE explicit_base++;
1409 // OBSOLETE base = 16;
1410 // OBSOLETE tokptr++;
1412 // OBSOLETE case 'o':
1413 // OBSOLETE case 'O':
1414 // OBSOLETE explicit_base++;
1415 // OBSOLETE base = 8;
1416 // OBSOLETE tokptr++;
1418 // OBSOLETE default:
1419 // OBSOLETE base = 10;
1423 // OBSOLETE /* If we found an explicit base ensure that the character after the
1424 // OBSOLETE explicit base is a single quote. */
1426 // OBSOLETE if (explicit_base && (*tokptr++ != '\''))
1428 // OBSOLETE return (0);
1431 // OBSOLETE /* Attempt to decode whatever follows as an integer value in the
1432 // OBSOLETE indicated base, updating the token pointer in the process and
1433 // OBSOLETE computing the value into ival. Also, if we have an explicit
1434 // OBSOLETE base, then the next character must not be a single quote, or we
1435 // OBSOLETE have a bitstring literal, so reject the entire token in this case.
1436 // OBSOLETE Otherwise, update the lexical scan pointer, and return non-zero
1437 // OBSOLETE for success. */
1439 // OBSOLETE if (!decode_integer_value (base, &tokptr, &ival))
1441 // OBSOLETE return (0);
1443 // OBSOLETE else if (explicit_base && (*tokptr == '\''))
1445 // OBSOLETE return (0);
1449 // OBSOLETE *valptr = ival;
1450 // OBSOLETE *tokptrptr = tokptr;
1451 // OBSOLETE return (1);
1455 // OBSOLETE /* If it wasn't for the fact that floating point values can contain '_'
1456 // OBSOLETE characters, we could just let strtod do all the hard work by letting it
1457 // OBSOLETE try to consume as much of the current token buffer as possible and
1458 // OBSOLETE find a legal conversion. Unfortunately we need to filter out the '_'
1459 // OBSOLETE characters before calling strtod, which we do by copying the other
1460 // OBSOLETE legal chars to a local buffer to be converted. However since we also
1461 // OBSOLETE need to keep track of where the last unconsumed character in the input
1462 // OBSOLETE buffer is, we have transfer only as many characters as may compose a
1463 // OBSOLETE legal floating point value. */
1465 // OBSOLETE static enum ch_terminal
1466 // OBSOLETE match_float_literal (void)
1468 // OBSOLETE char *tokptr = lexptr;
1469 // OBSOLETE char *buf;
1470 // OBSOLETE char *copy;
1471 // OBSOLETE double dval;
1472 // OBSOLETE extern double strtod ();
1474 // OBSOLETE /* Make local buffer in which to build the string to convert. This is
1475 // OBSOLETE required because underscores are valid in chill floating point numbers
1476 // OBSOLETE but not in the string passed to strtod to convert. The string will be
1477 // OBSOLETE no longer than our input string. */
1479 // OBSOLETE copy = buf = (char *) alloca (strlen (tokptr) + 1);
1481 // OBSOLETE /* Transfer all leading digits to the conversion buffer, discarding any
1482 // OBSOLETE underscores. */
1484 // OBSOLETE while (isdigit (*tokptr) || *tokptr == '_')
1486 // OBSOLETE if (*tokptr != '_')
1488 // OBSOLETE *copy++ = *tokptr;
1490 // OBSOLETE tokptr++;
1493 // OBSOLETE /* Now accept either a '.', or one of [eEdD]. Dot is legal regardless
1494 // OBSOLETE of whether we found any leading digits, and we simply accept it and
1495 // OBSOLETE continue on to look for the fractional part and/or exponent. One of
1496 // OBSOLETE [eEdD] is legal only if we have seen digits, and means that there
1497 // OBSOLETE is no fractional part. If we find neither of these, then this is
1498 // OBSOLETE not a floating point number, so return failure. */
1500 // OBSOLETE switch (*tokptr++)
1502 // OBSOLETE case '.':
1503 // OBSOLETE /* Accept and then look for fractional part and/or exponent. */
1504 // OBSOLETE *copy++ = '.';
1507 // OBSOLETE case 'e':
1508 // OBSOLETE case 'E':
1509 // OBSOLETE case 'd':
1510 // OBSOLETE case 'D':
1511 // OBSOLETE if (copy == buf)
1513 // OBSOLETE return (0);
1515 // OBSOLETE *copy++ = 'e';
1516 // OBSOLETE goto collect_exponent;
1519 // OBSOLETE default:
1520 // OBSOLETE return (0);
1524 // OBSOLETE /* We found a '.', copy any fractional digits to the conversion buffer, up
1525 // OBSOLETE to the first nondigit, non-underscore character. */
1527 // OBSOLETE while (isdigit (*tokptr) || *tokptr == '_')
1529 // OBSOLETE if (*tokptr != '_')
1531 // OBSOLETE *copy++ = *tokptr;
1533 // OBSOLETE tokptr++;
1536 // OBSOLETE /* Look for an exponent, which must start with one of [eEdD]. If none
1537 // OBSOLETE is found, jump directly to trying to convert what we have collected
1538 // OBSOLETE so far. */
1540 // OBSOLETE switch (*tokptr)
1542 // OBSOLETE case 'e':
1543 // OBSOLETE case 'E':
1544 // OBSOLETE case 'd':
1545 // OBSOLETE case 'D':
1546 // OBSOLETE *copy++ = 'e';
1547 // OBSOLETE tokptr++;
1549 // OBSOLETE default:
1550 // OBSOLETE goto convert_float;
1554 // OBSOLETE /* Accept an optional '-' or '+' following one of [eEdD]. */
1556 // OBSOLETE collect_exponent:
1557 // OBSOLETE if (*tokptr == '+' || *tokptr == '-')
1559 // OBSOLETE *copy++ = *tokptr++;
1562 // OBSOLETE /* Now copy an exponent into the conversion buffer. Note that at the
1563 // OBSOLETE moment underscores are *not* allowed in exponents. */
1565 // OBSOLETE while (isdigit (*tokptr))
1567 // OBSOLETE *copy++ = *tokptr++;
1570 // OBSOLETE /* If we transfered any chars to the conversion buffer, try to interpret its
1571 // OBSOLETE contents as a floating point value. If any characters remain, then we
1572 // OBSOLETE must not have a valid floating point string. */
1574 // OBSOLETE convert_float:
1575 // OBSOLETE *copy = '\0';
1576 // OBSOLETE if (copy != buf)
1578 // OBSOLETE dval = strtod (buf, ©);
1579 // OBSOLETE if (*copy == '\0')
1581 // OBSOLETE yylval.dval = dval;
1582 // OBSOLETE lexptr = tokptr;
1583 // OBSOLETE return (FLOAT_LITERAL);
1586 // OBSOLETE return (0);
1589 // OBSOLETE /* Recognize a string literal. A string literal is a sequence
1590 // OBSOLETE of characters enclosed in matching single or double quotes, except that
1591 // OBSOLETE a single character inside single quotes is a character literal, which
1592 // OBSOLETE we reject as a string literal. To embed the terminator character inside
1593 // OBSOLETE a string, it is simply doubled (I.E. "this""is""one""string") */
1595 // OBSOLETE static enum ch_terminal
1596 // OBSOLETE match_string_literal (void)
1598 // OBSOLETE char *tokptr = lexptr;
1599 // OBSOLETE int in_ctrlseq = 0;
1600 // OBSOLETE LONGEST ival;
1602 // OBSOLETE for (tempbufindex = 0, tokptr++; *tokptr != '\0'; tokptr++)
1604 // OBSOLETE CHECKBUF (1);
1605 // OBSOLETE tryagain:;
1606 // OBSOLETE if (in_ctrlseq)
1608 // OBSOLETE /* skip possible whitespaces */
1609 // OBSOLETE while ((*tokptr == ' ' || *tokptr == '\t') && *tokptr)
1610 // OBSOLETE tokptr++;
1611 // OBSOLETE if (*tokptr == ')')
1613 // OBSOLETE in_ctrlseq = 0;
1614 // OBSOLETE tokptr++;
1615 // OBSOLETE goto tryagain;
1617 // OBSOLETE else if (*tokptr != ',')
1618 // OBSOLETE error ("Invalid control sequence");
1619 // OBSOLETE tokptr++;
1620 // OBSOLETE /* skip possible whitespaces */
1621 // OBSOLETE while ((*tokptr == ' ' || *tokptr == '\t') && *tokptr)
1622 // OBSOLETE tokptr++;
1623 // OBSOLETE if (!decode_integer_literal (&ival, &tokptr))
1624 // OBSOLETE error ("Invalid control sequence");
1625 // OBSOLETE tokptr--;
1627 // OBSOLETE else if (*tokptr == *lexptr)
1629 // OBSOLETE if (*(tokptr + 1) == *lexptr)
1631 // OBSOLETE ival = *tokptr++;
1638 // OBSOLETE else if (*tokptr == '^')
1640 // OBSOLETE if (*(tokptr + 1) == '(')
1642 // OBSOLETE in_ctrlseq = 1;
1643 // OBSOLETE tokptr += 2;
1644 // OBSOLETE if (!decode_integer_literal (&ival, &tokptr))
1645 // OBSOLETE error ("Invalid control sequence");
1646 // OBSOLETE tokptr--;
1648 // OBSOLETE else if (*(tokptr + 1) == '^')
1649 // OBSOLETE ival = *tokptr++;
1651 // OBSOLETE error ("Invalid control sequence");
1654 // OBSOLETE ival = *tokptr;
1655 // OBSOLETE tempbuf[tempbufindex++] = ival;
1657 // OBSOLETE if (in_ctrlseq)
1658 // OBSOLETE error ("Invalid control sequence");
1660 // OBSOLETE if (*tokptr == '\0' /* no terminator */
1661 // OBSOLETE || (tempbufindex == 1 && *tokptr == '\'')) /* char literal */
1663 // OBSOLETE return (0);
1667 // OBSOLETE tempbuf[tempbufindex] = '\0';
1668 // OBSOLETE yylval.sval.ptr = tempbuf;
1669 // OBSOLETE yylval.sval.length = tempbufindex;
1670 // OBSOLETE lexptr = ++tokptr;
1671 // OBSOLETE return (CHARACTER_STRING_LITERAL);
1675 // OBSOLETE /* Recognize a character literal. A character literal is single character
1676 // OBSOLETE or a control sequence, enclosed in single quotes. A control sequence
1677 // OBSOLETE is a comma separated list of one or more integer literals, enclosed
1678 // OBSOLETE in parenthesis and introduced with a circumflex character.
1680 // OBSOLETE EX: 'a' '^(7)' '^(7,8)'
1682 // OBSOLETE As a GNU chill extension, the syntax C'xx' is also recognized as a
1683 // OBSOLETE character literal, where xx is a hex value for the character.
1685 // OBSOLETE Note that more than a single character, enclosed in single quotes, is
1686 // OBSOLETE a string literal.
1688 // OBSOLETE Returns CHARACTER_LITERAL if a match is found.
1691 // OBSOLETE static enum ch_terminal
1692 // OBSOLETE match_character_literal (void)
1694 // OBSOLETE char *tokptr = lexptr;
1695 // OBSOLETE LONGEST ival = 0;
1697 // OBSOLETE if ((*tokptr == 'c' || *tokptr == 'C') && (*(tokptr + 1) == '\''))
1699 // OBSOLETE /* We have a GNU chill extension form, so skip the leading "C'",
1700 // OBSOLETE decode the hex value, and then ensure that we have a trailing
1701 // OBSOLETE single quote character. */
1702 // OBSOLETE tokptr += 2;
1703 // OBSOLETE if (!decode_integer_value (16, &tokptr, &ival) || (*tokptr != '\''))
1705 // OBSOLETE return (0);
1707 // OBSOLETE tokptr++;
1709 // OBSOLETE else if (*tokptr == '\'')
1711 // OBSOLETE tokptr++;
1713 // OBSOLETE /* Determine which form we have, either a control sequence or the
1714 // OBSOLETE single character form. */
1716 // OBSOLETE if (*tokptr == '^')
1718 // OBSOLETE if (*(tokptr + 1) == '(')
1720 // OBSOLETE /* Match and decode a control sequence. Return zero if we don't
1721 // OBSOLETE find a valid integer literal, or if the next unconsumed character
1722 // OBSOLETE after the integer literal is not the trailing ')'. */
1723 // OBSOLETE tokptr += 2;
1724 // OBSOLETE if (!decode_integer_literal (&ival, &tokptr) || (*tokptr++ != ')'))
1726 // OBSOLETE return (0);
1729 // OBSOLETE else if (*(tokptr + 1) == '^')
1731 // OBSOLETE ival = *tokptr;
1732 // OBSOLETE tokptr += 2;
1735 // OBSOLETE /* fail */
1736 // OBSOLETE error ("Invalid control sequence");
1738 // OBSOLETE else if (*tokptr == '\'')
1740 // OBSOLETE /* this must be duplicated */
1741 // OBSOLETE ival = *tokptr;
1742 // OBSOLETE tokptr += 2;
1746 // OBSOLETE ival = *tokptr++;
1749 // OBSOLETE /* The trailing quote has not yet been consumed. If we don't find
1750 // OBSOLETE it, then we have no match. */
1752 // OBSOLETE if (*tokptr++ != '\'')
1754 // OBSOLETE return (0);
1759 // OBSOLETE /* Not a character literal. */
1760 // OBSOLETE return (0);
1762 // OBSOLETE yylval.typed_val.val = ival;
1763 // OBSOLETE yylval.typed_val.type = builtin_type_chill_char;
1764 // OBSOLETE lexptr = tokptr;
1765 // OBSOLETE return (CHARACTER_LITERAL);
1768 // OBSOLETE /* Recognize an integer literal, as specified in Z.200 sec 5.2.4.2.
1769 // OBSOLETE Note that according to 5.2.4.2, a single "_" is also a valid integer
1770 // OBSOLETE literal, however GNU-chill requires there to be at least one "digit"
1771 // OBSOLETE in any integer literal. */
1773 // OBSOLETE static enum ch_terminal
1774 // OBSOLETE match_integer_literal (void)
1776 // OBSOLETE char *tokptr = lexptr;
1777 // OBSOLETE LONGEST ival;
1779 // OBSOLETE if (!decode_integer_literal (&ival, &tokptr))
1781 // OBSOLETE return (0);
1785 // OBSOLETE yylval.typed_val.val = ival;
1786 // OBSOLETE #if defined(CC_HAS_LONG_LONG)
1787 // OBSOLETE if (ival > (LONGEST) 2147483647U || ival < -(LONGEST) 2147483648U)
1788 // OBSOLETE yylval.typed_val.type = builtin_type_long_long;
1791 // OBSOLETE yylval.typed_val.type = builtin_type_int;
1792 // OBSOLETE lexptr = tokptr;
1793 // OBSOLETE return (INTEGER_LITERAL);
1797 // OBSOLETE /* Recognize a bit-string literal, as specified in Z.200 sec 5.2.4.8
1798 // OBSOLETE Note that according to 5.2.4.8, a single "_" is also a valid bit-string
1799 // OBSOLETE literal, however GNU-chill requires there to be at least one "digit"
1800 // OBSOLETE in any bit-string literal. */
1802 // OBSOLETE static enum ch_terminal
1803 // OBSOLETE match_bitstring_literal (void)
1805 // OBSOLETE register char *tokptr = lexptr;
1806 // OBSOLETE int bitoffset = 0;
1807 // OBSOLETE int bitcount = 0;
1808 // OBSOLETE int bits_per_char;
1809 // OBSOLETE int digit;
1811 // OBSOLETE tempbufindex = 0;
1812 // OBSOLETE CHECKBUF (1);
1813 // OBSOLETE tempbuf[0] = 0;
1815 // OBSOLETE /* Look for the required explicit base specifier. */
1817 // OBSOLETE switch (*tokptr++)
1819 // OBSOLETE case 'b':
1820 // OBSOLETE case 'B':
1821 // OBSOLETE bits_per_char = 1;
1823 // OBSOLETE case 'o':
1824 // OBSOLETE case 'O':
1825 // OBSOLETE bits_per_char = 3;
1827 // OBSOLETE case 'h':
1828 // OBSOLETE case 'H':
1829 // OBSOLETE bits_per_char = 4;
1831 // OBSOLETE default:
1832 // OBSOLETE return (0);
1836 // OBSOLETE /* Ensure that the character after the explicit base is a single quote. */
1838 // OBSOLETE if (*tokptr++ != '\'')
1840 // OBSOLETE return (0);
1843 // OBSOLETE while (*tokptr != '\0' && *tokptr != '\'')
1845 // OBSOLETE digit = *tokptr;
1846 // OBSOLETE if (isupper (digit))
1847 // OBSOLETE digit = tolower (digit);
1848 // OBSOLETE tokptr++;
1849 // OBSOLETE switch (digit)
1851 // OBSOLETE case '_':
1852 // OBSOLETE continue;
1853 // OBSOLETE case '0':
1854 // OBSOLETE case '1':
1855 // OBSOLETE case '2':
1856 // OBSOLETE case '3':
1857 // OBSOLETE case '4':
1858 // OBSOLETE case '5':
1859 // OBSOLETE case '6':
1860 // OBSOLETE case '7':
1861 // OBSOLETE case '8':
1862 // OBSOLETE case '9':
1863 // OBSOLETE digit -= '0';
1865 // OBSOLETE case 'a':
1866 // OBSOLETE case 'b':
1867 // OBSOLETE case 'c':
1868 // OBSOLETE case 'd':
1869 // OBSOLETE case 'e':
1870 // OBSOLETE case 'f':
1871 // OBSOLETE digit -= 'a';
1872 // OBSOLETE digit += 10;
1874 // OBSOLETE default:
1875 // OBSOLETE /* this is not a bitstring literal, probably an integer */
1876 // OBSOLETE return 0;
1878 // OBSOLETE if (digit >= 1 << bits_per_char)
1880 // OBSOLETE /* Found something not in domain for current base. */
1881 // OBSOLETE error ("Too-large digit in bitstring or integer.");
1885 // OBSOLETE /* Extract bits from digit, packing them into the bitstring byte. */
1886 // OBSOLETE int k = TARGET_BYTE_ORDER == BFD_ENDIAN_BIG ? bits_per_char - 1 : 0;
1887 // OBSOLETE for (; TARGET_BYTE_ORDER == BFD_ENDIAN_BIG ? k >= 0 : k < bits_per_char;
1888 // OBSOLETE TARGET_BYTE_ORDER == BFD_ENDIAN_BIG ? k-- : k++)
1890 // OBSOLETE bitcount++;
1891 // OBSOLETE if (digit & (1 << k))
1893 // OBSOLETE tempbuf[tempbufindex] |=
1894 // OBSOLETE (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
1895 // OBSOLETE ? (1 << (HOST_CHAR_BIT - 1 - bitoffset))
1896 // OBSOLETE : (1 << bitoffset);
1898 // OBSOLETE bitoffset++;
1899 // OBSOLETE if (bitoffset == HOST_CHAR_BIT)
1901 // OBSOLETE bitoffset = 0;
1902 // OBSOLETE tempbufindex++;
1903 // OBSOLETE CHECKBUF (1);
1904 // OBSOLETE tempbuf[tempbufindex] = 0;
1910 // OBSOLETE /* Verify that we consumed everything up to the trailing single quote,
1911 // OBSOLETE and that we found some bits (IE not just underbars). */
1913 // OBSOLETE if (*tokptr++ != '\'')
1915 // OBSOLETE return (0);
1919 // OBSOLETE yylval.sval.ptr = tempbuf;
1920 // OBSOLETE yylval.sval.length = bitcount;
1921 // OBSOLETE lexptr = tokptr;
1922 // OBSOLETE return (BIT_STRING_LITERAL);
1926 // OBSOLETE struct token
1928 // OBSOLETE char *operator;
1929 // OBSOLETE int token;
1932 // OBSOLETE static const struct token idtokentab[] =
1934 // OBSOLETE {"array", ARRAY},
1935 // OBSOLETE {"length", LENGTH},
1936 // OBSOLETE {"lower", LOWER},
1937 // OBSOLETE {"upper", UPPER},
1938 // OBSOLETE {"andif", ANDIF},
1939 // OBSOLETE {"pred", PRED},
1940 // OBSOLETE {"succ", SUCC},
1941 // OBSOLETE {"card", CARD},
1942 // OBSOLETE {"size", SIZE},
1943 // OBSOLETE {"orif", ORIF},
1944 // OBSOLETE {"num", NUM},
1945 // OBSOLETE {"abs", ABS},
1946 // OBSOLETE {"max", MAX_TOKEN},
1947 // OBSOLETE {"min", MIN_TOKEN},
1948 // OBSOLETE {"mod", MOD},
1949 // OBSOLETE {"rem", REM},
1950 // OBSOLETE {"not", NOT},
1951 // OBSOLETE {"xor", LOGXOR},
1952 // OBSOLETE {"and", LOGAND},
1953 // OBSOLETE {"in", IN},
1954 // OBSOLETE {"or", LOGIOR},
1955 // OBSOLETE {"up", UP},
1956 // OBSOLETE {"addr", ADDR_TOKEN},
1957 // OBSOLETE {"null", EMPTINESS_LITERAL}
1960 // OBSOLETE static const struct token tokentab2[] =
1962 // OBSOLETE {":=", GDB_ASSIGNMENT},
1963 // OBSOLETE {"//", SLASH_SLASH},
1964 // OBSOLETE {"->", POINTER},
1965 // OBSOLETE {"/=", NOTEQUAL},
1966 // OBSOLETE {"<=", LEQ},
1967 // OBSOLETE {">=", GEQ}
1970 // OBSOLETE /* Read one token, getting characters through lexptr. */
1971 // OBSOLETE /* This is where we will check to make sure that the language and the
1972 // OBSOLETE operators used are compatible. */
1974 // OBSOLETE static enum ch_terminal
1975 // OBSOLETE ch_lex (void)
1977 // OBSOLETE unsigned int i;
1978 // OBSOLETE enum ch_terminal token;
1979 // OBSOLETE char *inputname;
1980 // OBSOLETE struct symbol *sym;
1982 // OBSOLETE /* Skip over any leading whitespace. */
1983 // OBSOLETE while (isspace (*lexptr))
1985 // OBSOLETE lexptr++;
1987 // OBSOLETE /* Look for special single character cases which can't be the first
1988 // OBSOLETE character of some other multicharacter token. */
1989 // OBSOLETE switch (*lexptr)
1991 // OBSOLETE case '\0':
1992 // OBSOLETE return END_TOKEN;
1993 // OBSOLETE case ',':
1994 // OBSOLETE case '=':
1995 // OBSOLETE case ';':
1996 // OBSOLETE case '!':
1997 // OBSOLETE case '+':
1998 // OBSOLETE case '*':
1999 // OBSOLETE case '(':
2000 // OBSOLETE case ')':
2001 // OBSOLETE case '[':
2002 // OBSOLETE case ']':
2003 // OBSOLETE return (*lexptr++);
2005 // OBSOLETE /* Look for characters which start a particular kind of multicharacter
2006 // OBSOLETE token, such as a character literal, register name, convenience
2007 // OBSOLETE variable name, string literal, etc. */
2008 // OBSOLETE switch (*lexptr)
2010 // OBSOLETE case '\'':
2011 // OBSOLETE case '\"':
2012 // OBSOLETE /* First try to match a string literal, which is any
2013 // OBSOLETE sequence of characters enclosed in matching single or double
2014 // OBSOLETE quotes, except that a single character inside single quotes
2015 // OBSOLETE is a character literal, so we have to catch that case also. */
2016 // OBSOLETE token = match_string_literal ();
2017 // OBSOLETE if (token != 0)
2019 // OBSOLETE return (token);
2021 // OBSOLETE if (*lexptr == '\'')
2023 // OBSOLETE token = match_character_literal ();
2024 // OBSOLETE if (token != 0)
2026 // OBSOLETE return (token);
2030 // OBSOLETE case 'C':
2031 // OBSOLETE case 'c':
2032 // OBSOLETE token = match_character_literal ();
2033 // OBSOLETE if (token != 0)
2035 // OBSOLETE return (token);
2038 // OBSOLETE case '$':
2039 // OBSOLETE yylval.sval.ptr = lexptr;
2042 // OBSOLETE lexptr++;
2044 // OBSOLETE while (isalnum (*lexptr) || *lexptr == '_' || *lexptr == '$');
2045 // OBSOLETE yylval.sval.length = lexptr - yylval.sval.ptr;
2046 // OBSOLETE write_dollar_variable (yylval.sval);
2047 // OBSOLETE return GDB_VARIABLE;
2050 // OBSOLETE /* See if it is a special token of length 2. */
2051 // OBSOLETE for (i = 0; i < sizeof (tokentab2) / sizeof (tokentab2[0]); i++)
2053 // OBSOLETE if (STREQN (lexptr, tokentab2[i].operator, 2))
2055 // OBSOLETE lexptr += 2;
2056 // OBSOLETE return (tokentab2[i].token);
2059 // OBSOLETE /* Look for single character cases which which could be the first
2060 // OBSOLETE character of some other multicharacter token, but aren't, or we
2061 // OBSOLETE would already have found it. */
2062 // OBSOLETE switch (*lexptr)
2064 // OBSOLETE case '-':
2065 // OBSOLETE case ':':
2066 // OBSOLETE case '/':
2067 // OBSOLETE case '<':
2068 // OBSOLETE case '>':
2069 // OBSOLETE return (*lexptr++);
2071 // OBSOLETE /* Look for a float literal before looking for an integer literal, so
2072 // OBSOLETE we match as much of the input stream as possible. */
2073 // OBSOLETE token = match_float_literal ();
2074 // OBSOLETE if (token != 0)
2076 // OBSOLETE return (token);
2078 // OBSOLETE token = match_bitstring_literal ();
2079 // OBSOLETE if (token != 0)
2081 // OBSOLETE return (token);
2083 // OBSOLETE token = match_integer_literal ();
2084 // OBSOLETE if (token != 0)
2086 // OBSOLETE return (token);
2089 // OBSOLETE /* Try to match a simple name string, and if a match is found, then
2090 // OBSOLETE further classify what sort of name it is and return an appropriate
2091 // OBSOLETE token. Note that attempting to match a simple name string consumes
2092 // OBSOLETE the token from lexptr, so we can't back out if we later find that
2093 // OBSOLETE we can't classify what sort of name it is. */
2095 // OBSOLETE inputname = match_simple_name_string ();
2097 // OBSOLETE if (inputname != NULL)
2099 // OBSOLETE char *simplename = (char *) alloca (strlen (inputname) + 1);
2101 // OBSOLETE char *dptr = simplename, *sptr = inputname;
2102 // OBSOLETE for (; *sptr; sptr++)
2103 // OBSOLETE *dptr++ = isupper (*sptr) ? tolower (*sptr) : *sptr;
2104 // OBSOLETE *dptr = '\0';
2106 // OBSOLETE /* See if it is a reserved identifier. */
2107 // OBSOLETE for (i = 0; i < sizeof (idtokentab) / sizeof (idtokentab[0]); i++)
2109 // OBSOLETE if (STREQ (simplename, idtokentab[i].operator))
2111 // OBSOLETE return (idtokentab[i].token);
2115 // OBSOLETE /* Look for other special tokens. */
2116 // OBSOLETE if (STREQ (simplename, "true"))
2118 // OBSOLETE yylval.ulval = 1;
2119 // OBSOLETE return (BOOLEAN_LITERAL);
2121 // OBSOLETE if (STREQ (simplename, "false"))
2123 // OBSOLETE yylval.ulval = 0;
2124 // OBSOLETE return (BOOLEAN_LITERAL);
2127 // OBSOLETE sym = lookup_symbol (inputname, expression_context_block,
2128 // OBSOLETE VAR_NAMESPACE, (int *) NULL,
2129 // OBSOLETE (struct symtab **) NULL);
2130 // OBSOLETE if (sym == NULL && strcmp (inputname, simplename) != 0)
2132 // OBSOLETE sym = lookup_symbol (simplename, expression_context_block,
2133 // OBSOLETE VAR_NAMESPACE, (int *) NULL,
2134 // OBSOLETE (struct symtab **) NULL);
2136 // OBSOLETE if (sym != NULL)
2138 // OBSOLETE yylval.ssym.stoken.ptr = NULL;
2139 // OBSOLETE yylval.ssym.stoken.length = 0;
2140 // OBSOLETE yylval.ssym.sym = sym;
2141 // OBSOLETE yylval.ssym.is_a_field_of_this = 0; /* FIXME, C++'ism */
2142 // OBSOLETE switch (SYMBOL_CLASS (sym))
2144 // OBSOLETE case LOC_BLOCK:
2145 // OBSOLETE /* Found a procedure name. */
2146 // OBSOLETE return (GENERAL_PROCEDURE_NAME);
2147 // OBSOLETE case LOC_STATIC:
2148 // OBSOLETE /* Found a global or local static variable. */
2149 // OBSOLETE return (LOCATION_NAME);
2150 // OBSOLETE case LOC_REGISTER:
2151 // OBSOLETE case LOC_ARG:
2152 // OBSOLETE case LOC_REF_ARG:
2153 // OBSOLETE case LOC_REGPARM:
2154 // OBSOLETE case LOC_REGPARM_ADDR:
2155 // OBSOLETE case LOC_LOCAL:
2156 // OBSOLETE case LOC_LOCAL_ARG:
2157 // OBSOLETE case LOC_BASEREG:
2158 // OBSOLETE case LOC_BASEREG_ARG:
2159 // OBSOLETE if (innermost_block == NULL
2160 // OBSOLETE || contained_in (block_found, innermost_block))
2162 // OBSOLETE innermost_block = block_found;
2164 // OBSOLETE return (LOCATION_NAME);
2166 // OBSOLETE case LOC_CONST:
2167 // OBSOLETE case LOC_LABEL:
2168 // OBSOLETE return (LOCATION_NAME);
2170 // OBSOLETE case LOC_TYPEDEF:
2171 // OBSOLETE yylval.tsym.type = SYMBOL_TYPE (sym);
2172 // OBSOLETE return TYPENAME;
2173 // OBSOLETE case LOC_UNDEF:
2174 // OBSOLETE case LOC_CONST_BYTES:
2175 // OBSOLETE case LOC_OPTIMIZED_OUT:
2176 // OBSOLETE error ("Symbol \"%s\" names no location.", inputname);
2178 // OBSOLETE default:
2179 // OBSOLETE internal_error (__FILE__, __LINE__,
2180 // OBSOLETE "unhandled SYMBOL_CLASS in ch_lex()");
2184 // OBSOLETE else if (!have_full_symbols () && !have_partial_symbols ())
2186 // OBSOLETE error ("No symbol table is loaded. Use the \"file\" command.");
2190 // OBSOLETE error ("No symbol \"%s\" in current context.", inputname);
2194 // OBSOLETE /* Catch single character tokens which are not part of some
2195 // OBSOLETE longer token. */
2197 // OBSOLETE switch (*lexptr)
2199 // OBSOLETE case '.': /* Not float for example. */
2200 // OBSOLETE lexptr++;
2201 // OBSOLETE while (isspace (*lexptr))
2202 // OBSOLETE lexptr++;
2203 // OBSOLETE inputname = match_simple_name_string ();
2204 // OBSOLETE if (!inputname)
2205 // OBSOLETE return '.';
2206 // OBSOLETE return DOT_FIELD_NAME;
2209 // OBSOLETE return (ILLEGAL_TOKEN);
2212 // OBSOLETE static void
2213 // OBSOLETE write_lower_upper_value (enum exp_opcode opcode, /* Either UNOP_LOWER or UNOP_UPPER */
2214 // OBSOLETE struct type *type)
2216 // OBSOLETE if (type == NULL)
2217 // OBSOLETE write_exp_elt_opcode (opcode);
2220 // OBSOLETE struct type *result_type;
2221 // OBSOLETE LONGEST val = type_lower_upper (opcode, type, &result_type);
2222 // OBSOLETE write_exp_elt_opcode (OP_LONG);
2223 // OBSOLETE write_exp_elt_type (result_type);
2224 // OBSOLETE write_exp_elt_longcst (val);
2225 // OBSOLETE write_exp_elt_opcode (OP_LONG);
2230 // OBSOLETE chill_error (char *msg)
2232 // OBSOLETE /* Never used. */
This page took 0.074328 seconds and 4 git commands to generate.