From: Paul Hilfinger <hilfingr@gnat.com>
To: gdb-patches@sources.redhat.com
Subject: [RFA] Add language-dependent post-parser
Date: Fri, 19 Mar 2004 00:09:00 -0000 [thread overview]
Message-ID: <20040304113345.5DADDF2EDC@nile.gnat.com> (raw)
For Ada, we found it convenient to do a name-resolution pass after parsing and
before evaluation of expressions. The most convenient form on which to
perform this resolution is the prefix form (that way, we can use the usual
type-computing machinery already included in expression evaluation).
Unfortunately, prefixification occurs after and separate from parsing.
The obvious thing to do was to add a function to the language vector for
post-parsing. For most languages, it does nothing. The patch below
does most of the work in inserting this hook, including the introduction
of a parse-in-type-context function that provides a type context for
the post-parser. In its current form, this patch is a NOP that merely
provides the hooks.
Paul Hilfinger
2004-03-04 Paul N. Hilfinger <Hilfinger@gnat.com>
* 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.
Index: submit.32/gdb/p-lang.c
--- submit.32/gdb/p-lang.c Sun, 25 Jan 2004 23:26:24 -0800 hilfingr (GdbPub/e/26_p-lang.c 1.1.1.2.2.1.2.1.1.1.3.1 644)
+++ submit.34/gdb/p-lang.c Thu, 04 Mar 2004 02:50:17 -0800 hilfingr (GdbPub/e/26_p-lang.c 1.1.1.2.2.1.2.1.1.1.3.1.1.1 644)
@@ -454,6 +454,7 @@ const struct language_defn pascal_langua
&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 */
Index: submit.32/gdb/c-lang.c
--- submit.32/gdb/c-lang.c Sun, 25 Jan 2004 23:26:24 -0800 hilfingr (GdbPub/g/28_c-lang.c 1.1.1.3.2.1.2.1.1.1.3.1 644)
+++ submit.34/gdb/c-lang.c Thu, 04 Mar 2004 02:50:17 -0800 hilfingr (GdbPub/g/28_c-lang.c 1.1.1.3.2.1.2.1.1.1.3.1.1.1 644)
@@ -546,6 +546,7 @@ const struct language_defn c_language_de
&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_languag
&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_
&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_langu
&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 */
Index: submit.32/gdb/expression.h
--- submit.32/gdb/expression.h Thu, 25 Sep 2003 23:43:38 -0700 hilfingr (GdbPub/h/30_expression 1.1.1.2.3.1.1.1 644)
+++ submit.34/gdb/expression.h Thu, 04 Mar 2004 03:21:17 -0800 hilfingr (GdbPub/h/30_expression 1.1.1.2.3.1.1.1.2.1 644)
@@ -378,6 +378,8 @@ struct expression
extern struct expression *parse_expression (char *);
+extern struct expression* parse_expression_in_context (char*, struct type*);
+
extern struct expression *parse_exp_1 (char **, struct block *, int);
/* The innermost context required by the stack and register variables
Index: submit.32/gdb/f-lang.c
--- submit.32/gdb/f-lang.c Wed, 18 Feb 2004 01:34:45 -0800 hilfingr (GdbPub/h/32_f-lang.c 1.1.1.2.2.1.2.1.1.1.1.1.1.1.3.1.1.1 644)
+++ submit.34/gdb/f-lang.c Thu, 04 Mar 2004 02:50:17 -0800 hilfingr (GdbPub/h/32_f-lang.c 1.1.1.2.2.1.2.1.1.1.1.1.1.1.3.1.1.1.1.1 644)
@@ -465,6 +465,7 @@ const struct language_defn f_language_de
&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 */
Index: submit.32/gdb/jv-lang.c
--- submit.32/gdb/jv-lang.c Mon, 09 Feb 2004 01:03:21 -0800 hilfingr (GdbPub/i/30_jv-lang.c 1.1.1.3.3.1.1.1.2.1.1.1.3.1.1.1 644)
+++ submit.34/gdb/jv-lang.c Thu, 04 Mar 2004 02:50:17 -0800 hilfingr (GdbPub/i/30_jv-lang.c 1.1.1.3.3.1.1.1.2.1.1.1.3.1.1.1.1.1 644)
@@ -1036,6 +1036,7 @@ const struct language_defn java_language
&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 */
Index: submit.32/gdb/language.c
--- submit.32/gdb/language.c Sun, 25 Jan 2004 23:26:24 -0800 hilfingr (GdbPub/i/34_language.c 1.1.1.3.1.1.3.1.2.1.1.1.1.1.1.1.3.1 644)
+++ submit.34/gdb/language.c Thu, 04 Mar 2004 02:50:17 -0800 hilfingr (GdbPub/i/34_language.c 1.1.1.3.1.1.3.1.2.1.1.1.1.1.1.1.3.1.1.1 644)
@@ -1279,6 +1279,7 @@ const struct language_defn unknown_langu
&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
&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_languag
&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,
Index: submit.32/gdb/language.h
--- submit.32/gdb/language.h Sun, 25 Jan 2004 23:26:24 -0800 hilfingr (GdbPub/i/35_language.h 1.1.1.3.1.1.2.1.1.1.3.1 644)
+++ submit.34/gdb/language.h Thu, 04 Mar 2004 02:50:17 -0800 hilfingr (GdbPub/i/35_language.h 1.1.1.3.1.1.2.1.1.1.3.1.1.1 644)
@@ -180,6 +180,10 @@ struct language_defn
void (*la_error) (char *);
+ /* Post-parser processing on prefixified expression, in context
+ * expecting a particular type. */
+ void (*la_post_parser) (struct expression **, struct type *);
+
void (*la_printchar) (int ch, struct ui_file * stream);
void (*la_printstr) (struct ui_file * stream, char *string,
Index: submit.32/gdb/m2-lang.c
--- submit.32/gdb/m2-lang.c Sun, 25 Jan 2004 23:26:24 -0800 hilfingr (GdbPub/i/38_m2-lang.c 1.1.1.2.2.1.2.1.1.1.3.1 644)
+++ submit.34/gdb/m2-lang.c Thu, 04 Mar 2004 02:50:17 -0800 hilfingr (GdbPub/i/38_m2-lang.c 1.1.1.2.2.1.2.1.1.1.3.1.1.1 644)
@@ -418,6 +418,7 @@ const struct language_defn m2_language_d
&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 */
Index: submit.32/gdb/parse.c
--- submit.32/gdb/parse.c Wed, 18 Feb 2004 01:34:45 -0800 hilfingr (GdbPub/j/29_parse.c 1.1.1.4.3.1.3.1.1.1.3.1 644)
+++ submit.34/gdb/parse.c Thu, 04 Mar 2004 03:21:17 -0800 hilfingr (GdbPub/j/29_parse.c 1.1.1.4.3.1.3.1.1.1.3.1.1.2 644)
@@ -104,6 +104,9 @@ static void prefixify_expression (struct
static void prefixify_subexp (struct expression *, struct expression *, int,
int);
+static struct expression *parse_exp_in_context (char**, struct block*, int,
+ struct type*);
+
void _initialize_parse (void);
/* Data structure for saving values of arglist_len for function calls whose
@@ -1023,6 +1026,17 @@ prefixify_subexp (struct expression *ine
struct expression *
parse_exp_1 (char **stringptr, struct block *block, int comma)
{
+ return parse_exp_in_context (stringptr, block, comma, NULL);
+}
+
+/* As for parse_exp_1, except give preference to CONTEXT_TYPE as the
+ type of the result value, if CONTEXT_TYPE is non-null, in languages
+ where context can determine resolution. */
+
+static struct expression*
+parse_exp_in_context (char** stringptr, struct block* block, int comma,
+ struct type* context_type)
+{
struct cleanup *old_chain;
lexptr = *stringptr;
@@ -1078,6 +1092,8 @@ parse_exp_1 (char **stringptr, struct bl
prefixify_expression (expout);
+ current_language->la_post_parser (&expout, context_type);
+
if (expressiondebug)
dump_prefix_expression (expout, gdb_stdlog);
@@ -1096,6 +1112,29 @@ parse_expression (char *string)
if (*string)
error ("Junk after end of expression.");
return exp;
+}
+
+
+/* As for parse_expression, except give preference to CONTEXT_TYPE as the
+ type of the result value, if CONTEXT_TYPE is non-null, in languages
+ where context can determine resolution. */
+
+struct expression *
+parse_expression_in_context (char *string, struct type *context_type)
+{
+ struct expression* exp;
+ exp = parse_exp_in_context (&string, 0, 0, context_type);
+ 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, struct type *type)
+{
}
\f
/* Stuff for maintaining a stack of types. Currently just used by C, but
Index: submit.32/gdb/parser-defs.h
--- submit.32/gdb/parser-defs.h Thu, 25 Sep 2003 23:43:38 -0700 hilfingr (GdbPub/j/30_parser-def 1.1.1.2.4.1.1.1 644)
+++ submit.34/gdb/parser-defs.h Thu, 04 Mar 2004 02:50:17 -0800 hilfingr (GdbPub/j/30_parser-def 1.1.1.2.4.1.1.1.3.1 644)
@@ -172,6 +172,8 @@ extern char *op_name_standard (enum exp_
extern struct type *follow_types (struct type *);
+extern void null_post_parser (struct expression **exp, struct type *type);
+
/* During parsing of a C expression, the pointer to the next character
is in this variable. */
Index: submit.32/gdb/scm-lang.c
--- submit.32/gdb/scm-lang.c Sun, 25 Jan 2004 23:26:24 -0800 hilfingr (GdbPub/k/14_scm-lang.c 1.1.1.3.2.1.2.1.1.1.3.1 644)
+++ submit.34/gdb/scm-lang.c Thu, 04 Mar 2004 02:50:17 -0800 hilfingr (GdbPub/k/14_scm-lang.c 1.1.1.3.2.1.2.1.1.1.3.1.1.1 644)
@@ -253,6 +253,7 @@ const struct language_defn scm_language_
&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 */
Index: submit.32/gdb/objc-lang.c
--- submit.32/gdb/objc-lang.c Wed, 18 Feb 2004 01:34:45 -0800 hilfingr (GdbPub/C/b/24_objc-lang. 1.4.3.1.2.1.1.1.3.1.1.1 644)
+++ submit.34/gdb/objc-lang.c Thu, 04 Mar 2004 02:50:17 -0800 hilfingr (GdbPub/C/b/24_objc-lang. 1.4.3.1.2.1.1.1.3.1.1.1.1.1 644)
@@ -662,6 +662,7 @@ const struct language_defn objc_language
&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,
WARNING: multiple messages have this Message-ID
From: Paul Hilfinger <hilfingr@gnat.com>
To: gdb-patches@sources.redhat.com
Subject: [RFA] Add language-dependent post-parser
Date: Thu, 04 Mar 2004 11:33:00 -0000 [thread overview]
Message-ID: <20040304113345.5DADDF2EDC@nile.gnat.com> (raw)
Message-ID: <20040304113300.qynTYmJmGDNX85VJdWhT07qmAk6AV281g4fBOUXPr9Y@z> (raw)
For Ada, we found it convenient to do a name-resolution pass after parsing and
before evaluation of expressions. The most convenient form on which to
perform this resolution is the prefix form (that way, we can use the usual
type-computing machinery already included in expression evaluation).
Unfortunately, prefixification occurs after and separate from parsing.
The obvious thing to do was to add a function to the language vector for
post-parsing. For most languages, it does nothing. The patch below
does most of the work in inserting this hook, including the introduction
of a parse-in-type-context function that provides a type context for
the post-parser. In its current form, this patch is a NOP that merely
provides the hooks.
Paul Hilfinger
2004-03-04 Paul N. Hilfinger <Hilfinger@gnat.com>
* 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.
Index: submit.32/gdb/p-lang.c
--- submit.32/gdb/p-lang.c Sun, 25 Jan 2004 23:26:24 -0800 hilfingr (GdbPub/e/26_p-lang.c 1.1.1.2.2.1.2.1.1.1.3.1 644)
+++ submit.34/gdb/p-lang.c Thu, 04 Mar 2004 02:50:17 -0800 hilfingr (GdbPub/e/26_p-lang.c 1.1.1.2.2.1.2.1.1.1.3.1.1.1 644)
@@ -454,6 +454,7 @@ const struct language_defn pascal_langua
&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 */
Index: submit.32/gdb/c-lang.c
--- submit.32/gdb/c-lang.c Sun, 25 Jan 2004 23:26:24 -0800 hilfingr (GdbPub/g/28_c-lang.c 1.1.1.3.2.1.2.1.1.1.3.1 644)
+++ submit.34/gdb/c-lang.c Thu, 04 Mar 2004 02:50:17 -0800 hilfingr (GdbPub/g/28_c-lang.c 1.1.1.3.2.1.2.1.1.1.3.1.1.1 644)
@@ -546,6 +546,7 @@ const struct language_defn c_language_de
&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_languag
&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_
&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_langu
&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 */
Index: submit.32/gdb/expression.h
--- submit.32/gdb/expression.h Thu, 25 Sep 2003 23:43:38 -0700 hilfingr (GdbPub/h/30_expression 1.1.1.2.3.1.1.1 644)
+++ submit.34/gdb/expression.h Thu, 04 Mar 2004 03:21:17 -0800 hilfingr (GdbPub/h/30_expression 1.1.1.2.3.1.1.1.2.1 644)
@@ -378,6 +378,8 @@ struct expression
extern struct expression *parse_expression (char *);
+extern struct expression* parse_expression_in_context (char*, struct type*);
+
extern struct expression *parse_exp_1 (char **, struct block *, int);
/* The innermost context required by the stack and register variables
Index: submit.32/gdb/f-lang.c
--- submit.32/gdb/f-lang.c Wed, 18 Feb 2004 01:34:45 -0800 hilfingr (GdbPub/h/32_f-lang.c 1.1.1.2.2.1.2.1.1.1.1.1.1.1.3.1.1.1 644)
+++ submit.34/gdb/f-lang.c Thu, 04 Mar 2004 02:50:17 -0800 hilfingr (GdbPub/h/32_f-lang.c 1.1.1.2.2.1.2.1.1.1.1.1.1.1.3.1.1.1.1.1 644)
@@ -465,6 +465,7 @@ const struct language_defn f_language_de
&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 */
Index: submit.32/gdb/jv-lang.c
--- submit.32/gdb/jv-lang.c Mon, 09 Feb 2004 01:03:21 -0800 hilfingr (GdbPub/i/30_jv-lang.c 1.1.1.3.3.1.1.1.2.1.1.1.3.1.1.1 644)
+++ submit.34/gdb/jv-lang.c Thu, 04 Mar 2004 02:50:17 -0800 hilfingr (GdbPub/i/30_jv-lang.c 1.1.1.3.3.1.1.1.2.1.1.1.3.1.1.1.1.1 644)
@@ -1036,6 +1036,7 @@ const struct language_defn java_language
&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 */
Index: submit.32/gdb/language.c
--- submit.32/gdb/language.c Sun, 25 Jan 2004 23:26:24 -0800 hilfingr (GdbPub/i/34_language.c 1.1.1.3.1.1.3.1.2.1.1.1.1.1.1.1.3.1 644)
+++ submit.34/gdb/language.c Thu, 04 Mar 2004 02:50:17 -0800 hilfingr (GdbPub/i/34_language.c 1.1.1.3.1.1.3.1.2.1.1.1.1.1.1.1.3.1.1.1 644)
@@ -1279,6 +1279,7 @@ const struct language_defn unknown_langu
&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
&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_languag
&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,
Index: submit.32/gdb/language.h
--- submit.32/gdb/language.h Sun, 25 Jan 2004 23:26:24 -0800 hilfingr (GdbPub/i/35_language.h 1.1.1.3.1.1.2.1.1.1.3.1 644)
+++ submit.34/gdb/language.h Thu, 04 Mar 2004 02:50:17 -0800 hilfingr (GdbPub/i/35_language.h 1.1.1.3.1.1.2.1.1.1.3.1.1.1 644)
@@ -180,6 +180,10 @@ struct language_defn
void (*la_error) (char *);
+ /* Post-parser processing on prefixified expression, in context
+ * expecting a particular type. */
+ void (*la_post_parser) (struct expression **, struct type *);
+
void (*la_printchar) (int ch, struct ui_file * stream);
void (*la_printstr) (struct ui_file * stream, char *string,
Index: submit.32/gdb/m2-lang.c
--- submit.32/gdb/m2-lang.c Sun, 25 Jan 2004 23:26:24 -0800 hilfingr (GdbPub/i/38_m2-lang.c 1.1.1.2.2.1.2.1.1.1.3.1 644)
+++ submit.34/gdb/m2-lang.c Thu, 04 Mar 2004 02:50:17 -0800 hilfingr (GdbPub/i/38_m2-lang.c 1.1.1.2.2.1.2.1.1.1.3.1.1.1 644)
@@ -418,6 +418,7 @@ const struct language_defn m2_language_d
&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 */
Index: submit.32/gdb/parse.c
--- submit.32/gdb/parse.c Wed, 18 Feb 2004 01:34:45 -0800 hilfingr (GdbPub/j/29_parse.c 1.1.1.4.3.1.3.1.1.1.3.1 644)
+++ submit.34/gdb/parse.c Thu, 04 Mar 2004 03:21:17 -0800 hilfingr (GdbPub/j/29_parse.c 1.1.1.4.3.1.3.1.1.1.3.1.1.2 644)
@@ -104,6 +104,9 @@ static void prefixify_expression (struct
static void prefixify_subexp (struct expression *, struct expression *, int,
int);
+static struct expression *parse_exp_in_context (char**, struct block*, int,
+ struct type*);
+
void _initialize_parse (void);
/* Data structure for saving values of arglist_len for function calls whose
@@ -1023,6 +1026,17 @@ prefixify_subexp (struct expression *ine
struct expression *
parse_exp_1 (char **stringptr, struct block *block, int comma)
{
+ return parse_exp_in_context (stringptr, block, comma, NULL);
+}
+
+/* As for parse_exp_1, except give preference to CONTEXT_TYPE as the
+ type of the result value, if CONTEXT_TYPE is non-null, in languages
+ where context can determine resolution. */
+
+static struct expression*
+parse_exp_in_context (char** stringptr, struct block* block, int comma,
+ struct type* context_type)
+{
struct cleanup *old_chain;
lexptr = *stringptr;
@@ -1078,6 +1092,8 @@ parse_exp_1 (char **stringptr, struct bl
prefixify_expression (expout);
+ current_language->la_post_parser (&expout, context_type);
+
if (expressiondebug)
dump_prefix_expression (expout, gdb_stdlog);
@@ -1096,6 +1112,29 @@ parse_expression (char *string)
if (*string)
error ("Junk after end of expression.");
return exp;
+}
+
+
+/* As for parse_expression, except give preference to CONTEXT_TYPE as the
+ type of the result value, if CONTEXT_TYPE is non-null, in languages
+ where context can determine resolution. */
+
+struct expression *
+parse_expression_in_context (char *string, struct type *context_type)
+{
+ struct expression* exp;
+ exp = parse_exp_in_context (&string, 0, 0, context_type);
+ 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, struct type *type)
+{
}
\f
/* Stuff for maintaining a stack of types. Currently just used by C, but
Index: submit.32/gdb/parser-defs.h
--- submit.32/gdb/parser-defs.h Thu, 25 Sep 2003 23:43:38 -0700 hilfingr (GdbPub/j/30_parser-def 1.1.1.2.4.1.1.1 644)
+++ submit.34/gdb/parser-defs.h Thu, 04 Mar 2004 02:50:17 -0800 hilfingr (GdbPub/j/30_parser-def 1.1.1.2.4.1.1.1.3.1 644)
@@ -172,6 +172,8 @@ extern char *op_name_standard (enum exp_
extern struct type *follow_types (struct type *);
+extern void null_post_parser (struct expression **exp, struct type *type);
+
/* During parsing of a C expression, the pointer to the next character
is in this variable. */
Index: submit.32/gdb/scm-lang.c
--- submit.32/gdb/scm-lang.c Sun, 25 Jan 2004 23:26:24 -0800 hilfingr (GdbPub/k/14_scm-lang.c 1.1.1.3.2.1.2.1.1.1.3.1 644)
+++ submit.34/gdb/scm-lang.c Thu, 04 Mar 2004 02:50:17 -0800 hilfingr (GdbPub/k/14_scm-lang.c 1.1.1.3.2.1.2.1.1.1.3.1.1.1 644)
@@ -253,6 +253,7 @@ const struct language_defn scm_language_
&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 */
Index: submit.32/gdb/objc-lang.c
--- submit.32/gdb/objc-lang.c Wed, 18 Feb 2004 01:34:45 -0800 hilfingr (GdbPub/C/b/24_objc-lang. 1.4.3.1.2.1.1.1.3.1.1.1 644)
+++ submit.34/gdb/objc-lang.c Thu, 04 Mar 2004 02:50:17 -0800 hilfingr (GdbPub/C/b/24_objc-lang. 1.4.3.1.2.1.1.1.3.1.1.1.1.1 644)
@@ -662,6 +662,7 @@ const struct language_defn objc_language
&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,
next reply other threads:[~2004-03-04 11:33 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-19 0:09 Paul Hilfinger [this message]
2004-03-04 11:33 ` Paul Hilfinger
2004-03-19 0:09 ` Daniel Jacobowitz
2004-03-04 22:29 ` Daniel Jacobowitz
2004-03-05 8:15 ` Paul Hilfinger
2004-03-19 0:09 ` Paul Hilfinger
2004-04-02 16:33 ` Daniel Jacobowitz
2004-04-03 12:05 ` Paul Hilfinger
2004-04-07 9:32 ` Paul Hilfinger
2004-04-09 22:40 ` Daniel Jacobowitz
2004-04-10 22:12 ` Paul Hilfinger
2004-03-30 9:24 Paul Hilfinger
2004-03-30 14:27 ` Daniel Jacobowitz
2004-03-31 8:02 ` Paul Hilfinger
2004-03-31 15:30 ` Daniel Jacobowitz
2004-03-31 15:36 ` Daniel Jacobowitz
2004-03-31 16:49 ` Andrew Cagney
2004-03-31 16:58 ` Daniel Jacobowitz
2004-04-01 10:43 ` Paul Hilfinger
2004-04-02 16:25 ` Andrew Cagney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040304113345.5DADDF2EDC@nile.gnat.com \
--to=hilfingr@gnat.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox