-
Notifications
You must be signed in to change notification settings - Fork 25
/
language.js
118 lines (103 loc) · 2.66 KB
/
language.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
export const OutputOnlyOverrides = {
KEY: 'OutputOnly',
NAME: '-',
};
export const gradingLanguageNamesMap = {
C: 'C',
Cpp11: 'C++11',
Cpp17: 'C++17',
Cpp20: 'C++20',
Go: 'Go',
Java: 'Java 11',
Pascal: 'Pascal',
Python3: 'Python 3',
PyPy3: 'PyPy 3',
Rust2021: 'Rust 2021',
OutputOnly: '-',
};
export const gradingLanguageFamiliesMap = {
C: 'C',
Cpp11: 'C++',
Cpp17: 'C++',
Cpp20: 'C++',
Go: 'Go',
Java: 'Java',
Pascal: 'Pascal',
Python3: 'Python',
PyPy3: 'Python',
Rust2021: 'Rust',
};
export const gradingLanguageFilenameExtensionsMap = {
C: ['c'],
Cpp11: ['cc', 'cpp'],
Cpp17: ['cc', 'cpp'],
Cpp20: ['cc', 'cpp'],
Go: ['go'],
Java: ['java'],
Pascal: ['pas'],
Python3: ['py'],
PyPy3: ['py'],
Rust2021: ['rs'],
OutputOnly: ['zip'],
};
export const gradingLanguageSyntaxHighlighterValueMap = {
C: 'c',
Cpp11: 'cpp',
Cpp17: 'cpp',
Cpp20: 'cpp',
Go: 'go',
Java: 'java',
Pascal: 'pascal',
Python3: 'python',
PyPy3: 'python',
Rust2021: 'rust',
OutputOnly: '',
};
export const gradingLanguageEditorSubmissionFilenamesMap = {
C: 'solution.c',
Cpp11: 'solution.cpp',
Cpp17: 'solution.cpp',
Cpp20: 'solution.cpp',
Go: 'solution.go',
Java: 'Solution.java',
Pascal: 'solution.pas',
Python3: 'solution.py',
PyPy3: 'solution.py',
Rust2021: 'solution.rs',
};
export const gradingLanguageEditorSubmissionHintsMap = {
Java: 'Public class name must be Solution',
};
export const gradingLanguages = Object.keys(gradingLanguageNamesMap)
.filter(l => l !== OutputOnlyOverrides.KEY)
.sort();
export function getGradingLanguageName(code) {
return gradingLanguageNamesMap[code] || code;
}
export function getGradingLanguageFamily(code) {
return gradingLanguageFamiliesMap[code];
}
export function getGradingLanguageFilenameExtensions(code) {
return gradingLanguageFilenameExtensionsMap[code] || [];
}
export function getGradingLanguageSyntaxHighlighterValue(code) {
return gradingLanguageSyntaxHighlighterValueMap[code] || code;
}
export function getGradingLanguageEditorSubmissionFilename(code) {
return gradingLanguageEditorSubmissionFilenamesMap[code];
}
export function getGradingLanguageEditorSubmissionHint(code) {
return gradingLanguageEditorSubmissionHintsMap[code];
}
export function getAllowedGradingLanguages(gradingEngine, restriction) {
if (gradingEngine.startsWith(OutputOnlyOverrides.KEY)) {
return [OutputOnlyOverrides.KEY];
}
if (restriction.allowedLanguageNames.length === 0) {
return gradingLanguages;
}
return restriction.allowedLanguageNames;
}
export function allLanguagesAllowed(r) {
return !r.allowedLanguageNames || r.allowedLanguageNames.length === 0;
}