2016-04-27 09:38:08 +08:00
|
|
|
|
/* Bison parser for Rust expressions, for GDB.
|
2019-01-01 14:01:51 +08:00
|
|
|
|
Copyright (C) 2016-2019 Free Software Foundation, Inc.
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
/* The Bison manual says that %pure-parser is deprecated, but we use
|
|
|
|
|
it anyway because it also works with Byacc. That is also why
|
|
|
|
|
this uses %lex-param and %parse-param rather than the simpler
|
|
|
|
|
%param -- Byacc does not support the latter. */
|
|
|
|
|
%pure-parser
|
|
|
|
|
%lex-param {struct rust_parser *parser}
|
|
|
|
|
%parse-param {struct rust_parser *parser}
|
|
|
|
|
|
2016-04-27 09:38:08 +08:00
|
|
|
|
/* Removing the last conflict seems difficult. */
|
|
|
|
|
%expect 1
|
|
|
|
|
|
|
|
|
|
%{
|
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
|
|
|
|
|
#include "block.h"
|
|
|
|
|
#include "charset.h"
|
|
|
|
|
#include "cp-support.h"
|
|
|
|
|
#include "gdb_obstack.h"
|
|
|
|
|
#include "gdb_regex.h"
|
|
|
|
|
#include "rust-lang.h"
|
|
|
|
|
#include "parser-defs.h"
|
2019-01-24 01:21:39 +08:00
|
|
|
|
#include "common/selftest.h"
|
2016-04-27 09:38:08 +08:00
|
|
|
|
#include "value.h"
|
2019-01-24 01:21:39 +08:00
|
|
|
|
#include "common/vec.h"
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
#define GDB_YY_REMAP_PREFIX rust
|
|
|
|
|
#include "yy-remap.h"
|
|
|
|
|
|
|
|
|
|
#define RUSTSTYPE YYSTYPE
|
|
|
|
|
|
|
|
|
|
struct rust_op;
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
typedef std::vector<const struct rust_op *> rust_op_vector;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
/* A typed integer constant. */
|
|
|
|
|
|
|
|
|
|
struct typed_val_int
|
|
|
|
|
{
|
|
|
|
|
LONGEST val;
|
|
|
|
|
struct type *type;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* A typed floating point constant. */
|
|
|
|
|
|
|
|
|
|
struct typed_val_float
|
|
|
|
|
{
|
Target FP: Use target format throughout expression parsing
When parsing floating-point literals, the language parsers currently
use parse_float or some equivalent routine to parse the input string
into a DOUBLEST, which is then stored within a OP_DOUBLE expression
node. When evaluating the expression, the OP_DOUBLE is finally
converted into a value in target format.
On the other hand, *decimal* floating-point literals are parsed
directly into target format and stored that way in a OP_DECFLOAT
expression node. In order to eliminate the DOUBLEST, this patch
therefore unifies the handling of binary and decimal floating-
point literals and stores them both in target format within a
new OP_FLOAT expression node, replacing both OP_DOUBLE and
OP_DECFLOAT.
In order to store literals in target format, the parse_float
routine needs to know the type of the literal. All parsers
therefore need to be changed to determine the appropriate type
(e.g. by detecting suffixes) *before* calling parse_float,
instead of after it as today. However, this change is mostly
straightforward -- again, this is already done for decimal FP
today.
The core of the literal parsing is moved into a new routine
floatformat_from_string, mirroring floatformat_to_string.
The parse_float routine now calls either floatformat_from_string
or decimal_from_sting, allowing it to handle any type of FP
literal.
All language parsers need to be updated. Some notes on
specific changes to the various languages:
- C: Decimal FP is now handled in parse_float, and no longer
needs to be handled specially.
- D: Straightforward.
- Fortran: Still used a hard-coded "atof", also replaced by
parse_float now. Continues to always use builtin_real_s8
as the type of literal, even though this is probably wrong.
- Go: This used to handle "f" and "l" suffixes, even though
the Go language actually doesn't support those. I kept this
support for now -- maybe revisit later. Note the the GDB
test suite for some reason actually *verifies* that GDB supports
those unsupported suffixes ...
- Pascal: Likewise -- this handles suffixes that are not
supported in the language standard.
- Modula-2: Like Fortran, used to use "atof".
- Rust: Mostly straightforward, except for a unit-testing hitch.
The code use to set a special "unit_testing" flag which would
cause "rust_type" to always return NULL. This makes it not
possible to encode a literal into target format (which type?).
The reason for this flag appears to have been that during
unit testing, there is no "rust_parser" context set up, which
means no "gdbarch" is available to use its types. To fix this,
I removed the unit_testing flag, and instead simply just set up
a dummy rust_parser context during unit testing.
- Ada: This used to check sizeof (DOUBLEST) to determine which
type to use for floating-point literal. This seems questionable
to begin with (since DOUBLEST is quite unrelated to target formats),
and in any case we need to get rid of DOUBLEST. I'm now simply
always using the largest type (builtin_long_double).
gdb/ChangeLog:
2017-10-25 Ulrich Weigand <uweigand@de.ibm.com>
* doublest.c (floatformat_from_string): New function.
* doublest.h (floatformat_from_string): Add prototype.
* std-operator.def (OP_DOUBLE, OP_DECFLOAT): Remove, replace by ...
(OP_FLOAT): ... this.
* expression.h: Do not include "doublest.h".
(union exp_element): Replace doubleconst and decfloatconst by
new element floatconst.
* ada-lang.c (resolve_subexp): Handle OP_FLOAT instead of OP_DOUBLE.
(ada_evaluate_subexp): Likewise.
* eval.c (evaluate_subexp_standard): Handle OP_FLOAT instead of
OP_DOUBLE and OP_DECFLOAT.
* expprint.c (print_subexp_standard): Likewise.
(dump_subexp_body_standard): Likewise.
* breakpoint.c (watchpoint_exp_is_const): Likewise.
* parse.c: Include "dfp.h".
(write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove.
(write_exp_elt_floatcst): New function.
(operator_length_standard): Handle OP_FLOAT instead of OP_DOUBLE
and OP_DECFLOAT.
(operator_check_standard): Likewise.
(parse_float): Do not accept suffix. Take type as input. Return bool.
Return target format buffer instead of host DOUBLEST.
Use floatformat_from_string and decimal_from_string to parse
either binary or decimal floating-point types.
(parse_c_float): Remove.
* parser-defs.h: Do not include "doublest.h".
(write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove.
(write_exp_elt_floatcst): Add prototype.
(parse_float): Update prototype.
(parse_c_float): Remove.
* c-exp.y: Do not include "dfp.h".
(typed_val_float): Use byte buffer instead of DOUBLEST.
(typed_val_decfloat): Remove.
(DECFLOAT): Remove.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
Handle decimal and binary FP types the same way.
* d-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT_LITERAL): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
* f-exp.y: Replace dval by typed_val_float.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Use parse_float instead of atof.
* go-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(parse_go_float): Remove.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Call parse_float instead of parse_go_float.
Parse suffixes and determine type before calling parse_float.
* p-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
* m2-exp.y: Replace dval by byte buffer val.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Call parse_float instead of atof.
* rust-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(lex_number): Call parse_float instead of strtod.
(ast_dliteral): Use OP_FLOAT instead of OP_DOUBLE.
(convert_ast_to_expression): Handle OP_FLOAT instead of OP_DOUBLE.
Use write_exp_elt_floatcst.
(unit_testing): Remove static variable.
(rust_type): Do not check unit_testing.
(rust_lex_tests): Do not set uint_testing. Set up dummy rust_parser.
* ada-exp.y (type_float, type_double): Remove.
(typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
* ada-lex.l (processReal): Use parse_float instead of sscanf.
2017-10-25 21:32:23 +08:00
|
|
|
|
gdb_byte val[16];
|
2016-04-27 09:38:08 +08:00
|
|
|
|
struct type *type;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* An identifier and an expression. This is used to represent one
|
|
|
|
|
element of a struct initializer. */
|
|
|
|
|
|
|
|
|
|
struct set_field
|
|
|
|
|
{
|
|
|
|
|
struct stoken name;
|
|
|
|
|
const struct rust_op *init;
|
|
|
|
|
};
|
|
|
|
|
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
typedef std::vector<set_field> rust_set_vector;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
%}
|
|
|
|
|
|
|
|
|
|
%union
|
|
|
|
|
{
|
|
|
|
|
/* A typed integer constant. */
|
|
|
|
|
struct typed_val_int typed_val_int;
|
|
|
|
|
|
|
|
|
|
/* A typed floating point constant. */
|
|
|
|
|
struct typed_val_float typed_val_float;
|
|
|
|
|
|
|
|
|
|
/* An identifier or string. */
|
|
|
|
|
struct stoken sval;
|
|
|
|
|
|
|
|
|
|
/* A token representing an opcode, like "==". */
|
|
|
|
|
enum exp_opcode opcode;
|
|
|
|
|
|
|
|
|
|
/* A list of expressions; for example, the arguments to a function
|
|
|
|
|
call. */
|
|
|
|
|
rust_op_vector *params;
|
|
|
|
|
|
|
|
|
|
/* A list of field initializers. */
|
|
|
|
|
rust_set_vector *field_inits;
|
|
|
|
|
|
|
|
|
|
/* A single field initializer. */
|
|
|
|
|
struct set_field one_field_init;
|
|
|
|
|
|
|
|
|
|
/* An expression. */
|
|
|
|
|
const struct rust_op *op;
|
|
|
|
|
|
|
|
|
|
/* A plain integer, for example used to count the number of
|
|
|
|
|
"super::" prefixes on a path. */
|
|
|
|
|
unsigned int depth;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
%{
|
|
|
|
|
|
|
|
|
|
struct rust_parser;
|
|
|
|
|
static int rustyylex (YYSTYPE *, rust_parser *);
|
|
|
|
|
static void rustyyerror (rust_parser *parser, const char *msg);
|
|
|
|
|
|
2016-04-27 09:38:08 +08:00
|
|
|
|
static void rust_push_back (char c);
|
|
|
|
|
static struct stoken make_stoken (const char *);
|
|
|
|
|
static struct block_symbol rust_lookup_symbol (const char *name,
|
|
|
|
|
const struct block *block,
|
|
|
|
|
const domain_enum domain);
|
|
|
|
|
|
|
|
|
|
/* A regular expression for matching Rust numbers. This is split up
|
|
|
|
|
since it is very long and this gives us a way to comment the
|
|
|
|
|
sections. */
|
|
|
|
|
|
|
|
|
|
static const char *number_regex_text =
|
|
|
|
|
/* subexpression 1: allows use of alternation, otherwise uninteresting */
|
|
|
|
|
"^("
|
|
|
|
|
/* First comes floating point. */
|
|
|
|
|
/* Recognize number after the decimal point, with optional
|
|
|
|
|
exponent and optional type suffix.
|
|
|
|
|
subexpression 2: allows "?", otherwise uninteresting
|
|
|
|
|
subexpression 3: if present, type suffix
|
|
|
|
|
*/
|
|
|
|
|
"[0-9][0-9_]*\\.[0-9][0-9_]*([eE][-+]?[0-9][0-9_]*)?(f32|f64)?"
|
|
|
|
|
#define FLOAT_TYPE1 3
|
|
|
|
|
"|"
|
|
|
|
|
/* Recognize exponent without decimal point, with optional type
|
|
|
|
|
suffix.
|
|
|
|
|
subexpression 4: if present, type suffix
|
|
|
|
|
*/
|
|
|
|
|
#define FLOAT_TYPE2 4
|
|
|
|
|
"[0-9][0-9_]*[eE][-+]?[0-9][0-9_]*(f32|f64)?"
|
|
|
|
|
"|"
|
|
|
|
|
/* "23." is a valid floating point number, but "23.e5" and
|
|
|
|
|
"23.f32" are not. So, handle the trailing-. case
|
|
|
|
|
separately. */
|
|
|
|
|
"[0-9][0-9_]*\\."
|
|
|
|
|
"|"
|
|
|
|
|
/* Finally come integers.
|
|
|
|
|
subexpression 5: text of integer
|
|
|
|
|
subexpression 6: if present, type suffix
|
|
|
|
|
subexpression 7: allows use of alternation, otherwise uninteresting
|
|
|
|
|
*/
|
|
|
|
|
#define INT_TEXT 5
|
|
|
|
|
#define INT_TYPE 6
|
|
|
|
|
"(0x[a-fA-F0-9_]+|0o[0-7_]+|0b[01_]+|[0-9][0-9_]*)"
|
|
|
|
|
"([iu](size|8|16|32|64))?"
|
|
|
|
|
")";
|
|
|
|
|
/* The number of subexpressions to allocate space for, including the
|
|
|
|
|
"0th" whole match subexpression. */
|
|
|
|
|
#define NUM_SUBEXPRESSIONS 8
|
|
|
|
|
|
|
|
|
|
/* The compiled number-matching regex. */
|
|
|
|
|
|
|
|
|
|
static regex_t number_regex;
|
|
|
|
|
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
/* An instance of this is created before parsing, and destroyed when
|
|
|
|
|
parsing is finished. */
|
|
|
|
|
|
|
|
|
|
struct rust_parser
|
|
|
|
|
{
|
|
|
|
|
rust_parser (struct parser_state *state)
|
|
|
|
|
: rust_ast (nullptr),
|
|
|
|
|
pstate (state)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~rust_parser ()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create a new rust_set_vector. The storage for the new vector is
|
|
|
|
|
managed by this class. */
|
|
|
|
|
rust_set_vector *new_set_vector ()
|
|
|
|
|
{
|
|
|
|
|
rust_set_vector *result = new rust_set_vector;
|
|
|
|
|
set_vectors.push_back (std::unique_ptr<rust_set_vector> (result));
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create a new rust_ops_vector. The storage for the new vector is
|
|
|
|
|
managed by this class. */
|
|
|
|
|
rust_op_vector *new_op_vector ()
|
|
|
|
|
{
|
|
|
|
|
rust_op_vector *result = new rust_op_vector;
|
|
|
|
|
op_vectors.push_back (std::unique_ptr<rust_op_vector> (result));
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return the parser's language. */
|
|
|
|
|
const struct language_defn *language () const
|
|
|
|
|
{
|
2019-03-24 23:01:18 +08:00
|
|
|
|
return pstate->language ();
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return the parser's gdbarch. */
|
|
|
|
|
struct gdbarch *arch () const
|
|
|
|
|
{
|
Turn parse_gdbarch into a method
This changes parse_gdbarch into a method of parser_state. This patch
was written by a script.
gdb/ChangeLog
2019-04-04 Tom Tromey <tom@tromey.com>
* rust-exp.y: Replace "parse_gdbarch" with method call.
* parse.c (write_dollar_variable, insert_type_address_space):
Replace "parse_gdbarch" with method call.
* p-exp.y (parse_type, yylex): Replace "parse_gdbarch" with method
call.
* objc-lang.c (end_msglist): Replace "parse_gdbarch" with method
call.
* m2-exp.y (parse_type, parse_m2_type, yylex): Replace
"parse_gdbarch" with method call.
* go-exp.y (parse_type, classify_name): Replace "parse_gdbarch"
with method call.
* f-exp.y (parse_type, parse_f_type, yylex): Replace
"parse_gdbarch" with method call.
* d-exp.y (parse_type, parse_d_type, lex_one_token): Replace
"parse_gdbarch" with method call.
* c-exp.y (parse_type, parse_number, classify_name): Replace
"parse_gdbarch" with method call.
* ada-lex.l: Replace "parse_gdbarch" with method call.
* ada-exp.y (parse_type, find_primitive_type, type_char)
(type_system_address): Replace "parse_gdbarch" with method call.
2019-03-24 22:56:33 +08:00
|
|
|
|
return pstate->gdbarch ();
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
/* A helper to look up a Rust type, or fail. This only works for
|
|
|
|
|
types defined by rust_language_arch_info. */
|
|
|
|
|
|
|
|
|
|
struct type *get_type (const char *name)
|
|
|
|
|
{
|
|
|
|
|
struct type *type;
|
|
|
|
|
|
|
|
|
|
type = language_lookup_primitive_type (language (), arch (), name);
|
|
|
|
|
if (type == NULL)
|
|
|
|
|
error (_("Could not find Rust type %s"), name);
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *copy_name (const char *name, int len);
|
|
|
|
|
struct stoken concat3 (const char *s1, const char *s2, const char *s3);
|
|
|
|
|
const struct rust_op *crate_name (const struct rust_op *name);
|
|
|
|
|
const struct rust_op *super_name (const struct rust_op *ident,
|
|
|
|
|
unsigned int n_supers);
|
|
|
|
|
|
|
|
|
|
int lex_character (YYSTYPE *lvalp);
|
|
|
|
|
int lex_number (YYSTYPE *lvalp);
|
|
|
|
|
int lex_string (YYSTYPE *lvalp);
|
|
|
|
|
int lex_identifier (YYSTYPE *lvalp);
|
|
|
|
|
|
|
|
|
|
struct type *rust_lookup_type (const char *name, const struct block *block);
|
|
|
|
|
std::vector<struct type *> convert_params_to_types (rust_op_vector *params);
|
|
|
|
|
struct type *convert_ast_to_type (const struct rust_op *operation);
|
|
|
|
|
const char *convert_name (const struct rust_op *operation);
|
|
|
|
|
void convert_params_to_expression (rust_op_vector *params,
|
|
|
|
|
const struct rust_op *top);
|
|
|
|
|
void convert_ast_to_expression (const struct rust_op *operation,
|
|
|
|
|
const struct rust_op *top,
|
|
|
|
|
bool want_type = false);
|
|
|
|
|
|
|
|
|
|
struct rust_op *ast_basic_type (enum type_code typecode);
|
|
|
|
|
const struct rust_op *ast_operation (enum exp_opcode opcode,
|
|
|
|
|
const struct rust_op *left,
|
|
|
|
|
const struct rust_op *right);
|
|
|
|
|
const struct rust_op *ast_compound_assignment
|
|
|
|
|
(enum exp_opcode opcode, const struct rust_op *left,
|
|
|
|
|
const struct rust_op *rust_op);
|
|
|
|
|
const struct rust_op *ast_literal (struct typed_val_int val);
|
|
|
|
|
const struct rust_op *ast_dliteral (struct typed_val_float val);
|
|
|
|
|
const struct rust_op *ast_structop (const struct rust_op *left,
|
|
|
|
|
const char *name,
|
|
|
|
|
int completing);
|
|
|
|
|
const struct rust_op *ast_structop_anonymous
|
|
|
|
|
(const struct rust_op *left, struct typed_val_int number);
|
|
|
|
|
const struct rust_op *ast_unary (enum exp_opcode opcode,
|
|
|
|
|
const struct rust_op *expr);
|
|
|
|
|
const struct rust_op *ast_cast (const struct rust_op *expr,
|
|
|
|
|
const struct rust_op *type);
|
|
|
|
|
const struct rust_op *ast_call_ish (enum exp_opcode opcode,
|
|
|
|
|
const struct rust_op *expr,
|
|
|
|
|
rust_op_vector *params);
|
|
|
|
|
const struct rust_op *ast_path (struct stoken name,
|
|
|
|
|
rust_op_vector *params);
|
|
|
|
|
const struct rust_op *ast_string (struct stoken str);
|
|
|
|
|
const struct rust_op *ast_struct (const struct rust_op *name,
|
|
|
|
|
rust_set_vector *fields);
|
|
|
|
|
const struct rust_op *ast_range (const struct rust_op *lhs,
|
|
|
|
|
const struct rust_op *rhs,
|
|
|
|
|
bool inclusive);
|
|
|
|
|
const struct rust_op *ast_array_type (const struct rust_op *lhs,
|
|
|
|
|
struct typed_val_int val);
|
|
|
|
|
const struct rust_op *ast_slice_type (const struct rust_op *type);
|
|
|
|
|
const struct rust_op *ast_reference_type (const struct rust_op *type);
|
|
|
|
|
const struct rust_op *ast_pointer_type (const struct rust_op *type,
|
|
|
|
|
int is_mut);
|
|
|
|
|
const struct rust_op *ast_function_type (const struct rust_op *result,
|
|
|
|
|
rust_op_vector *params);
|
|
|
|
|
const struct rust_op *ast_tuple_type (rust_op_vector *params);
|
|
|
|
|
|
|
|
|
|
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
/* A pointer to this is installed globally. */
|
|
|
|
|
auto_obstack obstack;
|
|
|
|
|
|
|
|
|
|
/* Result of parsing. Points into obstack. */
|
|
|
|
|
const struct rust_op *rust_ast;
|
|
|
|
|
|
|
|
|
|
/* This keeps track of the various vectors we allocate. */
|
|
|
|
|
std::vector<std::unique_ptr<rust_set_vector>> set_vectors;
|
|
|
|
|
std::vector<std::unique_ptr<rust_op_vector>> op_vectors;
|
|
|
|
|
|
|
|
|
|
/* The parser state gdb gave us. */
|
|
|
|
|
struct parser_state *pstate;
|
2019-03-25 01:33:10 +08:00
|
|
|
|
|
|
|
|
|
/* Depth of parentheses. */
|
|
|
|
|
int paren_depth = 0;
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
};
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
/* Rust AST operations. We build a tree of these; then lower them to
|
|
|
|
|
gdb expressions when parsing has completed. */
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
struct rust_op
|
|
|
|
|
{
|
|
|
|
|
/* The opcode. */
|
|
|
|
|
enum exp_opcode opcode;
|
|
|
|
|
/* If OPCODE is OP_TYPE, then this holds information about what type
|
|
|
|
|
is described by this node. */
|
|
|
|
|
enum type_code typecode;
|
|
|
|
|
/* Indicates whether OPCODE actually represents a compound
|
|
|
|
|
assignment. For example, if OPCODE is GTGT and this is false,
|
|
|
|
|
then this rust_op represents an ordinary ">>"; but if this is
|
|
|
|
|
true, then this rust_op represents ">>=". Unused in other
|
|
|
|
|
cases. */
|
|
|
|
|
unsigned int compound_assignment : 1;
|
|
|
|
|
/* Only used by a field expression; if set, indicates that the field
|
|
|
|
|
name occurred at the end of the expression and is eligible for
|
|
|
|
|
completion. */
|
|
|
|
|
unsigned int completing : 1;
|
2018-03-30 04:14:07 +08:00
|
|
|
|
/* For OP_RANGE, indicates whether the range is inclusive or
|
|
|
|
|
exclusive. */
|
|
|
|
|
unsigned int inclusive : 1;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
/* Operands of expression. Which one is used and how depends on the
|
|
|
|
|
particular opcode. */
|
|
|
|
|
RUSTSTYPE left;
|
|
|
|
|
RUSTSTYPE right;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
|
|
%token <sval> GDBVAR
|
|
|
|
|
%token <sval> IDENT
|
|
|
|
|
%token <sval> COMPLETE
|
|
|
|
|
%token <typed_val_int> INTEGER
|
|
|
|
|
%token <typed_val_int> DECIMAL_INTEGER
|
|
|
|
|
%token <sval> STRING
|
|
|
|
|
%token <sval> BYTESTRING
|
|
|
|
|
%token <typed_val_float> FLOAT
|
|
|
|
|
%token <opcode> COMPOUND_ASSIGN
|
|
|
|
|
|
|
|
|
|
/* Keyword tokens. */
|
|
|
|
|
%token <voidval> KW_AS
|
|
|
|
|
%token <voidval> KW_IF
|
|
|
|
|
%token <voidval> KW_TRUE
|
|
|
|
|
%token <voidval> KW_FALSE
|
|
|
|
|
%token <voidval> KW_SUPER
|
|
|
|
|
%token <voidval> KW_SELF
|
|
|
|
|
%token <voidval> KW_MUT
|
|
|
|
|
%token <voidval> KW_EXTERN
|
|
|
|
|
%token <voidval> KW_CONST
|
|
|
|
|
%token <voidval> KW_FN
|
2016-10-29 20:55:58 +08:00
|
|
|
|
%token <voidval> KW_SIZEOF
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
/* Operator tokens. */
|
|
|
|
|
%token <voidval> DOTDOT
|
2018-03-30 04:14:07 +08:00
|
|
|
|
%token <voidval> DOTDOTEQ
|
2016-04-27 09:38:08 +08:00
|
|
|
|
%token <voidval> OROR
|
|
|
|
|
%token <voidval> ANDAND
|
|
|
|
|
%token <voidval> EQEQ
|
|
|
|
|
%token <voidval> NOTEQ
|
|
|
|
|
%token <voidval> LTEQ
|
|
|
|
|
%token <voidval> GTEQ
|
|
|
|
|
%token <voidval> LSH RSH
|
|
|
|
|
%token <voidval> COLONCOLON
|
|
|
|
|
%token <voidval> ARROW
|
|
|
|
|
|
|
|
|
|
%type <op> type
|
|
|
|
|
%type <op> path_for_expr
|
|
|
|
|
%type <op> identifier_path_for_expr
|
|
|
|
|
%type <op> path_for_type
|
|
|
|
|
%type <op> identifier_path_for_type
|
|
|
|
|
%type <op> just_identifiers_for_type
|
|
|
|
|
|
|
|
|
|
%type <params> maybe_type_list
|
|
|
|
|
%type <params> type_list
|
|
|
|
|
|
|
|
|
|
%type <depth> super_path
|
|
|
|
|
|
|
|
|
|
%type <op> literal
|
|
|
|
|
%type <op> expr
|
|
|
|
|
%type <op> field_expr
|
|
|
|
|
%type <op> idx_expr
|
|
|
|
|
%type <op> unop_expr
|
|
|
|
|
%type <op> binop_expr
|
|
|
|
|
%type <op> binop_expr_expr
|
|
|
|
|
%type <op> type_cast_expr
|
|
|
|
|
%type <op> assignment_expr
|
|
|
|
|
%type <op> compound_assignment_expr
|
|
|
|
|
%type <op> paren_expr
|
|
|
|
|
%type <op> call_expr
|
|
|
|
|
%type <op> path_expr
|
|
|
|
|
%type <op> tuple_expr
|
|
|
|
|
%type <op> unit_expr
|
|
|
|
|
%type <op> struct_expr
|
|
|
|
|
%type <op> array_expr
|
|
|
|
|
%type <op> range_expr
|
|
|
|
|
|
|
|
|
|
%type <params> expr_list
|
|
|
|
|
%type <params> maybe_expr_list
|
|
|
|
|
%type <params> paren_expr_list
|
|
|
|
|
|
|
|
|
|
%type <field_inits> struct_expr_list
|
|
|
|
|
%type <one_field_init> struct_expr_tail
|
|
|
|
|
|
|
|
|
|
/* Precedence. */
|
2018-03-30 04:14:07 +08:00
|
|
|
|
%nonassoc DOTDOT DOTDOTEQ
|
2016-04-27 09:38:08 +08:00
|
|
|
|
%right '=' COMPOUND_ASSIGN
|
|
|
|
|
%left OROR
|
|
|
|
|
%left ANDAND
|
|
|
|
|
%nonassoc EQEQ NOTEQ '<' '>' LTEQ GTEQ
|
|
|
|
|
%left '|'
|
|
|
|
|
%left '^'
|
|
|
|
|
%left '&'
|
|
|
|
|
%left LSH RSH
|
|
|
|
|
%left '@'
|
|
|
|
|
%left '+' '-'
|
|
|
|
|
%left '*' '/' '%'
|
|
|
|
|
/* These could be %precedence in Bison, but that isn't a yacc
|
|
|
|
|
feature. */
|
|
|
|
|
%left KW_AS
|
|
|
|
|
%left UNARY
|
|
|
|
|
%left '[' '.' '('
|
|
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
|
|
start:
|
|
|
|
|
expr
|
|
|
|
|
{
|
|
|
|
|
/* If we are completing and see a valid parse,
|
|
|
|
|
rust_ast will already have been set. */
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
if (parser->rust_ast == NULL)
|
|
|
|
|
parser->rust_ast = $1;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
/* Note that the Rust grammar includes a method_call_expr, but we
|
|
|
|
|
handle this differently, to avoid a shift/reduce conflict with
|
|
|
|
|
call_expr. */
|
|
|
|
|
expr:
|
|
|
|
|
literal
|
|
|
|
|
| path_expr
|
|
|
|
|
| tuple_expr
|
|
|
|
|
| unit_expr
|
|
|
|
|
| struct_expr
|
|
|
|
|
| field_expr
|
|
|
|
|
| array_expr
|
|
|
|
|
| idx_expr
|
|
|
|
|
| range_expr
|
2018-03-07 04:27:12 +08:00
|
|
|
|
| unop_expr /* Must precede call_expr because of ambiguity with
|
|
|
|
|
sizeof. */
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| binop_expr
|
|
|
|
|
| paren_expr
|
|
|
|
|
| call_expr
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
tuple_expr:
|
|
|
|
|
'(' expr ',' maybe_expr_list ')'
|
|
|
|
|
{
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
$4->push_back ($2);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
error (_("Tuple expressions not supported yet"));
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
unit_expr:
|
|
|
|
|
'(' ')'
|
|
|
|
|
{
|
|
|
|
|
struct typed_val_int val;
|
|
|
|
|
|
|
|
|
|
val.type
|
2018-03-07 04:27:12 +08:00
|
|
|
|
= (language_lookup_primitive_type
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
(parser->language (), parser->arch (),
|
2018-03-07 04:27:12 +08:00
|
|
|
|
"()"));
|
2016-04-27 09:38:08 +08:00
|
|
|
|
val.val = 0;
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
$$ = parser->ast_literal (val);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
/* To avoid a shift/reduce conflict with call_expr, we don't handle
|
|
|
|
|
tuple struct expressions here, but instead when examining the
|
|
|
|
|
AST. */
|
|
|
|
|
struct_expr:
|
|
|
|
|
path_for_expr '{' struct_expr_list '}'
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_struct ($1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
struct_expr_tail:
|
|
|
|
|
DOTDOT expr
|
|
|
|
|
{
|
|
|
|
|
struct set_field sf;
|
|
|
|
|
|
|
|
|
|
sf.name.ptr = NULL;
|
|
|
|
|
sf.name.length = 0;
|
|
|
|
|
sf.init = $2;
|
|
|
|
|
|
|
|
|
|
$$ = sf;
|
|
|
|
|
}
|
|
|
|
|
| IDENT ':' expr
|
|
|
|
|
{
|
|
|
|
|
struct set_field sf;
|
|
|
|
|
|
|
|
|
|
sf.name = $1;
|
|
|
|
|
sf.init = $3;
|
|
|
|
|
$$ = sf;
|
|
|
|
|
}
|
2018-03-20 00:25:05 +08:00
|
|
|
|
| IDENT
|
|
|
|
|
{
|
|
|
|
|
struct set_field sf;
|
|
|
|
|
|
|
|
|
|
sf.name = $1;
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
sf.init = parser->ast_path ($1, NULL);
|
2018-03-20 00:25:05 +08:00
|
|
|
|
$$ = sf;
|
|
|
|
|
}
|
2016-04-27 09:38:08 +08:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
struct_expr_list:
|
2016-07-12 05:02:10 +08:00
|
|
|
|
/* %empty */
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
$$ = parser->new_set_vector ();
|
2016-07-12 05:02:10 +08:00
|
|
|
|
}
|
|
|
|
|
| struct_expr_tail
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rust_set_vector *result = parser->new_set_vector ();
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
result->push_back ($1);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
$$ = result;
|
|
|
|
|
}
|
|
|
|
|
| IDENT ':' expr ',' struct_expr_list
|
|
|
|
|
{
|
|
|
|
|
struct set_field sf;
|
|
|
|
|
|
|
|
|
|
sf.name = $1;
|
|
|
|
|
sf.init = $3;
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
$5->push_back (sf);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
$$ = $5;
|
|
|
|
|
}
|
2018-03-20 00:25:05 +08:00
|
|
|
|
| IDENT ',' struct_expr_list
|
|
|
|
|
{
|
|
|
|
|
struct set_field sf;
|
|
|
|
|
|
|
|
|
|
sf.name = $1;
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
sf.init = parser->ast_path ($1, NULL);
|
2018-03-20 00:25:05 +08:00
|
|
|
|
$3->push_back (sf);
|
|
|
|
|
$$ = $3;
|
|
|
|
|
}
|
2016-04-27 09:38:08 +08:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
array_expr:
|
|
|
|
|
'[' KW_MUT expr_list ']'
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_call_ish (OP_ARRAY, NULL, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| '[' expr_list ']'
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_call_ish (OP_ARRAY, NULL, $2); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| '[' KW_MUT expr ';' expr ']'
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (OP_RUST_ARRAY, $3, $5); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| '[' expr ';' expr ']'
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (OP_RUST_ARRAY, $2, $4); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
range_expr:
|
|
|
|
|
expr DOTDOT
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_range ($1, NULL, false); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| expr DOTDOT expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_range ($1, $3, false); }
|
2018-03-30 04:14:07 +08:00
|
|
|
|
| expr DOTDOTEQ expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_range ($1, $3, true); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| DOTDOT expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_range (NULL, $2, false); }
|
2018-03-30 04:14:07 +08:00
|
|
|
|
| DOTDOTEQ expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_range (NULL, $2, true); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| DOTDOT
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_range (NULL, NULL, false); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
literal:
|
|
|
|
|
INTEGER
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_literal ($1); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| DECIMAL_INTEGER
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_literal ($1); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| FLOAT
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_dliteral ($1); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| STRING
|
|
|
|
|
{
|
|
|
|
|
struct set_field field;
|
|
|
|
|
struct typed_val_int val;
|
|
|
|
|
struct stoken token;
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rust_set_vector *fields = parser->new_set_vector ();
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
/* Wrap the raw string in the &str struct. */
|
|
|
|
|
field.name.ptr = "data_ptr";
|
|
|
|
|
field.name.length = strlen (field.name.ptr);
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
field.init = parser->ast_unary (UNOP_ADDR,
|
|
|
|
|
parser->ast_string ($1));
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
fields->push_back (field);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
val.type = parser->get_type ("usize");
|
2016-04-27 09:38:08 +08:00
|
|
|
|
val.val = $1.length;
|
|
|
|
|
|
|
|
|
|
field.name.ptr = "length";
|
|
|
|
|
field.name.length = strlen (field.name.ptr);
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
field.init = parser->ast_literal (val);
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
fields->push_back (field);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
token.ptr = "&str";
|
|
|
|
|
token.length = strlen (token.ptr);
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
$$ = parser->ast_struct (parser->ast_path (token, NULL),
|
|
|
|
|
fields);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
| BYTESTRING
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_string ($1); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| KW_TRUE
|
|
|
|
|
{
|
|
|
|
|
struct typed_val_int val;
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
val.type = language_bool_type (parser->language (),
|
|
|
|
|
parser->arch ());
|
2016-04-27 09:38:08 +08:00
|
|
|
|
val.val = 1;
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
$$ = parser->ast_literal (val);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
| KW_FALSE
|
|
|
|
|
{
|
|
|
|
|
struct typed_val_int val;
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
val.type = language_bool_type (parser->language (),
|
|
|
|
|
parser->arch ());
|
2016-04-27 09:38:08 +08:00
|
|
|
|
val.val = 0;
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
$$ = parser->ast_literal (val);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
field_expr:
|
|
|
|
|
expr '.' IDENT
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_structop ($1, $3.ptr, 0); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| expr '.' COMPLETE
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
$$ = parser->ast_structop ($1, $3.ptr, 1);
|
|
|
|
|
parser->rust_ast = $$;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
| expr '.' DECIMAL_INTEGER
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_structop_anonymous ($1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
idx_expr:
|
|
|
|
|
expr '[' expr ']'
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_SUBSCRIPT, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
unop_expr:
|
|
|
|
|
'+' expr %prec UNARY
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_unary (UNOP_PLUS, $2); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| '-' expr %prec UNARY
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_unary (UNOP_NEG, $2); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| '!' expr %prec UNARY
|
|
|
|
|
{
|
|
|
|
|
/* Note that we provide a Rust-specific evaluator
|
|
|
|
|
override for UNOP_COMPLEMENT, so it can do the
|
|
|
|
|
right thing for both bool and integral
|
|
|
|
|
values. */
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
$$ = parser->ast_unary (UNOP_COMPLEMENT, $2);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
| '*' expr %prec UNARY
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_unary (UNOP_IND, $2); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| '&' expr %prec UNARY
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_unary (UNOP_ADDR, $2); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| '&' KW_MUT expr %prec UNARY
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_unary (UNOP_ADDR, $3); }
|
2018-03-07 04:27:12 +08:00
|
|
|
|
| KW_SIZEOF '(' expr ')' %prec UNARY
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_unary (UNOP_SIZEOF, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
binop_expr:
|
|
|
|
|
binop_expr_expr
|
|
|
|
|
| type_cast_expr
|
|
|
|
|
| assignment_expr
|
|
|
|
|
| compound_assignment_expr
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
binop_expr_expr:
|
|
|
|
|
expr '*' expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_MUL, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| expr '@' expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_REPEAT, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| expr '/' expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_DIV, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| expr '%' expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_REM, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| expr '<' expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_LESS, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| expr '>' expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_GTR, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| expr '&' expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_BITWISE_AND, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| expr '|' expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_BITWISE_IOR, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| expr '^' expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_BITWISE_XOR, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| expr '+' expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_ADD, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| expr '-' expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_SUB, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| expr OROR expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_LOGICAL_OR, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| expr ANDAND expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_LOGICAL_AND, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| expr EQEQ expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_EQUAL, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| expr NOTEQ expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_NOTEQUAL, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| expr LTEQ expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_LEQ, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| expr GTEQ expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_GEQ, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| expr LSH expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_LSH, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
| expr RSH expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_RSH, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
type_cast_expr:
|
|
|
|
|
expr KW_AS type
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_cast ($1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
assignment_expr:
|
|
|
|
|
expr '=' expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_operation (BINOP_ASSIGN, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
compound_assignment_expr:
|
|
|
|
|
expr COMPOUND_ASSIGN expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_compound_assignment ($2, $1, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
paren_expr:
|
|
|
|
|
'(' expr ')'
|
|
|
|
|
{ $$ = $2; }
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
expr_list:
|
|
|
|
|
expr
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
$$ = parser->new_op_vector ();
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
$$->push_back ($1);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
| expr_list ',' expr
|
|
|
|
|
{
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
$1->push_back ($3);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
$$ = $1;
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
maybe_expr_list:
|
|
|
|
|
/* %empty */
|
|
|
|
|
{
|
|
|
|
|
/* The result can't be NULL. */
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
$$ = parser->new_op_vector ();
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
| expr_list
|
|
|
|
|
{ $$ = $1; }
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
paren_expr_list:
|
2018-03-07 04:27:12 +08:00
|
|
|
|
'(' maybe_expr_list ')'
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{ $$ = $2; }
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
call_expr:
|
|
|
|
|
expr paren_expr_list
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_call_ish (OP_FUNCALL, $1, $2); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
maybe_self_path:
|
|
|
|
|
/* %empty */
|
|
|
|
|
| KW_SELF COLONCOLON
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
super_path:
|
|
|
|
|
KW_SUPER COLONCOLON
|
|
|
|
|
{ $$ = 1; }
|
|
|
|
|
| super_path KW_SUPER COLONCOLON
|
|
|
|
|
{ $$ = $1 + 1; }
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
path_expr:
|
|
|
|
|
path_for_expr
|
|
|
|
|
{ $$ = $1; }
|
|
|
|
|
| GDBVAR
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_path ($1, NULL); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| KW_SELF
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_path (make_stoken ("self"), NULL); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
path_for_expr:
|
|
|
|
|
identifier_path_for_expr
|
|
|
|
|
| KW_SELF COLONCOLON identifier_path_for_expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->super_name ($3, 0); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| maybe_self_path super_path identifier_path_for_expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->super_name ($3, $2); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| COLONCOLON identifier_path_for_expr
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->crate_name ($2); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| KW_EXTERN identifier_path_for_expr
|
|
|
|
|
{
|
|
|
|
|
/* This is a gdb extension to make it possible to
|
|
|
|
|
refer to items in other crates. It just bypasses
|
|
|
|
|
adding the current crate to the front of the
|
|
|
|
|
name. */
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
$$ = parser->ast_path (parser->concat3 ("::",
|
|
|
|
|
$2->left.sval.ptr,
|
|
|
|
|
NULL),
|
|
|
|
|
$2->right.params);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
identifier_path_for_expr:
|
|
|
|
|
IDENT
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_path ($1, NULL); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| identifier_path_for_expr COLONCOLON IDENT
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
$$ = parser->ast_path (parser->concat3 ($1->left.sval.ptr,
|
|
|
|
|
"::", $3.ptr),
|
|
|
|
|
NULL);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
| identifier_path_for_expr COLONCOLON '<' type_list '>'
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_path ($1->left.sval, $4); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| identifier_path_for_expr COLONCOLON '<' type_list RSH
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
$$ = parser->ast_path ($1->left.sval, $4);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
rust_push_back ('>');
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
path_for_type:
|
|
|
|
|
identifier_path_for_type
|
|
|
|
|
| KW_SELF COLONCOLON identifier_path_for_type
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->super_name ($3, 0); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| maybe_self_path super_path identifier_path_for_type
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->super_name ($3, $2); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| COLONCOLON identifier_path_for_type
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->crate_name ($2); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| KW_EXTERN identifier_path_for_type
|
|
|
|
|
{
|
|
|
|
|
/* This is a gdb extension to make it possible to
|
|
|
|
|
refer to items in other crates. It just bypasses
|
|
|
|
|
adding the current crate to the front of the
|
|
|
|
|
name. */
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
$$ = parser->ast_path (parser->concat3 ("::",
|
|
|
|
|
$2->left.sval.ptr,
|
|
|
|
|
NULL),
|
|
|
|
|
$2->right.params);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
just_identifiers_for_type:
|
|
|
|
|
IDENT
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_path ($1, NULL); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| just_identifiers_for_type COLONCOLON IDENT
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
$$ = parser->ast_path (parser->concat3 ($1->left.sval.ptr,
|
|
|
|
|
"::", $3.ptr),
|
|
|
|
|
NULL);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
identifier_path_for_type:
|
|
|
|
|
just_identifiers_for_type
|
|
|
|
|
| just_identifiers_for_type '<' type_list '>'
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_path ($1->left.sval, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| just_identifiers_for_type '<' type_list RSH
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
$$ = parser->ast_path ($1->left.sval, $3);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
rust_push_back ('>');
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
type:
|
|
|
|
|
path_for_type
|
|
|
|
|
| '[' type ';' INTEGER ']'
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_array_type ($2, $4); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| '[' type ';' DECIMAL_INTEGER ']'
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_array_type ($2, $4); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| '&' '[' type ']'
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_slice_type ($3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| '&' type
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_reference_type ($2); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| '*' KW_MUT type
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_pointer_type ($3, 1); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| '*' KW_CONST type
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_pointer_type ($3, 0); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| KW_FN '(' maybe_type_list ')' ARROW type
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_function_type ($6, $3); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
| '(' maybe_type_list ')'
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
{ $$ = parser->ast_tuple_type ($2); }
|
2016-04-27 09:38:08 +08:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
maybe_type_list:
|
|
|
|
|
/* %empty */
|
|
|
|
|
{ $$ = NULL; }
|
|
|
|
|
| type_list
|
|
|
|
|
{ $$ = $1; }
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
type_list:
|
|
|
|
|
type
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rust_op_vector *result = parser->new_op_vector ();
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
result->push_back ($1);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
$$ = result;
|
|
|
|
|
}
|
|
|
|
|
| type_list ',' type
|
|
|
|
|
{
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
$1->push_back ($3);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
$$ = $1;
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
|
|
/* A struct of this type is used to describe a token. */
|
|
|
|
|
|
|
|
|
|
struct token_info
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
int value;
|
|
|
|
|
enum exp_opcode opcode;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Identifier tokens. */
|
|
|
|
|
|
|
|
|
|
static const struct token_info identifier_tokens[] =
|
|
|
|
|
{
|
|
|
|
|
{ "as", KW_AS, OP_NULL },
|
|
|
|
|
{ "false", KW_FALSE, OP_NULL },
|
|
|
|
|
{ "if", 0, OP_NULL },
|
|
|
|
|
{ "mut", KW_MUT, OP_NULL },
|
|
|
|
|
{ "const", KW_CONST, OP_NULL },
|
|
|
|
|
{ "self", KW_SELF, OP_NULL },
|
|
|
|
|
{ "super", KW_SUPER, OP_NULL },
|
|
|
|
|
{ "true", KW_TRUE, OP_NULL },
|
|
|
|
|
{ "extern", KW_EXTERN, OP_NULL },
|
|
|
|
|
{ "fn", KW_FN, OP_NULL },
|
2016-10-29 20:55:58 +08:00
|
|
|
|
{ "sizeof", KW_SIZEOF, OP_NULL },
|
2016-04-27 09:38:08 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Operator tokens, sorted longest first. */
|
|
|
|
|
|
|
|
|
|
static const struct token_info operator_tokens[] =
|
|
|
|
|
{
|
|
|
|
|
{ ">>=", COMPOUND_ASSIGN, BINOP_RSH },
|
|
|
|
|
{ "<<=", COMPOUND_ASSIGN, BINOP_LSH },
|
|
|
|
|
|
|
|
|
|
{ "<<", LSH, OP_NULL },
|
|
|
|
|
{ ">>", RSH, OP_NULL },
|
|
|
|
|
{ "&&", ANDAND, OP_NULL },
|
|
|
|
|
{ "||", OROR, OP_NULL },
|
|
|
|
|
{ "==", EQEQ, OP_NULL },
|
|
|
|
|
{ "!=", NOTEQ, OP_NULL },
|
|
|
|
|
{ "<=", LTEQ, OP_NULL },
|
|
|
|
|
{ ">=", GTEQ, OP_NULL },
|
|
|
|
|
{ "+=", COMPOUND_ASSIGN, BINOP_ADD },
|
|
|
|
|
{ "-=", COMPOUND_ASSIGN, BINOP_SUB },
|
|
|
|
|
{ "*=", COMPOUND_ASSIGN, BINOP_MUL },
|
|
|
|
|
{ "/=", COMPOUND_ASSIGN, BINOP_DIV },
|
|
|
|
|
{ "%=", COMPOUND_ASSIGN, BINOP_REM },
|
|
|
|
|
{ "&=", COMPOUND_ASSIGN, BINOP_BITWISE_AND },
|
|
|
|
|
{ "|=", COMPOUND_ASSIGN, BINOP_BITWISE_IOR },
|
|
|
|
|
{ "^=", COMPOUND_ASSIGN, BINOP_BITWISE_XOR },
|
2018-03-30 04:14:07 +08:00
|
|
|
|
{ "..=", DOTDOTEQ, OP_NULL },
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
{ "::", COLONCOLON, OP_NULL },
|
|
|
|
|
{ "..", DOTDOT, OP_NULL },
|
|
|
|
|
{ "->", ARROW, OP_NULL }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Helper function to copy to the name obstack. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const char *
|
|
|
|
|
rust_parser::copy_name (const char *name, int len)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
return (const char *) obstack_copy0 (&obstack, name, len);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper function to make an stoken from a C string. */
|
|
|
|
|
|
|
|
|
|
static struct stoken
|
|
|
|
|
make_stoken (const char *p)
|
|
|
|
|
{
|
|
|
|
|
struct stoken result;
|
|
|
|
|
|
|
|
|
|
result.ptr = p;
|
|
|
|
|
result.length = strlen (result.ptr);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper function to concatenate three strings on the name
|
|
|
|
|
obstack. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
struct stoken
|
|
|
|
|
rust_parser::concat3 (const char *s1, const char *s2, const char *s3)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
return make_stoken (obconcat (&obstack, s1, s2, s3, (char *) NULL));
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return an AST node referring to NAME, but relative to the crate's
|
|
|
|
|
name. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::crate_name (const struct rust_op *name)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
2019-03-25 01:20:05 +08:00
|
|
|
|
std::string crate = rust_crate_for_block (pstate->expression_context_block);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
struct stoken result;
|
|
|
|
|
|
|
|
|
|
gdb_assert (name->opcode == OP_VAR_VALUE);
|
|
|
|
|
|
2017-02-03 11:58:12 +08:00
|
|
|
|
if (crate.empty ())
|
2016-04-27 09:38:08 +08:00
|
|
|
|
error (_("Could not find crate for current location"));
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
result = make_stoken (obconcat (&obstack, "::", crate.c_str (), "::",
|
2016-04-27 09:38:08 +08:00
|
|
|
|
name->left.sval.ptr, (char *) NULL));
|
|
|
|
|
|
|
|
|
|
return ast_path (result, name->right.params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create an AST node referring to a "super::" qualified name. IDENT
|
|
|
|
|
is the base name and N_SUPERS is how many "super::"s were
|
|
|
|
|
provided. N_SUPERS can be zero. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::super_name (const struct rust_op *ident, unsigned int n_supers)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
2019-03-25 01:20:05 +08:00
|
|
|
|
const char *scope = block_scope (pstate->expression_context_block);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
int offset;
|
|
|
|
|
|
|
|
|
|
gdb_assert (ident->opcode == OP_VAR_VALUE);
|
|
|
|
|
|
|
|
|
|
if (scope[0] == '\0')
|
|
|
|
|
error (_("Couldn't find namespace scope for self::"));
|
|
|
|
|
|
|
|
|
|
if (n_supers > 0)
|
|
|
|
|
{
|
|
|
|
|
int len;
|
2016-11-09 11:32:50 +08:00
|
|
|
|
std::vector<int> offsets;
|
2016-06-07 04:18:30 +08:00
|
|
|
|
unsigned int current_len;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
current_len = cp_find_first_component (scope);
|
|
|
|
|
while (scope[current_len] != '\0')
|
|
|
|
|
{
|
2016-11-09 11:32:50 +08:00
|
|
|
|
offsets.push_back (current_len);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
gdb_assert (scope[current_len] == ':');
|
|
|
|
|
/* The "::". */
|
|
|
|
|
current_len += 2;
|
|
|
|
|
current_len += cp_find_first_component (scope
|
|
|
|
|
+ current_len);
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-09 11:32:50 +08:00
|
|
|
|
len = offsets.size ();
|
2016-04-27 09:38:08 +08:00
|
|
|
|
if (n_supers >= len)
|
|
|
|
|
error (_("Too many super:: uses from '%s'"), scope);
|
|
|
|
|
|
2016-11-09 11:32:50 +08:00
|
|
|
|
offset = offsets[len - n_supers];
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
offset = strlen (scope);
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
obstack_grow (&obstack, "::", 2);
|
|
|
|
|
obstack_grow (&obstack, scope, offset);
|
|
|
|
|
obstack_grow (&obstack, "::", 2);
|
|
|
|
|
obstack_grow0 (&obstack, ident->left.sval.ptr, ident->left.sval.length);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
return ast_path (make_stoken ((const char *) obstack_finish (&obstack)),
|
2016-04-27 09:38:08 +08:00
|
|
|
|
ident->right.params);
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-19 02:53:21 +08:00
|
|
|
|
/* A helper that updates the innermost block as appropriate. */
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
update_innermost_block (struct block_symbol sym)
|
|
|
|
|
{
|
2017-10-19 02:53:21 +08:00
|
|
|
|
if (symbol_read_needs_frame (sym.symbol))
|
|
|
|
|
innermost_block.update (sym);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Lex a hex number with at least MIN digits and at most MAX
|
|
|
|
|
digits. */
|
|
|
|
|
|
|
|
|
|
static uint32_t
|
|
|
|
|
lex_hex (int min, int max)
|
|
|
|
|
{
|
|
|
|
|
uint32_t result = 0;
|
|
|
|
|
int len = 0;
|
|
|
|
|
/* We only want to stop at MAX if we're lexing a byte escape. */
|
|
|
|
|
int check_max = min == max;
|
|
|
|
|
|
|
|
|
|
while ((check_max ? len <= max : 1)
|
|
|
|
|
&& ((lexptr[0] >= 'a' && lexptr[0] <= 'f')
|
|
|
|
|
|| (lexptr[0] >= 'A' && lexptr[0] <= 'F')
|
|
|
|
|
|| (lexptr[0] >= '0' && lexptr[0] <= '9')))
|
|
|
|
|
{
|
|
|
|
|
result *= 16;
|
|
|
|
|
if (lexptr[0] >= 'a' && lexptr[0] <= 'f')
|
|
|
|
|
result = result + 10 + lexptr[0] - 'a';
|
|
|
|
|
else if (lexptr[0] >= 'A' && lexptr[0] <= 'F')
|
|
|
|
|
result = result + 10 + lexptr[0] - 'A';
|
|
|
|
|
else
|
|
|
|
|
result = result + lexptr[0] - '0';
|
|
|
|
|
++lexptr;
|
|
|
|
|
++len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (len < min)
|
|
|
|
|
error (_("Not enough hex digits seen"));
|
|
|
|
|
if (len > max)
|
|
|
|
|
{
|
|
|
|
|
gdb_assert (min != max);
|
|
|
|
|
error (_("Overlong hex escape"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Lex an escape. IS_BYTE is true if we're lexing a byte escape;
|
|
|
|
|
otherwise we're lexing a character escape. */
|
|
|
|
|
|
|
|
|
|
static uint32_t
|
|
|
|
|
lex_escape (int is_byte)
|
|
|
|
|
{
|
|
|
|
|
uint32_t result;
|
|
|
|
|
|
|
|
|
|
gdb_assert (lexptr[0] == '\\');
|
|
|
|
|
++lexptr;
|
|
|
|
|
switch (lexptr[0])
|
|
|
|
|
{
|
|
|
|
|
case 'x':
|
|
|
|
|
++lexptr;
|
|
|
|
|
result = lex_hex (2, 2);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'u':
|
|
|
|
|
if (is_byte)
|
|
|
|
|
error (_("Unicode escape in byte literal"));
|
|
|
|
|
++lexptr;
|
|
|
|
|
if (lexptr[0] != '{')
|
|
|
|
|
error (_("Missing '{' in Unicode escape"));
|
|
|
|
|
++lexptr;
|
|
|
|
|
result = lex_hex (1, 6);
|
|
|
|
|
/* Could do range checks here. */
|
|
|
|
|
if (lexptr[0] != '}')
|
|
|
|
|
error (_("Missing '}' in Unicode escape"));
|
|
|
|
|
++lexptr;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'n':
|
|
|
|
|
result = '\n';
|
|
|
|
|
++lexptr;
|
|
|
|
|
break;
|
|
|
|
|
case 'r':
|
|
|
|
|
result = '\r';
|
|
|
|
|
++lexptr;
|
|
|
|
|
break;
|
|
|
|
|
case 't':
|
|
|
|
|
result = '\t';
|
|
|
|
|
++lexptr;
|
|
|
|
|
break;
|
|
|
|
|
case '\\':
|
|
|
|
|
result = '\\';
|
|
|
|
|
++lexptr;
|
|
|
|
|
break;
|
|
|
|
|
case '0':
|
|
|
|
|
result = '\0';
|
|
|
|
|
++lexptr;
|
|
|
|
|
break;
|
|
|
|
|
case '\'':
|
|
|
|
|
result = '\'';
|
|
|
|
|
++lexptr;
|
|
|
|
|
break;
|
|
|
|
|
case '"':
|
|
|
|
|
result = '"';
|
|
|
|
|
++lexptr;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
error (_("Invalid escape \\%c in literal"), lexptr[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Lex a character constant. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
int
|
|
|
|
|
rust_parser::lex_character (YYSTYPE *lvalp)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
int is_byte = 0;
|
|
|
|
|
uint32_t value;
|
|
|
|
|
|
|
|
|
|
if (lexptr[0] == 'b')
|
|
|
|
|
{
|
|
|
|
|
is_byte = 1;
|
|
|
|
|
++lexptr;
|
|
|
|
|
}
|
|
|
|
|
gdb_assert (lexptr[0] == '\'');
|
|
|
|
|
++lexptr;
|
|
|
|
|
/* This should handle UTF-8 here. */
|
|
|
|
|
if (lexptr[0] == '\\')
|
|
|
|
|
value = lex_escape (is_byte);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
value = lexptr[0] & 0xff;
|
|
|
|
|
++lexptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (lexptr[0] != '\'')
|
|
|
|
|
error (_("Unterminated character literal"));
|
|
|
|
|
++lexptr;
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
lvalp->typed_val_int.val = value;
|
|
|
|
|
lvalp->typed_val_int.type = get_type (is_byte ? "u8" : "char");
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
return INTEGER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return the offset of the double quote if STR looks like the start
|
|
|
|
|
of a raw string, or 0 if STR does not start a raw string. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
starts_raw_string (const char *str)
|
|
|
|
|
{
|
|
|
|
|
const char *save = str;
|
|
|
|
|
|
|
|
|
|
if (str[0] != 'r')
|
|
|
|
|
return 0;
|
|
|
|
|
++str;
|
|
|
|
|
while (str[0] == '#')
|
|
|
|
|
++str;
|
|
|
|
|
if (str[0] == '"')
|
|
|
|
|
return str - save;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return true if STR looks like the end of a raw string that had N
|
|
|
|
|
hashes at the start. */
|
|
|
|
|
|
2017-02-03 12:21:19 +08:00
|
|
|
|
static bool
|
2016-04-27 09:38:08 +08:00
|
|
|
|
ends_raw_string (const char *str, int n)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
gdb_assert (str[0] == '"');
|
|
|
|
|
for (i = 0; i < n; ++i)
|
|
|
|
|
if (str[i + 1] != '#')
|
2017-02-03 12:21:19 +08:00
|
|
|
|
return false;
|
|
|
|
|
return true;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Lex a string constant. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
int
|
|
|
|
|
rust_parser::lex_string (YYSTYPE *lvalp)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
int is_byte = lexptr[0] == 'b';
|
|
|
|
|
int raw_length;
|
|
|
|
|
|
|
|
|
|
if (is_byte)
|
|
|
|
|
++lexptr;
|
|
|
|
|
raw_length = starts_raw_string (lexptr);
|
|
|
|
|
lexptr += raw_length;
|
|
|
|
|
gdb_assert (lexptr[0] == '"');
|
|
|
|
|
++lexptr;
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
uint32_t value;
|
|
|
|
|
|
|
|
|
|
if (raw_length > 0)
|
|
|
|
|
{
|
|
|
|
|
if (lexptr[0] == '"' && ends_raw_string (lexptr, raw_length - 1))
|
|
|
|
|
{
|
|
|
|
|
/* Exit with lexptr pointing after the final "#". */
|
|
|
|
|
lexptr += raw_length;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (lexptr[0] == '\0')
|
|
|
|
|
error (_("Unexpected EOF in string"));
|
|
|
|
|
|
|
|
|
|
value = lexptr[0] & 0xff;
|
|
|
|
|
if (is_byte && value > 127)
|
|
|
|
|
error (_("Non-ASCII value in raw byte string"));
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
obstack_1grow (&obstack, value);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
++lexptr;
|
|
|
|
|
}
|
|
|
|
|
else if (lexptr[0] == '"')
|
|
|
|
|
{
|
|
|
|
|
/* Make sure to skip the quote. */
|
|
|
|
|
++lexptr;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (lexptr[0] == '\\')
|
|
|
|
|
{
|
|
|
|
|
value = lex_escape (is_byte);
|
|
|
|
|
|
|
|
|
|
if (is_byte)
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
obstack_1grow (&obstack, value);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
else
|
|
|
|
|
convert_between_encodings ("UTF-32", "UTF-8", (gdb_byte *) &value,
|
|
|
|
|
sizeof (value), sizeof (value),
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
&obstack, translit_none);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
else if (lexptr[0] == '\0')
|
|
|
|
|
error (_("Unexpected EOF in string"));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
value = lexptr[0] & 0xff;
|
|
|
|
|
if (is_byte && value > 127)
|
|
|
|
|
error (_("Non-ASCII value in byte string"));
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
obstack_1grow (&obstack, value);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
++lexptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
lvalp->sval.length = obstack_object_size (&obstack);
|
|
|
|
|
lvalp->sval.ptr = (const char *) obstack_finish (&obstack);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
return is_byte ? BYTESTRING : STRING;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return true if STRING starts with whitespace followed by a digit. */
|
|
|
|
|
|
2017-02-03 12:21:19 +08:00
|
|
|
|
static bool
|
2016-04-27 09:38:08 +08:00
|
|
|
|
space_then_number (const char *string)
|
|
|
|
|
{
|
|
|
|
|
const char *p = string;
|
|
|
|
|
|
|
|
|
|
while (p[0] == ' ' || p[0] == '\t')
|
|
|
|
|
++p;
|
|
|
|
|
if (p == string)
|
2017-02-03 12:21:19 +08:00
|
|
|
|
return false;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
return *p >= '0' && *p <= '9';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return true if C can start an identifier. */
|
|
|
|
|
|
2017-02-03 12:21:19 +08:00
|
|
|
|
static bool
|
2016-04-27 09:38:08 +08:00
|
|
|
|
rust_identifier_start_p (char c)
|
|
|
|
|
{
|
|
|
|
|
return ((c >= 'a' && c <= 'z')
|
|
|
|
|
|| (c >= 'A' && c <= 'Z')
|
|
|
|
|
|| c == '_'
|
|
|
|
|
|| c == '$');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Lex an identifier. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
int
|
|
|
|
|
rust_parser::lex_identifier (YYSTYPE *lvalp)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
const char *start = lexptr;
|
|
|
|
|
unsigned int length;
|
|
|
|
|
const struct token_info *token;
|
|
|
|
|
int i;
|
|
|
|
|
int is_gdb_var = lexptr[0] == '$';
|
|
|
|
|
|
|
|
|
|
gdb_assert (rust_identifier_start_p (lexptr[0]));
|
|
|
|
|
|
|
|
|
|
++lexptr;
|
|
|
|
|
|
|
|
|
|
/* For the time being this doesn't handle Unicode rules. Non-ASCII
|
|
|
|
|
identifiers are gated anyway. */
|
|
|
|
|
while ((lexptr[0] >= 'a' && lexptr[0] <= 'z')
|
|
|
|
|
|| (lexptr[0] >= 'A' && lexptr[0] <= 'Z')
|
|
|
|
|
|| lexptr[0] == '_'
|
|
|
|
|
|| (is_gdb_var && lexptr[0] == '$')
|
|
|
|
|
|| (lexptr[0] >= '0' && lexptr[0] <= '9'))
|
|
|
|
|
++lexptr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
length = lexptr - start;
|
|
|
|
|
token = NULL;
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE (identifier_tokens); ++i)
|
|
|
|
|
{
|
|
|
|
|
if (length == strlen (identifier_tokens[i].name)
|
|
|
|
|
&& strncmp (identifier_tokens[i].name, start, length) == 0)
|
|
|
|
|
{
|
|
|
|
|
token = &identifier_tokens[i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (token != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (token->value == 0)
|
|
|
|
|
{
|
|
|
|
|
/* Leave the terminating token alone. */
|
|
|
|
|
lexptr = start;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (token == NULL
|
|
|
|
|
&& (strncmp (start, "thread", length) == 0
|
|
|
|
|
|| strncmp (start, "task", length) == 0)
|
|
|
|
|
&& space_then_number (lexptr))
|
|
|
|
|
{
|
|
|
|
|
/* "task" or "thread" followed by a number terminates the
|
|
|
|
|
parse, per gdb rules. */
|
|
|
|
|
lexptr = start;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (token == NULL || (parse_completion && lexptr[0] == '\0'))
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
lvalp->sval = make_stoken (copy_name (start, length));
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
if (parse_completion && lexptr[0] == '\0')
|
|
|
|
|
{
|
|
|
|
|
/* Prevent rustyylex from returning two COMPLETE tokens. */
|
|
|
|
|
prev_lexptr = lexptr;
|
|
|
|
|
return COMPLETE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (token != NULL)
|
|
|
|
|
return token->value;
|
|
|
|
|
if (is_gdb_var)
|
|
|
|
|
return GDBVAR;
|
|
|
|
|
return IDENT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Lex an operator. */
|
|
|
|
|
|
|
|
|
|
static int
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
lex_operator (YYSTYPE *lvalp)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
const struct token_info *token = NULL;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE (operator_tokens); ++i)
|
|
|
|
|
{
|
|
|
|
|
if (strncmp (operator_tokens[i].name, lexptr,
|
|
|
|
|
strlen (operator_tokens[i].name)) == 0)
|
|
|
|
|
{
|
|
|
|
|
lexptr += strlen (operator_tokens[i].name);
|
|
|
|
|
token = &operator_tokens[i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (token != NULL)
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
lvalp->opcode = token->opcode;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
return token->value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return *lexptr++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Lex a number. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
int
|
|
|
|
|
rust_parser::lex_number (YYSTYPE *lvalp)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
regmatch_t subexps[NUM_SUBEXPRESSIONS];
|
|
|
|
|
int match;
|
|
|
|
|
int is_integer = 0;
|
|
|
|
|
int could_be_decimal = 1;
|
2016-05-19 07:22:30 +08:00
|
|
|
|
int implicit_i32 = 0;
|
2016-11-09 11:32:50 +08:00
|
|
|
|
const char *type_name = NULL;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
struct type *type;
|
|
|
|
|
int end_index;
|
|
|
|
|
int type_index = -1;
|
2016-11-09 11:32:50 +08:00
|
|
|
|
int i;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
match = regexec (&number_regex, lexptr, ARRAY_SIZE (subexps), subexps, 0);
|
|
|
|
|
/* Failure means the regexp is broken. */
|
|
|
|
|
gdb_assert (match == 0);
|
|
|
|
|
|
|
|
|
|
if (subexps[INT_TEXT].rm_so != -1)
|
|
|
|
|
{
|
|
|
|
|
/* Integer part matched. */
|
|
|
|
|
is_integer = 1;
|
|
|
|
|
end_index = subexps[INT_TEXT].rm_eo;
|
|
|
|
|
if (subexps[INT_TYPE].rm_so == -1)
|
2016-05-19 07:22:30 +08:00
|
|
|
|
{
|
|
|
|
|
type_name = "i32";
|
|
|
|
|
implicit_i32 = 1;
|
|
|
|
|
}
|
2016-04-27 09:38:08 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
type_index = INT_TYPE;
|
|
|
|
|
could_be_decimal = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (subexps[FLOAT_TYPE1].rm_so != -1)
|
|
|
|
|
{
|
|
|
|
|
/* Found floating point type suffix. */
|
|
|
|
|
end_index = subexps[FLOAT_TYPE1].rm_so;
|
|
|
|
|
type_index = FLOAT_TYPE1;
|
|
|
|
|
}
|
|
|
|
|
else if (subexps[FLOAT_TYPE2].rm_so != -1)
|
|
|
|
|
{
|
|
|
|
|
/* Found floating point type suffix. */
|
|
|
|
|
end_index = subexps[FLOAT_TYPE2].rm_so;
|
|
|
|
|
type_index = FLOAT_TYPE2;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Any other floating point match. */
|
|
|
|
|
end_index = subexps[0].rm_eo;
|
|
|
|
|
type_name = "f64";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We need a special case if the final character is ".". In this
|
|
|
|
|
case we might need to parse an integer. For example, "23.f()" is
|
|
|
|
|
a request for a trait method call, not a syntax error involving
|
|
|
|
|
the floating point number "23.". */
|
|
|
|
|
gdb_assert (subexps[0].rm_eo > 0);
|
|
|
|
|
if (lexptr[subexps[0].rm_eo - 1] == '.')
|
|
|
|
|
{
|
Rename _const functions to use overloading instead
This renames a few functions -- skip_spaces_const,
skip_to_space_const, get_number_const, extract_arg_const -- to drop
the "_const" suffix and instead rely on overloading.
This makes future const fixes simpler by reducing the number of lines
that must be changed. I think it is also not any less clear, as all
these functions have the same interface as their non-const versions by
design. Furthermore there's an example of using an overload in-tree
already, namely check_for_argument.
This patch was largely created using some perl one-liners; then a few
fixes were applied by hand.
ChangeLog
2017-09-11 Tom Tromey <tom@tromey.com>
* common/common-utils.h (skip_to_space): Remove macro, redeclare
as function.
(skip_to_space): Rename from skip_to_space_const.
* common/common-utils.c (skip_to_space): New function.
(skip_to_space): Rename from skip_to_space_const.
* cli/cli-utils.h (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
* cli/cli-utils.c (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
(number_or_range_parser::get_number): Use ::get_number.
* aarch64-linux-tdep.c, ada-lang.c, arm-linux-tdep.c, ax-gdb.c,
break-catch-throw.c, breakpoint.c, cli/cli-cmds.c, cli/cli-dump.c,
cli/cli-script.c, cli/cli-setshow.c, compile/compile.c,
completer.c, demangle.c, disasm.c, findcmd.c, linespec.c,
linux-tdep.c, linux-thread-db.c, location.c, mi/mi-parse.c,
minsyms.c, nat/linux-procfs.c, printcmd.c, probe.c,
python/py-breakpoint.c, record.c, rust-exp.y, serial.c, stack.c,
stap-probe.c, tid-parse.c, tracepoint.c: Update all callers.
2017-09-11 04:19:19 +08:00
|
|
|
|
const char *next = skip_spaces (&lexptr[subexps[0].rm_eo]);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
if (rust_identifier_start_p (*next) || *next == '.')
|
|
|
|
|
{
|
|
|
|
|
--subexps[0].rm_eo;
|
|
|
|
|
is_integer = 1;
|
|
|
|
|
end_index = subexps[0].rm_eo;
|
|
|
|
|
type_name = "i32";
|
|
|
|
|
could_be_decimal = 1;
|
2016-05-19 07:22:30 +08:00
|
|
|
|
implicit_i32 = 1;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Compute the type name if we haven't already. */
|
2016-11-09 11:32:50 +08:00
|
|
|
|
std::string type_name_holder;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
if (type_name == NULL)
|
|
|
|
|
{
|
|
|
|
|
gdb_assert (type_index != -1);
|
2016-11-09 11:32:50 +08:00
|
|
|
|
type_name_holder = std::string (lexptr + subexps[type_index].rm_so,
|
|
|
|
|
(subexps[type_index].rm_eo
|
|
|
|
|
- subexps[type_index].rm_so));
|
|
|
|
|
type_name = type_name_holder.c_str ();
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Look up the type. */
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
type = get_type (type_name);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
/* Copy the text of the number and remove the "_"s. */
|
2016-11-09 11:32:50 +08:00
|
|
|
|
std::string number;
|
|
|
|
|
for (i = 0; i < end_index && lexptr[i]; ++i)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
2016-11-09 11:32:50 +08:00
|
|
|
|
if (lexptr[i] == '_')
|
2016-04-27 09:38:08 +08:00
|
|
|
|
could_be_decimal = 0;
|
|
|
|
|
else
|
2016-11-09 11:32:50 +08:00
|
|
|
|
number.push_back (lexptr[i]);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Advance past the match. */
|
|
|
|
|
lexptr += subexps[0].rm_eo;
|
|
|
|
|
|
|
|
|
|
/* Parse the number. */
|
|
|
|
|
if (is_integer)
|
|
|
|
|
{
|
2016-05-19 07:22:30 +08:00
|
|
|
|
uint64_t value;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
int radix = 10;
|
2016-11-09 11:32:50 +08:00
|
|
|
|
int offset = 0;
|
|
|
|
|
|
2016-04-27 09:38:08 +08:00
|
|
|
|
if (number[0] == '0')
|
|
|
|
|
{
|
|
|
|
|
if (number[1] == 'x')
|
|
|
|
|
radix = 16;
|
|
|
|
|
else if (number[1] == 'o')
|
|
|
|
|
radix = 8;
|
|
|
|
|
else if (number[1] == 'b')
|
|
|
|
|
radix = 2;
|
|
|
|
|
if (radix != 10)
|
|
|
|
|
{
|
2016-11-09 11:32:50 +08:00
|
|
|
|
offset = 2;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
could_be_decimal = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-05-19 07:22:30 +08:00
|
|
|
|
|
2016-11-09 11:32:50 +08:00
|
|
|
|
value = strtoul (number.c_str () + offset, NULL, radix);
|
2016-05-19 07:22:30 +08:00
|
|
|
|
if (implicit_i32 && value >= ((uint64_t) 1) << 31)
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
type = get_type ("i64");
|
2016-05-19 07:22:30 +08:00
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
lvalp->typed_val_int.val = value;
|
|
|
|
|
lvalp->typed_val_int.type = type;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
lvalp->typed_val_float.type = type;
|
Target FP: Use target format throughout expression parsing
When parsing floating-point literals, the language parsers currently
use parse_float or some equivalent routine to parse the input string
into a DOUBLEST, which is then stored within a OP_DOUBLE expression
node. When evaluating the expression, the OP_DOUBLE is finally
converted into a value in target format.
On the other hand, *decimal* floating-point literals are parsed
directly into target format and stored that way in a OP_DECFLOAT
expression node. In order to eliminate the DOUBLEST, this patch
therefore unifies the handling of binary and decimal floating-
point literals and stores them both in target format within a
new OP_FLOAT expression node, replacing both OP_DOUBLE and
OP_DECFLOAT.
In order to store literals in target format, the parse_float
routine needs to know the type of the literal. All parsers
therefore need to be changed to determine the appropriate type
(e.g. by detecting suffixes) *before* calling parse_float,
instead of after it as today. However, this change is mostly
straightforward -- again, this is already done for decimal FP
today.
The core of the literal parsing is moved into a new routine
floatformat_from_string, mirroring floatformat_to_string.
The parse_float routine now calls either floatformat_from_string
or decimal_from_sting, allowing it to handle any type of FP
literal.
All language parsers need to be updated. Some notes on
specific changes to the various languages:
- C: Decimal FP is now handled in parse_float, and no longer
needs to be handled specially.
- D: Straightforward.
- Fortran: Still used a hard-coded "atof", also replaced by
parse_float now. Continues to always use builtin_real_s8
as the type of literal, even though this is probably wrong.
- Go: This used to handle "f" and "l" suffixes, even though
the Go language actually doesn't support those. I kept this
support for now -- maybe revisit later. Note the the GDB
test suite for some reason actually *verifies* that GDB supports
those unsupported suffixes ...
- Pascal: Likewise -- this handles suffixes that are not
supported in the language standard.
- Modula-2: Like Fortran, used to use "atof".
- Rust: Mostly straightforward, except for a unit-testing hitch.
The code use to set a special "unit_testing" flag which would
cause "rust_type" to always return NULL. This makes it not
possible to encode a literal into target format (which type?).
The reason for this flag appears to have been that during
unit testing, there is no "rust_parser" context set up, which
means no "gdbarch" is available to use its types. To fix this,
I removed the unit_testing flag, and instead simply just set up
a dummy rust_parser context during unit testing.
- Ada: This used to check sizeof (DOUBLEST) to determine which
type to use for floating-point literal. This seems questionable
to begin with (since DOUBLEST is quite unrelated to target formats),
and in any case we need to get rid of DOUBLEST. I'm now simply
always using the largest type (builtin_long_double).
gdb/ChangeLog:
2017-10-25 Ulrich Weigand <uweigand@de.ibm.com>
* doublest.c (floatformat_from_string): New function.
* doublest.h (floatformat_from_string): Add prototype.
* std-operator.def (OP_DOUBLE, OP_DECFLOAT): Remove, replace by ...
(OP_FLOAT): ... this.
* expression.h: Do not include "doublest.h".
(union exp_element): Replace doubleconst and decfloatconst by
new element floatconst.
* ada-lang.c (resolve_subexp): Handle OP_FLOAT instead of OP_DOUBLE.
(ada_evaluate_subexp): Likewise.
* eval.c (evaluate_subexp_standard): Handle OP_FLOAT instead of
OP_DOUBLE and OP_DECFLOAT.
* expprint.c (print_subexp_standard): Likewise.
(dump_subexp_body_standard): Likewise.
* breakpoint.c (watchpoint_exp_is_const): Likewise.
* parse.c: Include "dfp.h".
(write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove.
(write_exp_elt_floatcst): New function.
(operator_length_standard): Handle OP_FLOAT instead of OP_DOUBLE
and OP_DECFLOAT.
(operator_check_standard): Likewise.
(parse_float): Do not accept suffix. Take type as input. Return bool.
Return target format buffer instead of host DOUBLEST.
Use floatformat_from_string and decimal_from_string to parse
either binary or decimal floating-point types.
(parse_c_float): Remove.
* parser-defs.h: Do not include "doublest.h".
(write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove.
(write_exp_elt_floatcst): Add prototype.
(parse_float): Update prototype.
(parse_c_float): Remove.
* c-exp.y: Do not include "dfp.h".
(typed_val_float): Use byte buffer instead of DOUBLEST.
(typed_val_decfloat): Remove.
(DECFLOAT): Remove.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
Handle decimal and binary FP types the same way.
* d-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT_LITERAL): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
* f-exp.y: Replace dval by typed_val_float.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Use parse_float instead of atof.
* go-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(parse_go_float): Remove.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Call parse_float instead of parse_go_float.
Parse suffixes and determine type before calling parse_float.
* p-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
* m2-exp.y: Replace dval by byte buffer val.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Call parse_float instead of atof.
* rust-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(lex_number): Call parse_float instead of strtod.
(ast_dliteral): Use OP_FLOAT instead of OP_DOUBLE.
(convert_ast_to_expression): Handle OP_FLOAT instead of OP_DOUBLE.
Use write_exp_elt_floatcst.
(unit_testing): Remove static variable.
(rust_type): Do not check unit_testing.
(rust_lex_tests): Do not set uint_testing. Set up dummy rust_parser.
* ada-exp.y (type_float, type_double): Remove.
(typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
* ada-lex.l (processReal): Use parse_float instead of sscanf.
2017-10-25 21:32:23 +08:00
|
|
|
|
bool parsed = parse_float (number.c_str (), number.length (),
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
lvalp->typed_val_float.type,
|
|
|
|
|
lvalp->typed_val_float.val);
|
Target FP: Use target format throughout expression parsing
When parsing floating-point literals, the language parsers currently
use parse_float or some equivalent routine to parse the input string
into a DOUBLEST, which is then stored within a OP_DOUBLE expression
node. When evaluating the expression, the OP_DOUBLE is finally
converted into a value in target format.
On the other hand, *decimal* floating-point literals are parsed
directly into target format and stored that way in a OP_DECFLOAT
expression node. In order to eliminate the DOUBLEST, this patch
therefore unifies the handling of binary and decimal floating-
point literals and stores them both in target format within a
new OP_FLOAT expression node, replacing both OP_DOUBLE and
OP_DECFLOAT.
In order to store literals in target format, the parse_float
routine needs to know the type of the literal. All parsers
therefore need to be changed to determine the appropriate type
(e.g. by detecting suffixes) *before* calling parse_float,
instead of after it as today. However, this change is mostly
straightforward -- again, this is already done for decimal FP
today.
The core of the literal parsing is moved into a new routine
floatformat_from_string, mirroring floatformat_to_string.
The parse_float routine now calls either floatformat_from_string
or decimal_from_sting, allowing it to handle any type of FP
literal.
All language parsers need to be updated. Some notes on
specific changes to the various languages:
- C: Decimal FP is now handled in parse_float, and no longer
needs to be handled specially.
- D: Straightforward.
- Fortran: Still used a hard-coded "atof", also replaced by
parse_float now. Continues to always use builtin_real_s8
as the type of literal, even though this is probably wrong.
- Go: This used to handle "f" and "l" suffixes, even though
the Go language actually doesn't support those. I kept this
support for now -- maybe revisit later. Note the the GDB
test suite for some reason actually *verifies* that GDB supports
those unsupported suffixes ...
- Pascal: Likewise -- this handles suffixes that are not
supported in the language standard.
- Modula-2: Like Fortran, used to use "atof".
- Rust: Mostly straightforward, except for a unit-testing hitch.
The code use to set a special "unit_testing" flag which would
cause "rust_type" to always return NULL. This makes it not
possible to encode a literal into target format (which type?).
The reason for this flag appears to have been that during
unit testing, there is no "rust_parser" context set up, which
means no "gdbarch" is available to use its types. To fix this,
I removed the unit_testing flag, and instead simply just set up
a dummy rust_parser context during unit testing.
- Ada: This used to check sizeof (DOUBLEST) to determine which
type to use for floating-point literal. This seems questionable
to begin with (since DOUBLEST is quite unrelated to target formats),
and in any case we need to get rid of DOUBLEST. I'm now simply
always using the largest type (builtin_long_double).
gdb/ChangeLog:
2017-10-25 Ulrich Weigand <uweigand@de.ibm.com>
* doublest.c (floatformat_from_string): New function.
* doublest.h (floatformat_from_string): Add prototype.
* std-operator.def (OP_DOUBLE, OP_DECFLOAT): Remove, replace by ...
(OP_FLOAT): ... this.
* expression.h: Do not include "doublest.h".
(union exp_element): Replace doubleconst and decfloatconst by
new element floatconst.
* ada-lang.c (resolve_subexp): Handle OP_FLOAT instead of OP_DOUBLE.
(ada_evaluate_subexp): Likewise.
* eval.c (evaluate_subexp_standard): Handle OP_FLOAT instead of
OP_DOUBLE and OP_DECFLOAT.
* expprint.c (print_subexp_standard): Likewise.
(dump_subexp_body_standard): Likewise.
* breakpoint.c (watchpoint_exp_is_const): Likewise.
* parse.c: Include "dfp.h".
(write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove.
(write_exp_elt_floatcst): New function.
(operator_length_standard): Handle OP_FLOAT instead of OP_DOUBLE
and OP_DECFLOAT.
(operator_check_standard): Likewise.
(parse_float): Do not accept suffix. Take type as input. Return bool.
Return target format buffer instead of host DOUBLEST.
Use floatformat_from_string and decimal_from_string to parse
either binary or decimal floating-point types.
(parse_c_float): Remove.
* parser-defs.h: Do not include "doublest.h".
(write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove.
(write_exp_elt_floatcst): Add prototype.
(parse_float): Update prototype.
(parse_c_float): Remove.
* c-exp.y: Do not include "dfp.h".
(typed_val_float): Use byte buffer instead of DOUBLEST.
(typed_val_decfloat): Remove.
(DECFLOAT): Remove.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
Handle decimal and binary FP types the same way.
* d-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT_LITERAL): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
* f-exp.y: Replace dval by typed_val_float.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Use parse_float instead of atof.
* go-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(parse_go_float): Remove.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Call parse_float instead of parse_go_float.
Parse suffixes and determine type before calling parse_float.
* p-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
* m2-exp.y: Replace dval by byte buffer val.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Call parse_float instead of atof.
* rust-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(lex_number): Call parse_float instead of strtod.
(ast_dliteral): Use OP_FLOAT instead of OP_DOUBLE.
(convert_ast_to_expression): Handle OP_FLOAT instead of OP_DOUBLE.
Use write_exp_elt_floatcst.
(unit_testing): Remove static variable.
(rust_type): Do not check unit_testing.
(rust_lex_tests): Do not set uint_testing. Set up dummy rust_parser.
* ada-exp.y (type_float, type_double): Remove.
(typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
* ada-lex.l (processReal): Use parse_float instead of sscanf.
2017-10-25 21:32:23 +08:00
|
|
|
|
gdb_assert (parsed);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return is_integer ? (could_be_decimal ? DECIMAL_INTEGER : INTEGER) : FLOAT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The lexer. */
|
|
|
|
|
|
|
|
|
|
static int
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rustyylex (YYSTYPE *lvalp, rust_parser *parser)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
/* Skip all leading whitespace. */
|
|
|
|
|
while (lexptr[0] == ' ' || lexptr[0] == '\t' || lexptr[0] == '\r'
|
|
|
|
|
|| lexptr[0] == '\n')
|
|
|
|
|
++lexptr;
|
|
|
|
|
|
|
|
|
|
/* If we hit EOF and we're completing, then return COMPLETE -- maybe
|
|
|
|
|
we're completing an empty string at the end of a field_expr.
|
|
|
|
|
But, we don't want to return two COMPLETE tokens in a row. */
|
|
|
|
|
if (lexptr[0] == '\0' && lexptr == prev_lexptr)
|
|
|
|
|
return 0;
|
|
|
|
|
prev_lexptr = lexptr;
|
|
|
|
|
if (lexptr[0] == '\0')
|
|
|
|
|
{
|
|
|
|
|
if (parse_completion)
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
lvalp->sval = make_stoken ("");
|
2016-04-27 09:38:08 +08:00
|
|
|
|
return COMPLETE;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (lexptr[0] >= '0' && lexptr[0] <= '9')
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
return parser->lex_number (lvalp);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
else if (lexptr[0] == 'b' && lexptr[1] == '\'')
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
return parser->lex_character (lvalp);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
else if (lexptr[0] == 'b' && lexptr[1] == '"')
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
return parser->lex_string (lvalp);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
else if (lexptr[0] == 'b' && starts_raw_string (lexptr + 1))
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
return parser->lex_string (lvalp);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
else if (starts_raw_string (lexptr))
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
return parser->lex_string (lvalp);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
else if (rust_identifier_start_p (lexptr[0]))
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
return parser->lex_identifier (lvalp);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
else if (lexptr[0] == '"')
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
return parser->lex_string (lvalp);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
else if (lexptr[0] == '\'')
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
return parser->lex_character (lvalp);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
else if (lexptr[0] == '}' || lexptr[0] == ']')
|
|
|
|
|
{
|
|
|
|
|
/* Falls through to lex_operator. */
|
2019-03-25 01:33:10 +08:00
|
|
|
|
--parser->paren_depth;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
else if (lexptr[0] == '(' || lexptr[0] == '{')
|
|
|
|
|
{
|
|
|
|
|
/* Falls through to lex_operator. */
|
2019-03-25 01:33:10 +08:00
|
|
|
|
++parser->paren_depth;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
2019-03-25 08:07:00 +08:00
|
|
|
|
else if (lexptr[0] == ',' && parser->pstate->comma_terminates
|
|
|
|
|
&& parser->paren_depth == 0)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
return 0;
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
return lex_operator (lvalp);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Push back a single character to be re-lexed. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
rust_push_back (char c)
|
|
|
|
|
{
|
|
|
|
|
/* Can't be called before any lexing. */
|
|
|
|
|
gdb_assert (prev_lexptr != NULL);
|
|
|
|
|
|
|
|
|
|
--lexptr;
|
|
|
|
|
gdb_assert (*lexptr == c);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Make an arbitrary operation and fill in the fields. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::ast_operation (enum exp_opcode opcode, const struct rust_op *left,
|
|
|
|
|
const struct rust_op *right)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
struct rust_op *result = OBSTACK_ZALLOC (&obstack, struct rust_op);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
result->opcode = opcode;
|
|
|
|
|
result->left.op = left;
|
|
|
|
|
result->right.op = right;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make a compound assignment operation. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::ast_compound_assignment (enum exp_opcode opcode,
|
|
|
|
|
const struct rust_op *left,
|
|
|
|
|
const struct rust_op *right)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
struct rust_op *result = OBSTACK_ZALLOC (&obstack, struct rust_op);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
result->opcode = opcode;
|
|
|
|
|
result->compound_assignment = 1;
|
|
|
|
|
result->left.op = left;
|
|
|
|
|
result->right.op = right;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make a typed integer literal operation. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::ast_literal (struct typed_val_int val)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
struct rust_op *result = OBSTACK_ZALLOC (&obstack, struct rust_op);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
result->opcode = OP_LONG;
|
|
|
|
|
result->left.typed_val_int = val;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make a typed floating point literal operation. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::ast_dliteral (struct typed_val_float val)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
struct rust_op *result = OBSTACK_ZALLOC (&obstack, struct rust_op);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Target FP: Use target format throughout expression parsing
When parsing floating-point literals, the language parsers currently
use parse_float or some equivalent routine to parse the input string
into a DOUBLEST, which is then stored within a OP_DOUBLE expression
node. When evaluating the expression, the OP_DOUBLE is finally
converted into a value in target format.
On the other hand, *decimal* floating-point literals are parsed
directly into target format and stored that way in a OP_DECFLOAT
expression node. In order to eliminate the DOUBLEST, this patch
therefore unifies the handling of binary and decimal floating-
point literals and stores them both in target format within a
new OP_FLOAT expression node, replacing both OP_DOUBLE and
OP_DECFLOAT.
In order to store literals in target format, the parse_float
routine needs to know the type of the literal. All parsers
therefore need to be changed to determine the appropriate type
(e.g. by detecting suffixes) *before* calling parse_float,
instead of after it as today. However, this change is mostly
straightforward -- again, this is already done for decimal FP
today.
The core of the literal parsing is moved into a new routine
floatformat_from_string, mirroring floatformat_to_string.
The parse_float routine now calls either floatformat_from_string
or decimal_from_sting, allowing it to handle any type of FP
literal.
All language parsers need to be updated. Some notes on
specific changes to the various languages:
- C: Decimal FP is now handled in parse_float, and no longer
needs to be handled specially.
- D: Straightforward.
- Fortran: Still used a hard-coded "atof", also replaced by
parse_float now. Continues to always use builtin_real_s8
as the type of literal, even though this is probably wrong.
- Go: This used to handle "f" and "l" suffixes, even though
the Go language actually doesn't support those. I kept this
support for now -- maybe revisit later. Note the the GDB
test suite for some reason actually *verifies* that GDB supports
those unsupported suffixes ...
- Pascal: Likewise -- this handles suffixes that are not
supported in the language standard.
- Modula-2: Like Fortran, used to use "atof".
- Rust: Mostly straightforward, except for a unit-testing hitch.
The code use to set a special "unit_testing" flag which would
cause "rust_type" to always return NULL. This makes it not
possible to encode a literal into target format (which type?).
The reason for this flag appears to have been that during
unit testing, there is no "rust_parser" context set up, which
means no "gdbarch" is available to use its types. To fix this,
I removed the unit_testing flag, and instead simply just set up
a dummy rust_parser context during unit testing.
- Ada: This used to check sizeof (DOUBLEST) to determine which
type to use for floating-point literal. This seems questionable
to begin with (since DOUBLEST is quite unrelated to target formats),
and in any case we need to get rid of DOUBLEST. I'm now simply
always using the largest type (builtin_long_double).
gdb/ChangeLog:
2017-10-25 Ulrich Weigand <uweigand@de.ibm.com>
* doublest.c (floatformat_from_string): New function.
* doublest.h (floatformat_from_string): Add prototype.
* std-operator.def (OP_DOUBLE, OP_DECFLOAT): Remove, replace by ...
(OP_FLOAT): ... this.
* expression.h: Do not include "doublest.h".
(union exp_element): Replace doubleconst and decfloatconst by
new element floatconst.
* ada-lang.c (resolve_subexp): Handle OP_FLOAT instead of OP_DOUBLE.
(ada_evaluate_subexp): Likewise.
* eval.c (evaluate_subexp_standard): Handle OP_FLOAT instead of
OP_DOUBLE and OP_DECFLOAT.
* expprint.c (print_subexp_standard): Likewise.
(dump_subexp_body_standard): Likewise.
* breakpoint.c (watchpoint_exp_is_const): Likewise.
* parse.c: Include "dfp.h".
(write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove.
(write_exp_elt_floatcst): New function.
(operator_length_standard): Handle OP_FLOAT instead of OP_DOUBLE
and OP_DECFLOAT.
(operator_check_standard): Likewise.
(parse_float): Do not accept suffix. Take type as input. Return bool.
Return target format buffer instead of host DOUBLEST.
Use floatformat_from_string and decimal_from_string to parse
either binary or decimal floating-point types.
(parse_c_float): Remove.
* parser-defs.h: Do not include "doublest.h".
(write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove.
(write_exp_elt_floatcst): Add prototype.
(parse_float): Update prototype.
(parse_c_float): Remove.
* c-exp.y: Do not include "dfp.h".
(typed_val_float): Use byte buffer instead of DOUBLEST.
(typed_val_decfloat): Remove.
(DECFLOAT): Remove.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
Handle decimal and binary FP types the same way.
* d-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT_LITERAL): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
* f-exp.y: Replace dval by typed_val_float.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Use parse_float instead of atof.
* go-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(parse_go_float): Remove.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Call parse_float instead of parse_go_float.
Parse suffixes and determine type before calling parse_float.
* p-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
* m2-exp.y: Replace dval by byte buffer val.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Call parse_float instead of atof.
* rust-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(lex_number): Call parse_float instead of strtod.
(ast_dliteral): Use OP_FLOAT instead of OP_DOUBLE.
(convert_ast_to_expression): Handle OP_FLOAT instead of OP_DOUBLE.
Use write_exp_elt_floatcst.
(unit_testing): Remove static variable.
(rust_type): Do not check unit_testing.
(rust_lex_tests): Do not set uint_testing. Set up dummy rust_parser.
* ada-exp.y (type_float, type_double): Remove.
(typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
* ada-lex.l (processReal): Use parse_float instead of sscanf.
2017-10-25 21:32:23 +08:00
|
|
|
|
result->opcode = OP_FLOAT;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
result->left.typed_val_float = val;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make a unary operation. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::ast_unary (enum exp_opcode opcode, const struct rust_op *expr)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
return ast_operation (opcode, expr, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make a cast operation. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::ast_cast (const struct rust_op *expr, const struct rust_op *type)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
struct rust_op *result = OBSTACK_ZALLOC (&obstack, struct rust_op);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
result->opcode = UNOP_CAST;
|
|
|
|
|
result->left.op = expr;
|
|
|
|
|
result->right.op = type;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make a call-like operation. This is nominally a function call, but
|
|
|
|
|
when lowering we may discover that it actually represents the
|
|
|
|
|
creation of a tuple struct. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::ast_call_ish (enum exp_opcode opcode, const struct rust_op *expr,
|
|
|
|
|
rust_op_vector *params)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
struct rust_op *result = OBSTACK_ZALLOC (&obstack, struct rust_op);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
result->opcode = opcode;
|
|
|
|
|
result->left.op = expr;
|
|
|
|
|
result->right.params = params;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make a structure creation operation. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::ast_struct (const struct rust_op *name, rust_set_vector *fields)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
struct rust_op *result = OBSTACK_ZALLOC (&obstack, struct rust_op);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
result->opcode = OP_AGGREGATE;
|
|
|
|
|
result->left.op = name;
|
|
|
|
|
result->right.field_inits = fields;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make an identifier path. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::ast_path (struct stoken path, rust_op_vector *params)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
struct rust_op *result = OBSTACK_ZALLOC (&obstack, struct rust_op);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
result->opcode = OP_VAR_VALUE;
|
|
|
|
|
result->left.sval = path;
|
|
|
|
|
result->right.params = params;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make a string constant operation. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::ast_string (struct stoken str)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
struct rust_op *result = OBSTACK_ZALLOC (&obstack, struct rust_op);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
result->opcode = OP_STRING;
|
|
|
|
|
result->left.sval = str;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make a field expression. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::ast_structop (const struct rust_op *left, const char *name,
|
|
|
|
|
int completing)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
struct rust_op *result = OBSTACK_ZALLOC (&obstack, struct rust_op);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
result->opcode = STRUCTOP_STRUCT;
|
|
|
|
|
result->completing = completing;
|
|
|
|
|
result->left.op = left;
|
|
|
|
|
result->right.sval = make_stoken (name);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make an anonymous struct operation, like 'x.0'. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::ast_structop_anonymous (const struct rust_op *left,
|
|
|
|
|
struct typed_val_int number)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
struct rust_op *result = OBSTACK_ZALLOC (&obstack, struct rust_op);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
result->opcode = STRUCTOP_ANONYMOUS;
|
|
|
|
|
result->left.op = left;
|
|
|
|
|
result->right.typed_val_int = number;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make a range operation. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::ast_range (const struct rust_op *lhs, const struct rust_op *rhs,
|
|
|
|
|
bool inclusive)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
struct rust_op *result = OBSTACK_ZALLOC (&obstack, struct rust_op);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2016-04-28 00:28:56 +08:00
|
|
|
|
result->opcode = OP_RANGE;
|
2018-03-30 04:14:07 +08:00
|
|
|
|
result->inclusive = inclusive;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
result->left.op = lhs;
|
|
|
|
|
result->right.op = rhs;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* A helper function to make a type-related AST node. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
struct rust_op *
|
|
|
|
|
rust_parser::ast_basic_type (enum type_code typecode)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
struct rust_op *result = OBSTACK_ZALLOC (&obstack, struct rust_op);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
result->opcode = OP_TYPE;
|
|
|
|
|
result->typecode = typecode;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create an AST node describing an array type. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::ast_array_type (const struct rust_op *lhs,
|
|
|
|
|
struct typed_val_int val)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
struct rust_op *result = ast_basic_type (TYPE_CODE_ARRAY);
|
|
|
|
|
|
|
|
|
|
result->left.op = lhs;
|
|
|
|
|
result->right.typed_val_int = val;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create an AST node describing a reference type. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::ast_slice_type (const struct rust_op *type)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
/* Use TYPE_CODE_COMPLEX just because it is handy. */
|
|
|
|
|
struct rust_op *result = ast_basic_type (TYPE_CODE_COMPLEX);
|
|
|
|
|
|
|
|
|
|
result->left.op = type;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create an AST node describing a reference type. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::ast_reference_type (const struct rust_op *type)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
struct rust_op *result = ast_basic_type (TYPE_CODE_REF);
|
|
|
|
|
|
|
|
|
|
result->left.op = type;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create an AST node describing a pointer type. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::ast_pointer_type (const struct rust_op *type, int is_mut)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
struct rust_op *result = ast_basic_type (TYPE_CODE_PTR);
|
|
|
|
|
|
|
|
|
|
result->left.op = type;
|
|
|
|
|
/* For the time being we ignore is_mut. */
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create an AST node describing a function type. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::ast_function_type (const struct rust_op *rtype,
|
|
|
|
|
rust_op_vector *params)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
struct rust_op *result = ast_basic_type (TYPE_CODE_FUNC);
|
|
|
|
|
|
|
|
|
|
result->left.op = rtype;
|
|
|
|
|
result->right.params = params;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create an AST node describing a tuple type. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const struct rust_op *
|
|
|
|
|
rust_parser::ast_tuple_type (rust_op_vector *params)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
struct rust_op *result = ast_basic_type (TYPE_CODE_STRUCT);
|
|
|
|
|
|
|
|
|
|
result->left.params = params;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* A helper to appropriately munge NAME and BLOCK depending on the
|
|
|
|
|
presence of a leading "::". */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
munge_name_and_block (const char **name, const struct block **block)
|
|
|
|
|
{
|
|
|
|
|
/* If it is a global reference, skip the current block in favor of
|
|
|
|
|
the static block. */
|
|
|
|
|
if (strncmp (*name, "::", 2) == 0)
|
|
|
|
|
{
|
|
|
|
|
*name += 2;
|
|
|
|
|
*block = block_static_block (*block);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Like lookup_symbol, but handles Rust namespace conventions, and
|
|
|
|
|
doesn't require field_of_this_result. */
|
|
|
|
|
|
|
|
|
|
static struct block_symbol
|
|
|
|
|
rust_lookup_symbol (const char *name, const struct block *block,
|
|
|
|
|
const domain_enum domain)
|
|
|
|
|
{
|
|
|
|
|
struct block_symbol result;
|
|
|
|
|
|
|
|
|
|
munge_name_and_block (&name, &block);
|
|
|
|
|
|
|
|
|
|
result = lookup_symbol (name, block, domain, NULL);
|
|
|
|
|
if (result.symbol != NULL)
|
|
|
|
|
update_innermost_block (result);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Look up a type, following Rust namespace conventions. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
struct type *
|
|
|
|
|
rust_parser::rust_lookup_type (const char *name, const struct block *block)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
struct block_symbol result;
|
|
|
|
|
struct type *type;
|
|
|
|
|
|
|
|
|
|
munge_name_and_block (&name, &block);
|
|
|
|
|
|
|
|
|
|
result = lookup_symbol (name, block, STRUCT_DOMAIN, NULL);
|
|
|
|
|
if (result.symbol != NULL)
|
|
|
|
|
{
|
|
|
|
|
update_innermost_block (result);
|
|
|
|
|
return SYMBOL_TYPE (result.symbol);
|
|
|
|
|
}
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
type = lookup_typename (language (), arch (), name, NULL, 1);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
if (type != NULL)
|
|
|
|
|
return type;
|
|
|
|
|
|
|
|
|
|
/* Last chance, try a built-in type. */
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
return language_lookup_primitive_type (language (), arch (), name);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Convert a vector of rust_ops representing types to a vector of
|
|
|
|
|
types. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
std::vector<struct type *>
|
|
|
|
|
rust_parser::convert_params_to_types (rust_op_vector *params)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
2016-11-09 11:32:50 +08:00
|
|
|
|
std::vector<struct type *> result;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2018-04-28 11:18:00 +08:00
|
|
|
|
if (params != nullptr)
|
|
|
|
|
{
|
|
|
|
|
for (const rust_op *op : *params)
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
result.push_back (convert_ast_to_type (op));
|
2018-04-28 11:18:00 +08:00
|
|
|
|
}
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Convert a rust_op representing a type to a struct type *. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
struct type *
|
|
|
|
|
rust_parser::convert_ast_to_type (const struct rust_op *operation)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
struct type *type, *result = NULL;
|
|
|
|
|
|
|
|
|
|
if (operation->opcode == OP_VAR_VALUE)
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const char *varname = convert_name (operation);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2019-03-25 01:20:05 +08:00
|
|
|
|
result = rust_lookup_type (varname, pstate->expression_context_block);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
if (result == NULL)
|
|
|
|
|
error (_("No typed name '%s' in current context"), varname);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gdb_assert (operation->opcode == OP_TYPE);
|
|
|
|
|
|
|
|
|
|
switch (operation->typecode)
|
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_ARRAY:
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
type = convert_ast_to_type (operation->left.op);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
if (operation->right.typed_val_int.val < 0)
|
|
|
|
|
error (_("Negative array length"));
|
|
|
|
|
result = lookup_array_range_type (type, 0,
|
|
|
|
|
operation->right.typed_val_int.val - 1);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_COMPLEX:
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
struct type *usize = get_type ("usize");
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
type = convert_ast_to_type (operation->left.op);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
result = rust_slice_type ("&[*gdb*]", type, usize);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_REF:
|
|
|
|
|
case TYPE_CODE_PTR:
|
|
|
|
|
/* For now we treat &x and *x identically. */
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
type = convert_ast_to_type (operation->left.op);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
result = lookup_pointer_type (type);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_FUNC:
|
|
|
|
|
{
|
2016-11-09 11:32:50 +08:00
|
|
|
|
std::vector<struct type *> args
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
(convert_params_to_types (operation->right.params));
|
2016-04-27 09:38:08 +08:00
|
|
|
|
struct type **argtypes = NULL;
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
type = convert_ast_to_type (operation->left.op);
|
2016-11-09 11:32:50 +08:00
|
|
|
|
if (!args.empty ())
|
|
|
|
|
argtypes = args.data ();
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
result
|
2016-11-09 11:32:50 +08:00
|
|
|
|
= lookup_function_type_with_arguments (type, args.size (),
|
2016-04-27 09:38:08 +08:00
|
|
|
|
argtypes);
|
|
|
|
|
result = lookup_pointer_type (result);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_STRUCT:
|
|
|
|
|
{
|
2016-11-09 11:32:50 +08:00
|
|
|
|
std::vector<struct type *> args
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
(convert_params_to_types (operation->left.params));
|
2016-04-27 09:38:08 +08:00
|
|
|
|
int i;
|
|
|
|
|
const char *name;
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
obstack_1grow (&obstack, '(');
|
2016-11-09 11:32:50 +08:00
|
|
|
|
for (i = 0; i < args.size (); ++i)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
2016-11-09 11:32:50 +08:00
|
|
|
|
std::string type_name = type_to_string (args[i]);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
if (i > 0)
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
obstack_1grow (&obstack, ',');
|
|
|
|
|
obstack_grow_str (&obstack, type_name.c_str ());
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
obstack_grow_str0 (&obstack, ")");
|
|
|
|
|
name = (const char *) obstack_finish (&obstack);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
/* We don't allow creating new tuple types (yet), but we do
|
|
|
|
|
allow looking up existing tuple types. */
|
2019-03-25 01:20:05 +08:00
|
|
|
|
result = rust_lookup_type (name, pstate->expression_context_block);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
if (result == NULL)
|
|
|
|
|
error (_("could not find tuple type '%s'"), name);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
gdb_assert_not_reached ("unhandled opcode in convert_ast_to_type");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gdb_assert (result != NULL);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* A helper function to turn a rust_op representing a name into a full
|
|
|
|
|
name. This applies generic arguments as needed. The returned name
|
|
|
|
|
is allocated on the work obstack. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const char *
|
|
|
|
|
rust_parser::convert_name (const struct rust_op *operation)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
gdb_assert (operation->opcode == OP_VAR_VALUE);
|
|
|
|
|
|
|
|
|
|
if (operation->right.params == NULL)
|
|
|
|
|
return operation->left.sval.ptr;
|
|
|
|
|
|
2016-11-09 11:32:50 +08:00
|
|
|
|
std::vector<struct type *> types
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
(convert_params_to_types (operation->right.params));
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
obstack_grow_str (&obstack, operation->left.sval.ptr);
|
|
|
|
|
obstack_1grow (&obstack, '<');
|
2016-11-09 11:32:50 +08:00
|
|
|
|
for (i = 0; i < types.size (); ++i)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
2016-11-09 11:32:50 +08:00
|
|
|
|
std::string type_name = type_to_string (types[i]);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
if (i > 0)
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
obstack_1grow (&obstack, ',');
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
obstack_grow_str (&obstack, type_name.c_str ());
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
obstack_grow_str0 (&obstack, ">");
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
return (const char *) obstack_finish (&obstack);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* A helper function that converts a vec of rust_ops to a gdb
|
|
|
|
|
expression. */
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
void
|
|
|
|
|
rust_parser::convert_params_to_expression (rust_op_vector *params,
|
|
|
|
|
const struct rust_op *top)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
for (const rust_op *elem : *params)
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
convert_ast_to_expression (elem, top);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Lower a rust_op to a gdb expression. STATE is the parser state.
|
|
|
|
|
OPERATION is the operation to lower. TOP is a pointer to the
|
|
|
|
|
top-most operation; it is used to handle the special case where the
|
|
|
|
|
top-most expression is an identifier and can be optionally lowered
|
2017-07-14 22:10:39 +08:00
|
|
|
|
to OP_TYPE. WANT_TYPE is a flag indicating that, if the expression
|
|
|
|
|
is the name of a type, then emit an OP_TYPE for it (rather than
|
|
|
|
|
erroring). If WANT_TYPE is set, then the similar TOP handling is
|
|
|
|
|
not done. */
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
void
|
|
|
|
|
rust_parser::convert_ast_to_expression (const struct rust_op *operation,
|
|
|
|
|
const struct rust_op *top,
|
|
|
|
|
bool want_type)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
switch (operation->opcode)
|
|
|
|
|
{
|
|
|
|
|
case OP_LONG:
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
write_exp_elt_opcode (pstate, OP_LONG);
|
|
|
|
|
write_exp_elt_type (pstate, operation->left.typed_val_int.type);
|
|
|
|
|
write_exp_elt_longcst (pstate, operation->left.typed_val_int.val);
|
|
|
|
|
write_exp_elt_opcode (pstate, OP_LONG);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
break;
|
|
|
|
|
|
Target FP: Use target format throughout expression parsing
When parsing floating-point literals, the language parsers currently
use parse_float or some equivalent routine to parse the input string
into a DOUBLEST, which is then stored within a OP_DOUBLE expression
node. When evaluating the expression, the OP_DOUBLE is finally
converted into a value in target format.
On the other hand, *decimal* floating-point literals are parsed
directly into target format and stored that way in a OP_DECFLOAT
expression node. In order to eliminate the DOUBLEST, this patch
therefore unifies the handling of binary and decimal floating-
point literals and stores them both in target format within a
new OP_FLOAT expression node, replacing both OP_DOUBLE and
OP_DECFLOAT.
In order to store literals in target format, the parse_float
routine needs to know the type of the literal. All parsers
therefore need to be changed to determine the appropriate type
(e.g. by detecting suffixes) *before* calling parse_float,
instead of after it as today. However, this change is mostly
straightforward -- again, this is already done for decimal FP
today.
The core of the literal parsing is moved into a new routine
floatformat_from_string, mirroring floatformat_to_string.
The parse_float routine now calls either floatformat_from_string
or decimal_from_sting, allowing it to handle any type of FP
literal.
All language parsers need to be updated. Some notes on
specific changes to the various languages:
- C: Decimal FP is now handled in parse_float, and no longer
needs to be handled specially.
- D: Straightforward.
- Fortran: Still used a hard-coded "atof", also replaced by
parse_float now. Continues to always use builtin_real_s8
as the type of literal, even though this is probably wrong.
- Go: This used to handle "f" and "l" suffixes, even though
the Go language actually doesn't support those. I kept this
support for now -- maybe revisit later. Note the the GDB
test suite for some reason actually *verifies* that GDB supports
those unsupported suffixes ...
- Pascal: Likewise -- this handles suffixes that are not
supported in the language standard.
- Modula-2: Like Fortran, used to use "atof".
- Rust: Mostly straightforward, except for a unit-testing hitch.
The code use to set a special "unit_testing" flag which would
cause "rust_type" to always return NULL. This makes it not
possible to encode a literal into target format (which type?).
The reason for this flag appears to have been that during
unit testing, there is no "rust_parser" context set up, which
means no "gdbarch" is available to use its types. To fix this,
I removed the unit_testing flag, and instead simply just set up
a dummy rust_parser context during unit testing.
- Ada: This used to check sizeof (DOUBLEST) to determine which
type to use for floating-point literal. This seems questionable
to begin with (since DOUBLEST is quite unrelated to target formats),
and in any case we need to get rid of DOUBLEST. I'm now simply
always using the largest type (builtin_long_double).
gdb/ChangeLog:
2017-10-25 Ulrich Weigand <uweigand@de.ibm.com>
* doublest.c (floatformat_from_string): New function.
* doublest.h (floatformat_from_string): Add prototype.
* std-operator.def (OP_DOUBLE, OP_DECFLOAT): Remove, replace by ...
(OP_FLOAT): ... this.
* expression.h: Do not include "doublest.h".
(union exp_element): Replace doubleconst and decfloatconst by
new element floatconst.
* ada-lang.c (resolve_subexp): Handle OP_FLOAT instead of OP_DOUBLE.
(ada_evaluate_subexp): Likewise.
* eval.c (evaluate_subexp_standard): Handle OP_FLOAT instead of
OP_DOUBLE and OP_DECFLOAT.
* expprint.c (print_subexp_standard): Likewise.
(dump_subexp_body_standard): Likewise.
* breakpoint.c (watchpoint_exp_is_const): Likewise.
* parse.c: Include "dfp.h".
(write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove.
(write_exp_elt_floatcst): New function.
(operator_length_standard): Handle OP_FLOAT instead of OP_DOUBLE
and OP_DECFLOAT.
(operator_check_standard): Likewise.
(parse_float): Do not accept suffix. Take type as input. Return bool.
Return target format buffer instead of host DOUBLEST.
Use floatformat_from_string and decimal_from_string to parse
either binary or decimal floating-point types.
(parse_c_float): Remove.
* parser-defs.h: Do not include "doublest.h".
(write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove.
(write_exp_elt_floatcst): Add prototype.
(parse_float): Update prototype.
(parse_c_float): Remove.
* c-exp.y: Do not include "dfp.h".
(typed_val_float): Use byte buffer instead of DOUBLEST.
(typed_val_decfloat): Remove.
(DECFLOAT): Remove.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
Handle decimal and binary FP types the same way.
* d-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT_LITERAL): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
* f-exp.y: Replace dval by typed_val_float.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Use parse_float instead of atof.
* go-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(parse_go_float): Remove.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Call parse_float instead of parse_go_float.
Parse suffixes and determine type before calling parse_float.
* p-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
* m2-exp.y: Replace dval by byte buffer val.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Call parse_float instead of atof.
* rust-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(lex_number): Call parse_float instead of strtod.
(ast_dliteral): Use OP_FLOAT instead of OP_DOUBLE.
(convert_ast_to_expression): Handle OP_FLOAT instead of OP_DOUBLE.
Use write_exp_elt_floatcst.
(unit_testing): Remove static variable.
(rust_type): Do not check unit_testing.
(rust_lex_tests): Do not set uint_testing. Set up dummy rust_parser.
* ada-exp.y (type_float, type_double): Remove.
(typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
* ada-lex.l (processReal): Use parse_float instead of sscanf.
2017-10-25 21:32:23 +08:00
|
|
|
|
case OP_FLOAT:
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
write_exp_elt_opcode (pstate, OP_FLOAT);
|
|
|
|
|
write_exp_elt_type (pstate, operation->left.typed_val_float.type);
|
|
|
|
|
write_exp_elt_floatcst (pstate, operation->left.typed_val_float.val);
|
|
|
|
|
write_exp_elt_opcode (pstate, OP_FLOAT);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case STRUCTOP_STRUCT:
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
convert_ast_to_expression (operation->left.op, top);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
if (operation->completing)
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
mark_struct_expression (pstate);
|
|
|
|
|
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
|
|
|
|
|
write_exp_string (pstate, operation->right.sval);
|
|
|
|
|
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case STRUCTOP_ANONYMOUS:
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
convert_ast_to_expression (operation->left.op, top);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
write_exp_elt_opcode (pstate, STRUCTOP_ANONYMOUS);
|
|
|
|
|
write_exp_elt_longcst (pstate, operation->right.typed_val_int.val);
|
|
|
|
|
write_exp_elt_opcode (pstate, STRUCTOP_ANONYMOUS);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2017-07-14 22:10:39 +08:00
|
|
|
|
case UNOP_SIZEOF:
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
convert_ast_to_expression (operation->left.op, top, true);
|
|
|
|
|
write_exp_elt_opcode (pstate, UNOP_SIZEOF);
|
2017-07-14 22:10:39 +08:00
|
|
|
|
break;
|
|
|
|
|
|
2016-04-27 09:38:08 +08:00
|
|
|
|
case UNOP_PLUS:
|
|
|
|
|
case UNOP_NEG:
|
|
|
|
|
case UNOP_COMPLEMENT:
|
|
|
|
|
case UNOP_IND:
|
|
|
|
|
case UNOP_ADDR:
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
convert_ast_to_expression (operation->left.op, top);
|
|
|
|
|
write_exp_elt_opcode (pstate, operation->opcode);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BINOP_SUBSCRIPT:
|
|
|
|
|
case BINOP_MUL:
|
|
|
|
|
case BINOP_REPEAT:
|
|
|
|
|
case BINOP_DIV:
|
|
|
|
|
case BINOP_REM:
|
|
|
|
|
case BINOP_LESS:
|
|
|
|
|
case BINOP_GTR:
|
|
|
|
|
case BINOP_BITWISE_AND:
|
|
|
|
|
case BINOP_BITWISE_IOR:
|
|
|
|
|
case BINOP_BITWISE_XOR:
|
|
|
|
|
case BINOP_ADD:
|
|
|
|
|
case BINOP_SUB:
|
|
|
|
|
case BINOP_LOGICAL_OR:
|
|
|
|
|
case BINOP_LOGICAL_AND:
|
|
|
|
|
case BINOP_EQUAL:
|
|
|
|
|
case BINOP_NOTEQUAL:
|
|
|
|
|
case BINOP_LEQ:
|
|
|
|
|
case BINOP_GEQ:
|
|
|
|
|
case BINOP_LSH:
|
|
|
|
|
case BINOP_RSH:
|
|
|
|
|
case BINOP_ASSIGN:
|
|
|
|
|
case OP_RUST_ARRAY:
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
convert_ast_to_expression (operation->left.op, top);
|
|
|
|
|
convert_ast_to_expression (operation->right.op, top);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
if (operation->compound_assignment)
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY);
|
|
|
|
|
write_exp_elt_opcode (pstate, operation->opcode);
|
|
|
|
|
write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
write_exp_elt_opcode (pstate, operation->opcode);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
if (operation->compound_assignment
|
|
|
|
|
|| operation->opcode == BINOP_ASSIGN)
|
|
|
|
|
{
|
|
|
|
|
struct type *type;
|
|
|
|
|
|
2019-03-24 23:01:18 +08:00
|
|
|
|
type = language_lookup_primitive_type (pstate->language (),
|
Turn parse_gdbarch into a method
This changes parse_gdbarch into a method of parser_state. This patch
was written by a script.
gdb/ChangeLog
2019-04-04 Tom Tromey <tom@tromey.com>
* rust-exp.y: Replace "parse_gdbarch" with method call.
* parse.c (write_dollar_variable, insert_type_address_space):
Replace "parse_gdbarch" with method call.
* p-exp.y (parse_type, yylex): Replace "parse_gdbarch" with method
call.
* objc-lang.c (end_msglist): Replace "parse_gdbarch" with method
call.
* m2-exp.y (parse_type, parse_m2_type, yylex): Replace
"parse_gdbarch" with method call.
* go-exp.y (parse_type, classify_name): Replace "parse_gdbarch"
with method call.
* f-exp.y (parse_type, parse_f_type, yylex): Replace
"parse_gdbarch" with method call.
* d-exp.y (parse_type, parse_d_type, lex_one_token): Replace
"parse_gdbarch" with method call.
* c-exp.y (parse_type, parse_number, classify_name): Replace
"parse_gdbarch" with method call.
* ada-lex.l: Replace "parse_gdbarch" with method call.
* ada-exp.y (parse_type, find_primitive_type, type_char)
(type_system_address): Replace "parse_gdbarch" with method call.
2019-03-24 22:56:33 +08:00
|
|
|
|
pstate->gdbarch (),
|
2016-04-27 09:38:08 +08:00
|
|
|
|
"()");
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
write_exp_elt_opcode (pstate, OP_LONG);
|
|
|
|
|
write_exp_elt_type (pstate, type);
|
|
|
|
|
write_exp_elt_longcst (pstate, 0);
|
|
|
|
|
write_exp_elt_opcode (pstate, OP_LONG);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
write_exp_elt_opcode (pstate, BINOP_COMMA);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case UNOP_CAST:
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
struct type *type = convert_ast_to_type (operation->right.op);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
convert_ast_to_expression (operation->left.op, top);
|
|
|
|
|
write_exp_elt_opcode (pstate, UNOP_CAST);
|
|
|
|
|
write_exp_elt_type (pstate, type);
|
|
|
|
|
write_exp_elt_opcode (pstate, UNOP_CAST);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_FUNCALL:
|
|
|
|
|
{
|
|
|
|
|
if (operation->left.op->opcode == OP_VAR_VALUE)
|
|
|
|
|
{
|
|
|
|
|
struct type *type;
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
const char *varname = convert_name (operation->left.op);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2019-03-25 01:20:05 +08:00
|
|
|
|
type = rust_lookup_type (varname,
|
|
|
|
|
pstate->expression_context_block);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
if (type != NULL)
|
|
|
|
|
{
|
|
|
|
|
/* This is actually a tuple struct expression, not a
|
|
|
|
|
call expression. */
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
rust_op_vector *params = operation->right.params;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
if (TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
|
|
|
|
|
{
|
|
|
|
|
if (!rust_tuple_struct_type_p (type))
|
|
|
|
|
error (_("Type %s is not a tuple struct"), varname);
|
|
|
|
|
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
for (int i = 0; i < params->size (); ++i)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
char *cell = get_print_cell ();
|
|
|
|
|
|
|
|
|
|
xsnprintf (cell, PRINT_CELL_SIZE, "__%d", i);
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
write_exp_elt_opcode (pstate, OP_NAME);
|
|
|
|
|
write_exp_string (pstate, make_stoken (cell));
|
|
|
|
|
write_exp_elt_opcode (pstate, OP_NAME);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
convert_ast_to_expression ((*params)[i], top);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
write_exp_elt_opcode (pstate, OP_AGGREGATE);
|
|
|
|
|
write_exp_elt_type (pstate, type);
|
|
|
|
|
write_exp_elt_longcst (pstate, 2 * params->size ());
|
|
|
|
|
write_exp_elt_opcode (pstate, OP_AGGREGATE);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
convert_ast_to_expression (operation->left.op, top);
|
|
|
|
|
convert_params_to_expression (operation->right.params, top);
|
|
|
|
|
write_exp_elt_opcode (pstate, OP_FUNCALL);
|
|
|
|
|
write_exp_elt_longcst (pstate, operation->right.params->size ());
|
|
|
|
|
write_exp_elt_longcst (pstate, OP_FUNCALL);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_ARRAY:
|
|
|
|
|
gdb_assert (operation->left.op == NULL);
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
convert_params_to_expression (operation->right.params, top);
|
|
|
|
|
write_exp_elt_opcode (pstate, OP_ARRAY);
|
|
|
|
|
write_exp_elt_longcst (pstate, 0);
|
|
|
|
|
write_exp_elt_longcst (pstate, operation->right.params->size () - 1);
|
|
|
|
|
write_exp_elt_longcst (pstate, OP_ARRAY);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_VAR_VALUE:
|
|
|
|
|
{
|
|
|
|
|
struct block_symbol sym;
|
|
|
|
|
const char *varname;
|
|
|
|
|
|
|
|
|
|
if (operation->left.sval.ptr[0] == '$')
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
write_dollar_variable (pstate, operation->left.sval);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
varname = convert_name (operation);
|
2019-03-25 01:20:05 +08:00
|
|
|
|
sym = rust_lookup_symbol (varname, pstate->expression_context_block,
|
2016-04-27 09:38:08 +08:00
|
|
|
|
VAR_DOMAIN);
|
2017-07-14 05:03:27 +08:00
|
|
|
|
if (sym.symbol != NULL && SYMBOL_CLASS (sym.symbol) != LOC_TYPEDEF)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
write_exp_elt_opcode (pstate, OP_VAR_VALUE);
|
|
|
|
|
write_exp_elt_block (pstate, sym.block);
|
|
|
|
|
write_exp_elt_sym (pstate, sym.symbol);
|
|
|
|
|
write_exp_elt_opcode (pstate, OP_VAR_VALUE);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-07-14 05:03:27 +08:00
|
|
|
|
struct type *type = NULL;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2017-07-14 05:03:27 +08:00
|
|
|
|
if (sym.symbol != NULL)
|
|
|
|
|
{
|
|
|
|
|
gdb_assert (SYMBOL_CLASS (sym.symbol) == LOC_TYPEDEF);
|
|
|
|
|
type = SYMBOL_TYPE (sym.symbol);
|
|
|
|
|
}
|
|
|
|
|
if (type == NULL)
|
2019-03-25 01:20:05 +08:00
|
|
|
|
type = rust_lookup_type (varname,
|
|
|
|
|
pstate->expression_context_block);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
if (type == NULL)
|
|
|
|
|
error (_("No symbol '%s' in current context"), varname);
|
|
|
|
|
|
2017-07-14 22:10:39 +08:00
|
|
|
|
if (!want_type
|
|
|
|
|
&& TYPE_CODE (type) == TYPE_CODE_STRUCT
|
2016-04-27 09:38:08 +08:00
|
|
|
|
&& TYPE_NFIELDS (type) == 0)
|
|
|
|
|
{
|
|
|
|
|
/* A unit-like struct. */
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
write_exp_elt_opcode (pstate, OP_AGGREGATE);
|
|
|
|
|
write_exp_elt_type (pstate, type);
|
|
|
|
|
write_exp_elt_longcst (pstate, 0);
|
|
|
|
|
write_exp_elt_opcode (pstate, OP_AGGREGATE);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
2017-07-14 22:10:39 +08:00
|
|
|
|
else if (want_type || operation == top)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
write_exp_elt_opcode (pstate, OP_TYPE);
|
|
|
|
|
write_exp_elt_type (pstate, type);
|
|
|
|
|
write_exp_elt_opcode (pstate, OP_TYPE);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
2017-07-14 22:10:39 +08:00
|
|
|
|
else
|
|
|
|
|
error (_("Found type '%s', which can't be "
|
|
|
|
|
"evaluated in this context"),
|
|
|
|
|
varname);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_AGGREGATE:
|
|
|
|
|
{
|
|
|
|
|
int length;
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
rust_set_vector *fields = operation->right.field_inits;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
struct type *type;
|
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
|
|
length = 0;
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
for (const set_field &init : *fields)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
if (init.name.ptr != NULL)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
write_exp_elt_opcode (pstate, OP_NAME);
|
|
|
|
|
write_exp_string (pstate, init.name);
|
|
|
|
|
write_exp_elt_opcode (pstate, OP_NAME);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
++length;
|
|
|
|
|
}
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
convert_ast_to_expression (init.init, top);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
++length;
|
|
|
|
|
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
if (init.name.ptr == NULL)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
/* This is handled differently from Ada in our
|
|
|
|
|
evaluator. */
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
write_exp_elt_opcode (pstate, OP_OTHERS);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
name = convert_name (operation->left.op);
|
2019-03-25 01:20:05 +08:00
|
|
|
|
type = rust_lookup_type (name, pstate->expression_context_block);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
if (type == NULL)
|
|
|
|
|
error (_("Could not find type '%s'"), operation->left.sval.ptr);
|
|
|
|
|
|
|
|
|
|
if (TYPE_CODE (type) != TYPE_CODE_STRUCT
|
|
|
|
|
|| rust_tuple_type_p (type)
|
|
|
|
|
|| rust_tuple_struct_type_p (type))
|
|
|
|
|
error (_("Struct expression applied to non-struct type"));
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
write_exp_elt_opcode (pstate, OP_AGGREGATE);
|
|
|
|
|
write_exp_elt_type (pstate, type);
|
|
|
|
|
write_exp_elt_longcst (pstate, length);
|
|
|
|
|
write_exp_elt_opcode (pstate, OP_AGGREGATE);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_STRING:
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
write_exp_elt_opcode (pstate, OP_STRING);
|
|
|
|
|
write_exp_string (pstate, operation->left.sval);
|
|
|
|
|
write_exp_elt_opcode (pstate, OP_STRING);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2016-04-28 00:28:56 +08:00
|
|
|
|
case OP_RANGE:
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
2016-04-28 00:28:56 +08:00
|
|
|
|
enum range_type kind = BOTH_BOUND_DEFAULT;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
if (operation->left.op != NULL)
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
convert_ast_to_expression (operation->left.op, top);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
kind = HIGH_BOUND_DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
if (operation->right.op != NULL)
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
convert_ast_to_expression (operation->right.op, top);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
if (kind == BOTH_BOUND_DEFAULT)
|
2018-03-30 04:14:07 +08:00
|
|
|
|
kind = (operation->inclusive
|
|
|
|
|
? LOW_BOUND_DEFAULT : LOW_BOUND_DEFAULT_EXCLUSIVE);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gdb_assert (kind == HIGH_BOUND_DEFAULT);
|
2018-03-30 04:14:07 +08:00
|
|
|
|
kind = (operation->inclusive
|
|
|
|
|
? NONE_BOUND_DEFAULT : NONE_BOUND_DEFAULT_EXCLUSIVE);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-30 04:14:07 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Nothing should make an inclusive range without an upper
|
|
|
|
|
bound. */
|
|
|
|
|
gdb_assert (!operation->inclusive);
|
|
|
|
|
}
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
write_exp_elt_opcode (pstate, OP_RANGE);
|
|
|
|
|
write_exp_elt_longcst (pstate, kind);
|
|
|
|
|
write_exp_elt_opcode (pstate, OP_RANGE);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
gdb_assert_not_reached ("unhandled opcode in convert_ast_to_expression");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* The parser as exposed to gdb. */
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
rust_parse (struct parser_state *state)
|
|
|
|
|
{
|
|
|
|
|
int result;
|
|
|
|
|
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
/* This sets various globals and also clears them on
|
|
|
|
|
destruction. */
|
|
|
|
|
rust_parser parser (state);
|
Eliminate make_cleanup_obstack_free, introduce auto_obstack
This commit eliminates make_cleanup_obstack_free, replacing it with a
new auto_obstack type that inherits obstack to add cdtors.
These changes in the parsers may not be obvious:
- obstack_init (&name_obstack);
- make_cleanup_obstack_free (&name_obstack);
+ name_obstack.clear ();
Here, the 'name_obstack' variable is a global. The change means that
the obstack's contents from a previous parse will stay around until
the next parsing starts. I.e., memory won't be reclaimed until then.
I don't think that's a problem, these objects don't really grow much
at all.
The other option I tried was to add a separate type that is like
auto_obstack but manages an external obstack, just for those cases. I
like the current approach better as that other approach adds more
boilerplate and yet another type to learn.
gdb/ChangeLog:
2017-06-27 Pedro Alves <palves@redhat.com>
* c-exp.y (name_obstack): Now an auto_obstack.
(yylex): Use auto_obstack::clear.
(c_parse): Use auto_obstack::clear instead of reinitializing and
freeing the obstack.
* c-lang.c (evaluate_subexp_c): Use auto_obstack.
* d-exp.y (name_obstack): Now an auto_obstack.
(yylex): Use auto_obstack::clear.
(d_parse): Use auto_obstack::clear instead of reinitializing and
freeing the obstack.
* dwarf2loc.c (fetch_const_value_from_synthetic_pointer): Use
auto_obstack.
* dwarf2read.c (create_addrmap_from_index)
(dwarf2_build_psymtabs_hard)
(update_enumeration_type_from_children): Likewise.
* gdb_obstack.h (auto_obstack): New type.
* go-exp.y (name_obstack): Now an auto_obstack.
(build_packaged_name): Use auto_obstack::clear.
(go_parse): Use auto_obstack::clear instead of reinitializing and
freeing the obstack.
* linux-tdep.c (linux_make_mappings_corefile_notes): Use
auto_obstack.
* printcmd.c (printf_wide_c_string, ui_printf): Use auto_obstack.
* rust-exp.y (work_obstack): Now an auto_obstack.
(rust_parse, rust_lex_tests): Use auto_obstack::clear instead of
reinitializing and freeing the obstack.
* utils.c (do_obstack_free, make_cleanup_obstack_free): Delete.
(host_char_to_target): Use auto_obstack.
* utils.h (make_cleanup_obstack_free): Delete declaration.
* valprint.c (generic_emit_char, generic_printstr): Use
auto_obstack.
2017-06-27 18:07:14 +08:00
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
result = rustyyparse (&parser);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Remove cleanups from Rust parser
This removes the few remaining cleanups in the Rust language code.
The main difficulty here was that the earlier code allocated VEC heads
on an obstack. The new code instead introduces an object that
allocates and maintains the storage for whatever vectors are needed
during the parse.
Regression tested on the buildbot.
ChangeLog
2017-08-05 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_op_ptr, set_field): Remove typedefs.
(rust_op_vector, rust_set_vector): New typedefs.
(current_parser): New global.
(work_obstack): Change to pointer type. Update all users.
(rust_ast, pstate): Remove globals.
(struct rust_parser): New.
(%union) <params, field_inits>: Change type.
(start, tuple_expr, unit_expr, struct_expr_list, literal)
(field_expr, expr_list, maybe_expr_list, type_list): Update.
(ast_call_ish, ast_path, ast_function_type, ast_tuple_type)
(convert_params_to_types, convert_params_to_expression): Change
type of "params".
(ast_string): Change type of "fields".
(rust_parse): Make a rust_parser. Remove cleanups.
(rust_lex_tests): Make and install an auto_obstack.
2017-08-04 21:30:26 +08:00
|
|
|
|
if (!result || (parse_completion && parser.rust_ast != NULL))
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
parser.convert_ast_to_expression (parser.rust_ast, parser.rust_ast);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The parser error handler. */
|
|
|
|
|
|
2018-06-02 13:02:37 +08:00
|
|
|
|
static void
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rustyyerror (rust_parser *parser, const char *msg)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
const char *where = prev_lexptr ? prev_lexptr : lexptr;
|
2018-06-02 13:02:37 +08:00
|
|
|
|
error (_("%s in expression, near `%s'."), msg, where);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if GDB_SELF_TEST
|
|
|
|
|
|
|
|
|
|
/* Initialize the lexer for testing. */
|
|
|
|
|
|
|
|
|
|
static void
|
2019-03-25 01:33:10 +08:00
|
|
|
|
rust_lex_test_init (rust_parser *parser, const char *input)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
prev_lexptr = NULL;
|
|
|
|
|
lexptr = input;
|
2019-03-25 01:33:10 +08:00
|
|
|
|
parser->paren_depth = 0;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* A test helper that lexes a string, expecting a single token. It
|
|
|
|
|
returns the lexer data for this token. */
|
|
|
|
|
|
|
|
|
|
static RUSTSTYPE
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rust_lex_test_one (rust_parser *parser, const char *input, int expected)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
int token;
|
|
|
|
|
RUSTSTYPE result;
|
|
|
|
|
|
2019-03-25 01:33:10 +08:00
|
|
|
|
rust_lex_test_init (parser, input);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
token = rustyylex (&result, parser);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
SELF_CHECK (token == expected);
|
|
|
|
|
|
|
|
|
|
if (token)
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
RUSTSTYPE ignore;
|
|
|
|
|
token = rustyylex (&ignore, parser);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
SELF_CHECK (token == 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Test that INPUT lexes as the integer VALUE. */
|
|
|
|
|
|
|
|
|
|
static void
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rust_lex_int_test (rust_parser *parser, const char *input, int value, int kind)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
RUSTSTYPE result = rust_lex_test_one (parser, input, kind);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
SELF_CHECK (result.typed_val_int.val == value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Test that INPUT throws an exception with text ERR. */
|
|
|
|
|
|
|
|
|
|
static void
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rust_lex_exception_test (rust_parser *parser, const char *input,
|
|
|
|
|
const char *err)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
TRY
|
|
|
|
|
{
|
|
|
|
|
/* The "kind" doesn't matter. */
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rust_lex_test_one (parser, input, DECIMAL_INTEGER);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
SELF_CHECK (0);
|
|
|
|
|
}
|
|
|
|
|
CATCH (except, RETURN_MASK_ERROR)
|
|
|
|
|
{
|
|
|
|
|
SELF_CHECK (strcmp (except.message, err) == 0);
|
|
|
|
|
}
|
|
|
|
|
END_CATCH
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Test that INPUT lexes as the identifier, string, or byte-string
|
|
|
|
|
VALUE. KIND holds the expected token kind. */
|
|
|
|
|
|
|
|
|
|
static void
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rust_lex_stringish_test (rust_parser *parser, const char *input,
|
|
|
|
|
const char *value, int kind)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
RUSTSTYPE result = rust_lex_test_one (parser, input, kind);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
SELF_CHECK (result.sval.length == strlen (value));
|
|
|
|
|
SELF_CHECK (strncmp (result.sval.ptr, value, result.sval.length) == 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper to test that a string parses as a given token sequence. */
|
|
|
|
|
|
|
|
|
|
static void
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rust_lex_test_sequence (rust_parser *parser, const char *input, int len,
|
|
|
|
|
const int expected[])
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
lexptr = input;
|
2019-03-25 01:33:10 +08:00
|
|
|
|
parser->paren_depth = 0;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
for (i = 0; i < len; ++i)
|
|
|
|
|
{
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
RUSTSTYPE ignore;
|
|
|
|
|
int token = rustyylex (&ignore, parser);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
SELF_CHECK (token == expected[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Tests for an integer-parsing corner case. */
|
|
|
|
|
|
|
|
|
|
static void
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rust_lex_test_trailing_dot (rust_parser *parser)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
const int expected1[] = { DECIMAL_INTEGER, '.', IDENT, '(', ')', 0 };
|
|
|
|
|
const int expected2[] = { INTEGER, '.', IDENT, '(', ')', 0 };
|
|
|
|
|
const int expected3[] = { FLOAT, EQEQ, '(', ')', 0 };
|
|
|
|
|
const int expected4[] = { DECIMAL_INTEGER, DOTDOT, DECIMAL_INTEGER, 0 };
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rust_lex_test_sequence (parser, "23.g()", ARRAY_SIZE (expected1), expected1);
|
|
|
|
|
rust_lex_test_sequence (parser, "23_0.g()", ARRAY_SIZE (expected2),
|
|
|
|
|
expected2);
|
|
|
|
|
rust_lex_test_sequence (parser, "23.==()", ARRAY_SIZE (expected3),
|
|
|
|
|
expected3);
|
|
|
|
|
rust_lex_test_sequence (parser, "23..25", ARRAY_SIZE (expected4), expected4);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Tests of completion. */
|
|
|
|
|
|
|
|
|
|
static void
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rust_lex_test_completion (rust_parser *parser)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
const int expected[] = { IDENT, '.', COMPLETE, 0 };
|
|
|
|
|
|
|
|
|
|
parse_completion = 1;
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rust_lex_test_sequence (parser, "something.wha", ARRAY_SIZE (expected),
|
|
|
|
|
expected);
|
|
|
|
|
rust_lex_test_sequence (parser, "something.", ARRAY_SIZE (expected),
|
|
|
|
|
expected);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
parse_completion = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Test pushback. */
|
|
|
|
|
|
|
|
|
|
static void
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rust_lex_test_push_back (rust_parser *parser)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
int token;
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
RUSTSTYPE lval;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2019-03-25 01:33:10 +08:00
|
|
|
|
rust_lex_test_init (parser, ">>=");
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
token = rustyylex (&lval, parser);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
SELF_CHECK (token == COMPOUND_ASSIGN);
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
SELF_CHECK (lval.opcode == BINOP_RSH);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
rust_push_back ('=');
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
token = rustyylex (&lval, parser);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
SELF_CHECK (token == '=');
|
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
token = rustyylex (&lval, parser);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
SELF_CHECK (token == 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Unit test the lexer. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
rust_lex_tests (void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
Target FP: Use target format throughout expression parsing
When parsing floating-point literals, the language parsers currently
use parse_float or some equivalent routine to parse the input string
into a DOUBLEST, which is then stored within a OP_DOUBLE expression
node. When evaluating the expression, the OP_DOUBLE is finally
converted into a value in target format.
On the other hand, *decimal* floating-point literals are parsed
directly into target format and stored that way in a OP_DECFLOAT
expression node. In order to eliminate the DOUBLEST, this patch
therefore unifies the handling of binary and decimal floating-
point literals and stores them both in target format within a
new OP_FLOAT expression node, replacing both OP_DOUBLE and
OP_DECFLOAT.
In order to store literals in target format, the parse_float
routine needs to know the type of the literal. All parsers
therefore need to be changed to determine the appropriate type
(e.g. by detecting suffixes) *before* calling parse_float,
instead of after it as today. However, this change is mostly
straightforward -- again, this is already done for decimal FP
today.
The core of the literal parsing is moved into a new routine
floatformat_from_string, mirroring floatformat_to_string.
The parse_float routine now calls either floatformat_from_string
or decimal_from_sting, allowing it to handle any type of FP
literal.
All language parsers need to be updated. Some notes on
specific changes to the various languages:
- C: Decimal FP is now handled in parse_float, and no longer
needs to be handled specially.
- D: Straightforward.
- Fortran: Still used a hard-coded "atof", also replaced by
parse_float now. Continues to always use builtin_real_s8
as the type of literal, even though this is probably wrong.
- Go: This used to handle "f" and "l" suffixes, even though
the Go language actually doesn't support those. I kept this
support for now -- maybe revisit later. Note the the GDB
test suite for some reason actually *verifies* that GDB supports
those unsupported suffixes ...
- Pascal: Likewise -- this handles suffixes that are not
supported in the language standard.
- Modula-2: Like Fortran, used to use "atof".
- Rust: Mostly straightforward, except for a unit-testing hitch.
The code use to set a special "unit_testing" flag which would
cause "rust_type" to always return NULL. This makes it not
possible to encode a literal into target format (which type?).
The reason for this flag appears to have been that during
unit testing, there is no "rust_parser" context set up, which
means no "gdbarch" is available to use its types. To fix this,
I removed the unit_testing flag, and instead simply just set up
a dummy rust_parser context during unit testing.
- Ada: This used to check sizeof (DOUBLEST) to determine which
type to use for floating-point literal. This seems questionable
to begin with (since DOUBLEST is quite unrelated to target formats),
and in any case we need to get rid of DOUBLEST. I'm now simply
always using the largest type (builtin_long_double).
gdb/ChangeLog:
2017-10-25 Ulrich Weigand <uweigand@de.ibm.com>
* doublest.c (floatformat_from_string): New function.
* doublest.h (floatformat_from_string): Add prototype.
* std-operator.def (OP_DOUBLE, OP_DECFLOAT): Remove, replace by ...
(OP_FLOAT): ... this.
* expression.h: Do not include "doublest.h".
(union exp_element): Replace doubleconst and decfloatconst by
new element floatconst.
* ada-lang.c (resolve_subexp): Handle OP_FLOAT instead of OP_DOUBLE.
(ada_evaluate_subexp): Likewise.
* eval.c (evaluate_subexp_standard): Handle OP_FLOAT instead of
OP_DOUBLE and OP_DECFLOAT.
* expprint.c (print_subexp_standard): Likewise.
(dump_subexp_body_standard): Likewise.
* breakpoint.c (watchpoint_exp_is_const): Likewise.
* parse.c: Include "dfp.h".
(write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove.
(write_exp_elt_floatcst): New function.
(operator_length_standard): Handle OP_FLOAT instead of OP_DOUBLE
and OP_DECFLOAT.
(operator_check_standard): Likewise.
(parse_float): Do not accept suffix. Take type as input. Return bool.
Return target format buffer instead of host DOUBLEST.
Use floatformat_from_string and decimal_from_string to parse
either binary or decimal floating-point types.
(parse_c_float): Remove.
* parser-defs.h: Do not include "doublest.h".
(write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove.
(write_exp_elt_floatcst): Add prototype.
(parse_float): Update prototype.
(parse_c_float): Remove.
* c-exp.y: Do not include "dfp.h".
(typed_val_float): Use byte buffer instead of DOUBLEST.
(typed_val_decfloat): Remove.
(DECFLOAT): Remove.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
Handle decimal and binary FP types the same way.
* d-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT_LITERAL): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
* f-exp.y: Replace dval by typed_val_float.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Use parse_float instead of atof.
* go-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(parse_go_float): Remove.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Call parse_float instead of parse_go_float.
Parse suffixes and determine type before calling parse_float.
* p-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
* m2-exp.y: Replace dval by byte buffer val.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Call parse_float instead of atof.
* rust-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(lex_number): Call parse_float instead of strtod.
(ast_dliteral): Use OP_FLOAT instead of OP_DOUBLE.
(convert_ast_to_expression): Handle OP_FLOAT instead of OP_DOUBLE.
Use write_exp_elt_floatcst.
(unit_testing): Remove static variable.
(rust_type): Do not check unit_testing.
(rust_lex_tests): Do not set uint_testing. Set up dummy rust_parser.
* ada-exp.y (type_float, type_double): Remove.
(typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
* ada-lex.l (processReal): Use parse_float instead of sscanf.
2017-10-25 21:32:23 +08:00
|
|
|
|
// Set up dummy "parser", so that rust_type works.
|
2019-03-25 01:20:05 +08:00
|
|
|
|
struct parser_state ps (&rust_language_defn, target_gdbarch (),
|
2019-03-25 08:07:00 +08:00
|
|
|
|
nullptr, 0, 0);
|
Target FP: Use target format throughout expression parsing
When parsing floating-point literals, the language parsers currently
use parse_float or some equivalent routine to parse the input string
into a DOUBLEST, which is then stored within a OP_DOUBLE expression
node. When evaluating the expression, the OP_DOUBLE is finally
converted into a value in target format.
On the other hand, *decimal* floating-point literals are parsed
directly into target format and stored that way in a OP_DECFLOAT
expression node. In order to eliminate the DOUBLEST, this patch
therefore unifies the handling of binary and decimal floating-
point literals and stores them both in target format within a
new OP_FLOAT expression node, replacing both OP_DOUBLE and
OP_DECFLOAT.
In order to store literals in target format, the parse_float
routine needs to know the type of the literal. All parsers
therefore need to be changed to determine the appropriate type
(e.g. by detecting suffixes) *before* calling parse_float,
instead of after it as today. However, this change is mostly
straightforward -- again, this is already done for decimal FP
today.
The core of the literal parsing is moved into a new routine
floatformat_from_string, mirroring floatformat_to_string.
The parse_float routine now calls either floatformat_from_string
or decimal_from_sting, allowing it to handle any type of FP
literal.
All language parsers need to be updated. Some notes on
specific changes to the various languages:
- C: Decimal FP is now handled in parse_float, and no longer
needs to be handled specially.
- D: Straightforward.
- Fortran: Still used a hard-coded "atof", also replaced by
parse_float now. Continues to always use builtin_real_s8
as the type of literal, even though this is probably wrong.
- Go: This used to handle "f" and "l" suffixes, even though
the Go language actually doesn't support those. I kept this
support for now -- maybe revisit later. Note the the GDB
test suite for some reason actually *verifies* that GDB supports
those unsupported suffixes ...
- Pascal: Likewise -- this handles suffixes that are not
supported in the language standard.
- Modula-2: Like Fortran, used to use "atof".
- Rust: Mostly straightforward, except for a unit-testing hitch.
The code use to set a special "unit_testing" flag which would
cause "rust_type" to always return NULL. This makes it not
possible to encode a literal into target format (which type?).
The reason for this flag appears to have been that during
unit testing, there is no "rust_parser" context set up, which
means no "gdbarch" is available to use its types. To fix this,
I removed the unit_testing flag, and instead simply just set up
a dummy rust_parser context during unit testing.
- Ada: This used to check sizeof (DOUBLEST) to determine which
type to use for floating-point literal. This seems questionable
to begin with (since DOUBLEST is quite unrelated to target formats),
and in any case we need to get rid of DOUBLEST. I'm now simply
always using the largest type (builtin_long_double).
gdb/ChangeLog:
2017-10-25 Ulrich Weigand <uweigand@de.ibm.com>
* doublest.c (floatformat_from_string): New function.
* doublest.h (floatformat_from_string): Add prototype.
* std-operator.def (OP_DOUBLE, OP_DECFLOAT): Remove, replace by ...
(OP_FLOAT): ... this.
* expression.h: Do not include "doublest.h".
(union exp_element): Replace doubleconst and decfloatconst by
new element floatconst.
* ada-lang.c (resolve_subexp): Handle OP_FLOAT instead of OP_DOUBLE.
(ada_evaluate_subexp): Likewise.
* eval.c (evaluate_subexp_standard): Handle OP_FLOAT instead of
OP_DOUBLE and OP_DECFLOAT.
* expprint.c (print_subexp_standard): Likewise.
(dump_subexp_body_standard): Likewise.
* breakpoint.c (watchpoint_exp_is_const): Likewise.
* parse.c: Include "dfp.h".
(write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove.
(write_exp_elt_floatcst): New function.
(operator_length_standard): Handle OP_FLOAT instead of OP_DOUBLE
and OP_DECFLOAT.
(operator_check_standard): Likewise.
(parse_float): Do not accept suffix. Take type as input. Return bool.
Return target format buffer instead of host DOUBLEST.
Use floatformat_from_string and decimal_from_string to parse
either binary or decimal floating-point types.
(parse_c_float): Remove.
* parser-defs.h: Do not include "doublest.h".
(write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove.
(write_exp_elt_floatcst): Add prototype.
(parse_float): Update prototype.
(parse_c_float): Remove.
* c-exp.y: Do not include "dfp.h".
(typed_val_float): Use byte buffer instead of DOUBLEST.
(typed_val_decfloat): Remove.
(DECFLOAT): Remove.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
Handle decimal and binary FP types the same way.
* d-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT_LITERAL): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
* f-exp.y: Replace dval by typed_val_float.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Use parse_float instead of atof.
* go-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(parse_go_float): Remove.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Call parse_float instead of parse_go_float.
Parse suffixes and determine type before calling parse_float.
* p-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
* m2-exp.y: Replace dval by byte buffer val.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Call parse_float instead of atof.
* rust-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(lex_number): Call parse_float instead of strtod.
(ast_dliteral): Use OP_FLOAT instead of OP_DOUBLE.
(convert_ast_to_expression): Handle OP_FLOAT instead of OP_DOUBLE.
Use write_exp_elt_floatcst.
(unit_testing): Remove static variable.
(rust_type): Do not check unit_testing.
(rust_lex_tests): Do not set uint_testing. Set up dummy rust_parser.
* ada-exp.y (type_float, type_double): Remove.
(typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
* ada-lex.l (processReal): Use parse_float instead of sscanf.
2017-10-25 21:32:23 +08:00
|
|
|
|
rust_parser parser (&ps);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rust_lex_test_one (&parser, "", 0);
|
|
|
|
|
rust_lex_test_one (&parser, " \t \n \r ", 0);
|
|
|
|
|
rust_lex_test_one (&parser, "thread 23", 0);
|
|
|
|
|
rust_lex_test_one (&parser, "task 23", 0);
|
|
|
|
|
rust_lex_test_one (&parser, "th 104", 0);
|
|
|
|
|
rust_lex_test_one (&parser, "ta 97", 0);
|
|
|
|
|
|
|
|
|
|
rust_lex_int_test (&parser, "'z'", 'z', INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "'\\xff'", 0xff, INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "'\\u{1016f}'", 0x1016f, INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "b'z'", 'z', INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "b'\\xfe'", 0xfe, INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "b'\\xFE'", 0xfe, INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "b'\\xfE'", 0xfe, INTEGER);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
/* Test all escapes in both modes. */
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rust_lex_int_test (&parser, "'\\n'", '\n', INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "'\\r'", '\r', INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "'\\t'", '\t', INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "'\\\\'", '\\', INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "'\\0'", '\0', INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "'\\''", '\'', INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "'\\\"'", '"', INTEGER);
|
|
|
|
|
|
|
|
|
|
rust_lex_int_test (&parser, "b'\\n'", '\n', INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "b'\\r'", '\r', INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "b'\\t'", '\t', INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "b'\\\\'", '\\', INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "b'\\0'", '\0', INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "b'\\''", '\'', INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "b'\\\"'", '"', INTEGER);
|
|
|
|
|
|
|
|
|
|
rust_lex_exception_test (&parser, "'z", "Unterminated character literal");
|
|
|
|
|
rust_lex_exception_test (&parser, "b'\\x0'", "Not enough hex digits seen");
|
|
|
|
|
rust_lex_exception_test (&parser, "b'\\u{0}'",
|
|
|
|
|
"Unicode escape in byte literal");
|
|
|
|
|
rust_lex_exception_test (&parser, "'\\x0'", "Not enough hex digits seen");
|
|
|
|
|
rust_lex_exception_test (&parser, "'\\u0'", "Missing '{' in Unicode escape");
|
|
|
|
|
rust_lex_exception_test (&parser, "'\\u{0", "Missing '}' in Unicode escape");
|
|
|
|
|
rust_lex_exception_test (&parser, "'\\u{0000007}", "Overlong hex escape");
|
|
|
|
|
rust_lex_exception_test (&parser, "'\\u{}", "Not enough hex digits seen");
|
|
|
|
|
rust_lex_exception_test (&parser, "'\\Q'", "Invalid escape \\Q in literal");
|
|
|
|
|
rust_lex_exception_test (&parser, "b'\\Q'", "Invalid escape \\Q in literal");
|
|
|
|
|
|
|
|
|
|
rust_lex_int_test (&parser, "23", 23, DECIMAL_INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "2_344__29", 234429, INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "0x1f", 0x1f, INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "23usize", 23, INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "23i32", 23, INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "0x1_f", 0x1f, INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "0b1_101011__", 0x6b, INTEGER);
|
|
|
|
|
rust_lex_int_test (&parser, "0o001177i64", 639, INTEGER);
|
|
|
|
|
|
|
|
|
|
rust_lex_test_trailing_dot (&parser);
|
|
|
|
|
|
|
|
|
|
rust_lex_test_one (&parser, "23.", FLOAT);
|
|
|
|
|
rust_lex_test_one (&parser, "23.99f32", FLOAT);
|
|
|
|
|
rust_lex_test_one (&parser, "23e7", FLOAT);
|
|
|
|
|
rust_lex_test_one (&parser, "23E-7", FLOAT);
|
|
|
|
|
rust_lex_test_one (&parser, "23e+7", FLOAT);
|
|
|
|
|
rust_lex_test_one (&parser, "23.99e+7f64", FLOAT);
|
|
|
|
|
rust_lex_test_one (&parser, "23.82f32", FLOAT);
|
|
|
|
|
|
|
|
|
|
rust_lex_stringish_test (&parser, "hibob", "hibob", IDENT);
|
|
|
|
|
rust_lex_stringish_test (&parser, "hibob__93", "hibob__93", IDENT);
|
|
|
|
|
rust_lex_stringish_test (&parser, "thread", "thread", IDENT);
|
|
|
|
|
|
|
|
|
|
rust_lex_stringish_test (&parser, "\"string\"", "string", STRING);
|
|
|
|
|
rust_lex_stringish_test (&parser, "\"str\\ting\"", "str\ting", STRING);
|
|
|
|
|
rust_lex_stringish_test (&parser, "\"str\\\"ing\"", "str\"ing", STRING);
|
|
|
|
|
rust_lex_stringish_test (&parser, "r\"str\\ing\"", "str\\ing", STRING);
|
|
|
|
|
rust_lex_stringish_test (&parser, "r#\"str\\ting\"#", "str\\ting", STRING);
|
|
|
|
|
rust_lex_stringish_test (&parser, "r###\"str\\\"ing\"###", "str\\\"ing",
|
|
|
|
|
STRING);
|
|
|
|
|
|
|
|
|
|
rust_lex_stringish_test (&parser, "b\"string\"", "string", BYTESTRING);
|
|
|
|
|
rust_lex_stringish_test (&parser, "b\"\x73tring\"", "string", BYTESTRING);
|
|
|
|
|
rust_lex_stringish_test (&parser, "b\"str\\\"ing\"", "str\"ing", BYTESTRING);
|
|
|
|
|
rust_lex_stringish_test (&parser, "br####\"\\x73tring\"####", "\\x73tring",
|
2016-04-27 09:38:08 +08:00
|
|
|
|
BYTESTRING);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE (identifier_tokens); ++i)
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rust_lex_test_one (&parser, identifier_tokens[i].name,
|
|
|
|
|
identifier_tokens[i].value);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE (operator_tokens); ++i)
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rust_lex_test_one (&parser, operator_tokens[i].name,
|
|
|
|
|
operator_tokens[i].value);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y. This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers. Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.
Tested on x86-64 Fedora 26.
gdb/ChangeLog
2018-07-20 Tom Tromey <tom@tromey.com>
* rust-exp.y: Now a pure parser. Update all rules.
(%union): Move earlier.
(current_parser, work_obstack): Remove globals.
(rust_parser, ~rust_parser): Update.
(class rust_parser) <copy_name, concat3, crate_name, super_name,
lex_character, lex_number, lex_string, lex_identifier,
rust_lookup_type, convert_params_to_types, convert_ast_to_type,
convert_name, convert_params_to_expression,
convert_ast_to_expression, ast_basic_type, ast_operation,
ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
ast_array_type, ast_slice_type, ast_reference_type,
ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
(rust_parse): Update.
(rustyyerror, rustyylex): Add parser parameter.
(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
(rust_lex_stringish_test, rust_lex_test_sequence)
(rust_lex_test_trailing_dot, rust_lex_test_completion)
(rust_lex_test_push_back, rust_lex_tests): Update.
2018-06-02 12:20:23 +08:00
|
|
|
|
rust_lex_test_completion (&parser);
|
|
|
|
|
rust_lex_test_push_back (&parser);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* GDB_SELF_TEST */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_initialize_rust_exp (void)
|
|
|
|
|
{
|
|
|
|
|
int code = regcomp (&number_regex, number_regex_text, REG_EXTENDED);
|
|
|
|
|
/* If the regular expression was incorrect, it was a programming
|
|
|
|
|
error. */
|
|
|
|
|
gdb_assert (code == 0);
|
|
|
|
|
|
|
|
|
|
#if GDB_SELF_TEST
|
Add selftests run filtering
With the growing number of selftests, I think it would be useful to be
able to run only a subset of the tests. This patch associates a name to
each registered selftest. It then allows doing something like:
(gdb) maintenance selftest aarch64
Running self-tests.
Running selftest aarch64-analyze-prologue.
Running selftest aarch64-process-record.
Ran 2 unit tests, 0 failed
or with gdbserver:
./gdbserver --selftest=aarch64
In both cases, only the tests that contain "aarch64" in their name are
ran. To help validate that the tests you want to run were actually ran,
it also prints a message with the test name before running each test.
Right now, all the arch-dependent tests are registered as a single test
of the selftests. To be able to filter those too, I made them
"first-class citizen" selftests. The selftest type is an interface,
with different implementations for "simple selftests" and "arch
selftests". The run_tests function simply iterates on that an invokes
operator() on each test.
I changed the tests data structure from a vector to a map, because
- it allows iterating in a stable (alphabetical) order
- it allows to easily verify if a test with a given name has been
registered, to avoid duplicates
There's also a new command "maintenance info selftests" that lists the
registered selftests.
gdb/ChangeLog:
* common/selftest.h (selftest): New struct/interface.
(register_test): Add name parameter, add new overload.
(run_tests): Add filter parameter.
(for_each_selftest_ftype): New typedef.
(for_each_selftest): New declaration.
* common/selftest.c (tests): Change type to
map<string, unique_ptr<selftest>>.
(simple_selftest): New struct.
(register_test): New function.
(register_test): Add name parameter and use it.
(run_tests): Add filter parameter and use it. Add prints.
Adjust to vector -> map change.
* aarch64-tdep.c (_initialize_aarch64_tdep): Add names when
registering selftests.
* arm-tdep.c (_initialize_arm_tdep): Likewise.
* disasm-selftests.c (_initialize_disasm_selftests): Likewise.
* dwarf2-frame.c (_initialize_dwarf2_frame): Likewise.
* dwarf2loc.c (_initialize_dwarf2loc): Likewise.
* findvar.c (_initialize_findvar): Likewise.
* gdbarch-selftests.c (_initialize_gdbarch_selftests): Likewise.
* maint.c (maintenance_selftest): Update call to run_tests.
(maintenance_info_selftests): New function.
(_initialize_maint_cmds): Register "maintenance info selftests"
command. Update "maintenance selftest" doc.
* regcache.c (_initialize_regcache): Add names when registering
selftests.
* rust-exp.y (_initialize_rust_exp): Likewise.
* selftest-arch.c (gdbarch_selftest): New struct.
(gdbarch_tests): Remove.
(register_test_foreach_arch): Add name parameter. Call
register_test.
(tests_with_arch): Remove, move most content to
gdbarch_selftest::operator().
(_initialize_selftests_foreach_arch): Remove.
* selftest-arch.h (register_test_foreach_arch): Add name
parameter.
(run_tests_with_arch): New declaration.
* utils-selftests.c (_initialize_utils_selftests): Add names
when registering selftests.
* utils.c (_initialize_utils): Likewise.
* unittests/array-view-selftests.c
(_initialize_array_view_selftests): Likewise.
* unittests/environ-selftests.c (_initialize_environ_selftests):
Likewise.
* unittests/function-view-selftests.c
(_initialize_function_view_selftests): Likewise.
* unittests/offset-type-selftests.c
(_initialize_offset_type_selftests): Likewise.
* unittests/optional-selftests.c
(_initialize_optional_selftests): Likewise.
* unittests/scoped_restore-selftests.c
(_initialize_scoped_restore_selftests): Likewise.
* NEWS: Document "maintenance selftest" and "maint info
selftests".
gdb/gdbserver/ChangeLog:
* server.c (captured_main): Accept argument for --selftest.
Update run_tests call.
* linux-x86-tdesc-selftest.c (initialize_low_tdesc): Add names
when registering selftests.
gdb/doc/ChangeLog:
* gdb.texinfo (Maintenance Commands): Document filter parameter
of "maint selftest". Document "maint info selftests" command.
2017-09-16 20:06:03 +08:00
|
|
|
|
selftests::register_test ("rust-lex", rust_lex_tests);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
#endif
|
|
|
|
|
}
|