Skip to content

Commit e2f5a13

Browse files
committed
string_literal: adding \a \b \f \v escapes
1 parent 44ea11d commit e2f5a13

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/std/zig/string_literal.zig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ pub fn parseEscapeSequence(slice: []const u8, offset: *usize) ParsedCharLiteral
163163
't' => return .{ .success = '\t' },
164164
'\'' => return .{ .success = '\'' },
165165
'"' => return .{ .success = '"' },
166+
'a' => return .{ .success = 0x07 },
167+
'b' => return .{ .success = 0x08 },
168+
'f' => return .{ .success = 0x0C },
169+
'v' => return .{ .success = 0x0B },
166170
'x' => {
167171
var value: u8 = 0;
168172
var i: usize = offset.*;
@@ -234,6 +238,10 @@ pub fn parseEscapeSequence(slice: []const u8, offset: *usize) ParsedCharLiteral
234238
}
235239

236240
test parseCharLiteral {
241+
try std.testing.expectEqual(
242+
ParsedCharLiteral{ .success = 0x07 },
243+
parseCharLiteral("'\\a'"),
244+
);
237245
try std.testing.expectEqual(
238246
ParsedCharLiteral{ .success = 'a' },
239247
parseCharLiteral("'a'"),

0 commit comments

Comments
 (0)