Rui Ueyama
f814033d04
Add struct
2020-10-15 14:22:16 +09:00
Rui Ueyama
e6307ad374
Add comma operator
...
This patch allows writing a comma expression on the left-hand side
of an assignment expression. This is called the "generalized lvalue"
which is a deprecated GCC language extension. I'm implementing it
anyway because it's useful to implement other features.
2020-10-15 14:22:16 +09:00
Rui Ueyama
1c91d1943a
Emit .file and .loc assembler directives
...
With these directives, gdb can print out an error location when
a compiled program crashes.
2020-10-15 14:22:16 +09:00
Rui Ueyama
6647ad9b84
Precompute line number for each token
...
No functionality change
2020-10-15 14:22:16 +09:00
Rui Ueyama
cd832a311e
Rewrite tests in shell script in C
2020-10-15 14:22:15 +09:00
Rui Ueyama
ca8b2434c9
Handle block scope
2020-10-08 16:23:53 +09:00
Rui Ueyama
6c0a42926a
Add line and block comments
2020-10-08 16:23:53 +09:00
Rui Ueyama
a0388bada4
Add -o and --help options
2020-10-08 16:23:53 +09:00
Rui Ueyama
7b8528f71c
Refactor -- no functionality change
2020-10-08 16:23:53 +09:00
Rui Ueyama
d9ea59757e
Read code from a file instead of argv[1]
2020-10-08 16:23:49 +09:00
Rui Ueyama
9dae23461e
[GNU] Add statement expression
...
This is a GNU C extension but will be useful for writing tests.
2020-10-08 15:43:05 +09:00
Rui Ueyama
c2cc1d3c45
Add \x<hexadecimal-sequence>
2020-10-08 15:43:05 +09:00
Rui Ueyama
699d2b7e3f
Add \<octal-sequence>
2020-10-08 15:43:04 +09:00
Rui Ueyama
ad7749f2fa
Add \a, \b, \t, \n \v, \f, \r and \e
2020-10-08 15:42:45 +09:00
Rui Ueyama
35a0bcd366
Refactoring: Add a utility function
2020-10-08 14:31:22 +09:00
Rui Ueyama
4cedda2dbe
Add string literal
2020-10-07 20:13:26 +09:00
Rui Ueyama
be38d63d1b
Add char type
2020-10-07 20:13:26 +09:00
Rui Ueyama
a4d3223a72
Add global variables
2020-10-07 20:13:26 +09:00
Rui Ueyama
0b7663481d
Merge Function with Var
...
No functional change
2020-10-07 20:13:26 +09:00
Rui Ueyama
3e55cafef8
Add sizeof
2020-10-07 20:13:26 +09:00
Rui Ueyama
648646bba7
Add [] operator
2020-10-07 20:13:26 +09:00
Rui Ueyama
3ce1b2d067
Add arrays of arrays
2020-10-07 20:13:26 +09:00
Rui Ueyama
8b6395d0f2
Add one dimensional arrays
2020-10-07 20:13:26 +09:00
Rui Ueyama
aacc0cfec2
Support function definition up to 6 parameters
2020-10-07 20:13:26 +09:00
Rui Ueyama
6cb4220f33
Support zero-arity function definition
2020-10-07 20:13:25 +09:00
Rui Ueyama
964b1d2a0e
Support function call with up to 6 arguments
2020-10-07 20:13:25 +09:00
Rui Ueyama
30a3992627
Support zero-arity function calls
2020-10-07 20:13:25 +09:00
Rui Ueyama
b4e82cf7ce
Add keyword "int" and make variable definition mandatory
2020-10-07 20:13:25 +09:00
Rui Ueyama
a6bc4ab101
Make pointer arithmetic work
2020-10-07 20:13:25 +09:00
Rui Ueyama
863e2b8de2
Add unary & and *
2020-10-07 20:13:25 +09:00
Rui Ueyama
3d8627719b
Add a representative node to each Node to improve error messages
2020-10-07 20:13:25 +09:00
Rui Ueyama
5b142b1dcf
Add LICENSE and README.md
2020-10-07 20:13:25 +09:00
Rui Ueyama
1f3eb34f63
Add "while" statement
2020-10-07 20:13:25 +09:00
Rui Ueyama
f5d480f139
Add "for" statement
2020-10-07 20:13:25 +09:00
Rui Ueyama
72b841508f
Add "if" statement
2020-10-07 20:13:19 +09:00
Rui Ueyama
ff8912c68e
Add null statement
2020-10-07 20:13:00 +09:00
Rui Ueyama
18ac283a5d
Add { ... }
2020-10-07 20:13:00 +09:00
Rui Ueyama
6cc1c1f064
Add "return" statement
2020-10-07 20:12:57 +09:00
Rui Ueyama
482c26b536
Support multi-letter local variables
2020-10-07 20:12:19 +09:00
Rui Ueyama
1f9f3adf32
Support single-letter local variables
2020-10-07 20:11:48 +09:00
Rui Ueyama
76cae0ad05
Accept multiple statements separated by semicolons
2020-10-07 20:11:22 +09:00
Rui Ueyama
725badfb49
Split main.c into multiple small files
2020-10-07 20:11:16 +09:00
Rui Ueyama
25b4b85b88
Add ==, !=, <= and >= operators
2020-10-07 20:10:14 +09:00
Rui Ueyama
bf9ab52860
Add unary plus and minus
2020-10-07 13:17:05 +09:00
Rui Ueyama
84cfcaf98f
Add *, / and ()
2020-10-07 13:17:05 +09:00
Rui Ueyama
cc5a6d9781
Improve error message
...
Now, chibicc can print out an error message with an error location
like this:
$ ./chibicc 1+foo
1+foo
^ expected a number
2020-10-07 13:17:05 +09:00
Rui Ueyama
a1ab0ff26f
Add a tokenizer to allow space characters between tokens
2020-10-07 13:17:04 +09:00
Rui Ueyama
bf7081fba7
Add + and - operators
2020-09-13 21:36:37 +09:00
Rui Ueyama
0522e2d77e
Compile an integer to an exectuable that exits with the given number
2020-09-13 21:36:28 +09:00