* c-exp.y (c_create_fundamental_type): New function to create
[deliverable/binutils-gdb.git] / gdb / ch-exp.y
CommitLineData
e58de8a2
FF
1/* YACC grammar for Chill expressions, for GDB.
2 Copyright (C) 1992 Free Software Foundation, Inc.
3
4This file is part of GDB.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
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.
28
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.
36
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.
51
52 */
53
54%{
55
56#include <stdio.h>
57#include <string.h>
58#include "defs.h"
59#include "symtab.h"
60#include "gdbtypes.h"
61#include "frame.h"
62#include "expression.h"
63#include "language.h"
64#include "value.h"
65#include "parser-defs.h"
66#include "bfd.h"
67#include "symfile.h"
68#include "objfiles.h"
69
70/* These MUST be included in any grammar file!!!! Please choose unique names!
71 Note that this are a combined list of variables that can be produced
72 by any one of bison, byacc, or yacc. */
73#define yymaxdepth chill_maxdepth
74#define yyparse chill_parse
75#define yylex chill_lex
76#define yyerror chill_error
77#define yylval chill_lval
78#define yychar chill_char
79#define yydebug chill_debug
80#define yypact chill_pact
81#define yyr1 chill_r1
82#define yyr2 chill_r2
83#define yydef chill_def
84#define yychk chill_chk
85#define yypgo chill_pgo
86#define yyact chill_act
87#define yyexca chill_exca
88#define yyerrflag chill_errflag
89#define yynerrs chill_nerrs
90#define yyps chill_ps
91#define yypv chill_pv
92#define yys chill_s
93#define yy_yys chill_yys
94#define yystate chill_state
95#define yytmp chill_tmp
96#define yyv chill_v
97#define yy_yyv chill_yyv
98#define yyval chill_val
99#define yylloc chill_lloc
100#define yyss chill_yyss /* byacc */
101#define yyssp chill_yysp /* byacc */
102#define yyvs chill_yyvs /* byacc */
103#define yyvsp chill_yyvsp /* byacc */
104
105static int
106yylex PARAMS ((void));
107
108static void
109yyerror PARAMS ((char *));
110
111int
112yyparse PARAMS ((void));
113
114/* #define YYDEBUG 1 */
115
116%}
117
118/* Although the yacc "value" of an expression is not used,
119 since the result is stored in the structure being created,
120 other node types do have values. */
121
122%union
123 {
124 LONGEST lval;
125 unsigned LONGEST ulval;
126 struct {
127 LONGEST val;
128 struct type *type;
129 } typed_val;
130 double dval;
131 struct symbol *sym;
132 struct type *tval;
133 struct stoken sval;
134 struct ttype tsym;
135 struct symtoken ssym;
136 int voidval;
137 struct block *bval;
138 enum exp_opcode opcode;
139 struct internalvar *ivar;
140
141 struct type **tvec;
142 int *ivec;
143 }
144
145%{
146static int parse_number PARAMS ((void));
147%}
148
149%token <voidval> FIXME
150
151%token <typed_val> INTEGER_LITERAL
152%token <ulval> BOOLEAN_LITERAL
2e66cf7d 153%token <typed_val> CHARACTER_LITERAL
cbd1bdc3
FF
154%token <ssym> GENERAL_PROCEDURE_NAME
155%token <ssym> LOCATION_NAME
e58de8a2
FF
156%token <voidval> SET_LITERAL
157%token <voidval> EMPTINESS_LITERAL
158%token <voidval> CHARACTER_STRING_LITERAL
159%token <voidval> BIT_STRING_LITERAL
160
161%token <voidval> STRING
162%token <voidval> CONSTANT
163%token <voidval> '.'
164%token <voidval> ';'
165%token <voidval> ':'
166%token <voidval> CASE
167%token <voidval> OF
168%token <voidval> ESAC
169%token <voidval> LOGIOR
170%token <voidval> ORIF
171%token <voidval> LOGXOR
172%token <voidval> LOGAND
173%token <voidval> ANDIF
174%token <voidval> '='
175%token <voidval> NOTEQUAL
176%token <voidval> '>'
177%token <voidval> GTR
178%token <voidval> '<'
179%token <voidval> LEQ
180%token <voidval> IN
181%token <voidval> '+'
182%token <voidval> '-'
183%token <voidval> '*'
184%token <voidval> '/'
185%token <voidval> SLASH_SLASH
186%token <voidval> MOD
187%token <voidval> REM
188%token <voidval> NOT
189%token <voidval> POINTER
190%token <voidval> RECEIVE
191%token <voidval> SC
192%token <voidval> '['
193%token <voidval> ']'
194%token <voidval> '('
195%token <voidval> ')'
196%token <voidval> UP
197%token <voidval> IF
198%token <voidval> THEN
199%token <voidval> ELSE
200%token <voidval> FI
201%token <voidval> ELSIF
202%token <voidval> ILLEGAL_TOKEN
203
204%type <voidval> location
cbd1bdc3 205%type <voidval> access_name
e58de8a2
FF
206%type <voidval> primitive_value
207%type <voidval> location_contents
208%type <voidval> value_name
209%type <voidval> literal
210%type <voidval> tuple
211%type <voidval> value_string_element
212%type <voidval> value_string_slice
213%type <voidval> value_array_element
214%type <voidval> value_array_slice
215%type <voidval> value_structure_field
216%type <voidval> expression_conversion
217%type <voidval> value_procedure_call
218%type <voidval> value_built_in_routine_call
219%type <voidval> start_expression
220%type <voidval> zero_adic_operator
221%type <voidval> parenthesised_expression
222%type <voidval> value
223%type <voidval> undefined_value
224%type <voidval> expression
225%type <voidval> conditional_expression
226%type <voidval> then_alternative
227%type <voidval> else_alternative
228%type <voidval> sub_expression
229%type <voidval> value_case_alternative
230%type <voidval> operand_0
231%type <voidval> operand_1
232%type <voidval> operand_2
233%type <voidval> operand_3
234%type <voidval> operand_4
235%type <voidval> operand_5
236%type <voidval> operand_6
237%type <voidval> integer_literal_expression
238%type <voidval> synonym_name
239%type <voidval> value_enumeration_name
240%type <voidval> value_do_with_name
241%type <voidval> value_receive_name
e58de8a2
FF
242%type <voidval> string_primitive_value
243%type <voidval> start_element
244%type <voidval> left_element
245%type <voidval> right_element
246%type <voidval> slice_size
247%type <voidval> array_primitive_value
248%type <voidval> expression_list
249%type <voidval> lower_element
250%type <voidval> upper_element
251%type <voidval> first_element
252%type <voidval> structure_primitive_value
253%type <voidval> field_name
254%type <voidval> mode_name
255%type <voidval> boolean_expression
256%type <voidval> case_selector_list
257%type <voidval> subexpression
258%type <voidval> case_label_specification
259%type <voidval> buffer_location
260
261%%
262
263/* Z.200, 5.3.1 */
264
265value : expression
266 {
2e66cf7d 267 $$ = 0; /* FIXME */
e58de8a2
FF
268 }
269 | undefined_value
270 {
2e66cf7d 271 $$ = 0; /* FIXME */
e58de8a2
FF
272 }
273 ;
274
275undefined_value : FIXME
276 {
2e66cf7d 277 $$ = 0; /* FIXME */
e58de8a2
FF
278 }
279 ;
280
281/* Z.200, 4.2.1 */
282
cbd1bdc3
FF
283location : access_name
284 {
285 $$ = 0; /* FIXME */
286 }
287 | FIXME
288 {
289 $$ = 0; /* FIXME */
290 }
291 ;
292
293/* Z.200, 4.2.2 */
294
295access_name : LOCATION_NAME
296 {
297 write_exp_elt_opcode (OP_VAR_VALUE);
298 write_exp_elt_sym ($1.sym);
299 write_exp_elt_opcode (OP_VAR_VALUE);
300 }
301 | FIXME
e58de8a2 302 {
2e66cf7d 303 $$ = 0; /* FIXME */
e58de8a2
FF
304 }
305 ;
306
307/* Z.200, 5.2.1 */
308
309primitive_value : location_contents
310 {
2e66cf7d 311 $$ = 0; /* FIXME */
e58de8a2
FF
312 }
313 | value_name
314 {
2e66cf7d 315 $$ = 0; /* FIXME */
e58de8a2
FF
316 }
317 | literal
318 {
2e66cf7d 319 $$ = 0; /* FIXME */
e58de8a2
FF
320 }
321 | tuple
322 {
2e66cf7d 323 $$ = 0; /* FIXME */
e58de8a2
FF
324 }
325 | value_string_element
326 {
2e66cf7d 327 $$ = 0; /* FIXME */
e58de8a2
FF
328 }
329 | value_string_slice
330 {
2e66cf7d 331 $$ = 0; /* FIXME */
e58de8a2
FF
332 }
333 | value_array_element
334 {
2e66cf7d 335 $$ = 0; /* FIXME */
e58de8a2
FF
336 }
337 | value_array_slice
338 {
2e66cf7d 339 $$ = 0; /* FIXME */
e58de8a2
FF
340 }
341 | value_structure_field
342 {
2e66cf7d 343 $$ = 0; /* FIXME */
e58de8a2
FF
344 }
345 | expression_conversion
346 {
2e66cf7d 347 $$ = 0; /* FIXME */
e58de8a2
FF
348 }
349 | value_procedure_call
350 {
2e66cf7d 351 $$ = 0; /* FIXME */
e58de8a2
FF
352 }
353 | value_built_in_routine_call
354 {
2e66cf7d 355 $$ = 0; /* FIXME */
e58de8a2
FF
356 }
357 | start_expression
358 {
2e66cf7d 359 $$ = 0; /* FIXME */
e58de8a2
FF
360 }
361 | zero_adic_operator
362 {
2e66cf7d 363 $$ = 0; /* FIXME */
e58de8a2
FF
364 }
365 | parenthesised_expression
366 {
2e66cf7d 367 $$ = 0; /* FIXME */
e58de8a2
FF
368 }
369 ;
370
371/* Z.200, 5.2.2 */
372
373location_contents: location
374 {
2e66cf7d 375 $$ = 0; /* FIXME */
e58de8a2
FF
376 }
377 ;
378
379/* Z.200, 5.2.3 */
380
381value_name : synonym_name
382 {
2e66cf7d 383 $$ = 0; /* FIXME */
e58de8a2
FF
384 }
385 | value_enumeration_name
386 {
2e66cf7d 387 $$ = 0; /* FIXME */
e58de8a2
FF
388 }
389 | value_do_with_name
390 {
2e66cf7d 391 $$ = 0; /* FIXME */
e58de8a2
FF
392 }
393 | value_receive_name
394 {
2e66cf7d 395 $$ = 0; /* FIXME */
e58de8a2 396 }
cbd1bdc3 397 | GENERAL_PROCEDURE_NAME
e58de8a2 398 {
cbd1bdc3
FF
399 write_exp_elt_opcode (OP_VAR_VALUE);
400 write_exp_elt_sym ($1.sym);
401 write_exp_elt_opcode (OP_VAR_VALUE);
e58de8a2
FF
402 }
403 ;
404
405/* Z.200, 5.2.4.1 */
406
407literal : INTEGER_LITERAL
408 {
2e66cf7d
FF
409 write_exp_elt_opcode (OP_LONG);
410 write_exp_elt_type ($1.type);
411 write_exp_elt_longcst ((LONGEST) ($1.val));
412 write_exp_elt_opcode (OP_LONG);
e58de8a2
FF
413 }
414 | BOOLEAN_LITERAL
415 {
2e66cf7d
FF
416 write_exp_elt_opcode (OP_BOOL);
417 write_exp_elt_longcst ((LONGEST) $1);
418 write_exp_elt_opcode (OP_BOOL);
e58de8a2
FF
419 }
420 | CHARACTER_LITERAL
421 {
2e66cf7d
FF
422 write_exp_elt_opcode (OP_LONG);
423 write_exp_elt_type ($1.type);
424 write_exp_elt_longcst ((LONGEST) ($1.val));
425 write_exp_elt_opcode (OP_LONG);
e58de8a2
FF
426 }
427 | SET_LITERAL
428 {
2e66cf7d 429 $$ = 0; /* FIXME */
e58de8a2
FF
430 }
431 | EMPTINESS_LITERAL
432 {
2e66cf7d 433 $$ = 0; /* FIXME */
e58de8a2
FF
434 }
435 | CHARACTER_STRING_LITERAL
436 {
2e66cf7d 437 $$ = 0; /* FIXME */
e58de8a2
FF
438 }
439 | BIT_STRING_LITERAL
440 {
2e66cf7d 441 $$ = 0; /* FIXME */
e58de8a2
FF
442 }
443 ;
444
445/* Z.200, 5.2.5 */
446
447tuple : FIXME
448 {
2e66cf7d 449 $$ = 0; /* FIXME */
e58de8a2
FF
450 }
451 ;
452
453
454/* Z.200, 5.2.6 */
455
456value_string_element: string_primitive_value '(' start_element ')'
457 {
2e66cf7d 458 $$ = 0; /* FIXME */
e58de8a2
FF
459 }
460 ;
461
462/* Z.200, 5.2.7 */
463
464value_string_slice: string_primitive_value '(' left_element ':' right_element ')'
465 {
2e66cf7d 466 $$ = 0; /* FIXME */
e58de8a2
FF
467 }
468 | string_primitive_value '(' start_element UP slice_size ')'
469 {
2e66cf7d 470 $$ = 0; /* FIXME */
e58de8a2
FF
471 }
472 ;
473
474/* Z.200, 5.2.8 */
475
476value_array_element: array_primitive_value '(' expression_list ')'
477 {
2e66cf7d 478 $$ = 0; /* FIXME */
e58de8a2
FF
479 }
480 ;
481
482/* Z.200, 5.2.9 */
483
484value_array_slice: array_primitive_value '(' lower_element ':' upper_element ')'
485 {
2e66cf7d 486 $$ = 0; /* FIXME */
e58de8a2
FF
487 }
488 | array_primitive_value '(' first_element UP slice_size '('
489 {
2e66cf7d 490 $$ = 0; /* FIXME */
e58de8a2
FF
491 }
492 ;
493
494/* Z.200, 5.2.10 */
495
496value_structure_field: structure_primitive_value '.' field_name
497 {
2e66cf7d 498 $$ = 0; /* FIXME */
e58de8a2
FF
499 }
500 ;
501
502/* Z.200, 5.2.11 */
503
504expression_conversion: mode_name '(' expression ')'
505 {
2e66cf7d 506 $$ = 0; /* FIXME */
e58de8a2
FF
507 }
508 ;
509
510/* Z.200, 5.2.12 */
511
512value_procedure_call: FIXME
513 {
2e66cf7d 514 $$ = 0; /* FIXME */
e58de8a2
FF
515 }
516 ;
517
518/* Z.200, 5.2.13 */
519
520value_built_in_routine_call: FIXME
521 {
2e66cf7d 522 $$ = 0; /* FIXME */
e58de8a2
FF
523 }
524 ;
525
526/* Z.200, 5.2.14 */
527
528start_expression: FIXME
529 {
2e66cf7d 530 $$ = 0; /* FIXME */
e58de8a2
FF
531 } /* Not in GNU-Chill */
532 ;
533
534/* Z.200, 5.2.15 */
535
536zero_adic_operator: FIXME
537 {
2e66cf7d 538 $$ = 0; /* FIXME */
e58de8a2
FF
539 }
540 ;
541
542/* Z.200, 5.2.16 */
543
544parenthesised_expression: '(' expression ')'
545 {
2e66cf7d 546 $$ = 0; /* FIXME */
e58de8a2
FF
547 }
548 ;
549
550/* Z.200, 5.3.2 */
551
552expression : operand_0
553 {
2e66cf7d 554 $$ = 0; /* FIXME */
e58de8a2
FF
555 }
556 | conditional_expression
557 {
2e66cf7d 558 $$ = 0; /* FIXME */
e58de8a2
FF
559 }
560 ;
561
562conditional_expression : IF boolean_expression then_alternative else_alternative FI
563 {
2e66cf7d 564 $$ = 0; /* FIXME */
e58de8a2
FF
565 }
566 | CASE case_selector_list OF value_case_alternative '[' ELSE sub_expression ']' ESAC
567 {
2e66cf7d 568 $$ = 0; /* FIXME */
e58de8a2
FF
569 }
570 ;
571
572then_alternative: THEN subexpression
573 {
2e66cf7d 574 $$ = 0; /* FIXME */
e58de8a2
FF
575 }
576 ;
577
578else_alternative: ELSE subexpression
579 {
2e66cf7d 580 $$ = 0; /* FIXME */
e58de8a2
FF
581 }
582 | ELSIF boolean_expression then_alternative else_alternative
583 {
2e66cf7d 584 $$ = 0; /* FIXME */
e58de8a2
FF
585 }
586 ;
587
588sub_expression : expression
589 {
2e66cf7d 590 $$ = 0; /* FIXME */
e58de8a2
FF
591 }
592 ;
593
594value_case_alternative: case_label_specification ':' sub_expression ';'
595 {
2e66cf7d 596 $$ = 0; /* FIXME */
e58de8a2
FF
597 }
598 ;
599
600/* Z.200, 5.3.3 */
601
602operand_0 : operand_1
603 {
2e66cf7d 604 $$ = 0; /* FIXME */
e58de8a2
FF
605 }
606 | operand_0 LOGIOR operand_1
607 {
2e66cf7d 608 write_exp_elt_opcode (BINOP_BITWISE_IOR);
e58de8a2
FF
609 }
610 | operand_0 ORIF operand_1
611 {
2e66cf7d 612 $$ = 0; /* FIXME */
e58de8a2
FF
613 }
614 | operand_0 LOGXOR operand_1
615 {
2e66cf7d 616 write_exp_elt_opcode (BINOP_BITWISE_XOR);
e58de8a2
FF
617 }
618 ;
619
620/* Z.200, 5.3.4 */
621
622operand_1 : operand_2
623 {
2e66cf7d 624 $$ = 0; /* FIXME */
e58de8a2
FF
625 }
626 | operand_1 LOGAND operand_2
627 {
2e66cf7d 628 write_exp_elt_opcode (BINOP_BITWISE_AND);
e58de8a2
FF
629 }
630 | operand_1 ANDIF operand_2
631 {
2e66cf7d 632 $$ = 0; /* FIXME */
e58de8a2
FF
633 }
634 ;
635
636/* Z.200, 5.3.5 */
637
638operand_2 : operand_3
639 {
2e66cf7d 640 $$ = 0; /* FIXME */
e58de8a2
FF
641 }
642 | operand_2 '=' operand_3
643 {
2e66cf7d 644 write_exp_elt_opcode (BINOP_EQUAL);
e58de8a2
FF
645 }
646 | operand_2 NOTEQUAL operand_3
647 {
2e66cf7d 648 write_exp_elt_opcode (BINOP_NOTEQUAL);
e58de8a2
FF
649 }
650 | operand_2 '>' operand_3
651 {
2e66cf7d 652 write_exp_elt_opcode (BINOP_GTR);
e58de8a2
FF
653 }
654 | operand_2 GTR operand_3
655 {
2e66cf7d 656 write_exp_elt_opcode (BINOP_GEQ);
e58de8a2
FF
657 }
658 | operand_2 '<' operand_3
659 {
2e66cf7d 660 write_exp_elt_opcode (BINOP_LESS);
e58de8a2
FF
661 }
662 | operand_2 LEQ operand_3
663 {
2e66cf7d 664 write_exp_elt_opcode (BINOP_LEQ);
e58de8a2
FF
665 }
666 | operand_2 IN operand_3
667 {
2e66cf7d 668 $$ = 0; /* FIXME */
e58de8a2
FF
669 }
670 ;
671
672
673/* Z.200, 5.3.6 */
674
675operand_3 : operand_4
676 {
2e66cf7d 677 $$ = 0; /* FIXME */
e58de8a2
FF
678 }
679 | operand_3 '+' operand_4
680 {
2e66cf7d 681 write_exp_elt_opcode (BINOP_ADD);
e58de8a2
FF
682 }
683 | operand_3 '-' operand_4
684 {
2e66cf7d 685 write_exp_elt_opcode (BINOP_SUB);
e58de8a2
FF
686 }
687 | operand_3 SLASH_SLASH operand_4
688 {
2e66cf7d 689 $$ = 0; /* FIXME */
e58de8a2
FF
690 }
691 ;
692
693/* Z.200, 5.3.7 */
694
695operand_4 : operand_5
696 {
2e66cf7d 697 $$ = 0; /* FIXME */
e58de8a2
FF
698 }
699 | operand_4 '*' operand_5
700 {
2e66cf7d 701 write_exp_elt_opcode (BINOP_MUL);
e58de8a2
FF
702 }
703 | operand_4 '/' operand_5
704 {
2e66cf7d 705 write_exp_elt_opcode (BINOP_DIV);
e58de8a2
FF
706 }
707 | operand_4 MOD operand_5
708 {
2e66cf7d 709 $$ = 0; /* FIXME */
e58de8a2
FF
710 }
711 | operand_4 REM operand_5
712 {
2e66cf7d 713 $$ = 0; /* FIXME */
e58de8a2
FF
714 }
715 ;
716
717/* Z.200, 5.3.8 */
718
719operand_5 : operand_6
720 {
2e66cf7d 721 $$ = 0; /* FIXME */
e58de8a2
FF
722 }
723 | '-' operand_6
724 {
2e66cf7d 725 write_exp_elt_opcode (UNOP_NEG);
e58de8a2
FF
726 }
727 | NOT operand_6
728 {
2e66cf7d 729 write_exp_elt_opcode (UNOP_LOGICAL_NOT);
e58de8a2
FF
730 }
731 | '(' integer_literal_expression ')' operand_6
732 {
2e66cf7d 733 $$ = 0; /* FIXME */
e58de8a2
FF
734 }
735 ;
736
737/* Z.200, 5.3.9 */
738
739operand_6 : POINTER location
740 {
2e66cf7d 741 $$ = 0; /* FIXME */
e58de8a2
FF
742 }
743 | RECEIVE buffer_location
744 {
2e66cf7d 745 $$ = 0; /* FIXME */
e58de8a2
FF
746 }
747 | primitive_value
748 {
2e66cf7d 749 $$ = 0; /* FIXME */
e58de8a2
FF
750 }
751 ;
752
753
754/* Z.200, 12.4.3 */
755/* FIXME: For now we just accept only a single integer literal. */
756
757integer_literal_expression:
758 INTEGER_LITERAL
759 {
2e66cf7d 760 $$ = 0;
e58de8a2
FF
761 }
762
763/* Things which still need productions... */
764synonym_name : FIXME { $$ = 0; }
765value_enumeration_name : FIXME { $$ = 0; }
766value_do_with_name : FIXME { $$ = 0; }
767value_receive_name : FIXME { $$ = 0; }
e58de8a2
FF
768string_primitive_value : FIXME { $$ = 0; }
769start_element : FIXME { $$ = 0; }
770left_element : FIXME { $$ = 0; }
771right_element : FIXME { $$ = 0; }
772slice_size : FIXME { $$ = 0; }
773array_primitive_value : FIXME { $$ = 0; }
774expression_list : FIXME { $$ = 0; }
775lower_element : FIXME { $$ = 0; }
776upper_element : FIXME { $$ = 0; }
777first_element : FIXME { $$ = 0; }
778structure_primitive_value: FIXME { $$ = 0; }
779field_name : FIXME { $$ = 0; }
780mode_name : FIXME { $$ = 0; }
781boolean_expression : FIXME { $$ = 0; }
782case_selector_list : FIXME { $$ = 0; }
783subexpression : FIXME { $$ = 0; }
784case_label_specification: FIXME { $$ = 0; }
785buffer_location : FIXME { $$ = 0; }
786
787%%
788
cbd1bdc3
FF
789/* Try to consume a simple name string token. If successful, returns
790 a pointer to a nullbyte terminated copy of the name that can be used
791 in symbol table lookups. If not successful, returns NULL. */
792
793static char *
794match_simple_name_string ()
795{
796 char *tokptr = lexptr;
797
798 if (isalpha (*tokptr))
799 {
800 do {
801 tokptr++;
802 } while (isalpha (*tokptr) || isdigit (*tokptr) || (*tokptr == '_'));
803 yylval.sval.ptr = lexptr;
804 yylval.sval.length = tokptr - lexptr;
805 lexptr = tokptr;
806 return (copy_name (yylval.sval));
807 }
808 return (NULL);
809}
810
5d074aa9
FF
811/* Start looking for a value composed of valid digits as set by the base
812 in use. Note that '_' characters are valid anywhere, in any quantity,
813 and are simply ignored. Since we must find at least one valid digit,
814 or reject this token as an integer literal, we keep track of how many
815 digits we have encountered. */
816
817static int
818decode_integer_value (base, tokptrptr, ivalptr)
819 int base;
820 char **tokptrptr;
821 int *ivalptr;
822{
823 char *tokptr = *tokptrptr;
824 int temp;
825 int digits = 0;
826
827 while (*tokptr != '\0')
828 {
829 temp = tolower (*tokptr);
830 tokptr++;
831 switch (temp)
832 {
833 case '_':
834 continue;
835 case '0': case '1': case '2': case '3': case '4':
836 case '5': case '6': case '7': case '8': case '9':
837 temp -= '0';
838 break;
839 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
840 temp -= 'a';
841 temp += 10;
842 break;
843 default:
844 temp = base;
845 break;
846 }
847 if (temp < base)
848 {
849 digits++;
850 *ivalptr *= base;
851 *ivalptr += temp;
852 }
853 else
854 {
855 /* Found something not in domain for current base. */
856 tokptr--; /* Unconsume what gave us indigestion. */
857 break;
858 }
859 }
860
861 /* If we didn't find any digits, then we don't have a valid integer
862 value, so reject the entire token. Otherwise, update the lexical
863 scan pointer, and return non-zero for success. */
864
865 if (digits == 0)
866 {
867 return (0);
868 }
869 else
870 {
871 *tokptrptr = tokptr;
872 return (1);
873 }
874}
875
e58de8a2 876static int
2e66cf7d 877decode_integer_literal (valptr, tokptrptr)
5d074aa9
FF
878 int *valptr;
879 char **tokptrptr;
e58de8a2 880{
2e66cf7d
FF
881 char *tokptr = *tokptrptr;
882 int base = 0;
883 int ival = 0;
884 int digits = 0;
885 int temp;
886 int explicit_base = 0;
887
888 /* Look for an explicit base specifier, which is optional. */
889
890 switch (*tokptr)
891 {
892 case 'd':
893 case 'D':
894 explicit_base++;
895 base = 10;
896 tokptr++;
897 break;
898 case 'b':
899 case 'B':
900 explicit_base++;
901 base = 2;
902 tokptr++;
903 break;
904 case 'h':
905 case 'H':
906 explicit_base++;
907 base = 16;
908 tokptr++;
909 break;
910 case 'o':
911 case 'O':
912 explicit_base++;
913 base = 8;
914 tokptr++;
915 break;
916 default:
917 base = 10;
918 break;
919 }
920
921 /* If we found an explicit base ensure that the character after the
922 explicit base is a single quote. */
923
924 if (explicit_base && (*tokptr++ != '\''))
925 {
926 return (0);
927 }
928
5d074aa9
FF
929 /* Attempt to decode whatever follows as an integer value in the
930 indicated base, updating the token pointer in the process and
931 computing the value into ival. Also, if we have an explicit
2e66cf7d 932 base, then the next character must not be a single quote, or we
5d074aa9
FF
933 have a bitstring literal, so reject the entire token in this case.
934 Otherwise, update the lexical scan pointer, and return non-zero
935 for success. */
936
937 if (!decode_integer_value (base, &tokptr, &ival))
2e66cf7d
FF
938 {
939 return (0);
940 }
941 else if (explicit_base && (*tokptr == '\''))
942 {
943 return (0);
944 }
945 else
946 {
947 *valptr = ival;
948 *tokptrptr = tokptr;
949 return (1);
950 }
951}
952
953/* Recognize a character literal. A character literal is single character
954 or a control sequence, enclosed in single quotes. A control sequence
955 is a comma separated list of one or more integer literals, enclosed
956 in parenthesis and introduced with a circumflex character.
957
958 EX: 'a' '^(7)' '^(7,8)'
959
5d074aa9
FF
960 As a GNU chill extension, the syntax C'xx' is also recognized as a
961 character literal, where xx is a hex value for the character.
962
2e66cf7d
FF
963 Returns CHARACTER_LITERAL if a match is found.
964 */
965
966static int
967match_character_literal ()
968{
969 char *tokptr = lexptr;
970 int ival = 0;
971
5d074aa9 972 if ((tolower (*tokptr) == 'c') && (*(tokptr + 1) == '\''))
2e66cf7d 973 {
5d074aa9
FF
974 /* We have a GNU chill extension form, so skip the leading "C'",
975 decode the hex value, and then ensure that we have a trailing
976 single quote character. */
2e66cf7d 977 tokptr += 2;
5d074aa9 978 if (!decode_integer_value (16, &tokptr, &ival) || (*tokptr != '\''))
e58de8a2 979 {
2e66cf7d 980 return (0);
e58de8a2 981 }
5d074aa9 982 tokptr++;
2e66cf7d 983 }
5d074aa9 984 else if (*tokptr == '\'')
2e66cf7d 985 {
5d074aa9 986 tokptr++;
2e66cf7d 987
5d074aa9
FF
988 /* Determine which form we have, either a control sequence or the
989 single character form. */
990
991 if ((*tokptr == '^') && (*(tokptr + 1) == '('))
992 {
993 /* Match and decode a control sequence. Return zero if we don't
994 find a valid integer literal, or if the next unconsumed character
995 after the integer literal is not the trailing ')'.
996 FIXME: We currently don't handle the multiple integer literal
997 form. */
998 tokptr += 2;
999 if (!decode_integer_literal (&ival, &tokptr) || (*tokptr++ != ')'))
1000 {
1001 return (0);
1002 }
1003 }
1004 else
1005 {
1006 ival = *tokptr++;
1007 }
1008
1009 /* The trailing quote has not yet been consumed. If we don't find
1010 it, then we have no match. */
1011
1012 if (*tokptr++ != '\'')
1013 {
1014 return (0);
1015 }
2e66cf7d 1016 }
2e66cf7d
FF
1017 yylval.typed_val.val = ival;
1018 yylval.typed_val.type = builtin_type_chill_char;
1019 lexptr = tokptr;
1020 return (CHARACTER_LITERAL);
e58de8a2
FF
1021}
1022
1023/* Recognize an integer literal, as specified in Z.200 sec 5.2.4.2.
1024 Note that according to 5.2.4.2, a single "_" is also a valid integer
1025 literal, however GNU-chill requires there to be at least one "digit"
1026 in any integer literal. */
1027
1028static int
2e66cf7d 1029match_integer_literal ()
e58de8a2 1030{
2e66cf7d 1031 char *tokptr = lexptr;
ae0afa4b 1032 int ival;
2e66cf7d 1033
ae0afa4b 1034 if (!decode_integer_literal (&ival, &tokptr))
2e66cf7d
FF
1035 {
1036 return (0);
1037 }
ae0afa4b 1038 else
2e66cf7d
FF
1039 {
1040 yylval.typed_val.val = ival;
1041 yylval.typed_val.type = builtin_type_int;
1042 lexptr = tokptr;
1043 return (INTEGER_LITERAL);
1044 }
e58de8a2
FF
1045}
1046
1047static void convert_float ()
1048{
1049#if 0
1050 extern double strtod ();
1051 double d;
1052 char tmp[256];
1053 char *p = yytext, *p1 = tmp;
1054 char c;
1055
1056 while (c = *p++)
1057 {
1058 switch (c)
1059 {
1060 case '_':
1061 break;
1062 case 'E':
1063 case 'd':
1064 case 'D':
1065 *p1++ = 'e';
1066 break;
1067 default:
1068 *p1++ = c;
1069 break;
1070 }
1071 }
1072 *p1 = '\0';
1073 d = strtod (tmp, &p1);
1074 if (*p1)
1075 {
1076 /* add error handling here */
1077 ;
1078 }
1079 yylval.dval = d;
1080#endif
1081}
1082
1083/* Take care of parsing a number (anything that starts with a digit).
1084 Set yylval and return the token type; update lexptr.
1085 LEN is the number of characters in it. */
1086
1087/*** Needs some error checking for the float case ***/
1088
1089static int
1090parse_number ()
1091{
1092}
1093
1094struct token
1095{
1096 char *operator;
1097 int token;
1098};
1099
1100const static struct token tokentab5[] =
1101{
1102 { "ANDIF", ANDIF }
1103};
1104
1105const static struct token tokentab4[] =
1106{
1107 { "ORIF", ORIF }
1108};
1109
1110const static struct token tokentab3[] =
1111{
1112 { "NOT", NOT },
1113 { "XOR", LOGXOR },
1114 { "AND", LOGAND }
1115};
1116
1117const static struct token tokentab2[] =
1118{
1119 { "//", SLASH_SLASH },
1120 { "/=", NOTEQUAL },
1121 { "<=", LEQ },
1122 { ">=", GTR },
1123 { "IN", IN },
1124 { "OR", LOGIOR }
1125};
1126
1127/* Read one token, getting characters through lexptr. */
1128/* This is where we will check to make sure that the language and the
1129 operators used are compatible. */
1130
1131static int
1132yylex ()
1133{
1134 unsigned int i;
1135 int token;
cbd1bdc3
FF
1136 char *simplename;
1137 struct symbol *sym;
e58de8a2
FF
1138
1139 /* Skip over any leading whitespace. */
1140 while (isspace (*lexptr))
1141 {
1142 lexptr++;
1143 }
1144 /* Look for special single character cases which can't be the first
1145 character of some other multicharacter token. */
1146 switch (*lexptr)
1147 {
1148 case '\0':
1149 return (0);
1150 case '.':
1151 case '=':
1152 case ':':
1153 case ';':
1154 case '!':
1155 case '+':
1156 case '-':
1157 case '*':
1158 case '/':
1159 case '(':
1160 case ')':
1161 case '[':
1162 case ']':
1163 return (*lexptr++);
1164 }
1165 /* Look for characters which start a particular kind of multicharacter
1166 token, such as a character literal. */
1167 switch (*lexptr)
2e66cf7d 1168 {
5d074aa9
FF
1169 case 'C':
1170 case 'c':
2e66cf7d
FF
1171 case '\'':
1172 token = match_character_literal ();
1173 if (token != 0)
1174 {
1175 return (token);
1176 }
1177 break;
1178 }
e58de8a2
FF
1179 /* See if it is a special token of length 5. */
1180 for (i = 0; i < sizeof (tokentab5) / sizeof (tokentab5[0]); i++)
1181 {
1182 if (strncmp (lexptr, tokentab5[i].operator, 5) == 0)
1183 {
1184 lexptr += 5;
1185 return (tokentab5[i].token);
1186 }
1187 }
1188 /* See if it is a special token of length 4. */
1189 for (i = 0; i < sizeof (tokentab4) / sizeof (tokentab4[0]); i++)
1190 {
1191 if (strncmp (lexptr, tokentab4[i].operator, 4) == 0)
1192 {
1193 lexptr += 4;
1194 return (tokentab4[i].token);
1195 }
1196 }
1197 /* See if it is a special token of length 3. */
1198 for (i = 0; i < sizeof (tokentab3) / sizeof (tokentab3[0]); i++)
1199 {
1200 if (strncmp (lexptr, tokentab3[i].operator, 3) == 0)
1201 {
1202 lexptr += 3;
1203 return (tokentab3[i].token);
1204 }
1205 }
1206 /* See if it is a special token of length 2. */
1207 for (i = 0; i < sizeof (tokentab2) / sizeof (tokentab2[0]); i++)
1208 {
1209 if (strncmp (lexptr, tokentab2[i].operator, 2) == 0)
1210 {
1211 lexptr += 2;
1212 return (tokentab2[i].token);
1213 }
1214 }
1215 /* Look for single character cases which which could be the first
1216 character of some other multicharacter token, but aren't, or we
1217 would already have found it. */
1218 switch (*lexptr)
1219 {
1220 case '/':
1221 case '<':
1222 case '>':
1223 return (*lexptr++);
1224 }
1225 /* Look for other special tokens. */
1226 if (strncmp (lexptr, "TRUE", 4) == 0) /* FIXME: What about lowercase? */
1227 {
1228 yylval.ulval = 1;
1229 lexptr += 4;
1230 return (BOOLEAN_LITERAL);
1231 }
1232 if (strncmp (lexptr, "FALSE", 5) == 0) /* FIXME: What about lowercase? */
1233 {
1234 yylval.ulval = 0;
1235 lexptr += 5;
1236 return (BOOLEAN_LITERAL);
1237 }
2e66cf7d 1238 token = match_integer_literal ();
cbd1bdc3 1239 if (token != 0)
e58de8a2
FF
1240 {
1241 return (token);
1242 }
cbd1bdc3
FF
1243
1244 /* Try to match a simple name string, and if a match is found, then
1245 further classify what sort of name it is and return an appropriate
1246 token. Note that attempting to match a simple name string consumes
1247 the token from lexptr, so we can't back out if we later find that
1248 we can't classify what sort of name it is. */
1249
1250 simplename = match_simple_name_string ();
1251 if (simplename != NULL)
1252 {
1253 sym = lookup_symbol (simplename, expression_context_block,
1254 VAR_NAMESPACE, (int *) NULL,
1255 (struct symtab **) NULL);
1256 if (sym != NULL)
1257 {
1258 yylval.ssym.stoken.ptr = NULL;
1259 yylval.ssym.stoken.length = 0;
1260 yylval.ssym.sym = sym;
1261 yylval.ssym.is_a_field_of_this = 0; /* FIXME, C++'ism */
1262 switch (SYMBOL_CLASS (sym))
1263 {
1264 case LOC_BLOCK:
1265 /* Found a procedure name. */
1266 return (GENERAL_PROCEDURE_NAME);
1267 case LOC_STATIC:
1268 /* Found a global or local static variable. */
1269 return (LOCATION_NAME);
1270 }
1271 }
1272 else if (!have_full_symbols () && !have_partial_symbols ())
1273 {
1274 error ("No symbol table is loaded. Use the \"file\" command.");
1275 }
1276 else
1277 {
1278 error ("No symbol \"%s\" in current context.", simplename);
1279 }
1280 }
1281
e58de8a2
FF
1282 return (ILLEGAL_TOKEN);
1283}
1284
1285static void
1286yyerror (msg)
1287 char *msg; /* unused */
1288{
1289 printf ("Parsing: %s\n", lexptr);
1290 if (yychar < 256)
1291 {
1292 error ("Invalid syntax in expression near character '%c'.", yychar);
1293 }
1294 else
1295 {
1296 error ("Invalid syntax in expression");
1297 }
1298}
1299
5d074aa9
FF
1300\f
1301static void
1302chill_printchar (c, stream)
1303 register int c;
1304 FILE *stream;
1305{
1306 c &= 0xFF; /* Avoid sign bit follies */
1307
5707ea9f 1308 if (PRINT_LITERAL_FORM (c))
5d074aa9 1309 {
5707ea9f 1310 fprintf_filtered (stream, "'%c'", c);
5d074aa9
FF
1311 }
1312 else
1313 {
5707ea9f 1314 fprintf_filtered (stream, "C'%.2x'", (unsigned int) c);
5d074aa9
FF
1315 }
1316}
1317
1318/* Print the character string STRING, printing at most LENGTH characters.
1319 Printing stops early if the number hits print_max; repeat counts
1320 are printed as appropriate. Print ellipses at the end if we
1321 had to stop before printing LENGTH characters, or if FORCE_ELLIPSES.
5707ea9f
FF
1322 Note that gdb maintains the length of strings without counting the
1323 terminating null byte, while chill strings are typically written with
1324 an explicit null byte. So we always assume an implied null byte
1325 until gdb is able to maintain non-null terminated strings as well
1326 as null terminated strings (FIXME).
5d074aa9
FF
1327 */
1328
1329static void
1330chill_printstr (stream, string, length, force_ellipses)
1331 FILE *stream;
1332 char *string;
1333 unsigned int length;
1334 int force_ellipses;
1335{
5707ea9f
FF
1336 register unsigned int i;
1337 unsigned int things_printed = 0;
1338 int in_literal_form = 0;
1339 int in_control_form = 0;
1340 int need_slashslash = 0;
1341 unsigned int c;
1342 extern int repeat_count_threshold;
1343 extern int print_max;
1344
1345 if (length == 0)
1346 {
1347 chill_printchar ('\0', stream);
1348 return;
1349 }
1350
1351 for (i = 0; i < length && things_printed < print_max; ++i)
1352 {
1353 /* Position of the character we are examining
1354 to see whether it is repeated. */
1355 unsigned int rep1;
1356 /* Number of repetitions we have detected so far. */
1357 unsigned int reps;
1358
1359 QUIT;
1360
1361 if (need_slashslash)
1362 {
1363 fputs_filtered ("//", stream);
1364 need_slashslash = 0;
1365 }
1366
1367 rep1 = i + 1;
1368 reps = 1;
1369 while (rep1 < length && string[rep1] == string[i])
1370 {
1371 ++rep1;
1372 ++reps;
1373 }
1374
1375 c = string[i];
1376 if (reps > repeat_count_threshold)
1377 {
1378 if (in_control_form || in_literal_form)
1379 {
1380 fputs_filtered ("'//", stream);
1381 in_control_form = in_literal_form = 0;
1382 }
1383 chill_printchar (c, stream);
1384 fprintf_filtered (stream, "<repeats %u times>", reps);
1385 i = rep1 - 1;
1386 things_printed += repeat_count_threshold;
1387 need_slashslash = 1;
1388 }
1389 else
1390 {
1391 if (PRINT_LITERAL_FORM (c))
1392 {
1393 if (!in_literal_form)
1394 {
1395 if (in_control_form)
1396 {
1397 fputs_filtered ("'//", stream);
1398 in_control_form = 0;
1399 }
1400 fputs_filtered ("'", stream);
1401 in_literal_form = 1;
1402 }
1403 fprintf_filtered (stream, "%c", c);
1404 }
1405 else
1406 {
1407 if (!in_control_form)
1408 {
1409 if (in_literal_form)
1410 {
1411 fputs_filtered ("'//", stream);
1412 in_literal_form = 0;
1413 }
1414 fputs_filtered ("c'", stream);
1415 in_control_form = 1;
1416 }
1417 fprintf_filtered (stream, "%.2x", c);
1418 }
1419 ++things_printed;
1420 }
1421 }
1422
1423 /* Terminate the quotes if necessary. */
1424 if (in_literal_form || in_control_form)
1425 {
1426 fputs_filtered ("'", stream);
1427 }
1428 if (force_ellipses || (i < length))
1429 {
1430 fputs_filtered ("...", stream);
1431 }
5d074aa9
FF
1432}
1433
bf229b4e
FF
1434static struct type *
1435chill_create_fundamental_type (objfile, typeid)
1436 struct objfile *objfile;
1437 int typeid;
1438{
1439 register struct type *type = NULL;
1440 register int nbytes;
1441
1442 switch (typeid)
1443 {
1444 default:
1445 /* FIXME: For now, if we are asked to produce a type not in this
1446 language, create the equivalent of a C integer type with the
1447 name "<?type?>". When all the dust settles from the type
1448 reconstruction work, this should probably become an error. */
1449 type = init_type (TYPE_CODE_INT,
1450 TARGET_INT_BIT / TARGET_CHAR_BIT,
1451 0, "<?type?>", objfile);
1452 warning ("internal error: no chill fundamental type %d", typeid);
1453 break;
1454 case FT_BOOLEAN:
1455 type = init_type (TYPE_CODE_BOOL, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
1456 TYPE_FLAG_UNSIGNED, "BOOL", objfile);
1457 break;
1458 case FT_CHAR:
1459 type = init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
1460 TYPE_FLAG_UNSIGNED, "CHAR", objfile);
1461 break;
1462 case FT_BYTE:
1463 type = init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
1464 TYPE_FLAG_SIGNED, "BYTE", objfile);
1465 break;
1466 case FT_UNSIGNED_BYTE:
1467 type = init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
1468 TYPE_FLAG_UNSIGNED, "UBYTE", objfile);
1469 break;
1470 case FT_INTEGER:
1471 type = init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
1472 TYPE_FLAG_SIGNED, "INT", objfile);
1473 break;
1474 case FT_UNSIGNED_INTEGER:
1475 type = init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
1476 TYPE_FLAG_UNSIGNED, "UINT", objfile);
1477 break;
1478 case FT_LONG:
1479 type = init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
1480 TYPE_FLAG_SIGNED, "LONG", objfile);
1481 break;
1482 case FT_UNSIGNED_LONG:
1483 type = init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
1484 TYPE_FLAG_UNSIGNED, "ULONG", objfile);
1485 break;
1486 case FT_FLOAT:
1487 type = init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
1488 0, "REAL", objfile);
1489 break;
1490 case FT_DBL_PREC_FLOAT:
1491 type = init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
1492 0, "LONG REAL", objfile);
1493 break;
1494 }
1495 return (type);
1496}
1497
e58de8a2
FF
1498\f
1499/* Table of operators and their precedences for printing expressions. */
1500
1501const static struct op_print chill_op_print_tab[] = {
1502 {"AND", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0},
1503 {"OR", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0},
1504 {"NOT", UNOP_LOGICAL_NOT, PREC_PREFIX, 0},
1505 {"MOD", BINOP_REM, PREC_MUL, 0},
1506 {":=", BINOP_ASSIGN, PREC_ASSIGN, 1},
1507 {"=", BINOP_EQUAL, PREC_EQUAL, 0},
1508 {"/=", BINOP_NOTEQUAL, PREC_EQUAL, 0},
1509 {"<=", BINOP_LEQ, PREC_ORDER, 0},
1510 {">=", BINOP_GEQ, PREC_ORDER, 0},
1511 {">", BINOP_GTR, PREC_ORDER, 0},
1512 {"<", BINOP_LESS, PREC_ORDER, 0},
1513 {"+", BINOP_ADD, PREC_ADD, 0},
1514 {"-", BINOP_SUB, PREC_ADD, 0},
1515 {"*", BINOP_MUL, PREC_MUL, 0},
1516 {"/", BINOP_DIV, PREC_MUL, 0},
1517 {"-", UNOP_NEG, PREC_PREFIX, 0},
1518 {NULL, 0, 0, 0}
1519};
1520
1521\f
1522/* The built-in types of Chill. */
1523
1524struct type *builtin_type_chill_bool;
2e66cf7d 1525struct type *builtin_type_chill_char;
e58de8a2
FF
1526struct type *builtin_type_chill_long;
1527struct type *builtin_type_chill_ulong;
1528struct type *builtin_type_chill_real;
1529
1530struct type ** const (chill_builtin_types[]) =
1531{
1532 &builtin_type_chill_bool,
2e66cf7d 1533 &builtin_type_chill_char,
e58de8a2
FF
1534 &builtin_type_chill_long,
1535 &builtin_type_chill_ulong,
1536 &builtin_type_chill_real,
1537 0
1538};
1539
1540const struct language_defn chill_language_defn = {
1541 "chill",
1542 language_chill,
1543 chill_builtin_types,
1544 range_check_on,
1545 type_check_on,
1546 chill_parse, /* parser */
1547 chill_error, /* parser error function */
5d074aa9
FF
1548 chill_printchar, /* print a character constant */
1549 chill_printstr, /* function to print a string constant */
bf229b4e 1550 chill_create_fundamental_type,/* Create fundamental type in this language */
e58de8a2
FF
1551 &BUILTIN_TYPE_LONGEST, /* longest signed integral type */
1552 &BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */
1553 &builtin_type_chill_real, /* longest floating point type */
2e66cf7d
FF
1554 {"", "B'", "", ""}, /* Binary format info */
1555 {"O'%o", "O'", "o", ""}, /* Octal format info */
1556 {"D'%d", "D'", "d", ""}, /* Decimal format info */
1557 {"H'%x", "H'", "x", ""}, /* Hex format info */
e58de8a2
FF
1558 chill_op_print_tab, /* expression operators for printing */
1559 LANG_MAGIC
1560};
1561
1562/* Initialization for Chill */
1563
1564void
1565_initialize_chill_exp ()
1566{
1567 builtin_type_chill_bool =
bf229b4e 1568 init_type (TYPE_CODE_BOOL, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
e58de8a2
FF
1569 TYPE_FLAG_UNSIGNED,
1570 "BOOL", (struct objfile *) NULL);
2e66cf7d
FF
1571 builtin_type_chill_char =
1572 init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
1573 TYPE_FLAG_UNSIGNED,
1574 "CHAR", (struct objfile *) NULL);
e58de8a2
FF
1575 builtin_type_chill_long =
1576 init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
1577 0,
1578 "LONG", (struct objfile *) NULL);
1579 builtin_type_chill_ulong =
1580 init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
1581 TYPE_FLAG_UNSIGNED,
1582 "ULONG", (struct objfile *) NULL);
1583 builtin_type_chill_real =
1584 init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
1585 0,
1586 "LONG_REAL", (struct objfile *) NULL);
1587
1588 add_language (&chill_language_defn);
1589}
This page took 0.118991 seconds and 4 git commands to generate.