diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 2a9084e..e596e1d 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -1,3 +1,33 @@ # C2 C2 is a compiler for a new language. 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 C–source-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. diff --git a/.github/skills/implement/SKILL.md b/.github/skills/implement/SKILL.md index 4ec1c4d..6a54071 100644 --- a/.github/skills/implement/SKILL.md +++ b/.github/skills/implement/SKILL.md @@ -2,5 +2,13 @@ name: implement 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. \ No newline at end of file +## 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. diff --git a/.gitignore b/.gitignore index e660fd9..3e029b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -bin/ +/c2 diff --git a/Makefile b/Makefile index ece90db..fb0c20f 100644 --- a/Makefile +++ b/Makefile @@ -7,4 +7,7 @@ c2: v0/bin/c2 test:: +clean:: + rm -f c2 + include v0/include.mk \ No newline at end of file diff --git a/README.md b/README.md index af4d241..7f442ee 100644 --- a/README.md +++ b/README.md @@ -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. ## Languages Specifications -See the specs directory for information on the actual language syntax. \ No newline at end of file +See the specs directory for information on the actual language syntax. diff --git a/copilot-instructions.md b/copilot-instructions.md new file mode 100644 index 0000000..4b6b545 --- /dev/null +++ b/copilot-instructions.md @@ -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 + diff --git a/specs/GENERAL.md b/specs/GENERAL.md new file mode 100644 index 0000000..9da3181 --- /dev/null +++ b/specs/GENERAL.md @@ -0,0 +1,14 @@ +# General +A C2–file starts with a module declaration followed by other declarations. + +For instance: + +```c2 +module mymodule; + +import libc.stdio; + +void main() { + puts("Hello, world!"); +} +``` diff --git a/v0/.gitignore b/v0/.gitignore new file mode 100644 index 0000000..65776c3 --- /dev/null +++ b/v0/.gitignore @@ -0,0 +1 @@ +/bin/ \ No newline at end of file diff --git a/v0/test.c b/v0/test.c index 78c7c1e..00af902 100644 --- a/v0/test.c +++ b/v0/test.c @@ -1,5 +1,5 @@ #include "test.h" -#include "../src/buffer.h" +#include "buffer.h" #include #include