update
This commit is contained in:
@@ -1,13 +1,18 @@
|
||||
import { reactive } from "vue"
|
||||
import { code, output } from "./code"
|
||||
import { computed, reactive } from "vue"
|
||||
import { output, status } from "./code"
|
||||
import { Status } from "../types"
|
||||
|
||||
export const analyse = reactive({
|
||||
line: -1,
|
||||
message: "",
|
||||
})
|
||||
|
||||
function findError(line: string) {
|
||||
const regex: any = {
|
||||
export const showAnalyse = computed(
|
||||
() => ![Status.Accepted, Status.NotStarted].includes(status.value),
|
||||
)
|
||||
|
||||
function findError(line: string, language = "python") {
|
||||
const python: any = {
|
||||
"EOFError: EOF when reading a line": "需要在输入框填写输入信息",
|
||||
"SyntaxError: invalid character in identifier":
|
||||
"可能是单词拼写错误,可能是括号、引号写成中文的了",
|
||||
@@ -18,6 +23,8 @@ function findError(line: string) {
|
||||
`命名错误,${name} 不知道是什么东西`,
|
||||
"IndentationError: expected an indented block": "缩进错误:这一行需要缩进",
|
||||
}
|
||||
const c: any = {}
|
||||
const regex = { c, python }[language]
|
||||
let message = ""
|
||||
for (let r in regex) {
|
||||
const err = line.match(r)
|
||||
@@ -33,17 +40,12 @@ function findError(line: string) {
|
||||
return message
|
||||
}
|
||||
|
||||
export function showAnalyse() {
|
||||
if (code.language === "python") {
|
||||
const line = output.value.match(/File "script.py", line (\d+)/)
|
||||
if (line) {
|
||||
analyse.line = parseInt(line[1])
|
||||
}
|
||||
const lines = output.value.split("\n")
|
||||
const lastLine = lines[lines.length - 1]
|
||||
analyse.message = findError(lastLine)
|
||||
}
|
||||
if (code.language === "c") {
|
||||
analyse.message = "C语言的正在制作中..."
|
||||
export function analyzeError() {
|
||||
const line = output.value.match(/File "script.py", line (\d+)/)
|
||||
if (line) {
|
||||
analyse.line = parseInt(line[1])
|
||||
}
|
||||
const lines = output.value.split("\n")
|
||||
const lastLine = lines[lines.length - 1]
|
||||
analyse.message = findError(lastLine)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user