diff options
author | Nala Ginrut <mulei@gnu.org> | 2020-05-05 17:42:22 +0800 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2020-11-28 19:10:37 +0000 |
commit | a4c6b7b751429b3cd7ed0804c2cab210bc9f00e9 (patch) | |
tree | bc76adb852d008eff02e0673777e35ebabe308f1 /gcc | |
parent | 4bbfea1e41577d62834a4a63794168847181a3c3 (diff) | |
download | gcc-a4c6b7b751429b3cd7ed0804c2cab210bc9f00e9.zip gcc-a4c6b7b751429b3cd7ed0804c2cab210bc9f00e9.tar.gz gcc-a4c6b7b751429b3cd7ed0804c2cab210bc9f00e9.tar.bz2 |
Fix string literal printing in AST dump
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/ast/rust-ast-full-test.cc | 3 | ||||
-rw-r--r-- | gcc/rust/ast/rust-ast.h | 12 |
2 files changed, 14 insertions, 1 deletions
diff --git a/gcc/rust/ast/rust-ast-full-test.cc b/gcc/rust/ast/rust-ast-full-test.cc index ea19c6b..347ad54 100644 --- a/gcc/rust/ast/rust-ast-full-test.cc +++ b/gcc/rust/ast/rust-ast-full-test.cc @@ -242,7 +242,8 @@ Token::as_string () const // return get_token_description(token_id); // maybe fixed - stores everything as string though, so storage-inefficient - return str; + ::std::string quote = is_string_lit () ? "\"" : ""; + return quote + str + quote; } ::std::string diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 5378378..b86d3cf 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -213,6 +213,18 @@ public: } } + inline bool is_string_lit () const + { + switch (token_id) + { + case STRING_LITERAL: + case BYTE_STRING_LITERAL: + return true; + default: + return false; + } + } + ::std::string as_string () const; virtual void accept_vis (ASTVisitor &vis) OVERRIDE; |