ast: add str for comment (#8019)

pull/8101/head
zakuro 2021-01-14 10:21:27 +09:00 committed by GitHub
parent fdf5f5003b
commit c8bcee9639
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -225,6 +225,15 @@ pub fn (x Expr) str() string {
CharLiteral {
return '`$x.val`'
}
Comment {
if x.is_multi {
lines := x.text.split_into_lines()
return '/* $lines.len lines comment */'
} else {
text := x.text.trim('\x01').trim_space()
return '// $text'
}
}
ComptimeSelector {
return '${x.left}.$$x.field_expr'
}