diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2024-05-21 17:45:34 +0200 |
---|---|---|
committer | P-E-P <32375388+P-E-P@users.noreply.github.com> | 2024-06-12 11:11:56 +0000 |
commit | a178a07e4322fca9bd3c4b12d3d1da32bedfe198 (patch) | |
tree | 2eae8c7103def5fbe3eb9ee60841b4886db1bf52 /gcc/rust/hir | |
parent | 6fc8ad5340aa21110fe1655fef477aa5b94846f6 (diff) | |
download | gcc-a178a07e4322fca9bd3c4b12d3d1da32bedfe198.zip gcc-a178a07e4322fca9bd3c4b12d3d1da32bedfe198.tar.gz gcc-a178a07e4322fca9bd3c4b12d3d1da32bedfe198.tar.bz2 |
Parse exclusive range pattern
Exclusive range pattern were not handled by the parser as this an
experimental feature.
gcc/rust/ChangeLog:
* ast/rust-pattern.cc (tokenid_to_rangekind): Add a new function to
get a range kind from the current token type.
(RangePattern::as_string): Change the string representation for range
pattern in order to handle excluded ranges.
* ast/rust-pattern.h (enum class): Add new enum class to differentiate
range kinds.
(tokenid_to_rangekind): New prototype for a function that converts a
token id to it's corresponding range kind.
(class RangePattern): Change the class to accept a range kind instead
of an ellipsis boolean.
* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Abort
when an excluded pattern has been found as we do not handle their
lowering yet.
* parse/rust-parse-impl.h (Parser::parse_literal_or_range_pattern):
Parse excluded range patterns.
(Parser::parse_pattern_no_alt): Likewise.
(Parser::parse_ident_leading_pattern): Likewise.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/hir')
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-pattern.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-pattern.cc b/gcc/rust/hir/rust-ast-lower-pattern.cc index 138e4b7..784c29a 100644 --- a/gcc/rust/hir/rust-ast-lower-pattern.cc +++ b/gcc/rust/hir/rust-ast-lower-pattern.cc @@ -18,6 +18,7 @@ #include "rust-ast-lower-pattern.h" #include "rust-ast-lower-expr.h" +#include "rust-system.h" namespace Rust { namespace HIR { @@ -253,6 +254,8 @@ ASTLoweringPattern::visit (AST::LiteralPattern &pattern) void ASTLoweringPattern::visit (AST::RangePattern &pattern) { + if (pattern.get_range_kind () == AST::RangeKind::EXCLUDED) + rust_unreachable (); // Not supported yet auto upper_bound = lower_range_pattern_bound (pattern.get_upper_bound ()); auto lower_bound = lower_range_pattern_bound (pattern.get_lower_bound ()); |