Skip to content

Commit

Permalink
Made formatting changes
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::left_denotations): it will stop parsing when '=>' or ',' is encountered if restrictions.stop_on_token is on
	(Parser::null_denotation): Same as above stopping for the special tokens
	* parse/rust-parse.h (struct ParseRestrictions): Added a field of stop_on_token for executing above functionality.
  • Loading branch information
sriganeshres committed Dec 4, 2024
1 parent fdf7178 commit 8c6471b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions gcc/rust/parse/rust-parse-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -12084,7 +12084,8 @@ Parser<ManagedTokenSource>::left_denotations (std::unique_ptr<AST::Expr> expr,
{
lexer.skip_token ();
if (restrictions.stop_on_token
&& (current_token->get_id() == MATCH_ARROW || current_token->get_id() == COMMA))
&& (current_token->get_id() == MATCH_ARROW
|| current_token->get_id() == COMMA))
{
rust_debug ("Stopping parsing at restricted token in left_denotations");
return expr;
Expand Down Expand Up @@ -12127,7 +12128,8 @@ Parser<ManagedTokenSource>::null_denotation (const_TokenPtr tok,
/* note: tok is previous character in input stream, not current one, as
* parse_expr skips it before passing it in */

if (restrictions.stop_on_token && (tok->get_id() == MATCH_ARROW || tok->get_id() == COMMA))
if (restrictions.stop_on_token
&& (tok->get_id() == MATCH_ARROW || tok->get_id() == COMMA))
{
rust_debug("Stopping parsing at restricted token in null_denotation");
return nullptr;
Expand Down
3 changes: 2 additions & 1 deletion gcc/rust/parse/rust-parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ struct ParseRestrictions
bool entered_from_unary = false;
bool expr_can_be_null = false;
bool expr_can_be_stmt = false;
bool stop_on_token = false; // This is for stopping parsing at a specific token
bool stop_on_token
= false; // This is for stopping parsing at a specific token
bool consume_semi = true;
/* Macro invocations that are statements can expand without a semicolon after
* the final statement, if it's an expression statement. */
Expand Down

0 comments on commit 8c6471b

Please sign in to comment.