Add expr_2021 nonterminal and feature flag

This commit adds a new nonterminal `expr_2021` in macro patterns, and
`expr_fragment_specifier_2024` feature flag. For now, `expr` and
`expr_2021` are treated the same, but in future PRs we will update
`expr` to match to new grammar.

Co-authored-by: Vincezo Palazzo <vincenzopalazzodev@gmail.com>
This commit is contained in:
Eric Holk 2024-04-12 10:19:23 -07:00
parent 030a12ce2b
commit ef6478ba5f
No known key found for this signature in database
GPG key ID: 8EA6B43ED4CE0911
10 changed files with 48 additions and 3 deletions

View file

@ -37,7 +37,7 @@ impl<'a> Parser<'a> {
}
match kind {
NonterminalKind::Expr => {
NonterminalKind::Expr | NonterminalKind::Expr2021 => {
token.can_begin_expr()
// This exception is here for backwards compatibility.
&& !token.is_keyword(kw::Let)
@ -145,7 +145,9 @@ impl<'a> Parser<'a> {
})?)
}
NonterminalKind::Expr => NtExpr(self.parse_expr_force_collect()?),
NonterminalKind::Expr | NonterminalKind::Expr2021 => {
NtExpr(self.parse_expr_force_collect()?)
}
NonterminalKind::Literal => {
// The `:literal` matcher does not support attributes
NtLiteral(self.collect_tokens_no_attrs(|this| this.parse_literal_maybe_minus())?)