Commit Graph

316 Commits

Author SHA1 Message Date
Rui Ueyama 006a45ccd4 Add extern 2020-12-07 12:00:06 +09:00
Rui Ueyama 157356c769 Align global variables 2020-12-07 12:00:06 +09:00
Rui Ueyama 7a1f816783 Accept `void` as a parameter list
`foo(void)` indicate that function foo does not take a parameter.
2020-12-07 12:00:06 +09:00
Rui Ueyama cd688a89b8 Allow to initialize struct flexible array member 2020-12-07 12:00:06 +09:00
Rui Ueyama 824543bb2f Add flexible array member 2020-12-07 12:00:06 +09:00
Rui Ueyama 3d216e3e06 Emit uninitialized global data to .bss instead of .data 2020-12-07 12:00:06 +09:00
Rui Ueyama fde464c47c Allow extraneous comma at the end of enum or initializer list 2020-12-07 12:00:06 +09:00
Rui Ueyama a58958ccb4 Allow extraneous braces for scalar initializer 2020-12-07 12:00:06 +09:00
Rui Ueyama efa0f3366d Allow parentheses in initializers to be omitted 2020-12-07 12:00:06 +09:00
Rui Ueyama 1eae5ae367 Handle union initializers for global variable 2020-12-07 12:00:06 +09:00
Rui Ueyama eeb62b6dd5 Add struct initializer for global variable 2020-12-07 12:00:06 +09:00
Rui Ueyama bbfe3f4369 Add global initializer for scalar and string 2020-12-07 12:00:06 +09:00
Rui Ueyama 483b194a80 Handle union initializers for local variables 2020-12-07 12:00:06 +09:00
Rui Ueyama aca19dd350 Allow to initialize a struct with other struct 2020-12-07 12:00:06 +09:00
Rui Ueyama e9d2c46ab3 Handle struct initializers for local variables 2020-12-07 12:00:06 +09:00
Rui Ueyama 5b95533603 Allow to omit array length if an initializer is given
So that you can write something like `int x[] = {1, 2, 3}`
instead of `int x[3] = {1, 2, 3}`.
2020-12-07 12:00:06 +09:00
Rui Ueyama 0d717373cc Add string literal initializer 2020-12-07 12:00:06 +09:00
Rui Ueyama a754732c04 Skip excess initializer elements 2020-12-07 12:00:06 +09:00
Rui Ueyama ae0a37dc4b Initialize excess array elements with zero 2020-12-07 12:00:06 +09:00
Rui Ueyama 22dd560ecf Support local variable initializers 2020-12-07 12:00:06 +09:00
Rui Ueyama 79f5de21eb Add constant expression 2020-12-07 12:00:06 +09:00
Rui Ueyama 447ee098c5 Add ?: operator 2020-12-07 12:00:06 +09:00
Rui Ueyama d0c0cb74b2 Add <<, >>, <<= and >>= 2020-12-07 12:00:06 +09:00
Rui Ueyama 044d9ae07b Add switch-case 2020-12-07 12:00:06 +09:00
Rui Ueyama 3c83dfd8af Add continue statement 2020-12-07 12:00:06 +09:00
Rui Ueyama b3047f2317 Add break statement 2020-12-07 12:00:06 +09:00
Rui Ueyama a4be55b333 Resolve conflict between labels and typedefs 2020-12-07 12:00:06 +09:00
Rui Ueyama 6116cae4c4 Add goto and labeled statement 2020-12-07 12:00:06 +09:00
Rui Ueyama 61a1055120 Add a notion of an incomplete struct type 2020-12-07 12:00:06 +09:00
Rui Ueyama 79632219d0 Decay an array to a pointer in the func param context 2020-12-07 12:00:06 +09:00
Rui Ueyama 29ed294906 Add a notion of an incomplete array type 2020-12-07 12:00:06 +09:00
Rui Ueyama f30f78175c Add && and || 2020-12-07 12:00:06 +09:00
Rui Ueyama 86440068b4 Add &, |, ^, &=, |= and ^= 2020-12-07 12:00:06 +09:00
Rui Ueyama daa739817c Add % and %= 2020-12-07 12:00:06 +09:00
Rui Ueyama 46a96d6862 Add ~ operator 2020-12-07 12:00:06 +09:00
Rui Ueyama 6b88bcb306 Add ! operator 2020-12-07 12:00:06 +09:00
Rui Ueyama 7df934d2b6 Add hexadecimal, octal and binary number literals 2020-12-07 12:00:06 +09:00
Rui Ueyama e8ca48cf41 Add post ++ and -- 2020-12-07 12:00:06 +09:00
Rui Ueyama 47f19371f7 Add pre ++ and -- 2020-12-07 12:00:06 +09:00
Rui Ueyama 01a94c04aa Add +=, -=, *= and /= 2020-12-07 12:00:06 +09:00
Rui Ueyama a4fea2ba3e Allow for-loops to define local variables 2020-12-07 12:00:06 +09:00
Rui Ueyama 736232f3d6 Support file-scope functions 2020-12-07 12:00:05 +09:00
Rui Ueyama 48ba2656fe Add enum 2020-12-07 12:00:05 +09:00
Rui Ueyama aa0accc75e Add character literal 2020-12-07 12:00:05 +09:00
Rui Ueyama 44bba965cb Add _Bool type
_Bool isn't just a 1-bit integer because when you convert a value
to bool, the result is 1 if the original value is non-zero. This
is contrary to the other small integral types, e.g. char, as you
can see below:

  char x  = 256; // x is 0
  _Bool y = 256; // y is 1
2020-12-07 12:00:05 +09:00
Rui Ueyama fdc80bc6b5 Handle function argument type conversion 2020-12-07 12:00:05 +09:00
Rui Ueyama 818352acc0 Handle return type conversion 2020-12-07 12:00:05 +09:00
Rui Ueyama 9e211cbf1d Report an error on undefined/undeclared functions 2020-12-07 12:00:05 +09:00
Rui Ueyama 8b430a6c5f Implement usual arithmetic conversion 2020-12-07 12:00:05 +09:00
Rui Ueyama cfc4fa94c1 Add type cast 2020-12-07 12:00:05 +09:00