diff --git a/README.md b/README.md index 1ed83e5..88de921 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,9 @@ One of the following languages is set in `lang`. - `pas` Pascal (FPC 3.0.4) - `go` Go (Go 1.12) - `fs` F# (FSharp 4.5) +- `c` C (GCC 8.2.0) +- `cpp` C++ (G++ 8.2.0) +- `cs` C# (Mono 5.18.0) ## Options @@ -92,3 +95,12 @@ For Go: For F#: - None + +For C: +- None + +For C++: +- None + +For C#: +- `e` evaluates a single expression instead of a module diff --git a/docker/c/Dockerfile b/docker/c/Dockerfile new file mode 100644 index 0000000..7ddcf4c --- /dev/null +++ b/docker/c/Dockerfile @@ -0,0 +1,8 @@ +FROM alpine +LABEL author="1Computer1" + +RUN apk update +RUN apk add gcc libc-dev + +COPY run.sh /var/run/ +WORKDIR /var/ws diff --git a/docker/c/run.sh b/docker/c/run.sh new file mode 100644 index 0000000..3759528 --- /dev/null +++ b/docker/c/run.sh @@ -0,0 +1,2 @@ +echo "$1" > program.c +gcc program.c -o program && ./program diff --git a/docker/cpp/Dockerfile b/docker/cpp/Dockerfile new file mode 100644 index 0000000..d4aefad --- /dev/null +++ b/docker/cpp/Dockerfile @@ -0,0 +1,8 @@ +FROM alpine +LABEL author="1Computer1" + +RUN apk update +RUN apk add g++ + +COPY run.sh /var/run/ +WORKDIR /var/ws diff --git a/docker/cpp/run.sh b/docker/cpp/run.sh new file mode 100644 index 0000000..cd796f4 --- /dev/null +++ b/docker/cpp/run.sh @@ -0,0 +1,2 @@ +echo "$1" > program.cpp +g++ program.cpp -o program && ./program diff --git a/docker/csharp/Dockerfile b/docker/csharp/Dockerfile new file mode 100644 index 0000000..c4c42ba --- /dev/null +++ b/docker/csharp/Dockerfile @@ -0,0 +1,5 @@ +FROM mono +LABEL author="1Computer1" + +COPY run.sh /var/run/ +WORKDIR /var/ws diff --git a/docker/csharp/run.sh b/docker/csharp/run.sh new file mode 100644 index 0000000..f848c24 --- /dev/null +++ b/docker/csharp/run.sh @@ -0,0 +1,6 @@ +if [ "$EVAL_EXPR" = "true" ]; then + csharp -e "$1" +else + echo "$1" > program.cs + csc program.cs >/dev/null && mono program.exe +fi diff --git a/src/languages/c.js b/src/languages/c.js new file mode 100644 index 0000000..c33c2bc --- /dev/null +++ b/src/languages/c.js @@ -0,0 +1,11 @@ +const Language = require('../struct/Language'); + +class C extends Language { + constructor() { + super('c', { + aliases: ['c'] + }); + } +} + +module.exports = C; diff --git a/src/languages/cpp.js b/src/languages/cpp.js new file mode 100644 index 0000000..a7a2053 --- /dev/null +++ b/src/languages/cpp.js @@ -0,0 +1,11 @@ +const Language = require('../struct/Language'); + +class CPP extends Language { + constructor() { + super('cpp', { + aliases: ['cpp', 'c++'] + }); + } +} + +module.exports = CPP; diff --git a/src/languages/csharp.js b/src/languages/csharp.js new file mode 100644 index 0000000..9b27342 --- /dev/null +++ b/src/languages/csharp.js @@ -0,0 +1,22 @@ +const Language = require('../struct/Language'); + +class CSharp extends Language { + constructor() { + super('csharp', { + aliases: ['csharp', 'cs'], + options: { + e: () => '' + } + }); + } + + runWith(options) { + if (options.has('e')) { + return { id: this.id, env: { EVAL_EXPR: 'true' } }; + } + + return super.runWith(options); + } +} + +module.exports = CSharp;