From: Paul N. Hilfinger Date: Sat, 10 Apr 2004 22:10:01 +0000 (+0000) Subject: * language.h (language_defn): Add new la_post_parser field. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e85c3284f3920865d80242a740dc7c4803f59840;p=binutils-gdb.git * language.h (language_defn): Add new la_post_parser field. * parser-defs.h (null_post_parser): New declaration (default for la_post_parser). * parse.c (parse_exp_1): Move code to parse_exp_in_context and insert call to that function. (parse_exp_in_context): New function, including code formerly in parse_exp_1. Calls language-dependent post-parser after prefixification. (parse_expression_in_context): New exported function. (null_post_parser): New definition. * expression.h (parse_expression_in_context): Add declaration. * p-lang.c (pascal_language_defn): Add trivial post-parser. * c-lang.c (c_language_defn): Ditto. (cplus_language_defn): Ditto. (asm_language_defn): Ditto. (minimal_language_defn): Ditto. * f-lang.c (f_language_defn): Ditto. * jv-lang.c (java_language_defn): Ditto. * language.c (unknown_language_defn): Ditto. (auto_language_defn): Ditto. (local_language_defn): Ditto. * m2-lang.c (m2_language_defn): Ditto. * scm-lang.c (scm_language_defn): Ditto. * obj-lang.c (objc_language_defn): Ditto. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 02f04a6fbfc..d7837292008 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,32 @@ +2004-03-10 Paul N. Hilfinger + + * language.h (language_defn): Add new la_post_parser field. + * parser-defs.h (null_post_parser): New declaration (default for + la_post_parser). + + * parse.c (parse_exp_1): Move code to parse_exp_in_context and + insert call to that function. + (parse_exp_in_context): New function, including code formerly in + parse_exp_1. Calls language-dependent post-parser after + prefixification. + (parse_expression_in_context): New exported function. + (null_post_parser): New definition. + * expression.h (parse_expression_in_context): Add declaration. + + * p-lang.c (pascal_language_defn): Add trivial post-parser. + * c-lang.c (c_language_defn): Ditto. + (cplus_language_defn): Ditto. + (asm_language_defn): Ditto. + (minimal_language_defn): Ditto. + * f-lang.c (f_language_defn): Ditto. + * jv-lang.c (java_language_defn): Ditto. + * language.c (unknown_language_defn): Ditto. + (auto_language_defn): Ditto. + (local_language_defn): Ditto. + * m2-lang.c (m2_language_defn): Ditto. + * scm-lang.c (scm_language_defn): Ditto. + * obj-lang.c (objc_language_defn): Ditto. + 2004-04-10 Mark Kettenis * amd64nbsd-tdep.c (amd64nbsd_sigcontext_addr): Remove function. diff --git a/gdb/c-lang.c b/gdb/c-lang.c index ba34540f386..3b52890309a 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -546,6 +546,7 @@ const struct language_defn c_language_defn = &exp_descriptor_standard, c_preprocess_and_parse, c_error, + null_post_parser, c_printchar, /* Print a character constant */ c_printstr, /* Function to print string constant */ c_emit_char, /* Print a single char */ @@ -604,6 +605,7 @@ const struct language_defn cplus_language_defn = &exp_descriptor_standard, c_preprocess_and_parse, c_error, + null_post_parser, c_printchar, /* Print a character constant */ c_printstr, /* Function to print string constant */ c_emit_char, /* Print a single char */ @@ -639,6 +641,7 @@ const struct language_defn asm_language_defn = &exp_descriptor_standard, c_preprocess_and_parse, c_error, + null_post_parser, c_printchar, /* Print a character constant */ c_printstr, /* Function to print string constant */ c_emit_char, /* Print a single char */ @@ -679,6 +682,7 @@ const struct language_defn minimal_language_defn = &exp_descriptor_standard, c_preprocess_and_parse, c_error, + null_post_parser, c_printchar, /* Print a character constant */ c_printstr, /* Function to print string constant */ c_emit_char, /* Print a single char */ diff --git a/gdb/expression.h b/gdb/expression.h index 03b45c2ef9a..2b09716e907 100644 --- a/gdb/expression.h +++ b/gdb/expression.h @@ -378,6 +378,8 @@ struct expression extern struct expression *parse_expression (char *); +extern struct expression *parse_expression_in_context (char *, int); + extern struct expression *parse_exp_1 (char **, struct block *, int); /* The innermost context required by the stack and register variables diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 1e7cd45362c..0e30c70dd0d 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -465,6 +465,7 @@ const struct language_defn f_language_defn = &exp_descriptor_standard, f_parse, /* parser */ f_error, /* parser error function */ + null_post_parser, f_printchar, /* Print character constant */ f_printstr, /* function to print string constant */ f_emit_char, /* Function to print a single character */ diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c index 6db6e88efa5..e8401916832 100644 --- a/gdb/jv-lang.c +++ b/gdb/jv-lang.c @@ -1036,6 +1036,7 @@ const struct language_defn java_language_defn = &exp_descriptor_java, java_parse, java_error, + null_post_parser, c_printchar, /* Print a character constant */ c_printstr, /* Function to print string constant */ java_emit_char, /* Function to print a single character */ diff --git a/gdb/language.c b/gdb/language.c index bc00b473a6c..b4d38ea364a 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -1279,6 +1279,7 @@ const struct language_defn unknown_language_defn = &exp_descriptor_standard, unk_lang_parser, unk_lang_error, + null_post_parser, unk_lang_printchar, /* Print character constant */ unk_lang_printstr, unk_lang_emit_char, @@ -1315,6 +1316,7 @@ const struct language_defn auto_language_defn = &exp_descriptor_standard, unk_lang_parser, unk_lang_error, + null_post_parser, unk_lang_printchar, /* Print character constant */ unk_lang_printstr, unk_lang_emit_char, @@ -1350,6 +1352,7 @@ const struct language_defn local_language_defn = &exp_descriptor_standard, unk_lang_parser, unk_lang_error, + null_post_parser, unk_lang_printchar, /* Print character constant */ unk_lang_printstr, unk_lang_emit_char, diff --git a/gdb/language.h b/gdb/language.h index 8ed9fb08417..27c1491d76d 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -180,6 +180,14 @@ struct language_defn void (*la_error) (char *); + /* Given an expression *EXPP created by prefixifying the result of + la_parser, perform any remaining processing necessary to complete + its translation. *EXPP may change; la_post_parser is responsible + for releasing its previous contents, if necessary. If + VOID_CONTEXT_P, then no value is expected from the expression. */ + + void (*la_post_parser) (struct expression ** expp, int void_context_p); + void (*la_printchar) (int ch, struct ui_file * stream); void (*la_printstr) (struct ui_file * stream, char *string, diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index e5b6b500e7c..c66b70341e2 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -418,6 +418,7 @@ const struct language_defn m2_language_defn = &exp_descriptor_standard, m2_parse, /* parser */ m2_error, /* parser error function */ + null_post_parser, m2_printchar, /* Print character constant */ m2_printstr, /* function to print string constant */ m2_emit_char, /* Function to print a single character */ diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index 5c184f35d7a..ecbce77b190 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -662,6 +662,7 @@ const struct language_defn objc_language_defn = { &exp_descriptor_standard, objc_parse, objc_error, + null_post_parser, objc_printchar, /* Print a character constant */ objc_printstr, /* Function to print string constant */ objc_emit_char, diff --git a/gdb/p-lang.c b/gdb/p-lang.c index a4025322ca7..9ab55734a1d 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -454,6 +454,7 @@ const struct language_defn pascal_language_defn = &exp_descriptor_standard, pascal_parse, pascal_error, + null_post_parser, pascal_printchar, /* Print a character constant */ pascal_printstr, /* Function to print string constant */ pascal_emit_char, /* Print a single char */ diff --git a/gdb/parse.c b/gdb/parse.c index 3bf06b96a88..4af6d7c7bf0 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -102,6 +102,9 @@ static void prefixify_expression (struct expression *); static void prefixify_subexp (struct expression *, struct expression *, int, int); +static struct expression *parse_exp_in_context (char **, struct block *, int, + int); + void _initialize_parse (void); /* Data structure for saving values of arglist_len for function calls whose @@ -1020,6 +1023,16 @@ prefixify_subexp (struct expression *inexpr, struct expression * parse_exp_1 (char **stringptr, struct block *block, int comma) +{ + return parse_exp_in_context (stringptr, block, comma, 0); +} + +/* As for parse_exp_1, except that if VOID_CONTEXT_P, then + no value is expected from the expression. */ + +static struct expression * +parse_exp_in_context (char **stringptr, struct block *block, int comma, + int void_context_p) { struct cleanup *old_chain; @@ -1076,6 +1089,8 @@ parse_exp_1 (char **stringptr, struct block *block, int comma) prefixify_expression (expout); + current_language->la_post_parser (&expout, void_context_p); + if (expressiondebug) dump_prefix_expression (expout, gdb_stdlog); @@ -1095,6 +1110,28 @@ parse_expression (char *string) error ("Junk after end of expression."); return exp; } + + +/* As for parse_expression, except that if VOID_CONTEXT_P, then + no value is expected from the expression. */ + +struct expression * +parse_expression_in_context (char *string, int void_context_p) +{ + struct expression *exp; + exp = parse_exp_in_context (&string, 0, 0, void_context_p); + if (*string != '\000') + error ("Junk after end of expression."); + return exp; +} + +/* A post-parser that does nothing */ + +/* ARGSUSED */ +void +null_post_parser (struct expression **exp, int void_context_p) +{ +} /* Stuff for maintaining a stack of types. Currently just used by C, but probably useful for any language which declares its types "backwards". */ diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h index c84fcad2c1f..43a07c37466 100644 --- a/gdb/parser-defs.h +++ b/gdb/parser-defs.h @@ -172,6 +172,8 @@ extern char *op_name_standard (enum exp_opcode); extern struct type *follow_types (struct type *); +extern void null_post_parser (struct expression **, int); + /* During parsing of a C expression, the pointer to the next character is in this variable. */ diff --git a/gdb/scm-lang.c b/gdb/scm-lang.c index 872dcaf89fc..1c410766963 100644 --- a/gdb/scm-lang.c +++ b/gdb/scm-lang.c @@ -253,6 +253,7 @@ const struct language_defn scm_language_defn = &exp_descriptor_scm, scm_parse, c_error, + null_post_parser, scm_printchar, /* Print a character constant */ scm_printstr, /* Function to print string constant */ NULL, /* Function to print a single character */