Andrew Kelley
d3ffacb55c
AstGen: hook up hex float parsing to float literals
...
Thanks @LemonBoy!
2021-04-28 15:13:43 -07:00
Andrew Kelley
df24ce52b1
Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
...
In particular I wanted to take advantage of the new hex float parsing
code.
2021-04-28 14:57:38 -07:00
LemonBoy
55c58f226d
std: Add a parser for hexadecimal floating point numbers
...
Should be good enough to unblock progress on the stage2 compiler.
Unifying this parser and the regular one (and perhaps rewrite it, #2207 )
is left as an exercise for the reader.
2021-04-28 17:36:12 -04:00
jacob gw
ce41ddcd23
std: fix potential bug in parseInt
2021-04-22 22:42:46 -04:00
Andrew Kelley
93d1c2d6d4
std: fix compile errors caught by stage2 AstGen
...
Follow-up from 507a8096d2f9624bafaf963c3e189a477ef6b7bf
2021-04-22 19:32:57 -07:00
Andrew Kelley
507a8096d2
std: fix compile errors caught by stage2 AstGen
...
* `comptime const` is redundant
* don't use `extern enum`; specify a tag type.
`extern enum` is only when you need tags to alias. But aliasing tags
is a smell. I will be making a proposal shortly to remove `extern enum`
from the language.
* there is no such thing as `packed enum`.
* instead of `catch |_|`, omit the capture entirely.
* unused function definition with missing parameter name
* using `try` outside of a function or test
2021-04-22 18:07:46 -07:00
jacob gw
b4aec0e31d
stage2: make std.fmt.parseInt ignore _
2021-04-20 17:08:05 -04:00
Andrew Kelley
429cd2b5dd
std: change @import("builtin") to std.builtin
2021-04-15 19:06:39 -07:00
Jonathan Knezek
bbe6a0dddd
Add a test & fix for std.fmt.fmtDuration
2021-03-28 15:44:15 +02:00
Jonathan Knezek
0447a2c041
Implement fmtDuration using Formatter ( #8137 )
...
* Implement fmtDuration using Formatter
Deprecate Duration, duration
* fmtDuration: Fixed ns remainder
* fmtDuration: Fixed visibility; removed [Dd]uration
2021-03-07 15:00:15 +02:00
LemonBoy
72664df491
std: Deprecate the B and Bi format specifiers
...
Following #8007 and #8137 let's get rid of the last weird format.
2021-03-07 14:58:45 +02:00
LemonBoy
cd7c870bd8
std: Deprecate 'x'/'X'/'e'/'E' special cases for u8 slices
...
Let's follow the road paved by the removal of 'z'/'Z', the Formatter
pattern is nice enough to let us remove the remaining four special cases
and declare u8 slices free from any special casing!
2021-03-01 15:33:10 -08:00
Andrew Kelley
5f35dc0c0d
zig fmt the std lib
2021-02-24 21:29:23 -07:00
LemonBoy
057bf1afc9
std: Add more error checking in hexToBytes
...
Prevent the function from turning into an endless loop that may or may
not perform OOB accesses.
2021-02-21 12:19:03 +02:00
Jonathan Marler
a448210fcf
remove z/Z format specifier deprecations
...
The z/Z format specifiers were merged last October (4 months ago). They were then deprecated in January (just over a month ago). This PR removes them altogether.
2021-02-21 11:55:21 +02:00
Jonathan Marler
1480c42806
require specifier for arrayish types
2021-02-09 22:25:52 -08:00
Dmitry Atamanov
290efc0747
Improve error messages in std.fmt ( #7898 )
2021-01-30 13:12:44 +02:00
Asherah Connor
e8740a90b9
complete {Z} deprecation in std.fmt.formatIntValue
...
formatZigEscapes doesn't exist any more.
2021-01-29 20:46:39 +02:00
Jay Petacat
a021c7b1b2
Move fmt.testFmt to testing.expectFmt
2021-01-12 18:13:29 -08:00
Jonathan Knezek
fc10c9c4ce
Add std.fmt.formatDuration and std.fmt.duration ( #7297 )
...
`formatDuration` works on a writer, and `duration` wraps a u64 to allow pleasant injection into format strings.
2021-01-11 19:15:56 -05:00
Jonathan Marler
31802c6c68
remove z/Z format specifiers
...
Zig's format system is flexible enough to add custom formatters. This PR removes the new z/Z format specifiers that were added for printing Zig identifiers and replaces them with custom formatters.
2021-01-07 23:49:22 -08:00
LemonBoy
608a73efb1
Decrement max_depth when printing slice elements
2021-01-02 17:12:57 -07:00
LemonBoy
1ca2deca33
std: Disable the special casing of {} for u8 slices/arrays
...
Unless {s} is specified the contents won't be treated as a string.
2021-01-02 17:12:57 -07:00
LemonBoy
dd973fb365
std: Use {s} instead of {} when printing strings
2021-01-02 17:12:57 -07:00
LemonBoy
5a06fdfa55
Use same brace pairs for arrays/slices/vectors
2021-01-02 17:12:57 -07:00
LemonBoy
d4a8fc8b67
Small cleanup
2021-01-02 17:12:57 -07:00
data-man
2b5e93fd3e
Add formatting for arrays
2021-01-02 17:12:57 -07:00
LemonBoy
6f53653db1
std: Refactor the slice formatting code
...
Also fix the `*` specifier for more types, print an error message if we
can't show the value address.
2021-01-02 17:12:57 -07:00
ryuukk
5275280ede
Formatting fix
2021-01-02 17:12:57 -07:00
ryuukk
1d97747665
Pretty print Slices
...
This code is adapted from pixelherodev paste from IRC
I have added a new fmt option to handle printing slice values ``{v}`` or ``{V}``
While i think it can be made the default, i want your opinion about it
```zig
var slicea = [0]u32{};
var sliceb = [3]u32{ 1, 2, 3 };
std.log.info("Content: {v}", .{slicea});
std.log.info("Content: {v}", .{sliceb});
```
will print:
```
info: Content: []
info: Content: [1, 2, 3]
```
Question:
Should we drop ``{v}`` and make it the default behavior?
2021-01-02 17:12:57 -07:00
Frank Denis
6c2e0c2046
Year++
2020-12-31 15:45:24 -08:00
LemonBoy
a471a57560
std: Fix formatting of type values
...
Closes #7429
2020-12-13 23:21:23 -05:00
LemonBoy
3da6b1218a
std: Implement named arguments & runtime width/precision
2020-11-20 08:36:47 +01:00
LemonBoy
6b39167fdc
std: Rewrite the fmt parser
...
Turn the FSM parser into a linear one so that's easier to implement new
features and/or more error checking without adding more and more states.
Functionally-speaking the two parsers are at feature parity.
2020-11-20 08:36:10 +01:00
Andrew Kelley
473cb1fd74
Merge pull request #6390 from LemonBoy/reboot-3970
...
std.fmt meets UTF-8
2020-11-19 14:58:11 -08:00
LemonBoy
60638f0c82
Nicer code for the error code path
2020-11-19 18:16:23 +01:00
Tadeo Kondrak
25ec2dbc1e
Add builtin.Signedness, use it instead of is_signed
2020-11-19 18:59:21 +02:00
LemonBoy
3a1f515e09
Address review comments
2020-11-05 16:10:34 +01:00
LemonBoy
1982e0c18a
Fix typo in documentation
2020-11-05 16:10:34 +01:00
LemonBoy
0316ac959c
Make std.formatBuf UTF-8 aware
2020-11-05 16:10:34 +01:00
LemonBoy
675de8d6b7
Clean up the unicode codepoint formatter a bit
2020-11-05 16:10:34 +01:00
LemonBoy
2cce23062b
Update the API and add add error-recovery path
2020-11-05 16:10:33 +01:00
data-man
678ecc94ca
Add 'u' specifier to std.format
2020-11-05 16:10:33 +01:00
LemonBoy
35a8d90e55
std: Make parseInt/parseUnsigned detect the radix
2020-11-02 14:13:06 -05:00
Isaac Freund
50ba018223
std/ascii: add spaces array
...
This may be combined with std.mem.trim to form a proper replacement for
the now deprecated std.fmt.trimWhitespace().
2020-11-02 13:20:58 -05:00
Andrew Kelley
af60931a48
Merge pull request #6888 from jcmoyer/issues/6874
...
Update std.fmt docs and add test for null terminated slices with embedded null bytes
2020-11-01 18:30:09 -05:00
Jakub Konka
d530e7f9c7
Make std.fmt.bufPrintIntToSlice public
...
Deprecate `std.fmt.trim` and `std.fmt.isWhiteSpace` in favour of
`std.mem` alternatives.
Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
2020-11-01 15:48:50 -05:00
J.C. Moyer
788900c35c
Add test for null terminated slices with embedded null bytes
2020-10-30 23:58:23 -04:00
J.C. Moyer
b38dea37c7
Update doc comments to reflect current behavior
2020-10-30 23:58:23 -04:00
data-man
194e29adfc
Format null type in std.fmt
2020-10-26 15:40:48 -04:00