@@ -25,7 +25,7 @@ documentedDeclaration : DOCCOMMENT* declaration;
25
25
// a module declaration
26
26
declaration : ' const' qualId ' :' type # const
27
27
| ' var' qualId ' :' type # var
28
- | ' assume' identOrHole ' =' expr # assume
28
+ | ' assume' (assumeName= identOrHole) ' =' expr # assume
29
29
| instanceMod # instance
30
30
| operDef # oper
31
31
| typeDef # typeDefs
@@ -39,17 +39,28 @@ declaration : 'const' qualId ':' type # const
39
39
;
40
40
41
41
// An operator definition.
42
- // We embed two kinds of parameters right in this rule.
43
- // Otherwise, the parser would start recognizing parameters everywhere.
44
- operDef : qualifier normalCallName
45
- ( /* ML-like parameter lists */
46
- ' (' (parameter (' ,' parameter)*)? ' )' (' :' type)?
47
- | ' :' type
48
- /* C-like parameter lists */
49
- | ' (' (parameter ' :' type (' ,' parameter ' :' type)*) ' )' ' :' type
50
- )?
51
- (' =' expr)? ' ;' ?
52
- ;
42
+ operDef
43
+ : qualifier normalCallName
44
+ // Fully-annotated parameter list with at least one parameter
45
+ ' (' (annotOperParam+=annotatedParameter (' ,' annotOperParam+=annotatedParameter)*) ' )'
46
+ // Mandatory annotation for return type
47
+ ' :' type
48
+ // We support header declaration with no implementation for documentation genaration
49
+ (' =' expr)?
50
+ // Optionally terminated with a semicolon
51
+ ' ;' ?
52
+ # annotatedOperDef
53
+ | qualifier normalCallName // TODO: Remove as per https://github.com/informalsystems/quint/issues/923
54
+ // Unannotated parameter list
55
+ (' (' (operParam+=parameter (' ,' operParam+=parameter)*)? ' )' )?
56
+ // Optional type annotation using the deprecated format
57
+ (' :' annotatedRetType=type)?
58
+ // We support header declaration with no implementation for documentation genaration
59
+ (' =' expr)?
60
+ // Optionally terminated with a semicolon
61
+ ' ;' ?
62
+ # deprecatedOperDef
63
+ ;
53
64
54
65
typeDef
55
66
: ' type' qualId # typeAbstractDef
@@ -205,10 +216,12 @@ lambdaUnsugared : parameter '=>' expr
205
216
lambdaTupleSugar : ' (' ' (' parameter (' ,' parameter)+ ' )' ' )' ' =>' expr;
206
217
207
218
// an identifier or a hole '_'
208
- identOrHole : ' _' | qualId
209
- ;
219
+ identOrHole : ' _' | qualId;
210
220
211
- parameter : identOrHole;
221
+ // TODO: Combine these into a single rule that support optionally annotated parameters
222
+ // Requires https://github.com/informalsystems/quint/issues/923
223
+ parameter : paramName=identOrHole;
224
+ annotatedParameter : paramName=identOrHole ' :' type;
212
225
213
226
// an identifier or a star '*'
214
227
identOrStar : ' *' | qualId
0 commit comments