原来 C / C++ 的编译错误学生看到的是 gcc 的英文原文。现在和 Python 一样一张翻译表 (cError.ts),照全库 2851 条 C / C++ 编译错误用现在的判题机(gcc-14)重新编译出来的 报错定的,只看第一条 error,98% 能给出说明。 三件事先于句式判,因为 gcc 对同一个错报法五花八门: - 交成了 Python 代码(330 条):gcc 报的是 request for member 之类,直接说换语言; - C 里写了 C++(iostream、cout); - 中文标点:gcc-14 不再报 stray,而是把「;」吞进变量名、错报到下一行,所以直接在 代码里找引号和注释之外的中文标点,行号按代码算。中文标点查找认 C 的 // 和 /* */。 句式上:缺分号报在下一句开头的往回挪一行,把分号写成冒号、关键字拼错(coutinue、 RETURN、return0)、文字没加引号、#include 拼错、main 外面写语句等各有说法。 gcc 的 did you mean 会从库函数里挑(num → enum),只信学生代码里有的名字。 列范围按 gcc 的显示宽度换算(中文占两格),含中文的行也能标到具体位置。 卡片改名 CompileErrorExplain,提交结果、运行例子、提交列表弹框三处都接上了。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4c6f2e7611
commit
fa092d334c
9 files changed
+508
-39
No files matched your search
@@ -15,7 +15,7 @@ import SubmissionResultTag from "shared/components/SubmissionResultTag.vue"
|
||||
import { useProblemStore } from "oj/store/problem"
|
||||
import { useSubmissionStore } from "oj/store/submission"
|
||||
import { markdownToText } from "oj/problem/utils/plainText"
|
||||
import PythonErrorExplain from "./PythonErrorExplain.vue"
|
||||
import CompileErrorExplain from "./CompileErrorExplain.vue"
|
||||
import RuntimeErrorExplain from "./RuntimeErrorExplain.vue"
|
||||
import WrongAnswerExplain from "./WrongAnswerExplain.vue"
|
||||
import LessonNext from "./LessonNext.vue"
|
||||
@@ -62,14 +62,11 @@ function stripJudgePath(text: string) {
|
||||
return text.replace(/\/judger\/run\/[^/"]+\//g, "")
|
||||
}
|
||||
|
||||
/**
|
||||
* Python 的编译错误交给 PythonErrorExplain 翻成中文。只管 Python:C / C++ 的
|
||||
* gcc 报错另是一套句式,还没做。
|
||||
*/
|
||||
const pythonCompileError = computed(() => {
|
||||
/** 编译错误交给 CompileErrorExplain 翻成中文:Python、C、C++ 各有一张翻译表 */
|
||||
const compileError = computed(() => {
|
||||
const submission = props.submission
|
||||
if (!submission || submission.result !== SubmissionStatus.compile_error) return ""
|
||||
if (submission.language !== "Python") return ""
|
||||
if (!["Python", "C", "C++"].includes(submission.language)) return ""
|
||||
return submission.statisticInfo?.err_info ?? ""
|
||||
})
|
||||
|
||||
@@ -117,8 +114,8 @@ const showSimilar = computed(
|
||||
|
||||
const msg = computed(() => {
|
||||
if (!props.submission) return ""
|
||||
// 走 PythonErrorExplain / RuntimeErrorExplain 那两张中文卡片
|
||||
if (pythonCompileError.value || runtimeError.value) return ""
|
||||
// 走 CompileErrorExplain / RuntimeErrorExplain 那两张中文卡片
|
||||
if (compileError.value || runtimeError.value) return ""
|
||||
|
||||
let msg = ""
|
||||
const result = props.submission.result
|
||||
@@ -318,7 +315,7 @@ const columns: DataTableColumn<JudgeCaseResult>[] = [
|
||||
<n-flex
|
||||
vertical
|
||||
v-if="
|
||||
pythonCompileError ||
|
||||
compileError ||
|
||||
runtimeError ||
|
||||
sampleCheck ||
|
||||
msg ||
|
||||
@@ -326,7 +323,11 @@ const columns: DataTableColumn<JudgeCaseResult>[] = [
|
||||
submission.statisticInfo?.ast_results?.length
|
||||
"
|
||||
>
|
||||
<PythonErrorExplain v-if="pythonCompileError" :err-info="pythonCompileError" />
|
||||
<CompileErrorExplain
|
||||
v-if="compileError"
|
||||
:err-info="compileError"
|
||||
:language="submission.language"
|
||||
/>
|
||||
<RuntimeErrorExplain v-if="runtimeError" :info="runtimeError" :code="submission.code" />
|
||||
<WrongAnswerExplain
|
||||
v-if="sampleCheck"
|
||||
|
||||
Reference in new issue
Block a user