146 Commits

Author SHA1 Message Date
LemonBoy
fabf45f5fc Add the noinline keyword for function declarations 2019-09-05 13:04:58 -04:00
Andrew Kelley
8a7e2e3479
Merge branch 'comment-in-array' of https://github.com/Vexu/zig into Vexu-comment-in-array 2019-09-03 21:49:35 -04:00
Hong Shick Pak
9f4d44bc49 zig fmt: fix nested if 2019-08-29 21:10:26 -07:00
Andrew Kelley
d5b3d97c23
Merge pull request #2760 from Vexu/fmt-comment-fix
Fix non-empty comments getting removed with empty comments
2019-08-28 12:01:08 -04:00
yvt
c98f792ff8 Improve the handling of zig fmt: off/on
This commit reworks the handling of `zig fmt: off/on`. A motivating
example is shown below:

    const c = d;
    // zig fmt: off
    // comment
    const a = b;
    // zig fmt: on

Before processing the decl `const a = b;`, `renderRoot` looks for
`zig fmt: off` that appears between this decl and the previous one. If
it finds one, it searches for the next `zig fmt: on` that re-enables
reformatting (or EOF if none was found), and copies the input code
between `zig fmt: off` and `zig fmt: on` to the output stream. After
that, it proceeds to the next decl.

The important thing to notice here is that `renderTopLevelDecl` emits
line comment tokens that follow the decl. Therefore, when copying code,
we must be careful not to copy the line comment tokens that already have
been written to the output stream. The original code failed to take this
fact into consideration. It did skip `// zig fmt: off`, but not the
remaining ones. As a result, when the above example is fed as input, it
duplicated the line `// comment`.
2019-08-28 11:57:01 -04:00
Tetralux
43587af01a
rendering of align(N) on struct fields 2019-08-22 22:58:38 +00:00
Vexu
c3407ed097
Merge branch 'master' into comment-in-array 2019-08-16 20:02:47 +03:00
Vexu
92a81252cb
Merge branch 'master' into fmt-comment-fix 2019-08-16 17:40:20 +03:00
Andrew Kelley
7874d5a40b
zig fmt: add more test cases 2019-08-16 10:11:53 -04:00
Vexu
2151f84d59 implement new async syntax in self-hosted compiler 2019-08-16 06:17:28 -07:00
Andrew Kelley
13b5a4bf8c
remove cancel 2019-08-15 14:05:12 -04:00
Andrew Kelley
5092634103
avoid the word "coroutine", they're "async functions" 2019-08-13 14:14:19 -04:00
Andrew Kelley
4d8d513e16
all tests passing 2019-08-11 19:53:10 -04:00
Andrew Kelley
f07f09a373
Merge branch 'master' into rewrite-coroutines 2019-08-02 16:13:36 -04:00
Andrew Kelley
ee64a22045
add the anyframe and anyframe->T types 2019-07-26 19:52:35 -04:00
Timon Kruiper
59850c1ce1 Fixed an integer overflow in zig fmt and added testcase 2019-07-23 14:51:30 -04:00
Vexu
34d2a1465c
Merge branch 'master' into fmt-comment-fix 2019-07-17 01:22:20 +03:00
Vexu
f8e753e19c
Merge branch 'master' into comment-in-array 2019-07-17 01:20:59 +03:00
Andrew Kelley
21c60922e3
Merge pull request #2823 from hryx/unicode-escape
Unicode escapes: support u{N...}
2019-07-06 13:14:43 -04:00
hryx
7f618184ad Prevent unreachable when file ends with struct field 2019-07-06 13:09:07 -04:00
Andrew Kelley
9471f16c79
zig fmt ignores "zig fmt: off" directive for whitespace fixes 2019-07-05 15:09:22 -04:00
Andrew Kelley
4f43a4b30f
zig fmt: fix whitespace
closes #2819
closes #2825
2019-07-05 14:46:21 -04:00
hryx
8365a7aab4
Unicode escapes: stage2 tokenizer and parser test 2019-07-04 14:48:23 -07:00
Vexu
de369de312
fix comments getting removed after empty comments 2019-06-27 02:00:30 +03:00
Vexu
0063953d16
added better test cases 2019-06-27 00:30:34 +03:00
Andrew Kelley
3085d29af8
Merge remote-tracking branch 'origin/master' into copy-elision-3 2019-06-26 14:44:01 -04:00
Vexu
22194efe68
Merge branch 'master' into comment-in-array 2019-06-26 20:06:12 +03:00
Vexu
7325f80bb2
improved comment indentation in arrays 2019-06-26 20:03:38 +03:00
Vexu
fa42c99d82 fixed IfTypeExpr parsing 2019-06-26 11:04:34 -04:00
Andrew Kelley
c61e0a078c
fix union init with void payload
all std lib tests passing now
2019-06-25 11:31:38 -04:00
Vexu
f6d83ba918
fixed comment formatting in arrays and fn params 2019-06-25 01:12:28 +03:00
Andrew Kelley
5e58aa4884
uncomment passing std lib tests
these ones getting skipped need to get fixed before merging the branch
2019-06-23 01:29:18 -04:00
Timon Kruiper
fd771ea9fb Added LineComment support when MultiLines are used in ArrayInit
also added the corresponding testcase
2019-06-04 12:44:50 -04:00
Timon Kruiper
4e1f3a9ba3 Correct formatting for multiline string in arrays 2019-05-29 19:56:28 -04:00
Andrew Kelley
8a4ee5942b
zig fmt: fix 2 bugs of mangling source files 2019-05-29 19:09:58 -04:00
Andrew Kelley
b7a82288ad
change use to usingnamespace
See #2014

`use` syntax is still accepted for now. `zig fmt` automatically
updates code. After a release cycle the old syntax will be removed.
2019-05-29 19:09:58 -04:00
LemonBoy
08d41da916 Fix formatting for multiline asm expressions 2019-05-13 12:20:11 -04:00
hryx
3a3a738478
Recursive rewrite of stage2 parser, part 3 2019-05-12 02:01:45 -07:00
daurnimator
3d93c89fc5 std: the failing allocator didn't actually count allocations
Add a field '.allocations' to actually track the number of allocations.

Additionally, only increment '.deallocations' when memory is freed
2019-05-11 09:55:41 -04:00
Andrew Kelley
28071ac637
self-hosted translate-c emits a hello world AST
Also breaking std lib API change: the return value of
std.zig.parse returns `*ast.Tree` rather than `ast.Tree`.

See #1964
2019-04-26 15:43:36 -04:00
Shawn Landden
8ef7f6febb remove Shebang (#!) support
Closes:  #2165
2019-04-24 23:34:19 -04:00
Raul Leal
d44d2784e6 zig-fmt: allow comptime blocks in containers (#2308)
* zig-fmt: allow comptime blocks in containers
* add test for comptime block in container
2019-04-19 15:27:42 -04:00
Shritesh Bhattarai
2f236e6efb fmt: support trailing comma after var_args 2019-04-05 12:27:13 -04:00
Shritesh Bhattarai
8e6ff8d615 fmt: format multi line only on trailing comma (#2184)
* fmt: format multi line only on trailing comma
2019-04-04 19:33:32 -04:00
hryx
e827b9661b zig fmt: Prevent for-else on same line when body is interrupted by LF 2019-04-04 01:31:39 -04:00
hryx
cec8c8678a zig fmt: Fix regression in for-else (#2178) 2019-04-04 01:31:39 -04:00
hryx
c76d51de97 zig fmt: Allow one-line for loops 2019-04-01 11:31:00 -04:00
Shritesh Bhattarai
d645500883 fmt: fix first line comment indent in struct init 2019-03-31 22:33:32 -04:00
hryx
0563e8e1d4 Always write a multiline struct literal if a field expr is multiline 2019-03-31 21:09:56 -04:00
hryx
a4afacd182 Veritcally align array literal columns 2019-03-31 14:27:10 -04:00