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
|
;;;
;;; View `Notes` for more information
;;;
(in-package :tim-judge)
(defparameter *problem-class-structure*
`((problem-code "1")
(problem-name "Hello world")
(input-dir "test/")
(judge-program "compare-text.sh")
(time-limit 2.0)
(mem-limit (* 2.0 1024 1024))))
(defparameter *solution-class-structure*
`((problem-code "1")
(solution-file "test/printaline.py")
(solution-output "jail/1")
(language :python)
(solution-id 1)))
(defparameter *test-set-class-structure*
`((solution-id 1)
(problem-code "1")
(from-test 1)
(to-test 1)))
(defparameter *languages-compilers*
'(:python "cpython"
:c "gcc"
:c++ "g++"
:go "6g"
:pascal "fpc"))
(defparameter *languages-interpreters*
'(:python "python"))
(defparameter *languages-extensions*
'(:python "py"
:c "c"
:c++ "cpp"
:pascal "pas"
:go "go"))
(defparameter *test-extensions*
'(:input "in"
:output "out"
:answer "ans"))
(defun make-accessor (slot-name)
"Make accessor from slot-name for class generating."
(intern (concatenate 'string
"CONF-"
(string-upcase (string slot-name)))))
(defun make-initarg (slot-name)
"Make initarg from slot-name for class generating"
(intern (string slot-name) "KEYWORD"))
(defun make-class-from-structure (s
&optional (class-name 'judge-config))
"Generate a class from a convenient user-defined variable."
(eval `(defclass ,class-name ()
,(loop
for slot in s
collect
(let* ((slot-name (nth 0 slot))
(slot-init-value (nth 1 slot)))
(list slot-name
:accessor (make-accessor slot-name)
:initarg (make-initarg slot-name)
:initform slot-init-value))))))
(defun make-dump-string (class-structure)
(format nil "~{~{~a~*~}: ~~15a~~%~}" class-structure))
(defun get-slot-value (slot-name obj)
(eval `(funcall #',(intern (concatenate 'string "CONF-"
(symbol-name slot-name))) ,obj)))
(defun make-dump-parameters (class-structure class-object)
(loop
for slot in class-structure
collect (get-slot-value (first slot) class-object)))
(defun dump-class (obj class-structure &optional (stream *standard-output*))
(apply #'format stream (make-dump-string class-structure)
(make-dump-parameters class-structure obj)))
|