Project setup

This commit is contained in:
2026-04-24 09:29:53 +02:00
parent c90f3afd95
commit c73f99d9e6
9 changed files with 69 additions and 4 deletions
+30
View File
@@ -1,3 +1,33 @@
# C2 # C2
C2 is a compiler for a new language. C2 is a compiler for a new language.
See the README.md for information about this project. See the README.md for information about this project.
## Code Changes
After every code change, ensure the binary builds correctly,
and run the unit tests (`make test`).
Ensure that every new function and code path has useful unit tests.
### Creating Source Files
Whenever a new source file is created, it must be added to the `include.mk` file.
A test file should also be created.
Test source files do not have to be added to the include.mk file.
These are added to the `test.c` file by means of directly `#include`ing the C file.
### Testing
Any test source code must be prefixed with test_xyz, where xyz matches
the source file it is trying to test.
For instance, a test for `buffer.c` must be called `test_buffer.c`.
There will be no `test_buffer.h`. Instead, `test.c` will directly
`#include` the Csource-file directly.
## Language Syntax
Since this is a compiler for a new language, do not assume anything
of its syntax.
Always check the `specs` directory.
If there is anything unclear, ask the user for clarification.
It is certainly possible that there are contradictions in the
spec that have to be solved first.
+9 -1
View File
@@ -2,5 +2,13 @@
name: implement name: implement
description: 'Implement all @copilot annotations' description: 'Implement all @copilot annotations'
--- ---
# General
Find and implement all `@copilot` comments in the codebase. Modify only code related to those annotations, and always make sure that tests are added.
Find and implement all `@copilot` comments in the codebase. Only modify code related to those annotations. Skip e2e tests unless asked. ## Plan Mode
If you are currently in plan mode, look at all the annotations and always create a plan first.
Only start modifying code once the plan has been approved by the user.
## Implementation
Implement the changes requested at the location of the annotation.
After the implementation is finished, remove the comment containing the annotation.
+1 -1
View File
@@ -1 +1 @@
bin/ /c2
+3
View File
@@ -7,4 +7,7 @@ c2: v0/bin/c2
test:: test::
clean::
rm -f c2
include v0/include.mk include v0/include.mk
+1 -1
View File
@@ -14,4 +14,4 @@ In order to run the tests, run `make test`.
The current version is v0. Its source code lives in the `v0` directory. The current version is v0. Its source code lives in the `v0` directory.
## Languages Specifications ## Languages Specifications
See the specs directory for information on the actual language syntax. See the specs directory for information on the actual language syntax.
+9
View File
@@ -0,0 +1,9 @@
Copilot / contributor instructions for v0
- When adding new source or test files for v0, do NOT rely on wildcards. Add the file path explicitly to v0/include.mk in either V0_SRC (for library/source files) or V0_TEST (for test files beginning with `test_`).
- v0/include.mk is included by the top-level Makefile and is a dependency for object builds. Modifying v0/include.mk will force appropriate recompilation.
Example:
V0_SRC := v0/buffer.c v0/main.c
V0_TEST := v0/test.c v0/test_buffer.c
+14
View File
@@ -0,0 +1,14 @@
# General
A C2file starts with a module declaration followed by other declarations.
For instance:
```c2
module mymodule;
import libc.stdio;
void main() {
puts("Hello, world!");
}
```
+1
View File
@@ -0,0 +1 @@
/bin/
+1 -1
View File
@@ -1,5 +1,5 @@
#include "test.h" #include "test.h"
#include "../src/buffer.h" #include "buffer.h"
#include <setjmp.h> #include <setjmp.h>
#include <stdio.h> #include <stdio.h>