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++ != '\'')
1017 yylval.typed_val.val = ival;
1018 yylval.typed_val.type = builtin_type_chill_char;
1020 return (CHARACTER_LITERAL);
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. */
1029 match_integer_literal ()
1031 char *tokptr = lexptr;
1034 if (!decode_integer_literal (&ival, &tokptr))
1040 yylval.typed_val.val = ival;
1041 yylval.typed_val.type = builtin_type_int;
1043 return (INTEGER_LITERAL);
1047 static void convert_float ()
1050 extern double strtod ();
1053 char *p = yytext, *p1 = tmp;
1073 d = strtod (tmp, &p1);
1076 /* add error handling here */
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. */
1087 /*** Needs some error checking for the float case ***/
1100 const static struct token tokentab5[] =
1105 const static struct token tokentab4[] =
1110 const static struct token tokentab3[] =
1117 const static struct token tokentab2[] =
1119 { "//", SLASH_SLASH },
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. */
1139 /* Skip over any leading whitespace. */
1140 while (isspace (*lexptr))
1144 /* Look for special single character cases which can't be the first
1145 character of some other multicharacter token. */
1165 /* Look for characters which start a particular kind of multicharacter
1166 token, such as a character literal. */
1172 token = match_character_literal ();
1179 /* See if it is a special token of length 5. */
1180 for (i = 0; i < sizeof (tokentab5) / sizeof (tokentab5[0]); i++)
1182 if (strncmp (lexptr, tokentab5[i].operator, 5) == 0)
1185 return (tokentab5[i].token);
1188 /* See if it is a special token of length 4. */
1189 for (i = 0; i < sizeof (tokentab4) / sizeof (tokentab4[0]); i++)
1191 if (strncmp (lexptr, tokentab4[i].operator, 4) == 0)
1194 return (tokentab4[i].token);
1197 /* See if it is a special token of length 3. */
1198 for (i = 0; i < sizeof (tokentab3) / sizeof (tokentab3[0]); i++)
1200 if (strncmp (lexptr, tokentab3[i].operator, 3) == 0)
1203 return (tokentab3[i].token);
1206 /* See if it is a special token of length 2. */
1207 for (i = 0; i < sizeof (tokentab2) / sizeof (tokentab2[0]); i++)
1209 if (strncmp (lexptr, tokentab2[i].operator, 2) == 0)
1212 return (tokentab2[i].token);
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. */
1225 /* Look for other special tokens. */
1226 if (strncmp (lexptr, "TRUE", 4) == 0) /* FIXME: What about lowercase? */
1230 return (BOOLEAN_LITERAL);
1232 if (strncmp (lexptr, "FALSE", 5) == 0) /* FIXME: What about lowercase? */
1236 return (BOOLEAN_LITERAL);
1238 token = match_integer_literal ();
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. */
1250 simplename = match_simple_name_string ();
1251 if (simplename != NULL)
1253 sym = lookup_symbol (simplename, expression_context_block,
1254 VAR_NAMESPACE, (int *) NULL,
1255 (struct symtab **) NULL);
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))
1265 /* Found a procedure name. */
1266 return (GENERAL_PROCEDURE_NAME);
1268 /* Found a global or local static variable. */
1269 return (LOCATION_NAME);
1272 else if (!have_full_symbols () && !have_partial_symbols ())
1274 error ("No symbol table is loaded. Use the \"file\" command.");
1278 error ("No symbol \"%s\" in current context.", simplename);
1282 return (ILLEGAL_TOKEN);
1287 char *msg; /* unused */
1289 printf ("Parsing: %s\n", lexptr);
1292 error ("Invalid syntax in expression near character '%c'.", yychar);
1296 error ("Invalid syntax in expression");
1302 chill_printchar (c, stream)
1306 c &= 0xFF; /* Avoid sign bit follies */
1308 if (PRINT_LITERAL_FORM (c))
1310 fprintf_filtered (stream, "'%c'", c);
1314 fprintf_filtered (stream, "C'%.2x'", (unsigned int) c);
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.
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).
1330 chill_printstr (stream, string, length, force_ellipses)
1333 unsigned int length;
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;
1342 extern int repeat_count_threshold;
1343 extern int print_max;
1347 chill_printchar ('\0', stream);
1351 for (i = 0; i < length && things_printed < print_max; ++i)
1353 /* Position of the character we are examining
1354 to see whether it is repeated. */
1356 /* Number of repetitions we have detected so far. */
1361 if (need_slashslash)
1363 fputs_filtered ("//", stream);
1364 need_slashslash = 0;
1369 while (rep1 < length && string[rep1] == string[i])
1376 if (reps > repeat_count_threshold)
1378 if (in_control_form || in_literal_form)
1380 fputs_filtered ("'//", stream);
1381 in_control_form = in_literal_form = 0;
1383 chill_printchar (c, stream);
1384 fprintf_filtered (stream, "<repeats %u times>", reps);
1386 things_printed += repeat_count_threshold;
1387 need_slashslash = 1;
1391 if (PRINT_LITERAL_FORM (c))
1393 if (!in_literal_form)
1395 if (in_control_form)
1397 fputs_filtered ("'//", stream);
1398 in_control_form = 0;
1400 fputs_filtered ("'", stream);
1401 in_literal_form = 1;
1403 fprintf_filtered (stream, "%c", c);
1407 if (!in_control_form)
1409 if (in_literal_form)
1411 fputs_filtered ("'//", stream);
1412 in_literal_form = 0;
1414 fputs_filtered ("c'", stream);
1415 in_control_form = 1;
1417 fprintf_filtered (stream, "%.2x", c);
1423 /* Terminate the quotes if necessary. */
1424 if (in_literal_form || in_control_form)
1426 fputs_filtered ("'", stream);
1428 if (force_ellipses || (i < length))
1430 fputs_filtered ("...", stream);
1435 /* Table of operators and their precedences for printing expressions. */
1437 const static struct op_print chill_op_print_tab[] = {
1438 {"AND", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0},
1439 {"OR", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0},
1440 {"NOT", UNOP_LOGICAL_NOT, PREC_PREFIX, 0},
1441 {"MOD", BINOP_REM, PREC_MUL, 0},
1442 {":=", BINOP_ASSIGN, PREC_ASSIGN, 1},
1443 {"=", BINOP_EQUAL, PREC_EQUAL, 0},
1444 {"/=", BINOP_NOTEQUAL, PREC_EQUAL, 0},
1445 {"<=", BINOP_LEQ, PREC_ORDER, 0},
1446 {">=", BINOP_GEQ, PREC_ORDER, 0},
1447 {">", BINOP_GTR, PREC_ORDER, 0},
1448 {"<", BINOP_LESS, PREC_ORDER, 0},
1449 {"+", BINOP_ADD, PREC_ADD, 0},
1450 {"-", BINOP_SUB, PREC_ADD, 0},
1451 {"*", BINOP_MUL, PREC_MUL, 0},
1452 {"/", BINOP_DIV, PREC_MUL, 0},
1453 {"-", UNOP_NEG, PREC_PREFIX, 0},
1458 /* The built-in types of Chill. */
1460 struct type *builtin_type_chill_bool;
1461 struct type *builtin_type_chill_char;
1462 struct type *builtin_type_chill_long;
1463 struct type *builtin_type_chill_ulong;
1464 struct type *builtin_type_chill_real;
1466 struct type ** const (chill_builtin_types[]) =
1468 &builtin_type_chill_bool,
1469 &builtin_type_chill_char,
1470 &builtin_type_chill_long,
1471 &builtin_type_chill_ulong,
1472 &builtin_type_chill_real,
1476 const struct language_defn chill_language_defn = {
1479 chill_builtin_types,
1482 chill_parse, /* parser */
1483 chill_error, /* parser error function */
1484 chill_printchar, /* print a character constant */
1485 chill_printstr, /* function to print a string constant */
1486 &BUILTIN_TYPE_LONGEST, /* longest signed integral type */
1487 &BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */
1488 &builtin_type_chill_real, /* longest floating point type */
1489 {"", "B'", "", ""}, /* Binary format info */
1490 {"O'%o", "O'", "o", ""}, /* Octal format info */
1491 {"D'%d", "D'", "d", ""}, /* Decimal format info */
1492 {"H'%x", "H'", "x", ""}, /* Hex format info */
1493 chill_op_print_tab, /* expression operators for printing */
1497 /* Initialization for Chill */
1500 _initialize_chill_exp ()
1502 builtin_type_chill_bool =
1503 init_type (TYPE_CODE_BOOL, TARGET_INT_BIT / TARGET_CHAR_BIT,
1505 "BOOL", (struct objfile *) NULL);
1506 builtin_type_chill_char =
1507 init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
1509 "CHAR", (struct objfile *) NULL);
1510 builtin_type_chill_long =
1511 init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
1513 "LONG", (struct objfile *) NULL);
1514 builtin_type_chill_ulong =
1515 init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
1517 "ULONG", (struct objfile *) NULL);
1518 builtin_type_chill_real =
1519 init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
1521 "LONG_REAL", (struct objfile *) NULL);
1523 add_language (&chill_language_defn);