aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/parse/rust-parse.h
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2023-06-08 20:30:06 +0100
committerPhilip Herron <philip.herron@embecosm.com>2023-06-20 08:10:23 +0000
commitdbf982cbd898adc581a28934f701acd6db27d5f8 (patch)
treede7e6e73729b1ed0d7e31763993cfde26fc7ca93 /gcc/rust/parse/rust-parse.h
parent33544f79849a5b747d84fea0fc2be25e208e3ab4 (diff)
downloadgcc-dbf982cbd898adc581a28934f701acd6db27d5f8.zip
gcc-dbf982cbd898adc581a28934f701acd6db27d5f8.tar.gz
gcc-dbf982cbd898adc581a28934f701acd6db27d5f8.tar.bz2
gccrs: Parse statement macros as statements.
gcc/rust/ChangeLog: * ast/rust-ast.h (Expr::to_stmt): Remove method. * ast/rust-macro.h (MacroInvocation::to_stmt): Remove override. * ast/rust-stmt.h: Remove use of Expr::to_stmt. * expand/rust-macro-expand.h (struct MacroExpander): Add EXPR/STMT and remove BLOCK from ContextType. * expand/rust-expand-visitor.cc (ExpandVisitor::maybe_expand_expr): Use EXPR context. (ExpandVisitor::expand_inner_stmts): Use STMT context. (ExpandVisitor::visitor): Remove use of BLOCK context. * expand/rust-macro-expand.cc (transcribe_on_delimiter): Remove function. (transcribe_context): Use EXPR/STMT contexts. (MacroExpander::parse_proc_macro_output): Use EXPR/STMT contexts. * parse/rust-parse-impl.h (Parser::parse_stmt): Delegate macro parsing to parse_expr_stmt, check for ! after macro_rules. (Parser::parse_expr_stmt): Parse macro statements/expression statements starting with a macro. (Parser::parse_match_expr): Don't modify flag unnecessarily. (Parser::parse_stmt_or_expr): Parse macro statements/expression statements starting with a macro. (Parser::parse_path_based_stmt_or_expr): Remove method. (Parser::parse_macro_invocation_maybe_semi): Remove method. (Parser::parse_expr): Move code into left_denotations. (Parser::left_denotations): New method. (Parser::null_denotation): Split out methods for cases with and without paths. (Parser::null_denotation_path): New method. (Parser::null_denotation_not_path): New method. (Parser::parse_macro_invocation_partial): Don't check for semicolon here. * parse/rust-parse.h: Update declarations. gcc/testsuite/ChangeLog: * rust/compile/braced_macro_arm.rs: New test. * rust/compile/braced_macro_statements1.rs: New test. * rust/compile/braced_macro_statements2.rs: New test. * rust/compile/braced_macro_statements3.rs: New test. * rust/compile/issue-2225.rs: Update test. Signed-off-by: Matthew Jasper <mjjasper1@gmail.com>
Diffstat (limited to 'gcc/rust/parse/rust-parse.h')
-rw-r--r--gcc/rust/parse/rust-parse.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/gcc/rust/parse/rust-parse.h b/gcc/rust/parse/rust-parse.h
index 74313df..6202574 100644
--- a/gcc/rust/parse/rust-parse.h
+++ b/gcc/rust/parse/rust-parse.h
@@ -340,6 +340,17 @@ private:
null_denotation (const_TokenPtr t, AST::AttrVec outer_attrs = AST::AttrVec (),
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::Expr>
+ null_denotation_path (AST::PathInExpression path, AST::AttrVec outer_attrs,
+ ParseRestrictions restrictions = ParseRestrictions ());
+ std::unique_ptr<AST::Expr>
+ null_denotation_not_path (const_TokenPtr t, AST::AttrVec outer_attrs,
+ ParseRestrictions restrictions
+ = ParseRestrictions ());
+ std::unique_ptr<AST::Expr>
+ left_denotations (std::unique_ptr<AST::Expr> null_denotation,
+ int right_binding_power, AST::AttrVec outer_attrs,
+ ParseRestrictions restrictions = ParseRestrictions ());
+ std::unique_ptr<AST::Expr>
left_denotation (const_TokenPtr t, std::unique_ptr<AST::Expr> left,
AST::AttrVec outer_attrs = AST::AttrVec (),
ParseRestrictions restrictions = ParseRestrictions ());
@@ -637,12 +648,10 @@ private:
std::unique_ptr<AST::LetStmt> parse_let_stmt (AST::AttrVec outer_attrs,
ParseRestrictions restrictions
= ParseRestrictions ());
- std::unique_ptr<AST::ExprStmt> parse_expr_stmt (AST::AttrVec outer_attrs,
- ParseRestrictions restrictions
- = ParseRestrictions ());
+ std::unique_ptr<AST::Stmt> parse_expr_stmt (AST::AttrVec outer_attrs,
+ ParseRestrictions restrictions
+ = ParseRestrictions ());
ExprOrStmt parse_stmt_or_expr ();
- ExprOrStmt parse_macro_invocation_maybe_semi (AST::AttrVec outer_attrs);
- ExprOrStmt parse_path_based_stmt_or_expr (AST::AttrVec outer_attrs);
// Pattern-related
std::unique_ptr<AST::Pattern> parse_literal_or_range_pattern ();