Add C, C++, C#

This commit is contained in:
1computer1 2019-03-14 21:32:39 -04:00
parent 9a5258d91d
commit 139ec7b012
10 changed files with 87 additions and 0 deletions

View file

@ -69,6 +69,9 @@ One of the following languages is set in `lang`.
- `pas` Pascal (FPC 3.0.4) - `pas` Pascal (FPC 3.0.4)
- `go` Go (Go 1.12) - `go` Go (Go 1.12)
- `fs` F# (FSharp 4.5) - `fs` F# (FSharp 4.5)
- `c` C (GCC 8.2.0)
- `cpp` C++ (G++ 8.2.0)
- `cs` C# (Mono 5.18.0)
## Options ## Options
@ -92,3 +95,12 @@ For Go:
For F#: For F#:
- None - None
For C:
- None
For C++:
- None
For C#:
- `e` evaluates a single expression instead of a module

8
docker/c/Dockerfile Normal file
View file

@ -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

2
docker/c/run.sh Normal file
View file

@ -0,0 +1,2 @@
echo "$1" > program.c
gcc program.c -o program && ./program

8
docker/cpp/Dockerfile Normal file
View file

@ -0,0 +1,8 @@
FROM alpine
LABEL author="1Computer1"
RUN apk update
RUN apk add g++
COPY run.sh /var/run/
WORKDIR /var/ws

2
docker/cpp/run.sh Normal file
View file

@ -0,0 +1,2 @@
echo "$1" > program.cpp
g++ program.cpp -o program && ./program

5
docker/csharp/Dockerfile Normal file
View file

@ -0,0 +1,5 @@
FROM mono
LABEL author="1Computer1"
COPY run.sh /var/run/
WORKDIR /var/ws

6
docker/csharp/run.sh Normal file
View file

@ -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

11
src/languages/c.js Normal file
View file

@ -0,0 +1,11 @@
const Language = require('../struct/Language');
class C extends Language {
constructor() {
super('c', {
aliases: ['c']
});
}
}
module.exports = C;

11
src/languages/cpp.js Normal file
View file

@ -0,0 +1,11 @@
const Language = require('../struct/Language');
class CPP extends Language {
constructor() {
super('cpp', {
aliases: ['cpp', 'c++']
});
}
}
module.exports = CPP;

22
src/languages/csharp.js Normal file
View file

@ -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;