| ... | @@ -5971,11 +5971,13 @@ fn floatLiteral( | ... | @@ -5971,11 +5971,13 @@ fn floatLiteral( |
| 5971 | | 5971 | |
| 5972 | const main_token = main_tokens[node]; | 5972 | const main_token = main_tokens[node]; |
| 5973 | const bytes = tree.tokenSlice(main_token); | 5973 | const bytes = tree.tokenSlice(main_token); |
| 5974 | if (bytes.len > 2 and bytes[1] == 'x') { | 5974 | const float_number: f128 = if (bytes.len > 2 and bytes[1] == 'x') hex: { |
| 5975 | assert(bytes[0] == '0'); // validated by tokenizer | 5975 | assert(bytes[0] == '0'); // validated by tokenizer |
| 5976 | return astgen.failTok(main_token, "TODO implement hex floats", .{}); | 5976 | break :hex std.fmt.parseHexFloat(f128, bytes) catch |err| switch (err) { |
| 5977 | } | 5977 | error.InvalidCharacter => unreachable, // validated by tokenizer |
| 5978 | const float_number = std.fmt.parseFloat(f128, bytes) catch |e| switch (e) { | 5978 | error.Overflow => return astgen.failNode(node, "number literal cannot be represented in a 128-bit floating point", .{}), |
| | 5979 | }; |
| | 5980 | } else std.fmt.parseFloat(f128, bytes) catch |err| switch (err) { |
| 5979 | error.InvalidCharacter => unreachable, // validated by tokenizer | 5981 | error.InvalidCharacter => unreachable, // validated by tokenizer |
| 5980 | }; | 5982 | }; |
| 5981 | // If the value fits into a f32 without losing any precision, store it that way. | 5983 | // If the value fits into a f32 without losing any precision, store it that way. |