-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathgenerators.cue
75 lines (64 loc) · 2.24 KB
/
generators.cue
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
package problemformat
// Use cue version 0.11 or later
// To validate generators.yaml using cue:
// > cue vet generators.yaml *.cue -d "#Generators"
import "struct"
import "strings"
// A command invokes a generator, like "tree --n 5".
// The regex restricts occurrences of curly-bracketed expressions
// to things like "tree --random --seed {seed:5} {name} {count}"
// - {seed} can occur at most once
// - {name} and {count} can occur any number of times
#command_args: =~"([^{}]|\\{(name|count|seed(:[0-9]+)?)\\})*"
#command: C={
!~"\\{seed.*\\{seed" // don't use seed twice
_parts: strings.Fields(C)
_parts: [#path, ...#command_args]
}
// Test cases and test groups allow configuration of solution, visualiser, and random salt.
#config: {
// Path to solution starts with slash, such as "/submissions/accepted/foo.py"
solution?: #filepath & =~"^/"
// Visualiser can be omitted to disable visualisation, may not use {count}
visualizer?: #command & =~"^/" & !~"\\{count" | null
random_salt?: string
}
#testgroup_config: {
#config
"testdata.yaml": #testdata_settings
}
#testcase:
#command & !~"^/" |
{
generate?: #command & !~"^/"
count?: int & >=1 & <=100
// The "copy" key uses a path relative to "/generators/" ending in a testcase name,
// such as "manual/samples/3".
copy?: #dirpath
["in" | "ans" | "out" | "desc" | "hint"]: string
interaction?: =~"^([<>][^\\n]*\\n)+$"
#config
}
#data_dict: {[#name]: #testgroup | #testcase}
#data_list: {[#name | ""]: #testgroup | #testcase} & struct.MinFields(1) & struct.MaxFields(1)
#testgroup: {
data?: #data_dict | [...#data_list]
include?: [...#dirpath]
#testgroup_config
}
#Generators: {
// Generators are named like files or testcases, like "tree.py" or "a".
// Each consists of a nonempty list of paths relative to "/generators/",
// such as ["tree_generator/tree.py", "lib.py"].
generators?: [#name]: [...(#path & !~"^/")] & [_, ...]
data: close({
sample!: #testgroup
secret!: #testgroup
invalid_inputs?: #testgroup
invalid_answers?: #testgroup
invalid_outputs?: #testgroup
})
#testgroup_config
version: =~"^[0-9]{4}-[0-9]{2}$" | *"2024-12"
... // Do allow unknown_key at top level for tooling
}