-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathschema.rnc
178 lines (162 loc) · 7.12 KB
/
schema.rnc
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# This document is a schema for the GTA3script configuration files.
#
# Use it to validate (and to gasp the structure of) the configuration files.
#
# This schema is written in RELAX NG. A quick reference can be found at
# https://relaxng.org/compact-tutorial-20030326.html
#
namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0"
grammar {
start =
## A GTA3script configuration file consists of commands, alternators
## and constants.
##
## Those can be given in any order, but the order on which the entries
## in a section appear matter (e.g. one may replace definitions
## from another).
element GTA3Script {
attribute Version { string "2.0" }
& Import*
& Commands*
& Alternators*
& Constants*
}
Import =
## Immediately imports a configuration file.
##
## The imported file is completly processed before continuing the
## processing of this file.
##
## The maximum depth of imports is equal 1, that means only the
## main configuration file (`config.xml`) can import other files.
##
## The depth is a design choice to
## 1) Avoid too much memory usage.
## 2) Avoid too much disk access.
## 3) Avoid complexity in the parsing code (cycles, stacks, etc).
element Import {
## Imports the configurations from the specified game config.
## If not specified, imports from the config directory of the
## game being targeted. If equal "." imports from the
## same directory as the configuration file being read.
attribute From { string }?,
## Imports the specified filename.
attribute Name { string }
}
Commands =
element Commands {
element Command {
## The name of the command in the translation environment.
##
## If a command definition of same name already exists, it is
## completly replaced with this definition.
attribute Name { string },
element Params {
element Param {
## The type of the parameter
## (as specified in gta3script-specs).
attribute Type {
string "INT"
| string "FLOAT"
| string "VAR_INT"
| string "VAR_FLOAT"
| string "VAR_TEXT_LABEL"
| string "VAR_TEXT_LABEL16"
| string "LVAR_INT"
| string "LVAR_FLOAT"
| string "LVAR_TEXT_LABEL"
| string "LVAR_TEXT_LABEL16"
| string "VAR_INT_OPT"
| string "VAR_FLOAT_OPT"
| string "VAR_TEXT_LABEL_OPT"
| string "VAR_TEXT_LABEL16_OPT"
| string "LVAR_INT_OPT"
| string "LVAR_FLOAT_OPT"
| string "LVAR_TEXT_LABEL_OPT"
| string "LVAR_TEXT_LABEL16_OPT"
| string "INPUT_INT"
| string "INPUT_FLOAT"
| string "INPUT_OPT"
| string "OUTPUT_INT"
| string "OUTPUT_FLOAT"
| string "OUTPUT_TEXT_LABEL"
| string "OUTPUT_TEXT_LABEL16"
| string "LABEL"
| string "TEXT_LABEL"
| string "TEXT_LABEL16"
| string "TEXT_LABEL32"
},
## The enumeration associated with this parameter.
attribute Enum { string }?,
## The entity type associated with this parameter.
attribute Entity { string }?
# TODO Variadic
}*
}?
}*
## Associates a command to an identifier.
##
## A command association may appear before its command
## definition appear in the config file.
& element CommandId {
## Name of the command to associate an id to.
##
## If an command of same name has been already associated with an
## id, its association is replaced with the one that follows.
attribute Name { string },
## The id of the command.
##
## Multiple command names may be associated with a single id.
##
## If this id is not specified, the `Handled` attribute must
## be false.
attribute ID { xsd:unsignedShort | hex16 }?,
## Whether this command is supported by the execution environment.
[a:defaultValue = "true"]
attribute Handled { xsd:boolean }?
}*
}
Alternators =
element Alternators {
## An alternator definition may appear before its associated
## commands appear in the config file.
element Alternator {
## The name of the alternator.
##
## If an alternator of same name already exists, it is kept and
## the alternative commands that follow are added to it.
attribute Name { string },
element Alternative {
## The name of alternative command.
attribute Name { string }
}*
}*
}
Constants =
element Constants {
element Enum {
## The name of the enumeration.
##
## If no name is given, the constants are added to the global
## string constants enumeration.
##
## If an enumeration of same name already exists, that enumeration
## is preserved and the string constants that follow are added to it.
attribute Name { string }?,
element Constant {
## The name of this string constant.
##
## If a string constant of same name already exists in this enumeration,
## it is replaced by this value.
attribute Name { string },
## The value of this string constant.
##
## If no value is given, the value of this constant is equal
## the successor of the value in the previous constant.
attribute Value { xsd:int | hex32 }?
}*
}*
}
hex16 = xsd:string { pattern = "0[xX][0-9a-fA-F]{1,4}" }
hex32 = xsd:string { pattern = "0[xX][0-9a-fA-F]{1,8}" }
}