1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

ast: add str for comment (#8019)

This commit is contained in:
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

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'
}