refactor(parser/elf): modern structure
All checks were successful
build / build (push) Successful in 3m15s
build / build (pull_request) Successful in 3m14s
build / trigger-build-image (push) Has been skipped
build / trigger-build-image (pull_request) Has been skipped

This commit is contained in:
张泊明518370910136 2025-05-24 04:18:16 -04:00
parent b57e3f81ca
commit a4232884c5
GPG Key ID: D47306D7062CDA9D
3 changed files with 9 additions and 10 deletions

View File

@ -4,6 +4,13 @@ import "github.com/joint-online-judge/JOJ3/internal/stage"
var name = "elf"
type Conf struct {
Score int
Comment string
}
type Elf struct{}
func init() {
stage.RegisterParser(name, &Elf{})
}

View File

@ -5,22 +5,14 @@ import (
"fmt"
"log/slog"
"github.com/criyle/go-judge/envexec"
"github.com/joint-online-judge/JOJ3/internal/stage"
"github.com/mitchellh/mapstructure"
)
type Conf struct {
Score int
Comment string
}
type Elf struct{}
func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
stdout := executorResult.Files["stdout"]
stderr := executorResult.Files["stderr"]
if executorResult.Status != stage.Status(envexec.StatusAccepted) {
if executorResult.Status != stage.StatusAccepted {
return stage.ParserResult{
Score: 0,
Comment: fmt.Sprintf(
@ -88,7 +80,7 @@ func (*Elf) Run(results []stage.ExecutorResult, confAny any) (
if err != nil {
return nil, true, err
}
var res []stage.ParserResult
res := make([]stage.ParserResult, 0, len(results))
for _, result := range results {
res = append(res, Parse(result, *conf))
}