75 Commits

Author SHA1 Message Date
b22610a2b5 Add color coding to time output
This should make it easier to read how much each compiler stage took.

Signed-off-by: Slendi <slendi@socopon.com>
2024-05-04 13:43:28 +02:00
5af9845f93 Add command line arguments and make time printing nicer
This patch adds the following arguments:

1. `--dump-ast` or `-d`: This dumps the Abstract Syntax Tree
2. `--dont-emit-llvm` or `-L`: This skips the LLVM generation step only
   parsing and type checking. Useful for debugging.

Besides this, formatting of the time each compiler step took is also
improved and easier to read now.

Signed-off-by: Slendi <slendi@socopon.com>
2024-05-04 13:27:25 +02:00
a225a5b1fa Compute the size of structs
This patch makes it such that the size of a struct can be computed by
it's fields.

Signed-off-by: Slendi <slendi@socopon.com>
2024-05-04 12:57:19 +02:00
137e36b81c Make structs packed by default
Signed-off-by: Slendi <slendi@socopon.com>
2024-05-04 12:40:12 +02:00
9505d1c010 Add some more details in todo_list.md for self-hosted compiler
This patch makes it such that the type checker when re-implemented in
the self-hosted compiler for the kernel will check for some common
pitfalls and throw some errors out about them.

Signed-off-by: Slendi <slendi@socopon.com>
2024-05-03 23:49:19 +02:00
ee979eb216 Add performance benchmarks
This patch shows the time it took to parse and type check a program
which can be great to know where to optimize.

Signed-off-by: Slendi <slendi@socopon.com>
2024-05-03 23:48:37 +02:00
2e38b9dabc Make the type checker recognize enum definitions
This patch makes it such that if you define an enum inside of a scope,
the type checker will remember it. There is currently no support for
field accesses.

Signed-off-by: Slendi <slendi@socopon.com>
2024-04-30 10:46:00 +03:00
844a906d62 Resolve enum values
This patch makes it so that the compiler can automatically
increment/decrement values in order for enums while parsing.

Signed-off-by: Slendi <slendi@socopon.com>
2024-04-29 17:01:53 +03:00
95057fd359 Add support for enums in the parser
Signed-off-by: Slendi <slendi@socopon.com>
2024-04-29 16:42:28 +03:00
ea9c622865 Make TODO list a bit clearer
Signed-off-by: Slendi <slendi@socopon.com>
2024-04-27 13:59:56 +03:00
2469b38464 Add error message if a variable is already declared
Signed-off-by: Slendi <slendi@socopon.com>
2024-04-27 09:19:02 +03:00
b170e9a424 Add some support for recursive structs
Signed-off-by: Slendi <slendi@socopon.com>
2024-04-27 05:47:06 +03:00
c5747a103e Add support for multiple field accesses in parser and type checker
Signed-off-by: Slendi <slendi@socopon.com>
2024-04-27 04:03:51 +03:00
464532d9fe Replace shell script with makefile
Signed-off-by: Slendi <slendi@socopon.com>
2024-04-19 01:32:09 +03:00
24967b3eb7 Remove commented out code
Signed-off-by: Slendi <slendi@socopon.com>
2024-04-17 13:18:08 +03:00
8d666c0308 Make undefined variables be treated as strings
Signed-off-by: Slendi <slendi@socopon.com>
2024-04-17 13:14:54 +03:00
4782252f7e Add support for prefix increment/decrement ops
Signed-off-by: Slendi <slendi@socopon.com>
2024-04-11 09:20:15 +03:00
f65507c5e1 Add support for assign stacking
Signed-off-by: Slendi <slendi@socopon.com>
2024-04-10 19:26:20 +03:00
3b70d9786c Make zero length arrays ptrs, finish Raylib prog
Signed-off-by: Slendi <slendi@socopon.com>
2024-04-10 13:37:38 +03:00
1caebf3295 Do stuff
I forgor

Signed-off-by: Slendi <slendi@socopon.com>
2024-04-10 11:34:43 +03:00
d069f037a7 Fix order of operations for bitwise stuff
Signed-off-by: Slendi <slendi@socopon.com>
2024-04-09 02:37:52 +03:00
cb3183ba64 Fix bug with empty returns
Signed-off-by: Slendi <slendi@socopon.com>
2024-04-09 02:34:41 +03:00
a5fd0f24dc Add support for empty returns
Signed-off-by: Slendi <slendi@socopon.com>
2024-04-09 02:31:23 +03:00
9796d51ae0 Update todo list
Signed-off-by: Slendi <slendi@socopon.com>
2024-04-09 02:25:57 +03:00
66faf71ec7 Add support for struct field accesses
Signed-off-by: Slendi <slendi@socopon.com>
2024-04-09 02:24:45 +03:00
a372c4420a Fix bug with finding function calls
Signed-off-by: Slendi <slendi@socopon.com>
2024-04-09 02:22:09 +03:00
a966ff45a3 Improve messages, implement* field access
Compiler messages are now printed in color with their respective code,
field access support has been added in the type checker. However, field
access nodes that contain other field access nodes are not yet
supported.

Signed-off-by: Slendi <slendi@socopon.com>
2024-04-08 11:42:39 +03:00
0f5db0972c Use LLVM-18
Signed-off-by: Slendi <slendi@socopon.com>
2024-04-08 00:11:36 +03:00
0813d084cc Fix parsing of binary expressions
Signed-off-by: Slendi <slendi@socopon.com>
2024-04-07 15:13:33 +03:00
3dbe9b6915 Change Color struct in example
Signed-off-by: Slendi <slendi@socopon.com>
2024-03-28 08:24:44 +02:00
81b0c139ef Add initial support for structs
There is an issue with calling C functions sadly because LLVM seems to
prefer passing each element as its own parameter than "packing" them
into 64 bit registers.

Signed-off-by: Slendi <slendi@socopon.com>
2024-03-26 13:32:51 +02:00
177a41ebd2 Add support for structure definitions and initializers
Signed-off-by: Slendi <slendi@socopon.com>
2024-03-12 10:15:38 +02:00
ef52ee47f4 Update TODO list
Signed-off-by: Slendi <slendi@socopon.com>
2024-03-10 02:13:28 +02:00
d54f9fb2f8 Add support for void function calls
Signed-off-by: Slendi <slendi@socopon.com>
2024-03-10 02:10:02 +02:00
453689642c Add support for function declarations
Signed-off-by: Slendi <slendi@socopon.com>
2024-03-10 01:30:46 +02:00
e4289d577a Make the compiler work on macOS
Signed-off-by: Slendi <slendi@socopon.com>
2024-03-10 01:16:25 +02:00
1092c68317 Add TODO list
I don't want to lose track of progress, this should make sure that won't
happen.

Signed-off-by: Slendi <slendi@socopon.com>
2024-03-03 22:28:46 +02:00
fad3f16e04 Give up on the C parser
This is just going to overcomplicate things. It will not be needed
pretty much at all for the goals of this language.

Signed-off-by: Slendi <slendi@socopon.com>
2024-03-03 22:20:05 +02:00
a88806e1e7 Remove trailing whitespace
Signed-off-by: Slendi <slendi@socopon.com>
2024-03-03 03:20:09 +02:00
64034e9086 Various improvements 2024-03-02 23:14:45 +02:00
3f2ee15302 Add support for while loops 2024-03-02 21:47:36 +02:00
907a5d12ca Add support for infinite loops 2024-03-02 20:46:57 +02:00
71c337a3f4 Add support for comparison operators
Signed-off-by: Slendi <slendi@socopon.com>
2024-03-01 15:30:25 +02:00
92c8509125 Add support for if-else
Signed-off-by: Slendi <slendi@socopon.com>
2024-03-01 14:07:11 +02:00
5dc73ab5f2 Update gitignore, add support for arrays and pointers
Signed-off-by: Slendi <slendi@socopon.com>
2024-03-01 12:21:44 +02:00
327f2bdd86 Add support for variables to LLVM emitter
Signed-off-by: Slendi <slendi@socopon.com>
2024-02-29 16:20:51 +02:00
def0e2b8e0 Remove binary
Signed-off-by: Slendi <slendi@socopon.com>
2024-02-29 14:23:13 +02:00
5455919d6e LLVM my beloved
Signed-off-by: Slendi <slendi@socopon.com>
2024-02-29 14:04:28 +02:00
484d1a6e2c Add support or extern function
Signed-off-by: Slendi <slendi@socopon.com>
2024-02-29 09:29:21 +02:00
10ae992a7b idk what i am commiting lol 2024-02-28 17:28:33 +02:00