diff options
-rw-r--r-- | gdb/ChangeLog | 29 | ||||
-rw-r--r-- | gdb/c-exp.y | 12 | ||||
-rw-r--r-- | gdb/ch-exp.y | 598 | ||||
-rw-r--r-- | gdb/gdbtypes.h | 1 | ||||
-rw-r--r-- | gdb/language.c | 44 | ||||
-rw-r--r-- | gdb/language.h | 118 | ||||
-rw-r--r-- | gdb/m2-exp.y | 10 |
7 files changed, 552 insertions, 260 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a999142..7835012 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,32 @@ +Wed Nov 18 14:27:47 1992 Fred Fish (fnf@cygnus.com) + + * language.h (language_format_info): New structure to bundle + local formatting information. + * language.h (language_defn): Replace individual format info + with language_format_info structs. + * language.h (local_*_format, local_*_format_prefix, + local_*_format_specifier, local_*_format_suffix): New macros + for binary/octal/decimal/hex formats to access info elements. + * c-exp.y (c_language_defn): Update for new format handling. + * m2-exp.y (m2_language_defn): Update for new format handling. + * dbxread.c (language.h): Include for partial-stab.h use. + * defs.h (local_hex_format, local_hex_format_custom, + local_hex_string, local_hex_string_custom): Move to language.h. + * language.c (local_hex_format_custom, local_hex_string, + local_hex_string_custom, local_octal_format_custom): Use new + format handling. + * language.c (unknown_language_defn, auto_language_defn, + local_language_defn): Update for new format handling. + * printcmd.c (print_scalar_formatted): Use new macros + to access decimal and binary format info for printing. + **** start-sanitize-chill **** + * c-exp.y (chill_language_defn): Update for new format handling. + * ch-exp.y (CHARACTER_LITERAL): Add support to yylex. + * ch-exp.y (match_integer_literal): Add function. + * ch-exp.y (builtin_type_chill_char): Add definition. + * gdbtypes.h (builtin_type_chill_char): Add declaration. + **** end-sanitize-chill **** + Tue Nov 17 11:17:06 1992 Ian Lance Taylor (ian@cygnus.com) * tm-rs6000.h (BELIEVE_PCC_PROMOTION): Define, since AIX cc gets diff --git a/gdb/c-exp.y b/gdb/c-exp.y index c9258a0..e806629 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -1564,8 +1564,10 @@ const struct language_defn c_language_defn = { &BUILTIN_TYPE_LONGEST, /* longest signed integral type */ &BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */ &builtin_type_double, /* longest floating point type */ /*FIXME*/ - "0x%x", "0x%", "x", /* Hex format, prefix, suffix */ - "0%o", "0%", "o", /* Octal format, prefix, suffix */ + {"", "", "", ""}, /* Binary format info */ + {"0%o", "0", "o", ""}, /* Octal format info */ + {"%d", "", "d", ""}, /* Decimal format info */ + {"0x%x", "0x", "x", ""}, /* Hex format info */ c_op_print_tab, /* expression operators for printing */ LANG_MAGIC }; @@ -1581,8 +1583,10 @@ const struct language_defn cplus_language_defn = { &BUILTIN_TYPE_LONGEST, /* longest signed integral type */ &BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */ &builtin_type_double, /* longest floating point type */ /*FIXME*/ - "0x%x", "0x%", "x", /* Hex format, prefix, suffix */ - "0%o", "0%", "o", /* Octal format, prefix, suffix */ + {"", "", "", ""}, /* Binary format info */ + {"0%o", "0", "o", ""}, /* Octal format info */ + {"%d", "", "d", ""}, /* Decimal format info */ + {"0x%x", "0x", "x", ""}, /* Hex format info */ c_op_print_tab, /* expression operators for printing */ LANG_MAGIC }; diff --git a/gdb/ch-exp.y b/gdb/ch-exp.y index 9812fc7..3e2e9d5 100644 --- a/gdb/ch-exp.y +++ b/gdb/ch-exp.y @@ -150,7 +150,7 @@ static int parse_number PARAMS ((void)); %token <typed_val> INTEGER_LITERAL %token <ulval> BOOLEAN_LITERAL -%token <voidval> CHARACTER_LITERAL +%token <typed_val> CHARACTER_LITERAL %token <voidval> SET_LITERAL %token <voidval> EMPTINESS_LITERAL %token <voidval> CHARACTER_STRING_LITERAL @@ -262,17 +262,17 @@ static int parse_number PARAMS ((void)); value : expression { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | undefined_value { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; undefined_value : FIXME { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -280,7 +280,7 @@ undefined_value : FIXME location : FIXME { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -288,63 +288,63 @@ location : FIXME primitive_value : location_contents { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | value_name { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | literal { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | tuple { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | value_string_element { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | value_string_slice { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | value_array_element { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | value_array_slice { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | value_structure_field { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | expression_conversion { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | value_procedure_call { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | value_built_in_routine_call { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | start_expression { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | zero_adic_operator { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | parenthesised_expression { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -352,7 +352,7 @@ primitive_value : location_contents location_contents: location { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -360,23 +360,23 @@ location_contents: location value_name : synonym_name { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | value_enumeration_name { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | value_do_with_name { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | value_receive_name { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | general_procedure_name { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -384,36 +384,39 @@ value_name : synonym_name literal : INTEGER_LITERAL { - write_exp_elt_opcode (OP_LONG); - write_exp_elt_type ($1.type); - write_exp_elt_longcst ((LONGEST) ($1.val)); - write_exp_elt_opcode (OP_LONG); + write_exp_elt_opcode (OP_LONG); + write_exp_elt_type ($1.type); + write_exp_elt_longcst ((LONGEST) ($1.val)); + write_exp_elt_opcode (OP_LONG); } | BOOLEAN_LITERAL { - write_exp_elt_opcode (OP_BOOL); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_BOOL); + write_exp_elt_opcode (OP_BOOL); + write_exp_elt_longcst ((LONGEST) $1); + write_exp_elt_opcode (OP_BOOL); } | CHARACTER_LITERAL { - $$ = 0; /* FIXME */ + write_exp_elt_opcode (OP_LONG); + write_exp_elt_type ($1.type); + write_exp_elt_longcst ((LONGEST) ($1.val)); + write_exp_elt_opcode (OP_LONG); } | SET_LITERAL { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | EMPTINESS_LITERAL { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | CHARACTER_STRING_LITERAL { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | BIT_STRING_LITERAL { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -421,7 +424,7 @@ literal : INTEGER_LITERAL tuple : FIXME { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -430,7 +433,7 @@ tuple : FIXME value_string_element: string_primitive_value '(' start_element ')' { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -438,11 +441,11 @@ value_string_element: string_primitive_value '(' start_element ')' value_string_slice: string_primitive_value '(' left_element ':' right_element ')' { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | string_primitive_value '(' start_element UP slice_size ')' { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -450,7 +453,7 @@ value_string_slice: string_primitive_value '(' left_element ':' right_element ') value_array_element: array_primitive_value '(' expression_list ')' { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -458,11 +461,11 @@ value_array_element: array_primitive_value '(' expression_list ')' value_array_slice: array_primitive_value '(' lower_element ':' upper_element ')' { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | array_primitive_value '(' first_element UP slice_size '(' { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -470,7 +473,7 @@ value_array_slice: array_primitive_value '(' lower_element ':' upper_element ')' value_structure_field: structure_primitive_value '.' field_name { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -478,7 +481,7 @@ value_structure_field: structure_primitive_value '.' field_name expression_conversion: mode_name '(' expression ')' { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -486,7 +489,7 @@ expression_conversion: mode_name '(' expression ')' value_procedure_call: FIXME { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -494,7 +497,7 @@ value_procedure_call: FIXME value_built_in_routine_call: FIXME { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -502,7 +505,7 @@ value_built_in_routine_call: FIXME start_expression: FIXME { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } /* Not in GNU-Chill */ ; @@ -510,7 +513,7 @@ start_expression: FIXME zero_adic_operator: FIXME { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -518,7 +521,7 @@ zero_adic_operator: FIXME parenthesised_expression: '(' expression ')' { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -526,49 +529,49 @@ parenthesised_expression: '(' expression ')' expression : operand_0 { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | conditional_expression { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; conditional_expression : IF boolean_expression then_alternative else_alternative FI { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | CASE case_selector_list OF value_case_alternative '[' ELSE sub_expression ']' ESAC { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; then_alternative: THEN subexpression { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; else_alternative: ELSE subexpression { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | ELSIF boolean_expression then_alternative else_alternative { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; sub_expression : expression { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; value_case_alternative: case_label_specification ':' sub_expression ';' { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -576,19 +579,19 @@ value_case_alternative: case_label_specification ':' sub_expression ';' operand_0 : operand_1 { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | operand_0 LOGIOR operand_1 { - write_exp_elt_opcode (BINOP_BITWISE_IOR); + write_exp_elt_opcode (BINOP_BITWISE_IOR); } | operand_0 ORIF operand_1 { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | operand_0 LOGXOR operand_1 { - write_exp_elt_opcode (BINOP_BITWISE_XOR); + write_exp_elt_opcode (BINOP_BITWISE_XOR); } ; @@ -596,15 +599,15 @@ operand_0 : operand_1 operand_1 : operand_2 { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | operand_1 LOGAND operand_2 { - write_exp_elt_opcode (BINOP_BITWISE_AND); + write_exp_elt_opcode (BINOP_BITWISE_AND); } | operand_1 ANDIF operand_2 { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -612,35 +615,35 @@ operand_1 : operand_2 operand_2 : operand_3 { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | operand_2 '=' operand_3 { - write_exp_elt_opcode (BINOP_EQUAL); + write_exp_elt_opcode (BINOP_EQUAL); } | operand_2 NOTEQUAL operand_3 { - write_exp_elt_opcode (BINOP_NOTEQUAL); + write_exp_elt_opcode (BINOP_NOTEQUAL); } | operand_2 '>' operand_3 { - write_exp_elt_opcode (BINOP_GTR); + write_exp_elt_opcode (BINOP_GTR); } | operand_2 GTR operand_3 { - write_exp_elt_opcode (BINOP_GEQ); + write_exp_elt_opcode (BINOP_GEQ); } | operand_2 '<' operand_3 { - write_exp_elt_opcode (BINOP_LESS); + write_exp_elt_opcode (BINOP_LESS); } | operand_2 LEQ operand_3 { - write_exp_elt_opcode (BINOP_LEQ); + write_exp_elt_opcode (BINOP_LEQ); } | operand_2 IN operand_3 { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -649,19 +652,19 @@ operand_2 : operand_3 operand_3 : operand_4 { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | operand_3 '+' operand_4 { - write_exp_elt_opcode (BINOP_ADD); + write_exp_elt_opcode (BINOP_ADD); } | operand_3 '-' operand_4 { - write_exp_elt_opcode (BINOP_SUB); + write_exp_elt_opcode (BINOP_SUB); } | operand_3 SLASH_SLASH operand_4 { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -669,23 +672,23 @@ operand_3 : operand_4 operand_4 : operand_5 { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | operand_4 '*' operand_5 { - write_exp_elt_opcode (BINOP_MUL); + write_exp_elt_opcode (BINOP_MUL); } | operand_4 '/' operand_5 { - write_exp_elt_opcode (BINOP_DIV); + write_exp_elt_opcode (BINOP_DIV); } | operand_4 MOD operand_5 { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | operand_4 REM operand_5 { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -693,19 +696,19 @@ operand_4 : operand_5 operand_5 : operand_6 { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | '-' operand_6 { - write_exp_elt_opcode (UNOP_NEG); + write_exp_elt_opcode (UNOP_NEG); } | NOT operand_6 { - write_exp_elt_opcode (UNOP_LOGICAL_NOT); + write_exp_elt_opcode (UNOP_LOGICAL_NOT); } | '(' integer_literal_expression ')' operand_6 { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -713,15 +716,15 @@ operand_5 : operand_6 operand_6 : POINTER location { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | RECEIVE buffer_location { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } | primitive_value { - $$ = 0; /* FIXME */ + $$ = 0; /* FIXME */ } ; @@ -732,7 +735,7 @@ operand_6 : POINTER location integer_literal_expression: INTEGER_LITERAL { - $$ = 0; + $$ = 0; } /* Things which still need productions... */ @@ -762,36 +765,179 @@ buffer_location : FIXME { $$ = 0; } %% -/* Recognize a character literal. */ - static int -decode_character_literal () +decode_integer_literal (valptr, tokptrptr) +int *valptr; +char **tokptrptr; { - char *tokptr = lexptr; - int ival = 0; - - if (*tokptr++ != '\'') + char *tokptr = *tokptrptr; + int base = 0; + int ival = 0; + int digits = 0; + int temp; + int explicit_base = 0; + + /* Look for an explicit base specifier, which is optional. */ + + switch (*tokptr) + { + case 'd': + case 'D': + explicit_base++; + base = 10; + tokptr++; + break; + case 'b': + case 'B': + explicit_base++; + base = 2; + tokptr++; + break; + case 'h': + case 'H': + explicit_base++; + base = 16; + tokptr++; + break; + case 'o': + case 'O': + explicit_base++; + base = 8; + tokptr++; + break; + default: + base = 10; + break; + } + + /* If we found an explicit base ensure that the character after the + explicit base is a single quote. */ + + if (explicit_base && (*tokptr++ != '\'')) + { + return (0); + } + + /* Start looking for a value composed of valid digits as set by the base + in use. Note that '_' characters are valid anywhere, in any quantity, + and are simply ignored. Since we must find at least one valid digit, + or reject this token as an integer literal, we keep track of how many + digits we have encountered. */ + + while (*tokptr != '\0') + { + temp = tolower (*tokptr); + tokptr++; + switch (temp) { - return (0); + case '_': + continue; + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + temp -= '0'; + break; + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + temp -= 'a'; + temp += 10; + break; + default: + temp = base; + break; } - - if (*tokptr != '\\') + if (temp < base) { - ival = *++tokptr; - tokptr++; + digits++; + ival *= base; + ival += temp; } - else + else { - + /* Found something not in domain for current base. */ + tokptr--; /* Unconsume what gave us indigestion. */ + break; } - if (*++tokptr != '\'') + } + + /* If we didn't find any digits, then we don't have a valid integer + literal, so reject the entire token. Also, if we have an explicit + base, then the next character must not be a single quote, or we + have a bitstring literal, so reject the entire token in this case + as well. Otherwise, update the lexical scan pointer, and return + non-zero for success. */ + + if (digits == 0) + { + return (0); + } + else if (explicit_base && (*tokptr == '\'')) + { + return (0); + } + else + { + *valptr = ival; + *tokptrptr = tokptr; + return (1); + } +} + +/* Recognize a character literal. A character literal is single character + or a control sequence, enclosed in single quotes. A control sequence + is a comma separated list of one or more integer literals, enclosed + in parenthesis and introduced with a circumflex character. + + EX: 'a' '^(7)' '^(7,8)' + + Returns CHARACTER_LITERAL if a match is found. + */ + +static int +match_character_literal () +{ + char *tokptr = lexptr; + int ival = 0; + + /* All character literals must start with a single quote. If we don't + find it, don't bother looking any further. */ + + if (*tokptr++ != '\'') + { + return (0); + } + + /* Determine which form we have, either a control sequence or the + single character form. */ + + if ((*tokptr == '^') && (*(tokptr + 1) == '(')) + { + /* Match and decode a control sequence. Return zero if we don't + find a valid integer literal, or if the next unconsumed character + after the integer literal is not the trailing ')'. + FIXME: We currently don't handle the multiple integer literal + form. */ + tokptr += 2; + if (!decode_integer_literal (&ival, &tokptr) || (*tokptr++ != ')')) { - return (0); + return (0); } - yylval.typed_val.val = ival; - yylval.typed_val.type = builtin_type_int; - lexptr = tokptr; - return (CHARACTER_LITERAL); + } + else + { + ival = *tokptr++; + } + + /* The trailing quote has not yet been consumed. If we don't find + it, then we have no match. */ + + if (*tokptr++ != '\'') + { + return (0); + } + + yylval.typed_val.val = ival; + yylval.typed_val.type = builtin_type_chill_char; + lexptr = tokptr; + return (CHARACTER_LITERAL); } /* Recognize an integer literal, as specified in Z.200 sec 5.2.4.2. @@ -800,112 +946,111 @@ decode_character_literal () in any integer literal. */ static int -decode_integer_literal () +match_integer_literal () { - char *tokptr = lexptr; - int ival = 0; - int base = 0; - int digits = 0; - int temp; - - /* Look for an explicit base specifier, which is optional. */ - - switch (*tokptr) - { - case 'd': - case 'D': - base = 10; - tokptr++; - break; - case 'b': - case 'B': - base = 2; - tokptr++; - break; - case 'h': - case 'H': - base = 16; - tokptr++; - break; - case 'o': - case 'O': - base = 8; - tokptr++; - break; - } - - /* If we found no explicit base then default to 10, otherwise ensure - that the character after the explicit base is a single quote. */ - - if (base == 0) - { - base = 10; - } - else + char *tokptr = lexptr; + int ival = 0; + int base = 0; + int digits = 0; + int temp; + + /* Look for an explicit base specifier, which is optional. */ + + switch (*tokptr) + { + case 'd': + case 'D': + base = 10; + tokptr++; + break; + case 'b': + case 'B': + base = 2; + tokptr++; + break; + case 'h': + case 'H': + base = 16; + tokptr++; + break; + case 'o': + case 'O': + base = 8; + tokptr++; + break; + } + + /* If we found no explicit base then default to 10, otherwise ensure + that the character after the explicit base is a single quote. */ + + if (base == 0) + { + base = 10; + } + else + { + if (*tokptr++ != '\'') { - if (*tokptr++ != '\'') - { - return (0); - } + return (0); } - - /* Start looking for a value composed of valid digits as set by the base - in use. Note that '_' characters are valid anywhere, in any quantity, - and are simply ignored. Since we must find at least one valid digit, - or reject this token as an integer literal, we keep track of how many - digits we have encountered. */ - - while (*tokptr != '\0') + } + + /* Start looking for a value composed of valid digits as set by the base + in use. Note that '_' characters are valid anywhere, in any quantity, + and are simply ignored. Since we must find at least one valid digit, + or reject this token as an integer literal, we keep track of how many + digits we have encountered. */ + + while (*tokptr != '\0') + { + temp = tolower (*tokptr); + tokptr++; + switch (temp) { - temp = tolower (*tokptr); - tokptr++; - switch (temp) - { - case '_': - continue; - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - temp -= '0'; - break; - case 'a': case 'b': case 'c': case 'd': case 'e': - case 'f': - temp -= 'a'; - temp += 10; - break; - default: - temp = base; - break; - } - if (temp < base) - { - digits++; - ival *= base; - ival += temp; - } - else - { - /* Found something not in domain for current base. */ - tokptr--; /* Unconsume what gave us indigestion. */ - break; - } + case '_': + continue; + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + temp -= '0'; + break; + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + temp -= 'a'; + temp += 10; + break; + default: + temp = base; + break; } - - /* If we didn't find any digits, then we don't have a valid integer - literal, so reject the entire token. Otherwise, set up the parser - variables, advance the current lexical scan pointer, and return the - INTEGER_LITERAL token. */ - - if (digits == 0) + if (temp < base) { - return (0); + digits++; + ival *= base; + ival += temp; } - else + else { - yylval.typed_val.val = ival; - yylval.typed_val.type = builtin_type_int; - lexptr = tokptr; - return (INTEGER_LITERAL); + /* Found something not in domain for current base. */ + tokptr--; /* Unconsume what gave us indigestion. */ + break; } + } + + /* If we didn't find any digits, then we don't have a valid integer + literal, so reject the entire token. Otherwise, set up the parser + variables, advance the current lexical scan pointer, and return the + INTEGER_LITERAL token. */ + + if (digits == 0) + { + return (0); + } + else + { + yylval.typed_val.val = ival; + yylval.typed_val.type = builtin_type_int; + lexptr = tokptr; + return (INTEGER_LITERAL); + } } static void convert_float () @@ -1027,14 +1172,16 @@ yylex () /* Look for characters which start a particular kind of multicharacter token, such as a character literal. */ switch (*lexptr) - { - case '\'': - if ((token = decode_character_literal ()) != 0) - { - return (token); - } - break; - } + { + case '^': + case '\'': + token = match_character_literal (); + if (token != 0) + { + return (token); + } + break; + } /* See if it is a special token of length 5. */ for (i = 0; i < sizeof (tokentab5) / sizeof (tokentab5[0]); i++) { @@ -1094,7 +1241,8 @@ yylex () lexptr += 5; return (BOOLEAN_LITERAL); } - if ((token = decode_integer_literal ()) != 0) + token = match_integer_literal (); + if (token != 0); { return (token); } @@ -1143,6 +1291,7 @@ const static struct op_print chill_op_print_tab[] = { /* The built-in types of Chill. */ struct type *builtin_type_chill_bool; +struct type *builtin_type_chill_char; struct type *builtin_type_chill_long; struct type *builtin_type_chill_ulong; struct type *builtin_type_chill_real; @@ -1150,6 +1299,7 @@ struct type *builtin_type_chill_real; struct type ** const (chill_builtin_types[]) = { &builtin_type_chill_bool, + &builtin_type_chill_char, &builtin_type_chill_long, &builtin_type_chill_ulong, &builtin_type_chill_real, @@ -1167,8 +1317,10 @@ const struct language_defn chill_language_defn = { &BUILTIN_TYPE_LONGEST, /* longest signed integral type */ &BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */ &builtin_type_chill_real, /* longest floating point type */ - "0x%x", "0x%", "x", /* Hex format, prefix, suffix */ - "0%o", "0%", "o", /* Octal format, prefix, suffix */ + {"", "B'", "", ""}, /* Binary format info */ + {"O'%o", "O'", "o", ""}, /* Octal format info */ + {"D'%d", "D'", "d", ""}, /* Decimal format info */ + {"H'%x", "H'", "x", ""}, /* Hex format info */ chill_op_print_tab, /* expression operators for printing */ LANG_MAGIC }; @@ -1182,6 +1334,10 @@ _initialize_chill_exp () init_type (TYPE_CODE_BOOL, TARGET_INT_BIT / TARGET_CHAR_BIT, TYPE_FLAG_UNSIGNED, "BOOL", (struct objfile *) NULL); + builtin_type_chill_char = + init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT, + TYPE_FLAG_UNSIGNED, + "CHAR", (struct objfile *) NULL); builtin_type_chill_long = init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, 0, diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 0018336..deb8701 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -493,6 +493,7 @@ extern struct type *builtin_type_m2_bool; /* Chill types */ extern struct type *builtin_type_chill_bool; +extern struct type *builtin_type_chill_char; extern struct type *builtin_type_chill_long; extern struct type *builtin_type_chill_ulong; extern struct type *builtin_type_chill_real; diff --git a/gdb/language.c b/gdb/language.c index afe0832..a20053c 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -483,9 +483,11 @@ local_hex_format_custom(pre) { static char form[50]; - strcpy (form, current_language->la_hex_format_pre); + strcpy (form, local_hex_format_prefix ()); + strcat (form, "%"); strcat (form, pre); - strcat (form, current_language->la_hex_format_suf); + strcat (form, local_hex_format_specifier ()); + strcat (form, local_hex_format_suffix ()); return form; } @@ -497,7 +499,7 @@ local_hex_string (num) { static char res[50]; - sprintf (res, current_language->la_hex_format, num); + sprintf (res, local_hex_format(), num); return res; } @@ -522,9 +524,11 @@ local_octal_format_custom(pre) { static char form[50]; - strcpy (form, current_language->la_octal_format_pre); + strcpy (form, local_octal_format_prefix ()); + strcat (form, "%"); strcat (form, pre); - strcat (form, current_language->la_octal_format_suf); + strcat (form, local_octal_format_specifier ()); + strcat (form, local_octal_format_suffix ()); return form; } @@ -563,7 +567,10 @@ simple_type(type) } } -/* Returns non-zero if its argument is of an ordered type. */ +/* Returns non-zero if its argument is of an ordered type. + An ordered type is one in which the elements can be tested for the + properties of "greater than", "less than", etc, or for which the + operations "increment" or "decrement" make sense. */ int ordered_type (type) struct type *type; @@ -643,6 +650,9 @@ character_type (type) { switch(current_language->la_language) { + /* start-sanitize-chill */ + case language_chill: + /* end-sanitize-chill */ case language_m2: return TYPE_CODE(type) != TYPE_CODE_CHAR ? 0 : 1; @@ -651,10 +661,6 @@ character_type (type) return (TYPE_CODE(type) == TYPE_CODE_INT) && TYPE_LENGTH(type) == sizeof(char) ? 1 : 0; - /* start-sanitize-chill */ - case language_chill: - error ("Missing Chill support in function character_type."); /*FIXME*/ - /* end-sanitize-chill */ default: return (0); } @@ -1106,8 +1112,10 @@ const struct language_defn unknown_language_defn = { &builtin_type_error, /* longest signed integral type */ &builtin_type_error, /* longest unsigned integral type */ &builtin_type_error, /* longest floating point type */ - "0x%x", "0x%", "x", /* Hex format, prefix, suffix */ - "0%o", "0%", "o", /* Octal format, prefix, suffix */ + {"", "", "", ""}, /* Binary format info */ + {"0%o", "0", "o", ""}, /* Octal format info */ + {"%d", "", "d", ""}, /* Decimal format info */ + {"0x%x", "0x", "x", ""}, /* Hex format info */ unk_op_print_tab, /* expression operators for printing */ LANG_MAGIC }; @@ -1124,8 +1132,10 @@ const struct language_defn auto_language_defn = { &builtin_type_error, /* longest signed integral type */ &builtin_type_error, /* longest unsigned integral type */ &builtin_type_error, /* longest floating point type */ - "0x%x", "0x%", "x", /* Hex format, prefix, suffix */ - "0%o", "0%", "o", /* Octal format, prefix, suffix */ + {"", "", "", ""}, /* Binary format info */ + {"0%o", "0", "o", ""}, /* Octal format info */ + {"%d", "", "d", ""}, /* Decimal format info */ + {"0x%x", "0x", "x", ""}, /* Hex format info */ unk_op_print_tab, /* expression operators for printing */ LANG_MAGIC }; @@ -1141,8 +1151,10 @@ const struct language_defn local_language_defn = { &builtin_type_error, /* longest signed integral type */ &builtin_type_error, /* longest unsigned integral type */ &builtin_type_error, /* longest floating point type */ - "0x%x", "0x%", "x", /* Hex format, prefix, suffix */ - "0%o", "0%", "o", /* Octal format, prefix, suffix */ + {"", "", "", ""}, /* Binary format info */ + {"0%o", "0", "o", ""}, /* Octal format info */ + {"%d", "", "d", ""}, /* Decimal format info */ + {"0x%x", "0x", "x", ""}, /* Hex format info */ unk_op_print_tab, /* expression operators for printing */ LANG_MAGIC }; diff --git a/gdb/language.h b/gdb/language.h index ec8c539..2cc6a3b 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -64,6 +64,37 @@ extern enum type_mode {type_mode_auto, type_mode_manual} type_mode; extern enum type_check {type_check_off, type_check_warn, type_check_on} type_check; +/* Information for doing language dependent formatting of printed values. */ + +struct language_format_info +{ + /* The format that can be passed directly to standard C printf functions + to generate a completely formatted value in the format appropriate for + the language. */ + + char *la_format; + + /* The prefix to be used when directly printing a value, or constructing + a standard C printf format. This generally is everything up to the + conversion specification (the part introduced by the '%' character + and terminated by the conversion specifier character). */ + + char *la_format_prefix; + + /* The conversion specifier. This is generally everything after the + field width and precision, typically only a single character such + as 'o' for octal format or 'x' for hexadecimal format. */ + + char *la_format_specifier; + + /* The suffix to be used when directly printing a value, or constructing + a standard C printf format. This generally is everything after the + conversion specification (the part introduced by the '%' character + and terminated by the conversion specifier character). */ + + char *la_format_suffix; /* Suffix for custom format string */ +}; + /* Structure tying together assorted information about a language. */ struct language_defn { @@ -78,13 +109,15 @@ struct language_defn { struct type **la_longest_int; /* Longest signed integral type */ struct type **la_longest_unsigned_int; /* Longest uns integral type */ struct type **la_longest_float; /* Longest floating point type */ - char *la_hex_format; /* Hexadecimal printf format str */ - char *la_hex_format_pre; /* Prefix for custom format string */ - char *la_hex_format_suf; /* Suffix for custom format string */ - char *la_octal_format; /* Octal printf format str */ - char *la_octal_format_pre; /* Prefix for custom format string */ - char *la_octal_format_suf; /* Suffix for custom format string */ -const struct op_print + struct language_format_info + la_binary_format; /* Base 2 (binary) formats. */ + struct language_format_info + la_octal_format; /* Base 8 (octal) formats. */ + struct language_format_info + la_decimal_format; /* Base 10 (decimal) formats */ + struct language_format_info + la_hex_format; /* Base 16 (hexadecimal) formats */ + const struct op_print *la_op_print_tab; /* Table for printing expressions */ /* Add fields above this point, so the magic number is always last. */ long la_magic; /* Magic number for compat checking */ @@ -141,18 +174,73 @@ set_language PARAMS ((enum language)); #define longest_unsigned_int() (*current_language->la_longest_unsigned_int) #define longest_float() (*current_language->la_longest_float) -/* Hexadecimal number formatting is in defs.h because it is so common - throughout GDB. */ +/* Return a format string for printf that will print a number in one of + the local (language-specific) formats. Result is static and is + overwritten by the next call. Takes printf options like "08" or "l" + (to produce e.g. %08x or %lx). */ + +#define local_binary_format() \ + (current_language->la_binary_format.la_format) +#define local_binary_format_prefix() \ + (current_language->la_binary_format.la_format_prefix) +#define local_binary_format_specifier() \ + (current_language->la_binary_format.la_format_specifier) +#define local_binary_format_suffix() \ + (current_language->la_binary_format.la_format_suffix) + +#define local_octal_format() \ + (current_language->la_octal_format.la_format) +#define local_octal_format_prefix() \ + (current_language->la_octal_format.la_format_prefix) +#define local_octal_format_specifier() \ + (current_language->la_octal_format.la_format_specifier) +#define local_octal_format_suffix() \ + (current_language->la_octal_format.la_format_suffix) + +#define local_decimal_format() \ + (current_language->la_decimal_format.la_format) +#define local_decimal_format_prefix() \ + (current_language->la_decimal_format.la_format_prefix) +#define local_decimal_format_specifier() \ + (current_language->la_decimal_format.la_format_specifier) +#define local_decimal_format_suffix() \ + (current_language->la_decimal_format.la_format_suffix) + +#define local_hex_format() \ + (current_language->la_hex_format.la_format) +#define local_hex_format_prefix() \ + (current_language->la_hex_format.la_format_prefix) +#define local_hex_format_specifier() \ + (current_language->la_hex_format.la_format_specifier) +#define local_hex_format_suffix() \ + (current_language->la_hex_format.la_format_suffix) + +/* Return a format string for printf that will print a number in one of + the local (language-specific) formats. Result is static and is + overwritten by the next call. Takes printf options like "08" or "l" + (to produce e.g. %08x or %lx). */ -/* Return a format string for printf that will print a number in the local - (language-specific) octal format. Result is static and is - overwritten by the next call. local_octal_format_custom takes printf - options like "08" or "l" (to produce e.g. %08x or %lx). */ +extern char * +local_octal_format_custom PARAMS ((char *)); /* language.c */ + +extern char * +local_hex_format_custom PARAMS ((char *)); /* language.c */ -#define local_octal_format() (current_language->la_octal_format) +/* Return a string that contains a number formatted in one of the local + (language-specific) formats. Result is static and is overwritten by + the next call. Takes printf options like "08" or "l". */ + +extern char * +local_octal_string PARAMS ((int)); /* language.c */ + +extern char * +local_octal_string_custom PARAMS ((int, char *));/* language.c */ + +extern char * +local_hex_string PARAMS ((int)); /* language.c */ extern char * -local_octal_format_custom PARAMS ((char *)); +local_hex_string_custom PARAMS ((int, char *)); /* language.c */ /* Type predicates */ diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y index 3f83323..bfaf264 100644 --- a/gdb/m2-exp.y +++ b/gdb/m2-exp.y @@ -1228,10 +1228,12 @@ const struct language_defn m2_language_defn = { m2_parse, /* parser */ m2_error, /* parser error function */ &builtin_type_m2_int, /* longest signed integral type */ - &builtin_type_m2_card, /* longest unsigned integral type */ - &builtin_type_m2_real, /* longest floating point type */ - "0%XH", "0%", "XH", /* Hex format string, prefix, suffix */ - "%oB", "%", "oB", /* Octal format string, prefix, suffix */ + &builtin_type_m2_card, /* longest unsigned integral type */ + &builtin_type_m2_real, /* longest floating point type */ + {"", "", "", ""}, /* Binary format info */ + {"%oB", "", "o", "B"}, /* Octal format info */ + {"%d", "", "d", ""}, /* Decimal format info */ + {"0%XH", "0", "X", "H"}, /* Hex format info */ m2_op_print_tab, /* expression operators for printing */ LANG_MAGIC }; |