+2019-04-04 Tom Tromey <tom@tromey.com>
+
+ * rust-exp.y (struct rust_parser) <paren_depth>: New member.
+ (rustyylex, rust_lex_test_init, rust_lex_test_one)
+ (rust_lex_test_sequence, rust_lex_test_push_back): Update.
+ * parser-defs.h (paren_depth): Don't declare.
+ * parse.c (paren_depth): Remove global.
+ (parse_exp_in_context): Update.
+ * p-exp.y (paren_depth): New global.
+ (pascal_parse): Initialize it.
+ * m2-exp.y (paren_depth): New global.
+ (m2_parse): Initialize it.
+ * go-exp.y (paren_depth): New global.
+ (go_parse): Initialize it.
+ * f-exp.y (paren_depth): New global.
+ (f_parse): Initialize it.
+ * d-exp.y (paren_depth): New global.
+ (d_parse): Initialize it.
+ * c-exp.y (paren_depth): New global.
+ (c_parse): Initialize it.
+ * ada-lex.l (paren_depth): New global.
+ (lexer_init): Initialize it.
+
2019-04-04 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_parser::crate_name, rust_parser::super_name)
static int find_dot_all (const char *);
+/* Depth of parentheses. */
+static int paren_depth;
+
%}
%option case-insensitive interactive nodefault
lexer_init (FILE *inp)
{
BEGIN INITIAL;
+ paren_depth = 0;
yyrestart (inp);
}
operator -- either '.' or ARROW. */
static bool last_was_structop;
+/* Depth of parentheses. */
+static int paren_depth;
+
/* Read one token, getting characters through lexptr. */
static int
/* Initialize some state used by the lexer. */
last_was_structop = false;
saw_name_at_eof = 0;
+ paren_depth = 0;
token_fifo.clear ();
popping = 0;
This is used only when parsing to do field name completion. */
static int last_was_structop;
+/* Depth of parentheses. */
+static int paren_depth;
+
/* Read one token, getting characters through lexptr. */
static int
/* Initialize some state used by the lexer. */
last_was_structop = 0;
saw_name_at_eof = 0;
+ paren_depth = 0;
token_fifo.clear ();
popping = 0;
static struct parser_state *pstate = NULL;
+/* Depth of parentheses. */
+static int paren_depth;
+
int yyparse (void);
static int yylex (void);
parser_debug);
gdb_assert (par_state != NULL);
pstate = par_state;
+ paren_depth = 0;
return yyparse ();
}
do field name completion. */
static int last_was_structop;
+/* Depth of parentheses. */
+static int paren_depth;
+
/* Read one token, getting characters through lexptr. */
static int
/* Initialize some state used by the lexer. */
last_was_structop = 0;
saw_name_at_eof = 0;
+ paren_depth = 0;
token_fifo.clear ();
popping = 0;
};
+/* Depth of parentheses. */
+static int paren_depth;
+
/* Read one token, getting characters through lexptr. */
/* This is where we will check to make sure that the language and the
scoped_restore pstate_restore = make_scoped_restore (&pstate);
gdb_assert (par_state != NULL);
pstate = par_state;
+ paren_depth = 0;
return yyparse ();
}
static struct parser_state *pstate = NULL;
+/* Depth of parentheses. */
+static int paren_depth;
+
int yyparse (void);
static int yylex (void);
scoped_restore pstate_restore = make_scoped_restore (&pstate);
gdb_assert (par_state != NULL);
pstate = par_state;
+ paren_depth = 0;
return yyparse ();
}
static struct type_stack type_stack;
const char *lexptr;
const char *prev_lexptr;
-int paren_depth;
int comma_terminates;
/* True if parsing an expression to attempt completion. */
lexptr = *stringptr;
prev_lexptr = NULL;
- paren_depth = 0;
type_stack.elements.clear ();
expout_last_struct = -1;
expout_tag_completion_type = TYPE_CODE_UNDEF;
Currently used only for error reporting. */
extern const char *prev_lexptr;
-/* Current depth in parentheses within the expression. */
-
-extern int paren_depth;
-
/* Nonzero means stop parsing on first comma (if not within parentheses). */
extern int comma_terminates;
/* The parser state gdb gave us. */
struct parser_state *pstate;
+
+ /* Depth of parentheses. */
+ int paren_depth = 0;
};
/* Rust AST operations. We build a tree of these; then lower them to
else if (lexptr[0] == '}' || lexptr[0] == ']')
{
/* Falls through to lex_operator. */
- --paren_depth;
+ --parser->paren_depth;
}
else if (lexptr[0] == '(' || lexptr[0] == '{')
{
/* Falls through to lex_operator. */
- ++paren_depth;
+ ++parser->paren_depth;
}
- else if (lexptr[0] == ',' && comma_terminates && paren_depth == 0)
+ else if (lexptr[0] == ',' && comma_terminates && parser->paren_depth == 0)
return 0;
return lex_operator (lvalp);
/* Initialize the lexer for testing. */
static void
-rust_lex_test_init (const char *input)
+rust_lex_test_init (rust_parser *parser, const char *input)
{
prev_lexptr = NULL;
lexptr = input;
- paren_depth = 0;
+ parser->paren_depth = 0;
}
/* A test helper that lexes a string, expecting a single token. It
int token;
RUSTSTYPE result;
- rust_lex_test_init (input);
+ rust_lex_test_init (parser, input);
token = rustyylex (&result, parser);
SELF_CHECK (token == expected);
int i;
lexptr = input;
- paren_depth = 0;
+ parser->paren_depth = 0;
for (i = 0; i < len; ++i)
{
int token;
RUSTSTYPE lval;
- rust_lex_test_init (">>=");
+ rust_lex_test_init (parser, ">>=");
token = rustyylex (&lval, parser);
SELF_CHECK (token == COMPOUND_ASSIGN);