-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrdl_ebnf.txt
130 lines (107 loc) · 5.6 KB
/
rdl_ebnf.txt
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
SchemaV3 ::= SchemaOptions? TypeDef* ResourceDef*
SchemaOptions ::= NamespaceSpec? NameSpec? VersionSpec? BasePath? IncludeSpec* UseSpec*
NamespaceSpec ::= "namespace" Namespace (";")?
NameSpec ::= "name" Name (";")?
VersionSpec ::= "version" LiteralInteger (";")?
BasePath ::= "base" LiteralString (";")?
IncludeSpec ::= "include" LiteralString (";")?
UseSpec ::= "use" LiteralString (";")?
TypeDef ::= "type" Name TypeSpec (";")?
TypeSpec ::= TypeRef
| AliasTypeSpec
| BytesTypeSpec
| StringTypeSpec
| SymbolTypeSpec
| ArrayTypeSpec
| MapTypeSpec
| StructTypeSpec
| UnionTypeSpec
| EnumTypeSpec
AliasTypeSpec ::= TypeRef ("(" ExtendedOption ("," ExtendedOption)* ")")?
BytesTypeSpec ::= "Bytes" ("[" LiteralInteger "]")? ("(" BytesOption ("," BytesOption)* ")")?
BytesOption ::= "minsize" "=" LiteralInteger | "maxsize" "=" LiteralInteger
| ExtendedOption
StringTypeSpec ::= "String" ("(" StringOption ("," StringOption)* ")")?
StringOption ::= "pattern" "=" LiteralString
| "values" "=" "[" LiteralString ("," LiteralString)* "]"
| "minsize" "=" LiteralInteger | "maxsize" "=" LiteralInteger
| ExtendedOption
SymbolTypeSpec ::= "Symbol" ("(" SymbolOption ("," SymbolOption)* ")")?
SymbolOption ::= "values" "=" "[" LiteralSymbol ("," LiteralSymbol)* "]"
| ExtendedOption
ArrayTypeSpec ::= "Array" "<" TypeRef ">" ("(" ArrayOption ("," ArrayOption)* ")")?
ArrayOption ::= "size" "=" LiteralInteger | "minsize" "=" LiteralInteger | "maxsize" "=" LiteralInteger | ExtendedOption
MapTypeSpec ::= "Map" "<" TypeRef "," TypeRef ">" ("(" MapOption ("," MapOption)* ")")?
MapOption ::= "size" "=" LiteralInteger | "minsize" "=" LiteralInteger | "maxsize" "=" LiteralInteger | ExtendedOption
StructTypeSpec ::= "Struct" ("(" StructOption ("," StructOption)* ")")? "{" FieldSpec+ "}"
StructOption ::= "closed"
| ExtendedOption
FieldSpec ::= TypeSpec Name ("(" FieldOption ("," FieldOption)* ")")? ";"
FieldOption ::= "optional"
| "default" "=" Literal
| StringOption
| SymbolOption
| ArrayOption
| MapOption
| NumberOption
| ExtendedOption
NumberTypeSpec ::= NumberType ("(" NumberOption ("," NumberOption)* ")")?
NumberOption ::= "min" "=" LiteralNumber | "max" "=" LiteralNumber
| ExtendedOption
UnionTypeSpec ::= "Union" "<" TypeName ("," TypeName)* ">" ("(" UnionOption ("," UnionOption)* ")")?
UnionOption ::= ExtendedOption
EnumTypeSpec ::= "Enum" ("(" EnumOption ("," EnumOption)* ")")? "{" Identifier ("," Identifier)* ("}")?
EnumOption ::= ExtendedOption
ExtendedOption ::= "x_" LiteralSymbol
| "x_" LiteralSymbol "=" LiteralString
NumericType ::= "Int8" | "Int16" | "Int32" | "Int64" | "Float32" | "Float64"
TypeName ::= "Bool"
| "Bytes" | "String" | "Symbol"
| "UUID" | "Timestamp"
| "Array" | "Map" | "Struct"
| NumericType
| UserTypeName
TypeRef ::= TypeName | "Any"
UserTypeName ::= Name
Identifier ::= Name
Name ::= NameStartChar (NameChar)*
CompoundName ::= Name ("." Name)*
Namespace ::= CompoundName
Literal ::= LiteralMap | LiteralArray | LiteralNumber | LiteralString | LiteralSymbol | "true" | "false"
LiteralSymbol ::= Name
LiteralMap ::= "{" (Name ":" Literal) ("," Name ":" Literal)* "}"
LiteralArray ::= "[" Literal ("," Literal)* "}"
LiteralString ::= '"' [^"]* '"'
LiteralNumber ::= LiteralInteger ("." Digit+)?
LiteralInteger ::= ("-")? PositiveDigit (Digit)*
PositiveDigit ::= [1-9]
Digit ::= [0-9]
Alphanumeric ::= [A-Z] | [a-z] | [0-9]
NameStartChar ::= [A-Z] | "_" | [a-z]
NameChar ::= NameStartChar | [0-9]
ResourceDef ::= "resource" TypeName Method LiteralString "{" InputSpec+ OutputSpec+ Authorization ExpectedSpec ExceptionSpec "}"
Method ::= "GET"
| "PUT"
| "DELETE"
| "POST"
StringTemplate ::= '"' ([^"]* "{" Name "}")* '"'
InputSpec ::= TypeSpec Name ("(" InputOption ("," InputOption)* ")")? ";"
ParamOption ::= "optional"
| "header" "=" ParamName
| "context" "=" ("auth.credentials" | "auth.principal")
| "default" "=" Literal
OutputSpec ::= TypeSpec Name ("(" OutputOption ("," OutputOption)* ")")? ";"
OutputOption ::= "header" "=" ParamName
| "out"
Authorization ::= "authorize" "(" ActionName "," ResourceName ("," DomainName)? ")"
ExpectedSpec ::= "expected" Status ("," Status)* ";"
ExceptionSpec ::= "exception" "{" (TypeName Status ";")+ "}"
Status ::= "OK"
| "CREATED"
| "NO_CONTENT"
| "NOT_MODIFIED"
| "NOT_FOUND"
| "BAD_REQUEST"
| "etc"
ParamChar ::= [A-Z] | "-" | [a-z] | [0-9] | "_"
ParamName ::= (ParamChar)+