aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/parse
diff options
context:
space:
mode:
authoransh <anshmalik2002@gmail.com>2024-06-24 04:01:53 -0700
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-17 16:35:50 +0100
commit908a4f88c6b248f634f723b7530abd5e2fdf1dbd (patch)
tree93f3bd73c61452e9cb0752f841cae071fef49e19 /gcc/rust/parse
parenta9c95b82781062aeb0dcebdbcc21d38c6c185d7a (diff)
downloadgcc-908a4f88c6b248f634f723b7530abd5e2fdf1dbd.zip
gcc-908a4f88c6b248f634f723b7530abd5e2fdf1dbd.tar.gz
gcc-908a4f88c6b248f634f723b7530abd5e2fdf1dbd.tar.bz2
gccrs: Add RAW_STRING_LITERAL
gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Handle case for RAW_STRING_LITERAL. * ast/rust-ast.cc (AttributeParser::parse_meta_item_inner): Likewise. (AttributeParser::parse_literal): Likewise. * ast/rust-ast.h: Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_literal): Likewise. * lex/rust-lex.cc (Lexer::parse_raw_string): Likewise. * lex/rust-token.cc (Token::as_string): Likewise. * lex/rust-token.h (enum PrimitiveCoreType): Likewise. * parse/rust-parse-impl.h (Parser::parse_attr_input): Likewise. (Parser::parse_literal_expr): Likewise. (Parser::parse_pattern_no_alt): Likewise. Signed-off-by: ansh <anshmalik2002@gmail.com>
Diffstat (limited to 'gcc/rust/parse')
-rw-r--r--gcc/rust/parse/rust-parse-impl.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 7a9c0b7..d5383ad 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -854,6 +854,9 @@ Parser<ManagedTokenSource>::parse_attr_input ()
case BYTE_STRING_LITERAL:
lit_type = AST::Literal::BYTE_STRING;
break;
+ case RAW_STRING_LITERAL:
+ lit_type = AST::Literal::RAW_STRING;
+ break;
case STRING_LITERAL:
default:
lit_type = AST::Literal::STRING;
@@ -7511,6 +7514,11 @@ Parser<ManagedTokenSource>::parse_literal_expr (AST::AttrVec outer_attrs)
literal_value = t->get_str ();
lexer.skip_token ();
break;
+ case RAW_STRING_LITERAL:
+ type = AST::Literal::RAW_STRING;
+ literal_value = t->get_str ();
+ lexer.skip_token ();
+ break;
case INT_LITERAL:
type = AST::Literal::INT;
literal_value = t->get_str ();
@@ -10481,6 +10489,11 @@ Parser<ManagedTokenSource>::parse_pattern_no_alt ()
return std::unique_ptr<AST::LiteralPattern> (
new AST::LiteralPattern (t->get_str (), AST::Literal::BYTE_STRING,
t->get_locus (), t->get_type_hint ()));
+ case RAW_STRING_LITERAL:
+ lexer.skip_token ();
+ return std::unique_ptr<AST::LiteralPattern> (
+ new AST::LiteralPattern (t->get_str (), AST::Literal::RAW_STRING,
+ t->get_locus (), t->get_type_hint ()));
// raw string and raw byte string literals too if they are readded to
// lexer
case MINUS:
@@ -12275,6 +12288,10 @@ Parser<ManagedTokenSource>::null_denotation_not_path (
return std::unique_ptr<AST::LiteralExpr> (
new AST::LiteralExpr (tok->get_str (), AST::Literal::BYTE_STRING,
tok->get_type_hint (), {}, tok->get_locus ()));
+ case RAW_STRING_LITERAL:
+ return std::unique_ptr<AST::LiteralExpr> (
+ new AST::LiteralExpr (tok->get_str (), AST::Literal::RAW_STRING,
+ tok->get_type_hint (), {}, tok->get_locus ()));
case CHAR_LITERAL:
return std::unique_ptr<AST::LiteralExpr> (
new AST::LiteralExpr (tok->get_str (), AST::Literal::CHAR,