1 /* YACC grammar for Chill expressions, for GDB.
2 Copyright (C) 1992 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20 /* Parse a Chill expression from text in a string,
21 and return the result as a struct expression pointer.
22 That structure contains arithmetic operations in reverse polish,
23 with constants represented by operations that are followed by special data.
24 See expression.h for the details of the format.
25 What is important here is that it can be built up sequentially
26 during the process of parsing; the lower levels of the tree always
27 come first in the result.
29 Note that malloc's and realloc's in this file are transformed to
30 xmalloc and xrealloc respectively by the same sed command in the
31 makefile that remaps any other malloc/realloc inserted by the parser
32 generator. Doing this with #defines and trying to control the interaction
33 with include files (<malloc.h> and <stdlib.h> for example) just became
34 too messy, particularly when such includes can be inserted at random
35 times by the parser generator.
37 Also note that the language accepted by this parser is more liberal
38 than the one accepted by an actual Chill compiler. For example, the
39 language rule that a simple name string can not be one of the reserved
40 simple name strings is not enforced (e.g "case" is not treated as a
41 reserved name). Another example is that Chill is a strongly typed
42 language, and certain expressions that violate the type constraints
43 may still be evaluated if gdb can do so in a meaningful manner, while
44 such expressions would be rejected by the compiler. The reason for
45 this more liberal behavior is the philosophy that the debugger
46 is intended to be a tool that is used by the programmer when things
47 go wrong, and as such, it should provide as few artificial barriers
48 to it's use as possible. If it can do something meaningful, even
49 something that violates language contraints that are enforced by the
50 compiler, it should do so without complaint.
62 #include "expression.h"
65 #include "parser-defs.h"
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
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
93 #define yy_yys chill_yys
94 #define yystate chill_state
95 #define yytmp chill_tmp
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 */
106 yylex PARAMS ((void));
109 yyerror PARAMS ((char *));
112 yyparse PARAMS ((void));
114 /* #define YYDEBUG 1 */
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. */
125 unsigned LONGEST ulval;
135 struct symtoken ssym;
138 enum exp_opcode opcode;
139 struct internalvar *ivar;
146 static int parse_number PARAMS ((void));
149 %token <voidval> FIXME
151 %token <typed_val> INTEGER_LITERAL
152 %token <ulval> BOOLEAN_LITERAL
153 %token <typed_val> CHARACTER_LITERAL
154 %token <ssym> GENERAL_PROCEDURE_NAME
155 %token <ssym> LOCATION_NAME
156 %token <voidval> SET_LITERAL
157 %token <voidval> EMPTINESS_LITERAL
158 %token <voidval> CHARACTER_STRING_LITERAL
159 %token <voidval> BIT_STRING_LITERAL
161 %token <voidval> STRING
162 %token <voidval> CONSTANT
166 %token <voidval> CASE
168 %token <voidval> ESAC
169 %token <voidval> LOGIOR
170 %token <voidval> ORIF
171 %token <voidval> LOGXOR
172 %token <voidval> LOGAND
173 %token <voidval> ANDIF
175 %token <voidval> NOTEQUAL
185 %token <voidval> SLASH_SLASH
189 %token <voidval> POINTER
190 %token <voidval> RECEIVE
198 %token <voidval> THEN
199 %token <voidval> ELSE
201 %token <voidval> ELSIF
202 %token <voidval> ILLEGAL_TOKEN
204 %type <voidval> location
205 %type <voidval> access_name
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
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
275 undefined_value : FIXME
283 location : access_name
295 access_name : LOCATION_NAME
297 write_exp_elt_opcode (OP_VAR_VALUE);
298 write_exp_elt_sym ($1.sym);
299 write_exp_elt_opcode (OP_VAR_VALUE);
309 primitive_value : location_contents
325 | value_string_element
333 | value_array_element
341 | value_structure_field
345 | expression_conversion
349 | value_procedure_call
353 | value_built_in_routine_call
365 | parenthesised_expression
373 location_contents: location
381 value_name : synonym_name
385 | value_enumeration_name
397 | GENERAL_PROCEDURE_NAME
399 write_exp_elt_opcode (OP_VAR_VALUE);
400 write_exp_elt_sym ($1.sym);
401 write_exp_elt_opcode (OP_VAR_VALUE);
407 literal : INTEGER_LITERAL
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);
416 write_exp_elt_opcode (OP_BOOL);
417 write_exp_elt_longcst ((LONGEST) $1);
418 write_exp_elt_opcode (OP_BOOL);
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);
435 | CHARACTER_STRING_LITERAL
456 value_string_element: string_primitive_value '(' start_element ')'
464 value_string_slice: string_primitive_value '(' left_element ':' right_element ')'
468 | string_primitive_value '(' start_element UP slice_size ')'
476 value_array_element: array_primitive_value '(' expression_list ')'
484 value_array_slice: array_primitive_value '(' lower_element ':' upper_element ')'
488 | array_primitive_value '(' first_element UP slice_size '('
496 value_structure_field: structure_primitive_value '.' field_name
504 expression_conversion: mode_name '(' expression ')'
512 value_procedure_call: FIXME
520 value_built_in_routine_call: FIXME
528 start_expression: FIXME
531 } /* Not in GNU-Chill */
536 zero_adic_operator: FIXME
544 parenthesised_expression: '(' expression ')'
552 expression : operand_0
556 | conditional_expression
562 conditional_expression : IF boolean_expression then_alternative else_alternative FI
566 | CASE case_selector_list OF value_case_alternative '[' ELSE sub_expression ']' ESAC
572 then_alternative: THEN subexpression
578 else_alternative: ELSE subexpression
582 | ELSIF boolean_expression then_alternative else_alternative
588 sub_expression : expression
594 value_case_alternative: case_label_specification ':' sub_expression ';'
602 operand_0 : operand_1
606 | operand_0 LOGIOR operand_1
608 write_exp_elt_opcode (BINOP_BITWISE_IOR);
610 | operand_0 ORIF operand_1
614 | operand_0 LOGXOR operand_1
616 write_exp_elt_opcode (BINOP_BITWISE_XOR);
622 operand_1 : operand_2
626 | operand_1 LOGAND operand_2
628 write_exp_elt_opcode (BINOP_BITWISE_AND);
630 | operand_1 ANDIF operand_2
638 operand_2 : operand_3
642 | operand_2 '=' operand_3
644 write_exp_elt_opcode (BINOP_EQUAL);
646 | operand_2 NOTEQUAL operand_3
648 write_exp_elt_opcode (BINOP_NOTEQUAL);
650 | operand_2 '>' operand_3
652 write_exp_elt_opcode (BINOP_GTR);
654 | operand_2 GTR operand_3
656 write_exp_elt_opcode (BINOP_GEQ);
658 | operand_2 '<' operand_3
660 write_exp_elt_opcode (BINOP_LESS);
662 | operand_2 LEQ operand_3
664 write_exp_elt_opcode (BINOP_LEQ);
666 | operand_2 IN operand_3
675 operand_3 : operand_4
679 | operand_3 '+' operand_4
681 write_exp_elt_opcode (BINOP_ADD);
683 | operand_3 '-' operand_4
685 write_exp_elt_opcode (BINOP_SUB);
687 | operand_3 SLASH_SLASH operand_4
695 operand_4 : operand_5
699 | operand_4 '*' operand_5
701 write_exp_elt_opcode (BINOP_MUL);
703 | operand_4 '/' operand_5
705 write_exp_elt_opcode (BINOP_DIV);
707 | operand_4 MOD operand_5
711 | operand_4 REM operand_5
719 operand_5 : operand_6
725 write_exp_elt_opcode (UNOP_NEG);
729 write_exp_elt_opcode (UNOP_LOGICAL_NOT);
731 | '(' integer_literal_expression ')' operand_6
739 operand_6 : POINTER location
743 | RECEIVE buffer_location
755 /* FIXME: For now we just accept only a single integer literal. */
757 integer_literal_expression:
763 /* Things which still need productions... */
764 synonym_name : FIXME { $$ = 0; }
765 value_enumeration_name : FIXME { $$ = 0; }
766 value_do_with_name : FIXME { $$ = 0; }
767 value_receive_name : FIXME { $$ = 0; }
768 string_primitive_value : FIXME { $$ = 0; }
769 start_element : FIXME { $$ = 0; }
770 left_element : FIXME { $$ = 0; }
771 right_element : FIXME { $$ = 0; }
772 slice_size : FIXME { $$ = 0; }
773 array_primitive_value : FIXME { $$ = 0; }
774 expression_list : FIXME { $$ = 0; }
775 lower_element : FIXME { $$ = 0; }
776 upper_element : FIXME { $$ = 0; }
777 first_element : FIXME { $$ = 0; }
778 structure_primitive_value: FIXME { $$ = 0; }
779 field_name : FIXME { $$ = 0; }
780 mode_name : FIXME { $$ = 0; }
781 boolean_expression : FIXME { $$ = 0; }
782 case_selector_list : FIXME { $$ = 0; }
783 subexpression : FIXME { $$ = 0; }
784 case_label_specification: FIXME { $$ = 0; }
785 buffer_location : FIXME { $$ = 0; }
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. */
794 match_simple_name_string ()
796 char *tokptr = lexptr;
798 if (isalpha (*tokptr))
802 } while (isalpha (*tokptr) || isdigit (*tokptr) || (*tokptr == '_'));
803 yylval.sval.ptr = lexptr;
804 yylval.sval.length = tokptr - lexptr;
806 return (copy_name (yylval.sval));
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. */
818 decode_integer_value (base, tokptrptr, ivalptr)
823 char *tokptr = *tokptrptr;
827 while (*tokptr != '\0')
829 temp = tolower (*tokptr);
835 case '0': case '1': case '2': case '3': case '4':
836 case '5': case '6': case '7': case '8': case '9':
839 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
855 /* Found something not in domain for current base. */
856 tokptr--; /* Unconsume what gave us indigestion. */
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. */
877 decode_integer_literal (valptr, tokptrptr)
881 char *tokptr = *tokptrptr;
886 int explicit_base = 0;
888 /* Look for an explicit base specifier, which is optional. */
921 /* If we found an explicit base ensure that the character after the
922 explicit base is a single quote. */
924 if (explicit_base && (*tokptr++ != '\''))
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
932 base, then the next character must not be a single quote, or we
933 have a bitstring literal, so reject the entire token in this case.
934 Otherwise, update the lexical scan pointer, and return non-zero
937 if (!decode_integer_value (base, &tokptr, &ival))
941 else if (explicit_base && (*tokptr == '\''))
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.
958 EX: 'a' '^(7)' '^(7,8)'
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.
963 Returns CHARACTER_LITERAL if a match is found.
967 match_character_literal ()
969 char *tokptr = lexptr;
972 if ((tolower (*tokptr) == 'c') && (*(tokptr + 1) == '\''))
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. */
978 if (!decode_integer_value (16, &tokptr, &ival) || (*tokptr != '\''))
984 else if (*tokptr == '\'')
988 /* Determine which form we have, either a control sequence or the
989 single character form. */
991 if ((*tokptr == '^') && (*(tokptr + 1) == '('))
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
999 if (!decode_integer_literal (&ival, &tokptr) || (*tokptr++ != ')'))
1009 /* The trailing quote has not yet been consumed. If we don't find
1010 it, then we have no match. */
1012 if (*tokptr++ != '\'')
1019 /* Not a character literal. */
1022 yylval.typed_val.val = ival;
1023 yylval.typed_val.type = builtin_type_chill_char;
1025 return (CHARACTER_LITERAL);
1028 /* Recognize an integer literal, as specified in Z.200 sec 5.2.4.2.
1029 Note that according to 5.2.4.2, a single "_" is also a valid integer
1030 literal, however GNU-chill requires there to be at least one "digit"
1031 in any integer literal. */
1034 match_integer_literal ()
1036 char *tokptr = lexptr;
1039 if (!decode_integer_literal (&ival, &tokptr))
1045 yylval.typed_val.val = ival;
1046 yylval.typed_val.type = builtin_type_int;
1048 return (INTEGER_LITERAL);
1052 static void convert_float ()
1055 extern double strtod ();
1058 char *p = yytext, *p1 = tmp;
1078 d = strtod (tmp, &p1);
1081 /* add error handling here */
1088 /* Take care of parsing a number (anything that starts with a digit).
1089 Set yylval and return the token type; update lexptr.
1090 LEN is the number of characters in it. */
1092 /*** Needs some error checking for the float case ***/
1105 const static struct token tokentab5[] =
1110 const static struct token tokentab4[] =
1115 const static struct token tokentab3[] =
1122 const static struct token tokentab2[] =
1124 { "//", SLASH_SLASH },
1132 /* Read one token, getting characters through lexptr. */
1133 /* This is where we will check to make sure that the language and the
1134 operators used are compatible. */
1144 /* Skip over any leading whitespace. */
1145 while (isspace (*lexptr))
1149 /* Look for special single character cases which can't be the first
1150 character of some other multicharacter token. */
1170 /* Look for characters which start a particular kind of multicharacter
1171 token, such as a character literal. */
1177 token = match_character_literal ();
1184 /* See if it is a special token of length 5. */
1185 for (i = 0; i < sizeof (tokentab5) / sizeof (tokentab5[0]); i++)
1187 if (strncmp (lexptr, tokentab5[i].operator, 5) == 0)
1190 return (tokentab5[i].token);
1193 /* See if it is a special token of length 4. */
1194 for (i = 0; i < sizeof (tokentab4) / sizeof (tokentab4[0]); i++)
1196 if (strncmp (lexptr, tokentab4[i].operator, 4) == 0)
1199 return (tokentab4[i].token);
1202 /* See if it is a special token of length 3. */
1203 for (i = 0; i < sizeof (tokentab3) / sizeof (tokentab3[0]); i++)
1205 if (strncmp (lexptr, tokentab3[i].operator, 3) == 0)
1208 return (tokentab3[i].token);
1211 /* See if it is a special token of length 2. */
1212 for (i = 0; i < sizeof (tokentab2) / sizeof (tokentab2[0]); i++)
1214 if (strncmp (lexptr, tokentab2[i].operator, 2) == 0)
1217 return (tokentab2[i].token);
1220 /* Look for single character cases which which could be the first
1221 character of some other multicharacter token, but aren't, or we
1222 would already have found it. */
1230 /* Look for other special tokens. */
1231 if (strncmp (lexptr, "TRUE", 4) == 0) /* FIXME: What about lowercase? */
1235 return (BOOLEAN_LITERAL);
1237 if (strncmp (lexptr, "FALSE", 5) == 0) /* FIXME: What about lowercase? */
1241 return (BOOLEAN_LITERAL);
1243 token = match_integer_literal ();
1249 /* Try to match a simple name string, and if a match is found, then
1250 further classify what sort of name it is and return an appropriate
1251 token. Note that attempting to match a simple name string consumes
1252 the token from lexptr, so we can't back out if we later find that
1253 we can't classify what sort of name it is. */
1255 simplename = match_simple_name_string ();
1256 if (simplename != NULL)
1258 sym = lookup_symbol (simplename, expression_context_block,
1259 VAR_NAMESPACE, (int *) NULL,
1260 (struct symtab **) NULL);
1263 yylval.ssym.stoken.ptr = NULL;
1264 yylval.ssym.stoken.length = 0;
1265 yylval.ssym.sym = sym;
1266 yylval.ssym.is_a_field_of_this = 0; /* FIXME, C++'ism */
1267 switch (SYMBOL_CLASS (sym))
1270 /* Found a procedure name. */
1271 return (GENERAL_PROCEDURE_NAME);
1273 /* Found a global or local static variable. */
1274 return (LOCATION_NAME);
1277 else if (!have_full_symbols () && !have_partial_symbols ())
1279 error ("No symbol table is loaded. Use the \"file\" command.");
1283 error ("No symbol \"%s\" in current context.", simplename);
1287 return (ILLEGAL_TOKEN);
1292 char *msg; /* unused */
1294 printf ("Parsing: %s\n", lexptr);
1297 error ("Invalid syntax in expression near character '%c'.", yychar);
1301 error ("Invalid syntax in expression");
1307 chill_printchar (c, stream)
1311 c &= 0xFF; /* Avoid sign bit follies */
1313 if (PRINT_LITERAL_FORM (c))
1315 fprintf_filtered (stream, "'%c'", c);
1319 fprintf_filtered (stream, "C'%.2x'", (unsigned int) c);
1323 /* Print the character string STRING, printing at most LENGTH characters.
1324 Printing stops early if the number hits print_max; repeat counts
1325 are printed as appropriate. Print ellipses at the end if we
1326 had to stop before printing LENGTH characters, or if FORCE_ELLIPSES.
1327 Note that gdb maintains the length of strings without counting the
1328 terminating null byte, while chill strings are typically written with
1329 an explicit null byte. So we always assume an implied null byte
1330 until gdb is able to maintain non-null terminated strings as well
1331 as null terminated strings (FIXME).
1335 chill_printstr (stream, string, length, force_ellipses)
1338 unsigned int length;
1341 register unsigned int i;
1342 unsigned int things_printed = 0;
1343 int in_literal_form = 0;
1344 int in_control_form = 0;
1345 int need_slashslash = 0;
1347 extern int repeat_count_threshold;
1348 extern int print_max;
1352 chill_printchar ('\0', stream);
1356 for (i = 0; i < length && things_printed < print_max; ++i)
1358 /* Position of the character we are examining
1359 to see whether it is repeated. */
1361 /* Number of repetitions we have detected so far. */
1366 if (need_slashslash)
1368 fputs_filtered ("//", stream);
1369 need_slashslash = 0;
1374 while (rep1 < length && string[rep1] == string[i])
1381 if (reps > repeat_count_threshold)
1383 if (in_control_form || in_literal_form)
1385 fputs_filtered ("'//", stream);
1386 in_control_form = in_literal_form = 0;
1388 chill_printchar (c, stream);
1389 fprintf_filtered (stream, "<repeats %u times>", reps);
1391 things_printed += repeat_count_threshold;
1392 need_slashslash = 1;
1396 if (PRINT_LITERAL_FORM (c))
1398 if (!in_literal_form)
1400 if (in_control_form)
1402 fputs_filtered ("'//", stream);
1403 in_control_form = 0;
1405 fputs_filtered ("'", stream);
1406 in_literal_form = 1;
1408 fprintf_filtered (stream, "%c", c);
1412 if (!in_control_form)
1414 if (in_literal_form)
1416 fputs_filtered ("'//", stream);
1417 in_literal_form = 0;
1419 fputs_filtered ("c'", stream);
1420 in_control_form = 1;
1422 fprintf_filtered (stream, "%.2x", c);
1428 /* Terminate the quotes if necessary. */
1429 if (in_literal_form || in_control_form)
1431 fputs_filtered ("'", stream);
1433 if (force_ellipses || (i < length))
1435 fputs_filtered ("...", stream);
1439 static struct type *
1440 chill_create_fundamental_type (objfile, typeid)
1441 struct objfile *objfile;
1444 register struct type *type = NULL;
1445 register int nbytes;
1450 /* FIXME: For now, if we are asked to produce a type not in this
1451 language, create the equivalent of a C integer type with the
1452 name "<?type?>". When all the dust settles from the type
1453 reconstruction work, this should probably become an error. */
1454 type = init_type (TYPE_CODE_INT,
1455 TARGET_INT_BIT / TARGET_CHAR_BIT,
1456 0, "<?type?>", objfile);
1457 warning ("internal error: no chill fundamental type %d", typeid);
1460 type = init_type (TYPE_CODE_BOOL, 1, TYPE_FLAG_UNSIGNED, "BOOL", objfile);
1463 type = init_type (TYPE_CODE_INT, 1, TYPE_FLAG_UNSIGNED, "CHAR", objfile);
1465 case FT_SIGNED_CHAR:
1466 type = init_type (TYPE_CODE_INT, 1, TYPE_FLAG_SIGNED, "BYTE", objfile);
1468 case FT_UNSIGNED_CHAR:
1469 type = init_type (TYPE_CODE_INT, 1, TYPE_FLAG_UNSIGNED, "UBYTE", objfile);
1471 case FT_SHORT: /* Chill ints are 2 bytes */
1472 type = init_type (TYPE_CODE_INT, 2, TYPE_FLAG_SIGNED, "INT", objfile);
1474 case FT_UNSIGNED_SHORT: /* Chill ints are 2 bytes */
1475 type = init_type (TYPE_CODE_INT, 2, TYPE_FLAG_UNSIGNED, "UINT", objfile);
1477 case FT_INTEGER: /* Chill longs are 4 bytes */
1478 type = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_SIGNED, "LONG", objfile);
1480 case FT_UNSIGNED_INTEGER: /* Chill longs are 4 bytes */
1481 type = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED, "ULONG", objfile);
1484 type = init_type (TYPE_CODE_FLT, 4, 0, "REAL", objfile);
1486 case FT_DBL_PREC_FLOAT:
1487 type = init_type (TYPE_CODE_FLT, 8, 0, "LONG_REAL", objfile);
1494 /* Table of operators and their precedences for printing expressions. */
1496 const static struct op_print chill_op_print_tab[] = {
1497 {"AND", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0},
1498 {"OR", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0},
1499 {"NOT", UNOP_LOGICAL_NOT, PREC_PREFIX, 0},
1500 {"MOD", BINOP_REM, PREC_MUL, 0},
1501 {":=", BINOP_ASSIGN, PREC_ASSIGN, 1},
1502 {"=", BINOP_EQUAL, PREC_EQUAL, 0},
1503 {"/=", BINOP_NOTEQUAL, PREC_EQUAL, 0},
1504 {"<=", BINOP_LEQ, PREC_ORDER, 0},
1505 {">=", BINOP_GEQ, PREC_ORDER, 0},
1506 {">", BINOP_GTR, PREC_ORDER, 0},
1507 {"<", BINOP_LESS, PREC_ORDER, 0},
1508 {"+", BINOP_ADD, PREC_ADD, 0},
1509 {"-", BINOP_SUB, PREC_ADD, 0},
1510 {"*", BINOP_MUL, PREC_MUL, 0},
1511 {"/", BINOP_DIV, PREC_MUL, 0},
1512 {"-", UNOP_NEG, PREC_PREFIX, 0},
1517 /* The built-in types of Chill. */
1519 struct type *builtin_type_chill_bool;
1520 struct type *builtin_type_chill_char;
1521 struct type *builtin_type_chill_long;
1522 struct type *builtin_type_chill_ulong;
1523 struct type *builtin_type_chill_real;
1525 struct type ** const (chill_builtin_types[]) =
1527 &builtin_type_chill_bool,
1528 &builtin_type_chill_char,
1529 &builtin_type_chill_long,
1530 &builtin_type_chill_ulong,
1531 &builtin_type_chill_real,
1535 const struct language_defn chill_language_defn = {
1538 chill_builtin_types,
1541 chill_parse, /* parser */
1542 chill_error, /* parser error function */
1543 chill_printchar, /* print a character constant */
1544 chill_printstr, /* function to print a string constant */
1545 chill_create_fundamental_type,/* Create fundamental type in this language */
1546 &BUILTIN_TYPE_LONGEST, /* longest signed integral type */
1547 &BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */
1548 &builtin_type_chill_real, /* longest floating point type */
1549 {"", "B'", "", ""}, /* Binary format info */
1550 {"O'%o", "O'", "o", ""}, /* Octal format info */
1551 {"D'%d", "D'", "d", ""}, /* Decimal format info */
1552 {"H'%x", "H'", "x", ""}, /* Hex format info */
1553 chill_op_print_tab, /* expression operators for printing */
1557 /* Initialization for Chill */
1560 _initialize_chill_exp ()
1562 builtin_type_chill_bool =
1563 init_type (TYPE_CODE_BOOL, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
1565 "BOOL", (struct objfile *) NULL);
1566 builtin_type_chill_char =
1567 init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
1569 "CHAR", (struct objfile *) NULL);
1570 builtin_type_chill_long =
1571 init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
1573 "LONG", (struct objfile *) NULL);
1574 builtin_type_chill_ulong =
1575 init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
1577 "ULONG", (struct objfile *) NULL);
1578 builtin_type_chill_real =
1579 init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
1581 "LONG_REAL", (struct objfile *) NULL);
1583 add_language (&chill_language_defn);