@@ -176,7 +176,11 @@ A QL module definition has the following syntax:
176
176
177
177
::
178
178
179
- module ::= annotation* "module" modulename "{" moduleBody "}"
179
+ module ::= annotation* "module" modulename parameters? implements? "{" moduleBody "}"
180
+
181
+ parameters ::= "<" signatureExpr simpleId ("," signatureExpr simpleId)* ">"
182
+
183
+ implements ::= "implements" moduleSignatureExpr ("," moduleSignatureExpr)*
180
184
181
185
moduleBody ::= (import | predicate | class | module | alias | select)*
182
186
@@ -208,12 +212,15 @@ An import directive refers to a module identifier:
208
212
209
213
::
210
214
211
- import ::= annotations "import" importModuleId ("as" modulename)?
215
+ import ::= annotations "import" importModuleExpr ("as" modulename)?
212
216
213
217
qualId ::= simpleId | qualId "." simpleId
214
218
215
- importModuleId ::= qualId
216
- | importModuleId "::" simpleId
219
+ importModuleExpr ::= qualId | importModuleExpr "::" simpleId arguments?
220
+
221
+ arguments ::= "<" argument ("," argument)* ">"
222
+
223
+ argument ::= moduleExpr | type | predicateRef "/" int
217
224
218
225
An import directive may optionally name the imported module using an ``as `` declaration. If a name is defined, then the import directive adds to the declared module environment of the current module a mapping from the name to the declaration of the imported module. Otherwise, the current module *directly imports * the imported module.
219
226
@@ -280,9 +287,9 @@ With the exception of class domain types and character types (which cannot be re
280
287
281
288
::
282
289
283
- type ::= (moduleId "::")? classname | dbasetype | "boolean" | "date" | "float" | "int" | "string"
290
+ type ::= (moduleExpr "::")? classname | dbasetype | "boolean" | "date" | "float" | "int" | "string"
284
291
285
- moduleId ::= simpleId | moduleId "::" simpleId
292
+ moduleExpr ::= simpleId arguments? | moduleExpr "::" simpleId arguments?
286
293
287
294
A type reference is resolved to a type as follows:
288
295
@@ -597,7 +604,7 @@ Identifiers are used in following syntactic constructs:
597
604
modulename ::= simpleId
598
605
classname ::= upperId
599
606
dbasetype ::= atLowerId
600
- predicateRef ::= (moduleId "::")? literalId
607
+ predicateRef ::= (moduleExpr "::")? literalId
601
608
predicateName ::= lowerId
602
609
varname ::= lowerId
603
610
literalId ::= lowerId | atLowerId
@@ -1615,7 +1622,7 @@ Aliases define new names for existing QL entities.
1615
1622
1616
1623
alias ::= qldoc? annotations "predicate" literalId "=" predicateRef "/" int ";"
1617
1624
| qldoc? annotations "class" classname "=" type ";"
1618
- | qldoc? annotations "module" modulename "=" moduleId ";"
1625
+ | qldoc? annotations "module" modulename "=" moduleExpr ";"
1619
1626
1620
1627
1621
1628
An alias introduces a binding from the new name to the entity referred to by the right-hand side in the current module's declared predicate, type, or module environment respectively.
@@ -2064,16 +2071,23 @@ The complete grammar for QL is as follows:
2064
2071
2065
2072
ql ::= qldoc? moduleBody
2066
2073
2067
- module ::= annotation* "module" modulename "{" moduleBody "}"
2074
+ module ::= annotation* "module" modulename parameters? implements? "{" moduleBody "}"
2075
+
2076
+ parameters ::= "<" signatureExpr simpleId ("," signatureExpr simpleId)* ">"
2077
+
2078
+ implements ::= "implements" moduleSignatureExpr ("," moduleSignatureExpr)*
2068
2079
2069
2080
moduleBody ::= (import | predicate | class | module | alias | select)*
2070
2081
2071
- import ::= annotations "import" importModuleId ("as" modulename)?
2082
+ import ::= annotations "import" importModuleExpr ("as" modulename)?
2072
2083
2073
2084
qualId ::= simpleId | qualId "." simpleId
2074
2085
2075
- importModuleId ::= qualId
2076
- | importModuleId "::" simpleId
2086
+ importModuleExpr ::= qualId | importModuleExpr "::" simpleId arguments?
2087
+
2088
+ arguments ::= "<" argument ("," argument)* ">"
2089
+
2090
+ argument ::= moduleExpr | type | predicateRef "/" int
2077
2091
2078
2092
select ::= ("from" var_decls)? ("where" formula)? "select" as_exprs ("order" "by" orderbys)?
2079
2093
@@ -2120,15 +2134,19 @@ The complete grammar for QL is as follows:
2120
2134
2121
2135
field ::= qldoc? annotations var_decl ";"
2122
2136
2123
- moduleId ::= simpleId | moduleId "::" simpleId
2137
+ moduleExpr ::= simpleId arguments? | moduleExpr "::" simpleId arguments?
2138
+
2139
+ moduleSignatureExpr ::= (moduleExpr "::")? upperId arguments?
2140
+
2141
+ signatureExpr : (moduleExpr "::")? simpleId ("/" Integer | arguments)?;
2124
2142
2125
- type ::= (moduleId "::")? classname | dbasetype | "boolean" | "date" | "float" | "int" | "string"
2143
+ type ::= (moduleExpr "::")? classname | dbasetype | "boolean" | "date" | "float" | "int" | "string"
2126
2144
2127
2145
exprs ::= expr ("," expr)*
2128
2146
2129
2147
alias ::= qldoc? annotations "predicate" literalId "=" predicateRef "/" int ";"
2130
2148
| qldoc? annotations "class" classname "=" type ";"
2131
- | qldoc? annotations "module" modulename "=" moduleId ";"
2149
+ | qldoc? annotations "module" modulename "=" moduleExpr ";"
2132
2150
2133
2151
var_decls ::= (var_decl ("," var_decl)*)?
2134
2152
@@ -2249,7 +2267,7 @@ The complete grammar for QL is as follows:
2249
2267
2250
2268
dbasetype ::= atLowerId
2251
2269
2252
- predicateRef ::= (moduleId "::")? literalId
2270
+ predicateRef ::= (moduleExpr "::")? literalId
2253
2271
2254
2272
predicateName ::= lowerId
2255
2273
0 commit comments