Commit Graph

46 Commits (387fab60a61611c6cb48a5d9dd9d356911733210)

Author SHA1 Message Date
Andrew Kelley 387fab60a6 translate-c: fix do while with empty body 2018-08-05 18:32:38 -04:00
Andrew Kelley c420b234cc translate-c: handle for loop with empty body 2018-08-05 18:18:24 -04:00
Andrew Kelley aa232089f2 translate-c: fix while loop with no body 2018-08-05 18:06:39 -04:00
Andrew Kelley 77678b2cbc
breaking syntax change: orelse keyword instead of ?? (#1096)
use the `zig-fmt-optional-default` branch to have zig fmt
automatically do the changes.

closes #1023
2018-06-10 01:13:51 -04:00
Andrew Kelley 652f4bdf62 disallow unknown-length pointer to opaque
This also means that translate-c has to detect when a pointer to
opaque is happening, and use `*` instead of `[*]`.

See #1059
2018-06-05 18:03:21 -04:00
Andrew Kelley 96164ce613 disallow single-item pointer indexing
add pointer arithmetic for unknown length pointer
2018-06-04 01:39:57 -04:00
Andrew Kelley fcbb7426fa use * for pointer type instead of &
See #770

To help automatically translate code, see the
zig-fmt-pointer-reform-2 branch.

This will convert all & into *. Due to the syntax
ambiguity (which is why we are making this change),
even address-of & will turn into *, so you'll have
to manually fix thes instances. You will be guaranteed
to get compile errors for them - expected 'type', found 'foo'
2018-05-31 17:28:07 -04:00
Andrew Kelley 0c16cd2d0e run zig fmt on the codebase
See #1003
2018-05-29 04:23:38 -04:00
Andrew Kelley c38b165db4 all tests passing with postfix deref syntax 2018-05-17 23:21:44 -04:00
Andrew Kelley bf21747a42 translate-c: fix typedef duplicate definition of variable
closes #998
2018-05-09 20:23:36 -04:00
Jimmi Holst Christensen 1a9403f38a Added better support for none pure enums in tranlate C 2018-05-02 21:50:41 +02:00
Jimmi Holst Christensen 2e010c60ae Translate C now correctly converts ints, floats, ptrs and enums to bools
* Boolean "and" and "or" should also work with these types.
* This new method also simplifies to output code.
2018-03-08 15:34:00 +01:00
Jimmi Holst Christensen b2887620f3 Translate C will now handle ignored return values 2018-03-08 13:15:30 +01:00
Jimmi Holst Christensen 51b2f1b80b Translate C can now translate switch statements again 2018-03-08 10:29:29 +01:00
Jimmi Holst Christensen bb80daf509 Ast Render no longer outputs erroneous semicolon
closes #813
2018-03-07 10:39:32 +01:00
Jimmi Holst Christensen 5ab25798e3 We now also use trans_to_bool_expr on bool not 2018-03-06 12:04:14 +01:00
Jimmi Holst Christensen bf47cf418a expr to bool is now it's own function.
* Now while and for loops work on ints and floats, like if statements
* This fixes the loop problem in #813
2018-03-06 11:57:51 +01:00
Andrew Kelley 3671582c15 syntax: functions require return type. remove `->`
The purpose of this is:

 * Only one way to do things
 * Changing a function with void return type to return a possible
   error becomes a 1 character change, subtly encouraging
   people to use errors.

See #632

Here are some imperfect sed commands for performing this update:

remove arrow:

```
sed -i 's/\(\bfn\b.*\)-> /\1/g' $(find . -name "*.zig")
```

add void:

```
sed -i 's/\(\bfn\b.*\))\s*{/\1) void {/g' $(find ../ -name "*.zig")
```

Some cleanup may be necessary, but this should do the bulk of the work.
2018-01-25 04:10:11 -05:00
Jimmi Holst Christensen 3974b7d31d translate_c can now translate if statements on integers and floats 2018-01-16 15:48:28 +01:00
Jimmi Holst Christensen f59dcc5546 Fixed tests for undefined variables 2018-01-16 15:21:48 +01:00
Andrew Kelley d917815d81 explicitly return from blocks
instead of last statement being expression value

closes #629
2017-12-22 00:50:30 -05:00
Andrew Kelley 8bc523219c add labeled loops, labeled break, labeled continue. remove goto
closes #346
closes #630

regression: translate-c can no longer translate switch statements.
after #629 we can ressurect and modify the code to utilize arbitrarily
returning from blocks.
2017-12-20 23:00:19 -05:00
Andrew Kelley 9d9201c3b4 bring back code that uses export and fix tests
partial revert of 1fdebc1dc4
2017-12-19 02:39:43 -05:00
Andrew Kelley 1fdebc1dc4 wip export rewrite 2017-12-18 09:59:57 -05:00
Andrew Kelley 3577a80bb6 translate-c: more complex logic for translating a C cast in a macro 2017-12-08 12:28:21 -05:00
Andrew Kelley 182cf5b8de translate-c: support macros with pointer casting 2017-12-07 12:27:29 -05:00
Andrew Kelley 7729f6cf4e translate-c: support static incomplete array inside function 2017-11-29 21:50:38 -05:00
Andrew Kelley 7066283004 translate-c: support const ptr initializer 2017-11-28 23:44:45 -05:00
Andrew Kelley 26096e79d1 translate-c: fix clobbering primitive types 2017-11-28 03:17:28 -05:00
Andrew Kelley e745544dac translate-c: detect macros referencing field lookup
as fn calls which assert the fn ptr is non-null
2017-11-28 02:58:51 -05:00
Andrew Kelley f537c51f25 Merge branch 'c-field-expr' of https://github.com/dimenus/zig into dimenus-c-field-expr 2017-11-28 00:44:16 -05:00
Mason Remaley 3e8fd24547 Implements translation for the prefix not operator (#628) 2017-11-27 21:00:05 -05:00
Ryan Saunderson 57049b95b3 Resolving merge w/ upstream master 2017-11-27 11:42:48 -06:00
dimenus 04472f57be Added support for exporting of C field expressions 2017-11-27 11:23:14 -06:00
Andrew Kelley 671183fa9a translate-c: support pointer casting
also avoid some unnecessary casts
2017-11-26 20:05:55 -05:00
Andrew Kelley 93fac5f257 translate-c: support variable name shadowing 2017-11-26 17:30:43 -05:00
Andrew Kelley 9a8545d590 translate-c: fix translation when no default switch case 2017-11-26 16:03:56 -05:00
Andrew Kelley aa2ca3f02c translate-c: better way to translate switch
previously `continue` would be handled incorrectly
2017-11-26 15:58:49 -05:00
Andrew Kelley 1b0e90f70b translate-c supports switch statements 2017-11-26 00:58:11 -05:00
Andrew Kelley df0e875856 translate-c: introduce the concept of scopes
in preparation to implement switch and solve variable name collisions
2017-11-25 20:34:05 -05:00
Andrew Kelley b390929826 translate-c supports break and continue 2017-11-25 11:56:17 -05:00
Andrew Kelley bf20b260ce translate-c supports for loops 2017-11-25 00:57:48 -05:00
Andrew Kelley 18eb3c5f90 translate-c supports returning void 2017-11-25 00:25:47 -05:00
Andrew Kelley 40480c7cdc translate-c supports string literals 2017-11-24 19:26:05 -05:00
Andrew Kelley 68312afcdf translate-c: support pre increment and decrement operators 2017-11-24 16:36:39 -05:00
Andrew Kelley 5a25505668 rename "parsec" to "translate-c" 2017-11-24 14:56:05 -05:00