Skip to content

Commit 592278c

Browse files
committed
Fix string literal printing in AST dump
1 parent d121212 commit 592278c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

gcc/rust/ast/rust-ast-full-test.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ Token::as_string () const
242242
// return get_token_description(token_id);
243243

244244
// maybe fixed - stores everything as string though, so storage-inefficient
245-
return str;
245+
::std::string quote = is_string_lit () ? "\"" : "";
246+
return quote + str + quote;
246247
}
247248

248249
::std::string

gcc/rust/ast/rust-ast.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,18 @@ class Token : public TokenTree, public MacroMatch
213213
}
214214
}
215215

216+
inline bool is_string_lit () const
217+
{
218+
switch (token_id)
219+
{
220+
case STRING_LITERAL:
221+
case BYTE_STRING_LITERAL:
222+
return true;
223+
default:
224+
return false;
225+
}
226+
}
227+
216228
::std::string as_string () const;
217229

218230
virtual void accept_vis (ASTVisitor &vis) OVERRIDE;

0 commit comments

Comments
 (0)