feat: elf parser (#21) #30
|  | @ -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{}) | ||||
| } | ||||
|  | @ -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)) | ||||
| 	} | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user