Initial commit
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
# C2
|
||||||
|
C2 is a compiler for a new language.
|
||||||
|
See the README.md for information about this project.
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
name: implement
|
||||||
|
description: 'Implement all @copilot annotations'
|
||||||
|
---
|
||||||
|
|
||||||
|
Find and implement all `@copilot` comments in the codebase. Only modify code related to those annotations. Skip e2e tests unless asked.
|
||||||
@@ -1,19 +1,8 @@
|
|||||||
.PHONY: all clean
|
.PHONY: all test clean
|
||||||
|
|
||||||
SRC := main.c
|
|
||||||
BINDIR := bin
|
|
||||||
OBJ := $(SRC:%.c=$(BINDIR)/%.o)
|
|
||||||
|
|
||||||
all: c2
|
all: c2
|
||||||
|
|
||||||
clean:
|
c2: v0/bin/c2
|
||||||
rm -rv bin
|
# @copilot copy the compiler
|
||||||
|
|
||||||
c2: $(OBJ)
|
include v0/include.mk
|
||||||
gcc -o $@ $<
|
|
||||||
|
|
||||||
$(BINDIR)/%.o: %.c
|
|
||||||
gcc -c -o $@ $<
|
|
||||||
|
|
||||||
$(BINDIR):
|
|
||||||
mkdir -p $(BINDIR)
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# C2
|
||||||
|
C2 is a programming language based on C.
|
||||||
|
It adds modern high-level features such as metaprogramming, generics, etc,
|
||||||
|
but compiles down to C89.
|
||||||
|
|
||||||
|
## Building
|
||||||
|
To build the c2–compiler, simply run `make` or `make all`.
|
||||||
|
This will build the compiler and run the tests.
|
||||||
|
|
||||||
|
In order to only build the compiler, run `make c2`.
|
||||||
|
In order to run the tests, run `make test`.
|
||||||
|
|
||||||
|
## Versioning
|
||||||
|
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.
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
V0_SRC := # @copilot include everything in src
|
||||||
|
V0_TEST := # @copilot include everything in test
|
||||||
|
|
||||||
|
V0_SRC_OBJ := # @copilot implement. exampleL v0/src/main.c -> v0/bin/src/main.o
|
||||||
|
V0_TEST_OBJ := # @copilot
|
||||||
|
|
||||||
|
v0/bin/c2: $(V0_SRC OBJ)
|
||||||
|
# @copilot implement
|
||||||
|
|
||||||
|
v0/bin/test: $(V0_SRC_TEST)
|
||||||
|
# @copilot implement
|
||||||
|
|
||||||
|
# @copilot add target that builds each .c file into a .o file.
|
||||||
|
# Ensure header dependencies are tracked correctly.
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#include "test.h"
|
||||||
|
|
||||||
|
// @copilot implement fail()
|
||||||
|
|
||||||
|
static int s_totalTests;
|
||||||
|
static int s_greenTests;
|
||||||
|
|
||||||
|
static Test[] = {
|
||||||
|
// @copilot add all tests
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
/*
|
||||||
|
@copilot loop over each test.
|
||||||
|
If the test is good, count the test as part of green test.
|
||||||
|
Otherwise, go to the next one.
|
||||||
|
|
||||||
|
The start of the test must log the name of the test method.
|
||||||
|
After the test, log either "[OK]" or "[FAIL]".
|
||||||
|
|
||||||
|
At the very end, log the name of each failed test and the total
|
||||||
|
number of green tests compared to the total.
|
||||||
|
*/
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
/**
|
||||||
|
* Contains test assertions routines.
|
||||||
|
*/
|
||||||
|
#ifndef TEST_H
|
||||||
|
#define TEST_H
|
||||||
|
|
||||||
|
// @copilot fix the syntax. This is a typedef for any function taking a void and returning void.
|
||||||
|
typedef Test void(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fails a test.
|
||||||
|
* @param msg The message to print to the console.
|
||||||
|
*/
|
||||||
|
void fail(const char* msg);
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user