Commit Graph

3556 Commits

Author SHA1 Message Date
Andrew Kelley
ed1e5cb3f6 stage2: fix a couple off by one errors
All stage2 tests are passing again in this branch.

Remaining checklist for this branch:
 * get the rest of the zig fmt test cases passing
   - re-enable the translate-c test case that is blocking on this
 * implement the 2 `@panic(TODO)`'s in parse.zig
 * use fn_proto not fn_decl for extern function declarations
2021-02-19 21:47:11 -07:00
Andrew Kelley
d8560edc29 stage2: fix incorrect ast.Tree.getNodeSource impl 2021-02-19 20:28:47 -07:00
Andrew Kelley
8fee41b1d5 stage2: AST: clean up parse errors
* struct instead of tagged union
 * delete dead code
 * simplify parser code
 * remove unnecessary metaprogramming
2021-02-19 18:04:52 -07:00
Isaac Freund
95b95ea33e
stage2: make same line doc comments a parse error
Allowing same line doc comments causes some ambiguity as to how
generated docs should represent the case in which both same line
and preceding line doc comments are present:

/// preceding line
const foobar = 42; /// same line

Furthermore disallowing these makes things simpler as there is now only
one way to add a doc comment to a decl or struct field.
2021-02-19 22:59:27 +01:00
Veikka Tuominen
d672c20b8a
Merge pull request #7479 from ziglang/translate-c-ast
Make translate-c use intermediate AST
2021-02-19 13:03:29 +02:00
Andrew Kelley
9010bd8aec stage2: astgen: fix most of the remaining compile errors
more progress on converting astgen to the new AST memory layout.
only a few code paths left to update.
2021-02-18 20:09:29 -07:00
Andrew Kelley
29daf10639 stage2: fix a couple more compilation errors 2021-02-17 22:34:06 -07:00
Andrew Kelley
c66481f9bc astgen: finish updating expressions to new mem layout
Now all that is left is compile errors and whatever regressions this
branch introduced.
2021-02-17 20:59:21 -07:00
Isaac Freund
4b226286e8
zig fmt: get rid of Space.no_comment
Using this in its current state would be a bug as it could cause line
comments to be deleted or a `// zig fmt: (on|off)` directive to be
missed.

Removing it doesn't currently cause any test failures, if a reason for
its continued existence is discovered in the future another solution
will have to be found.
2021-02-17 00:03:39 +01:00
Isaac Freund
895fb2bd6d
zig fmt: implement 'zig fmt: (on|off)' directives
With the new implementation, these now work anywhere in the source code
as opposed to only at the top level.
2021-02-16 23:20:53 +01:00
Isaac Freund
070e548acf
std: remove io.AutoIndentingStream
This type is not widely applicable enough to be a public part of the
public interface of the std.

The current implementation in only fully utilized by the zig fmt
implementation, which could benefit by even tighter integration as
will be demonstrated in the next commit. Therefore, move the current
io.AutoIndentingStream to lib/std/zig/render.zig.

The C backend of the self hosted compiler also use this type currently,
but it does not require anywhere near its full complexity. Therefore,
implement a greatly simplified version of this interface in
src/codegen/c.zig.
2021-02-16 23:20:46 +01:00
Veikka Tuominen
78fba4e021
translate-c: get all run-translated-c tests passing 2021-02-16 16:40:43 +02:00
Veikka Tuominen
d7460db044
translate-c: render a bunch of simple nodes and calls 2021-02-16 16:40:39 +02:00
Isaac Freund
bbf5a4d7c5
zig fmt: fix inferred error union return types 2021-02-15 13:54:48 +01:00
Andrew Kelley
c2b4d51749 astgen: update a handful of expression types to new mem layout
break, continue, blocks, bit_not, negation, identifiers, string
literals, integer literals, inline assembly

also gave multiline string literals a different node tag from regular
string literals, for code clarity and to avoid an unnecessary load from
token_tags array.
2021-02-13 21:40:12 -07:00
Isaac Freund
24798b84ad zig fmt: implement multiline string literals 2021-02-13 16:57:34 -08:00
Isaac Freund
75ba8d8db6 zig fmt: remove empty lines at start/end of block 2021-02-13 16:57:34 -08:00
Andrew Kelley
7630a5c566 stage2: more progress towards Module/astgen building with new mem layout 2021-02-12 23:47:17 -07:00
Andrew Kelley
a9db40e870 zig fmt: add failing test case for inline/callconv conversion 2021-02-11 23:53:04 -07:00
Andrew Kelley
b4e344bcf8 Merge remote-tracking branch 'origin/master' into ast-memory-layout
Conflicts:
 * lib/std/zig/ast.zig
 * lib/std/zig/parse.zig
 * lib/std/zig/parser_test.zig
 * lib/std/zig/render.zig
 * src/Module.zig
 * src/zir.zig

I resolved some of the conflicts by reverting a small portion of
@tadeokondrak's stage2 logic here regarding `callconv(.Inline)`.
It will need to get reworked as part of this branch.
2021-02-11 23:45:40 -07:00
Andrew Kelley
3d0f4b9030 stage2: start reworking Module/astgen for memory layout changes
This commit does not reach any particular milestone, it is
work-in-progress towards getting things to build.

There's a `@panic("TODO")` in translate-c that should be removed when
working on translate-c stuff.
2021-02-11 23:29:55 -07:00
Veikka Tuominen
288e180598
snake_case render.Space 2021-02-12 02:14:07 +02:00
Veikka Tuominen
bb22490fcc
snake_case Node.Tag 2021-02-12 02:12:43 +02:00
Veikka Tuominen
e2289961c6
snake_case Token.Tag 2021-02-12 02:12:00 +02:00
Isaac Freund
faa3fa65ac zig fmt: implement line comments 2021-02-11 15:49:49 -08:00
Isaac Freund
b6448a533d zig fmt: fix Tree.lastToken() for empty *Two nodes 2021-02-11 15:49:49 -08:00
Tadeo Kondrak
1c15091bc8
stage1: switch from inline fn to callconv(.Inline) 2021-02-10 20:06:13 -07:00
Tadeo Kondrak
5dfe0e7e8f
Convert inline fn to callconv(.Inline) everywhere 2021-02-10 20:06:12 -07:00
Tadeo Kondrak
9c797fe3ac
std.zig: reformat inline fn to callconv(.Inline) 2021-02-10 20:06:11 -07:00
Jonathan Marler
61bcac108c Add more mingw def files
I've added more of the ".def" files from mingw. The list is based on all the libraries referenced by the win32metadata project. (see https://github.com/marlersoft/zigwin32).
2021-02-10 13:38:16 -08:00
Isaac Freund
4c8caf3343 zig fmt: implement Tree.lastToken() for all nodes 2021-02-10 11:53:53 -08:00
Isaac Freund
515d4920e7 zig fmt: fix 0 element struct and array init 2021-02-10 11:53:53 -08:00
Isaac Freund
5df7fc36c6 zig fmt: implement Tree.lastToken() for struct init 2021-02-10 11:53:53 -08:00
Isaac Freund
928f6f48a6 zig fmt: implement Tree.lastToken() for array init 2021-02-10 11:53:53 -08:00
Isaac Freund
3110a73486 zig fmt: implement Tree.lastToken() for array types 2021-02-10 11:53:53 -08:00
Isaac Freund
8c4f3e5a31 zig fmt: fix render of pointers with ** tokens 2021-02-10 11:53:53 -08:00
Isaac Freund
a524e57090 zig fmt: support bodyless function decls
extern function declarations do not have a body, so allow setting
the rhs for FnDecl to 0 to indicate this is the case.
2021-02-10 11:53:53 -08:00
Isaac Freund
80b719d967 zig fmt: fix typo in firstToken() for pointer types 2021-02-10 11:53:53 -08:00
Isaac Freund
6dc2236054 musl: update to 1.2.2 2021-02-10 11:50:55 -08:00
Jonathan Marler
1480c42806 require specifier for arrayish types 2021-02-09 22:25:52 -08:00
Andrew Kelley
58db3d2775 zig fmt: re-enable now-passing test cases 2021-02-09 23:07:29 -07:00
Andrew Kelley
fa5fcdd734 zig fmt: fix regression with many container members 2021-02-09 22:42:00 -07:00
Andrew Kelley
9d87e6aeb8 zig fmt: remove dead code
likely these will be resurrected to make array literal cases pass.
2021-02-09 22:29:01 -07:00
Andrew Kelley
36eee7bc6c zig fmt: anytype, fn calls with one param, trailing commas
and extra newlines between top level declarations
2021-02-09 22:26:21 -07:00
Andrew Kelley
25bcf4eb99 zig fmt: grouped expressions 2021-02-09 21:17:43 -07:00
Andrew Kelley
7295d4b807 zig fmt: suspend blocks 2021-02-09 20:35:43 -07:00
Andrew Kelley
ebf04c56e1 zig fmt: usingnamespace 2021-02-09 20:17:47 -07:00
Andrew Kelley
39acc4c020 zig fmt: for loops 2021-02-09 20:08:40 -07:00
Andrew Kelley
1c79eea125 zig fmt: while loops 2021-02-09 17:23:57 -07:00
Andrew Kelley
bcafc51e58 zig fmt: fn protos and anytype 2021-02-09 14:41:50 -07:00