Andrew Kelley
1253903fef
zig fmt: struct literal containing a multiline expression
...
I modified this test case to expect different results.
Now, the trailing comma on a list of struct fields is the only deciding
factor, not whether or not the field init expressions contain a newline.
2021-02-22 21:33:21 -07:00
Andrew Kelley
8379fff804
zig fmt: alignment in anonymous literal
2021-02-22 21:04:22 -07:00
Andrew Kelley
a6038f0375
zig fmt: function params should align nicely
2021-02-22 18:17:26 -07:00
Andrew Kelley
fec51ad7c5
zig fmt: while
2021-02-22 17:55:19 -07:00
Andrew Kelley
20cfa0b5b6
zig fmt: if condition has line break, no fn call comma
2021-02-22 17:34:30 -07:00
Andrew Kelley
ec987a7a46
zig fmt: if condition has line break but must not wrap
2021-02-22 16:39:50 -07:00
Andrew Kelley
b301999cd3
zig fmt: if condition wraps
2021-02-22 16:21:19 -07:00
Andrew Kelley
253906fb93
zig fmt: 2nd arg multiline string
2021-02-22 16:00:21 -07:00
Isaac Freund
45634851de
zig fmt: fix firstToken() for extern fn_protos
2021-02-22 23:51:54 +01:00
Isaac Freund
550688f427
zig fmt: insert trailing comma in switches
2021-02-22 23:51:54 +01:00
Veikka Tuominen
4758e0c9a6
update docgen to use new ast
2021-02-22 21:52:22 +02:00
Veikka Tuominen
d83698ab54
translate-c: check for noreturn in switch in more cases
2021-02-22 21:52:22 +02:00
Isaac Freund
f3ee10b454
zig fmt: fix comments ending with EOF after decls
...
Achieve this by reducing the amount of special casing to handle EOF so
that the already correct logic for normal comments does not need to be
duplicated.
2021-02-22 18:32:37 +01:00
Veikka Tuominen
011bc1b84f
translate-c: switch default should have an empty block not break
2021-02-22 19:26:19 +02:00
Isaac Freund
ce9b3ee0f9
parser: anytype is not a vaild return type
2021-02-22 17:38:09 +01:00
Isaac Freund
34c08a91d5
zig fmt: fix formatting of parser tests
2021-02-22 17:37:17 +01:00
Veikka Tuominen
928790364a
zig fmt: correct Node.firstToken for .fn_decl, add error for missing container
2021-02-22 17:39:41 +02:00
Veikka Tuominen
69d5a106da
render: handle comments ending in EOF
2021-02-22 16:59:44 +02:00
Veikka Tuominen
67dac2936c
parser: warn on missing for loop payload, recover from invalid global error set access
2021-02-22 10:04:05 +02:00
Andrew Kelley
621ad241d6
zig fmt: if nested
2021-02-21 20:25:31 -07:00
Andrew Kelley
a17a5ca3a8
translate-c: fix fn_decl vs fn_proto
...
Regressed in 15603f403c9ca91f7530798a5a7751cace284a28.
2021-02-21 18:31:32 -07:00
Andrew Kelley
c6efb23796
zig fmt: rewrite inline functions as callconv(.Inline)
2021-02-21 18:20:46 -07:00
Andrew Kelley
878e99d580
parser: fix recovery for missing semicolons
2021-02-21 18:04:23 -07:00
Andrew Kelley
1247b7b9ef
parser: modify another recovery test case
...
Zig no longer has `error` as the global error set; it is now a special
case keyword. The new parse error message is correct.
2021-02-21 18:00:37 -07:00
Andrew Kelley
79f1876367
parser: remove support for recovering from extra top level end curlies
...
After #35 is implemented,
we should be able to recover from this *at any indentation level*,
reporting a parse error and yet also parsing all the decls even
inside structs. Until then, I don't want to add any hacks to make
this work.
2021-02-21 17:57:04 -07:00
Andrew Kelley
2da2123128
parser: remove support for a recovery test case
...
I don't understand the idea here of this kind of recovery. If we
want to resurrect this test case we need some comments on it to explain
the purpose, example use cases, expected behavior, etc.
2021-02-21 17:37:39 -07:00
Andrew Kelley
866f7dc7d6
parser: support more recovery test cases
2021-02-21 17:37:10 -07:00
Andrew Kelley
15603f403c
AST: use fn_proto not fn_decl for extern decls
...
saves a few bytes per extern function declaration
2021-02-21 16:01:22 -07:00
Andrew Kelley
88d0e77b97
parse: implement error for invalid bit range and alignment
2021-02-21 00:18:20 -07:00
Veikka Tuominen
4074e79748
translate-c: use global scope for typedef/record/enum type translation if needed
...
If the type is a reference to a global declaration that has not yet
been translated we need to use the global scope for translation
so that other functions can also reference it.
2021-02-20 13:32:07 +02:00
Andrew Kelley
669c2054a8
stage2: debug line nops supports bigger padding
2021-02-19 22:55:42 -07:00
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
5b597a16c6
stage2: fix not setting up ZIR arg instruction correctly
...
This is a regression from when I briefly flirted with changing how arg
ZIR instructions work in this branch, and then failed to revert it
correctly.
2021-02-19 20:57:06 -07:00
Andrew Kelley
d8560edc29
stage2: fix incorrect ast.Tree.getNodeSource impl
2021-02-19 20:28:47 -07:00
Andrew Kelley
70761d7c52
stage2: remove incorrect newlines from log statements
2021-02-19 20:27:06 -07:00
Andrew Kelley
6959b177ef
stage2: test harness: panic on OOM rather than assert
...
also add a prefix to test names for C backend
2021-02-19 20:26:48 -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
Andrew Kelley
74878565e5
readme: update introduction link
2021-02-19 16:38:04 -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
6f6568b1fd
translate-c: correctly add semicolon to if statements
2021-02-19 20:48:06 +02: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
Veikka Tuominen
974a1c5525
translate-c: small fixes to avoid generating invalid code for macros
2021-02-19 12:50:42 +02:00
Andrew Kelley
914540ddb5
astgen: fix remaining compile errors
...
Now it builds and what remains in this branch is:
* fix the stage2 compiler regressions from this branch
* finish the rest of zig fmt test cases, get them passing
* Merge in Vexu's translate-c AST branch & fix translate-c regressions
2021-02-19 00:04:31 -07: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
Veikka Tuominen
3aba1fa04f
translate-c: ensure failed macros don't get defined multiple times
2021-02-19 01:52:27 +02:00
Veikka Tuominen
df5a8120df
translate-c: small miscellaneous improvements
2021-02-18 21:34:31 +02:00
Andrew Kelley
29daf10639
stage2: fix a couple more compilation errors
2021-02-17 22:34:06 -07:00
Andrew Kelley
5a2620fcca
stage2: fix some of the compilation errors in this branch
2021-02-17 22:22:10 -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
Veikka Tuominen
7ca53bdfaa
translate-c: improve switch translation
2021-02-17 22:11:26 +02:00