-
Notifications
You must be signed in to change notification settings - Fork 16
/
parser.y
2439 lines (2091 loc) · 97.4 KB
/
parser.y
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
#if __GLASGOW_HASKELL__ > 800
{-# OPTIONS_GHC -Wno-error=missing-signatures #-}
#endif
{-# LANGUAGE PatternGuards #-}
{-| The parser is generated by Happy (<http://www.haskell.org/happy>).
-
- Ideally, ranges should be as precise as possible, to get messages that
- emphasize precisely the faulting term(s) upon error.
-
- However, interactive highlighting is only applied at the end of each
- mutual block, keywords are only highlighted once (see
- `TypeChecking.Rules.Decl'). So if the ranges of two declarations
- interleave, one must ensure that keyword ranges are not included in
- the intersection. (Otherwise they are uncolored by the interactive
- highlighting.)
-
-}
module Agda.Syntax.Parser.Parser (
moduleParser
, moduleNameParser
, exprParser
, exprWhereParser
, tokensParser
, holeContentParser
, splitOnDots -- only used by the internal test-suite
) where
import Prelude hiding ( null )
import Control.Applicative ( (<|>) )
import Control.Monad
import Data.Bifunctor (first, second)
import Data.Char
import qualified Data.List as List
import Data.Maybe
import Data.Semigroup ((<>), sconcat)
import qualified Data.Traversable as T
import Agda.Syntax.Position hiding (tests)
import Agda.Syntax.Parser.Monad
import Agda.Syntax.Parser.Lexer
import Agda.Syntax.Parser.Tokens
import Agda.Syntax.Concrete as C
import Agda.Syntax.Concrete.Attribute
import Agda.Syntax.Concrete.Pattern
import Agda.Syntax.Common
import Agda.Syntax.Notation
import Agda.Syntax.Literal
import Agda.TypeChecking.Positivity.Occurrence hiding (tests)
import Agda.Utils.Either hiding (tests)
import Agda.Utils.Functor
import Agda.Utils.Hash
import Agda.Utils.List ( spanJust, chopWhen )
import Agda.Utils.List1 ( List1, pattern (:|), (<|) )
import Agda.Utils.Monad
import Agda.Utils.Null
import Agda.Utils.Pretty hiding ((<>))
import Agda.Utils.Singleton
import qualified Agda.Utils.Maybe.Strict as Strict
import qualified Agda.Utils.List1 as List1
import qualified Agda.Utils.List2 as List2
import Agda.Utils.Impossible
}
%name tokensParser Tokens
%name exprParser Expr
%name exprWhereParser ExprWhere
%name moduleParser File
%name moduleNameParser ModuleName
%name funclauseParser FunClause
%name holeContentParser HoleContent
%tokentype { Token }
%monad { Parser }
%lexer { lexer } { TokEOF{} }
%expect 8
-- * shift/reduce for \ x y z -> foo = bar
-- shifting means it'll parse as \ x y z -> (foo = bar) rather than
-- (\ x y z -> foo) = bar
--
-- * Telescope let and do-notation let.
-- Expr2 -> 'let' Declarations . LetBody
-- TypedBinding -> '(' 'let' Declarations . ')'
-- ')' shift, and enter state 486
-- (reduce using rule 189)
-- A do-block cannot end in a 'let' so committing to TypedBinding with a
-- shift is the right thing to do here.
--
-- * Named implicits in TypedBinding {x = y}. When encountering the '=' shift
-- treats this as a named implicit and reducing would fail later.
-- This is a trick to get rid of shift/reduce conflicts arising because we want
-- to parse things like "m >>= \x -> k x". See the Expr rule for more
-- information.
%nonassoc LOWEST
%nonassoc '->'
%token
'abstract' { TokKeyword KwAbstract $$ }
'codata' { TokKeyword KwCoData $$ }
'coinductive' { TokKeyword KwCoInductive $$ }
'constructor' { TokKeyword KwConstructor $$ }
'data' { TokKeyword KwData $$ }
'eta-equality' { TokKeyword KwEta $$ }
'field' { TokKeyword KwField $$ }
'forall' { TokKeyword KwForall $$ }
'variable' { TokKeyword KwVariable $$ }
'hiding' { TokKeyword KwHiding $$ }
'import' { TokKeyword KwImport $$ }
'in' { TokKeyword KwIn $$ }
'inductive' { TokKeyword KwInductive $$ }
'infix' { TokKeyword KwInfix $$ }
'infixl' { TokKeyword KwInfixL $$ }
'infixr' { TokKeyword KwInfixR $$ }
'instance' { TokKeyword KwInstance $$ }
'overlap' { TokKeyword KwOverlap $$ }
'let' { TokKeyword KwLet $$ }
'macro' { TokKeyword KwMacro $$ }
'module' { TokKeyword KwModule $$ }
'interleaved' { TokKeyword KwInterleaved $$ }
'mutual' { TokKeyword KwMutual $$ }
'no-eta-equality' { TokKeyword KwNoEta $$ }
'open' { TokKeyword KwOpen $$ }
'pattern' { TokKeyword KwPatternSyn $$ }
'postulate' { TokKeyword KwPostulate $$ }
'primitive' { TokKeyword KwPrimitive $$ }
'private' { TokKeyword KwPrivate $$ }
'public' { TokKeyword KwPublic $$ }
'quote' { TokKeyword KwQuote $$ }
'quoteTerm' { TokKeyword KwQuoteTerm $$ }
'record' { TokKeyword KwRecord $$ }
'renaming' { TokKeyword KwRenaming $$ }
'rewrite' { TokKeyword KwRewrite $$ }
'syntax' { TokKeyword KwSyntax $$ }
'tactic' { TokKeyword KwTactic $$ }
'to' { TokKeyword KwTo $$ }
'unquote' { TokKeyword KwUnquote $$ }
'unquoteDecl' { TokKeyword KwUnquoteDecl $$ }
'unquoteDef' { TokKeyword KwUnquoteDef $$ }
'using' { TokKeyword KwUsing $$ }
'where' { TokKeyword KwWhere $$ }
'do' { TokKeyword KwDo $$ }
'with' { TokKeyword KwWith $$ }
'BUILTIN' { TokKeyword KwBUILTIN $$ }
'CATCHALL' { TokKeyword KwCATCHALL $$ }
'DISPLAY' { TokKeyword KwDISPLAY $$ }
'ETA' { TokKeyword KwETA $$ }
'FOREIGN' { TokKeyword KwFOREIGN $$ }
'COMPILE' { TokKeyword KwCOMPILE $$ }
'IMPOSSIBLE' { TokKeyword KwIMPOSSIBLE $$ }
'INJECTIVE' { TokKeyword KwINJECTIVE $$ }
'INLINE' { TokKeyword KwINLINE $$ }
'NOINLINE' { TokKeyword KwNOINLINE $$ }
'MEASURE' { TokKeyword KwMEASURE $$ }
'NO_TERMINATION_CHECK' { TokKeyword KwNO_TERMINATION_CHECK $$ }
'NO_POSITIVITY_CHECK' { TokKeyword KwNO_POSITIVITY_CHECK $$ }
'NO_UNIVERSE_CHECK' { TokKeyword KwNO_UNIVERSE_CHECK $$ }
'NON_TERMINATING' { TokKeyword KwNON_TERMINATING $$ }
'NON_COVERING' { TokKeyword KwNON_COVERING $$ }
'OPTIONS' { TokKeyword KwOPTIONS $$ }
'POLARITY' { TokKeyword KwPOLARITY $$ }
'WARNING_ON_USAGE' { TokKeyword KwWARNING_ON_USAGE $$ }
'WARNING_ON_IMPORT' { TokKeyword KwWARNING_ON_IMPORT $$ }
'REWRITE' { TokKeyword KwREWRITE $$ }
'STATIC' { TokKeyword KwSTATIC $$ }
'TERMINATING' { TokKeyword KwTERMINATING $$ }
tex { TokTeX $$ }
comment { TokComment $$ }
'...' { TokSymbol SymEllipsis $$ }
'..' { TokSymbol SymDotDot $$ }
'.' { TokSymbol SymDot $$ }
';' { TokSymbol SymSemi $$ }
':' { TokSymbol SymColon $$ }
'=' { TokSymbol SymEqual $$ }
'_' { TokSymbol SymUnderscore $$ }
'?' { TokSymbol SymQuestionMark $$ }
'->' { TokSymbol SymArrow $$ }
'\\' { TokSymbol SymLambda $$ }
'@' { TokSymbol SymAs $$ }
'|' { TokSymbol SymBar $$ }
'(' { TokSymbol SymOpenParen $$ }
')' { TokSymbol SymCloseParen $$ }
'(|' { TokSymbol SymOpenIdiomBracket $$ }
'|)' { TokSymbol SymCloseIdiomBracket $$ }
'(|)' { TokSymbol SymEmptyIdiomBracket $$ }
'{{' { TokSymbol SymDoubleOpenBrace $$ }
'}}' { TokSymbol SymDoubleCloseBrace $$ }
'{' { TokSymbol SymOpenBrace $$ }
'}' { TokSymbol SymCloseBrace $$ }
-- ':{' { TokSymbol SymColonBrace $$ }
vopen { TokSymbol SymOpenVirtualBrace $$ }
vclose { TokSymbol SymCloseVirtualBrace $$ }
vsemi { TokSymbol SymVirtualSemi $$ }
'{-#' { TokSymbol SymOpenPragma $$ }
'#-}' { TokSymbol SymClosePragma $$ }
id { TokId $$ }
q_id { TokQId $$ }
string { TokString $$ }
literal { TokLiteral $$ }
%%
{--------------------------------------------------------------------------
Parsing the token stream. Used by the TeX compiler.
--------------------------------------------------------------------------}
-- Parse a list of tokens.
Tokens :: { [Token] }
Tokens : TokensR { reverse $1 }
-- Happy is much better at parsing left recursive grammars (constant
-- stack size vs. linear stack size for right recursive).
TokensR :: { [Token] }
TokensR : TokensR Token { $2 : $1 }
| { [] }
-- Parse single token.
Token :: { Token }
Token
-- Please keep these keywords in alphabetical order!
: 'abstract' { TokKeyword KwAbstract $1 }
| 'codata' { TokKeyword KwCoData $1 }
| 'coinductive' { TokKeyword KwCoInductive $1 }
| 'constructor' { TokKeyword KwConstructor $1 }
| 'data' { TokKeyword KwData $1 }
| 'do' { TokKeyword KwDo $1 }
| 'eta-equality' { TokKeyword KwEta $1 }
| 'field' { TokKeyword KwField $1 }
| 'forall' { TokKeyword KwForall $1 }
| 'hiding' { TokKeyword KwHiding $1 }
| 'import' { TokKeyword KwImport $1 }
| 'in' { TokKeyword KwIn $1 }
| 'inductive' { TokKeyword KwInductive $1 }
| 'infix' { TokKeyword KwInfix $1 }
| 'infixl' { TokKeyword KwInfixL $1 }
| 'infixr' { TokKeyword KwInfixR $1 }
| 'instance' { TokKeyword KwInstance $1 }
| 'let' { TokKeyword KwLet $1 }
| 'macro' { TokKeyword KwMacro $1 }
| 'module' { TokKeyword KwModule $1 }
| 'interleaved' { TokKeyword KwInterleaved $1 }
| 'mutual' { TokKeyword KwMutual $1 }
| 'no-eta-equality' { TokKeyword KwNoEta $1 }
| 'open' { TokKeyword KwOpen $1 }
| 'overlap' { TokKeyword KwOverlap $1 }
| 'pattern' { TokKeyword KwPatternSyn $1 }
| 'postulate' { TokKeyword KwPostulate $1 }
| 'primitive' { TokKeyword KwPrimitive $1 }
| 'private' { TokKeyword KwPrivate $1 }
| 'public' { TokKeyword KwPublic $1 }
| 'quote' { TokKeyword KwQuote $1 }
| 'quoteTerm' { TokKeyword KwQuoteTerm $1 }
| 'record' { TokKeyword KwRecord $1 }
| 'renaming' { TokKeyword KwRenaming $1 }
| 'rewrite' { TokKeyword KwRewrite $1 }
| 'syntax' { TokKeyword KwSyntax $1 }
| 'tactic' { TokKeyword KwTactic $1 }
| 'to' { TokKeyword KwTo $1 }
| 'unquote' { TokKeyword KwUnquote $1 }
| 'unquoteDecl' { TokKeyword KwUnquoteDecl $1 }
| 'unquoteDef' { TokKeyword KwUnquoteDef $1 }
| 'using' { TokKeyword KwUsing $1 }
| 'variable' { TokKeyword KwVariable $1 }
| 'where' { TokKeyword KwWhere $1 }
| 'with' { TokKeyword KwWith $1 }
-- Please keep these pragmas in alphabetical order!
| 'BUILTIN' { TokKeyword KwBUILTIN $1 }
| 'CATCHALL' { TokKeyword KwCATCHALL $1 }
| 'COMPILE' { TokKeyword KwCOMPILE $1 }
| 'DISPLAY' { TokKeyword KwDISPLAY $1 }
| 'ETA' { TokKeyword KwETA $1 }
| 'FOREIGN' { TokKeyword KwFOREIGN $1 }
| 'IMPOSSIBLE' { TokKeyword KwIMPOSSIBLE $1 }
| 'INJECTIVE' { TokKeyword KwINJECTIVE $1 }
| 'INLINE' { TokKeyword KwINLINE $1 }
| 'MEASURE' { TokKeyword KwMEASURE $1 }
| 'NOINLINE' { TokKeyword KwNOINLINE $1 }
| 'NO_POSITIVITY_CHECK' { TokKeyword KwNO_POSITIVITY_CHECK $1 }
| 'NO_TERMINATION_CHECK' { TokKeyword KwNO_TERMINATION_CHECK $1 }
| 'NO_UNIVERSE_CHECK' { TokKeyword KwNO_UNIVERSE_CHECK $1 }
| 'NON_TERMINATING' { TokKeyword KwNON_TERMINATING $1 }
| 'NON_COVERING' { TokKeyword KwNON_COVERING $1 }
| 'OPTIONS' { TokKeyword KwOPTIONS $1 }
| 'POLARITY' { TokKeyword KwPOLARITY $1 }
| 'REWRITE' { TokKeyword KwREWRITE $1 }
| 'STATIC' { TokKeyword KwSTATIC $1 }
| 'TERMINATING' { TokKeyword KwTERMINATING $1 }
| 'WARNING_ON_IMPORT' { TokKeyword KwWARNING_ON_IMPORT $1 }
| 'WARNING_ON_USAGE' { TokKeyword KwWARNING_ON_USAGE $1 }
| tex { TokTeX $1 }
| comment { TokComment $1 }
| '...' { TokSymbol SymEllipsis $1 }
| '..' { TokSymbol SymDotDot $1 }
| '.' { TokSymbol SymDot $1 }
| ';' { TokSymbol SymSemi $1 }
| ':' { TokSymbol SymColon $1 }
| '=' { TokSymbol SymEqual $1 }
| '_' { TokSymbol SymUnderscore $1 }
| '?' { TokSymbol SymQuestionMark $1 }
| '->' { TokSymbol SymArrow $1 }
| '\\' { TokSymbol SymLambda $1 }
| '@' { TokSymbol SymAs $1 }
| '|' { TokSymbol SymBar $1 }
| '(' { TokSymbol SymOpenParen $1 }
| ')' { TokSymbol SymCloseParen $1 }
| '(|' { TokSymbol SymOpenIdiomBracket $1 }
| '|)' { TokSymbol SymCloseIdiomBracket $1 }
| '(|)' { TokSymbol SymEmptyIdiomBracket $1 }
| '{{' { TokSymbol SymDoubleOpenBrace $1 }
| '}}' { TokSymbol SymDoubleCloseBrace $1 }
| '{' { TokSymbol SymOpenBrace $1 }
| '}' { TokSymbol SymCloseBrace $1 }
| vopen { TokSymbol SymOpenVirtualBrace $1 }
| vclose { TokSymbol SymCloseVirtualBrace $1 }
| vsemi { TokSymbol SymVirtualSemi $1 }
| '{-#' { TokSymbol SymOpenPragma $1 }
| '#-}' { TokSymbol SymClosePragma $1 }
| id { TokId $1 }
| q_id { TokQId $1 }
| string { TokString $1 }
| literal { TokLiteral $1 }
{--------------------------------------------------------------------------
Top level
--------------------------------------------------------------------------}
File :: { Module }
File : vopen TopLevel maybe_vclose { takeOptionsPragmas $2 }
maybe_vclose :: { () }
maybe_vclose : {- empty -} { () }
| vclose { () }
{--------------------------------------------------------------------------
Meta rules
--------------------------------------------------------------------------}
{- A layout block might have to be closed by a parse error. Example:
let x = e in e'
Here the 'let' starts a layout block which should end before the 'in'. The
problem is that the lexer doesn't know this, so there is no virtual close
brace. However when the parser sees the 'in' there will be a parse error.
This is our cue to close the layout block.
-}
close :: { () }
close : vclose { () }
| error {% popBlock }
-- You can use concrete semi colons in a layout block started with a virtual
-- brace, so we don't have to distinguish between the two semi colons. You can't
-- use a virtual semi colon in a block started by a concrete brace, but this is
-- simply because the lexer will not generate virtual semis in this case.
semi :: { Interval }
semi : ';' { $1 }
| vsemi { $1 }
-- Enter the 'imp_dir' lex state, where we can parse the keyword 'to'.
beginImpDir :: { () }
beginImpDir : {- empty -} {% pushLexState imp_dir }
{--------------------------------------------------------------------------
Helper rules
--------------------------------------------------------------------------}
-- A float. Used in fixity declarations.
Float :: { Ranged Double }
Float : literal {% forM $1 $ \case
{ LitNat i -> return $ fromInteger i
; LitFloat d -> return d
; _ -> parseError $ "Expected floating point number"
}
}
{--------------------------------------------------------------------------
Names
--------------------------------------------------------------------------}
-- A name is really a sequence of parts, but the lexer just sees it as a
-- string, so we have to do the translation here.
Id :: { Name }
Id : id {% mkName $1 }
-- Space separated list of one or more identifiers.
SpaceIds :: { List1 Name }
SpaceIds
: Id SpaceIds { $1 <| $2 }
| Id { singleton $1 }
-- When looking for a double closed brace, we accept either a single token '}}'
-- (which is what the unicode character "RIGHT WHITE CURLY BRACKET" is
-- postprocessed into in LexActions.hs), but also two consecutive tokens '}'
-- (which a string '}}' is lexed to). This small hack allows us to keep
-- "record { a = record { }}" working. In the second case, we check that the two
-- tokens '}' are immediately consecutive.
DoubleCloseBrace :: { Range }
DoubleCloseBrace
: '}}' { getRange $1 }
| '}' '}' {%
if posPos (fromJust (rEnd' (getRange $2))) -
posPos (fromJust (rStart' (getRange $1))) > 2
then parseErrorRange $2 "Expecting '}}', found separated '}'s."
else return $ getRange ($1, $2)
}
-- A possibly dotted identifier.
MaybeDottedId :: { Arg Name }
MaybeDottedId
: '..' Id { setRelevance NonStrict $ defaultArg $2 }
| '.' Id { setRelevance Irrelevant $ defaultArg $2 }
| Id { defaultArg $1 }
-- Space separated list of one or more possibly dotted identifiers.
MaybeDottedIds :: { List1 (Arg Name) }
MaybeDottedIds
: MaybeDottedId MaybeDottedIds { $1 <| $2 }
| MaybeDottedId { singleton $1 }
-- Space separated list of one or more identifiers, some of which may
-- be surrounded by braces or dotted.
ArgIds :: { List1 (Arg Name) }
ArgIds
: MaybeDottedId ArgIds { $1 <| $2 }
| MaybeDottedId { singleton $1 }
| '{{' MaybeDottedIds DoubleCloseBrace ArgIds { fmap makeInstance $2 <> $4 }
| '{{' MaybeDottedIds DoubleCloseBrace { fmap makeInstance $2 }
| '{' MaybeDottedIds '}' ArgIds { fmap hide $2 <> $4 }
| '{' MaybeDottedIds '}' { fmap hide $2 }
| '.' '{' SpaceIds '}' ArgIds { fmap (hide . setRelevance Irrelevant . defaultArg) $3 <> $5 }
| '.' '{' SpaceIds '}' { fmap (hide . setRelevance Irrelevant . defaultArg) $3 }
| '.' '{{' SpaceIds DoubleCloseBrace ArgIds { fmap (makeInstance . setRelevance Irrelevant . defaultArg) $3 <> $5 }
| '.' '{{' SpaceIds DoubleCloseBrace { fmap (makeInstance . setRelevance Irrelevant . defaultArg) $3 }
| '..' '{' SpaceIds '}' ArgIds { fmap (hide . setRelevance NonStrict . defaultArg) $3 <> $5 }
| '..' '{' SpaceIds '}' { fmap (hide . setRelevance NonStrict . defaultArg) $3 }
| '..' '{{' SpaceIds DoubleCloseBrace ArgIds { fmap (makeInstance . setRelevance NonStrict . defaultArg) $3 <> $5 }
| '..' '{{' SpaceIds DoubleCloseBrace { fmap (makeInstance . setRelevance NonStrict . defaultArg) $3 }
-- Modalities preceeding identifiers
ModalArgIds :: { ([Attr], List1 (Arg Name)) }
ModalArgIds : Attributes ArgIds {% ($1,) `fmap` mapM (applyAttrs $1) $2 }
-- Attributes are parsed as '@' followed by an atomic expression.
Attribute :: { Attr }
Attribute : '@' ExprOrAttr {% setRange (getRange ($1,$2)) `fmap` toAttribute $2 }
-- Parse a reverse list of modalities
Attributes :: { [Attr] }
Attributes : {- empty -} { [] }
| Attributes Attribute { $2 : $1 }
Attributes1 :: { List1 Attr }
Attributes1 : Attribute { singleton $1 }
| Attributes1 Attribute { $2 <| $1 }
QId :: { QName }
QId : q_id {% mkQName $1 }
| Id { QName $1 }
-- A module name is just a qualified name
ModuleName :: { QName }
ModuleName : QId { $1 }
-- A binding variable. Can be '_'
BId :: { Name }
BId : Id { $1 }
| '_' { setRange (getRange $1) simpleHole }
{- UNUSED
-- A binding variable. Can be '_'
MaybeDottedBId :: { (Relevance, Name) }
MaybeDottedBId
: BId { (Relevant , $1) }
| '.' BId { (Irrelevant, $2) }
| '..' BId { (NonStrict, $2) }
-}
-- Space separated list of binding identifiers. Used in fixity
-- declarations infixl 100 + -
SpaceBIds :: { List1 Name }
SpaceBIds
: BId SpaceBIds { $1 <| $2 }
| BId { singleton $1 }
{- DOES PRODUCE REDUCE/REDUCE CONFLICTS!
-- Space-separated list of binding identifiers. Used in dependent
-- function spaces: (x y z : Nat) -> ...
-- (Used to be comma-separated; hence the name)
-- QUESTION: Should this be replaced by SpaceBIds above?
--CommaBIds :: { [(Relevance,Name)] }
CommaBIds :: { [Name] }
CommaBIds
: CommaBIds BId { $1 ++ [$2] } -- SWITCHING DOES NOT HELP
| BId { [$1] }
-}
-- Space-separated list of binding identifiers. Used in dependent
-- function spaces: (x y z : Nat) -> ...
-- (Used to be comma-separated; hence the name)
-- QUESTION: Should this be replaced by SpaceBIds above?
-- Andreas, 2011-04-07 the trick avoids reduce/reduce conflicts
-- when parsing (x y z : A) -> B
-- at point (x y it is not clear whether x y is an application or
-- a variable list. We could be parsing (x y z) -> B
-- with ((x y) z) being a type.
CommaBIds :: { List1 (NamedArg Binder) }
CommaBIds : CommaBIdAndAbsurds {%
case $1 of
Left ns -> return ns
Right _ -> parseError $ "expected sequence of bound identifiers, not absurd pattern"
}
CommaBIdAndAbsurds :: { Either (List1 (NamedArg Binder)) (List1 Expr) }
CommaBIdAndAbsurds
: Application {% boundNamesOrAbsurd $1 }
| QId '=' QId {% (Left . singleton . updateNamedArg mkBinder) `fmap` mkNamedArg (Just $1) (Left $3) }
| '_' '=' QId {% (Left . singleton . updateNamedArg mkBinder) `fmap` mkNamedArg Nothing (Left $3) }
| QId '=' '_' {% (Left . singleton . updateNamedArg mkBinder) `fmap` mkNamedArg (Just $1) (Right $ getRange $3) }
| '_' '=' '_' {% (Left . singleton . updateNamedArg mkBinder) `fmap` mkNamedArg Nothing (Right $ getRange $3) }
-- Parse a sequence of identifiers, including hiding info.
-- Does not include instance arguments.
-- E.g. x {y z} _ {v}
-- To be used in typed bindings, like (x {y z} _ {v} : Nat).
BIdsWithHiding :: { List1 (NamedArg Binder) }
BIdsWithHiding : Application {%
-- interpret an expression as a name and maybe a pattern
case mapM exprAsNameOrHiddenNames $1 of
Nothing -> parseError "Expected sequence of possibly hidden bound identifiers"
Just good -> forM (sconcat good) $ updateNamedArgA $ \ (n, me) -> do
p <- traverse exprToPattern me
pure $ Binder p (mkBoundName_ n)
}
-- Space separated list of strings in a pragma.
PragmaStrings :: { [String] }
PragmaStrings
: {- empty -} { [] }
| string PragmaStrings { snd $1 : $2 }
{- Unused
PragmaString :: { String }
PragmaString
: string { snd $1 }
-}
Strings :: { [(Interval, String)] }
Strings : {- empty -} { [] }
| string Strings { $1 : $2 }
ForeignCode :: { [(Interval, String)] }
ForeignCode
: {- empty -} { [] }
| string ForeignCode { $1 : $2 }
| '{-#' ForeignCode '#-}' ForeignCode { [($1, "{-#")] ++ $2 ++ [($3, "#-}")] ++ $4 }
PragmaName :: { Name }
PragmaName : string {% mkName $1 }
PragmaQName :: { QName }
PragmaQName : string {% pragmaQName $1 } -- Issue 2125. WAS: string {% fmap QName (mkName $1) }
PragmaQNames :: { [QName] }
PragmaQNames : Strings {% mapM pragmaQName $1 }
{--------------------------------------------------------------------------
Expressions (terms and types)
--------------------------------------------------------------------------}
{- Expressions. You might expect lambdas and lets to appear in the first
expression category (lowest precedence). The reason they don't is that we
want to parse things like
m >>= \x -> k x
This will leads to a conflict in the following case
m >>= \x -> k x >>= \y -> k' y
At the second '>>=' we can either shift or reduce. We solve this problem
using Happy's precedence directives. The rule 'Expr -> Expr1' (which is the
rule you shouldn't use to reduce when seeing '>>=') is given LOWEST
precedence. The terminals '->' and op (which is what you should shift)
is given higher precedence.
-}
-- Top level: Function types.
Expr :: { Expr }
Expr
: TeleArrow Expr { Pi $1 $2 }
| Application3 '->' Expr { Fun (getRange ($1,$2,$3))
(defaultArg $ rawApp $1)
$3 }
| Attributes1 Application3 '->' Expr {% applyAttrs1 $1 (defaultArg $ rawApp $2) <&> \ dom ->
Fun (getRange ($1,$2,$3,$4)) dom $4 }
| Expr1 %prec LOWEST { $1 }
-- Level 1: Application
Expr1 :: { Expr }
Expr1
: UnnamedWithExprs
{% case $1 of
{ e :| [] -> return e
; e :| es -> return $ WithApp (fuseRange e es) e es
}
}
WithExprs :: { List1 (Named Name Expr) }
WithExprs
: Application3 'in' Id '|' WithExprs { named $3 (rawApp $1) <| $5 }
| Application3 {- empty -} '|' WithExprs { unnamed (rawApp $1) <| $3 }
| Application3 'in' Id { singleton (named $3 (rawApp $1)) }
| Application3 {- empty -} { singleton (unnamed (rawApp $1)) }
UnnamedWithExprs :: { List1 Expr }
UnnamedWithExprs
: Application3 '|' UnnamedWithExprs { (rawApp $1) <| $3 }
| {- empty -} Application { singleton (rawApp $1) }
Application :: { List1 Expr }
Application
: Expr2 { singleton $1 }
| Expr3 Application { $1 <| $2 }
-- Level 2: Lambdas and lets
Expr2 :: { Expr }
Expr2
: '\\' LamBindings Expr { Lam (getRange ($1,$2,$3)) $2 $3 }
| ExtendedOrAbsurdLam { $1 }
| 'forall' ForallBindings Expr { forallPi $2 $3 }
| 'let' Declarations LetBody { Let (getRange ($1,$2,$3)) $2 $3 }
| 'do' vopen DoStmts close { DoBlock (getRange ($1, $3)) $3 }
| Expr3 { $1 }
| 'tactic' Application3 { Tactic (getRange ($1, $2)) (rawApp $2) }
LetBody :: { Maybe Expr }
LetBody : 'in' Expr { Just $2 }
| {- empty -} { Nothing }
ExtendedOrAbsurdLam :: { Expr }
ExtendedOrAbsurdLam
: '\\' '{' LamClauses '}' {% extLam (getRange ($1, $2, $4)) [] $3 }
| '\\' Attributes1 '{' LamClauses '}' {% extLam (getRange ($1, $3, $5)) (List1.toList $2) $4 }
| '\\' 'where' vopen LamWhereClauses close {% extLam (getRange ($1, $2, $3, $5)) [] $4 }
| '\\' Attributes1 'where' vopen LamWhereClauses close {% extLam (getRange ($1, $3, $4, $6)) (List1.toList $2) $5 }
| '\\' AbsurdLamBindings {% extOrAbsLam (getRange $1) [] $2 }
| '\\' Attributes1 AbsurdLamBindings {% extOrAbsLam (getRange $1) (List1.toList $2) $3 }
Application3 :: { List1 Expr }
Application3
: Expr3 { singleton $1 }
| Expr3 Application3 { $1 <| $2 }
-- Christian Sattler, 2017-08-04, issue #2671
-- We allow empty lists of expressions for the LHS of extended lambda clauses.
-- I am not sure what Application3 is otherwise used for, so I keep the
-- original type and create this copy solely for extended lambda clauses.
Application3PossiblyEmpty :: { [Expr] }
Application3PossiblyEmpty
: { [] }
| Expr3 Application3PossiblyEmpty { $1 : $2 }
-- Level 3: Atoms
Expr3Curly :: { Expr }
Expr3Curly
: '{' Expr4 '}' {% HiddenArg (getRange ($1,$2,$3)) `fmap` maybeNamed $2 }
| '{' '}' { let r = fuseRange $1 $2 in HiddenArg r $ unnamed $ Absurd r }
| '{{' Expr4 DoubleCloseBrace {% InstanceArg (getRange ($1,$2,$3)) `fmap` maybeNamed $2 }
| '{{' DoubleCloseBrace { let r = fuseRange $1 $2 in InstanceArg r $ unnamed $ Absurd r }
Expr3NoCurly :: { Expr }
Expr3NoCurly
: '?' { QuestionMark (getRange $1) Nothing }
| '_' { Underscore (getRange $1) Nothing }
| 'quote' { Quote (getRange $1) }
| 'quoteTerm' { QuoteTerm (getRange $1) }
| 'unquote' { Unquote (getRange $1) }
| '(|' UnnamedWithExprs '|)' { IdiomBrackets (getRange ($1,$2,$3)) (List1.toList $2) }
| '(|)' { IdiomBrackets (getRange $1) [] }
| '(' ')' { Absurd (fuseRange $1 $2) }
| Id '@' Expr3 { As (getRange ($1,$2,$3)) $1 $3 }
| '.' Expr3 { Dot (fuseRange $1 $2) $2 }
| '..' Expr3 { DoubleDot (fuseRange $1 $2) $2 }
| 'record' '{' RecordAssignments '}' { Rec (getRange ($1,$2,$3,$4)) $3 }
| 'record' Expr3NoCurly '{' FieldAssignments '}' { RecUpdate (getRange ($1,$2,$3,$4,$5)) $2 $4 }
| '...' { Ellipsis (getRange $1) }
| ExprOrAttr { $1 }
-- Level 4: Maybe named, or cubical faces
Expr4 :: { Expr }
Expr4 : Expr1 '=' Expr { Equal (getRange ($1, $2, $3)) $1 $3 }
| Expr { $1 }
ExprOrAttr :: { Expr }
ExprOrAttr
: QId { Ident $1 }
| literal { Lit (getRange $1) (rangedThing $1) }
| '(' Expr4 ')' { Paren (getRange ($1,$2,$3)) $2 }
-- ^ this is needed for cubical stuff
Expr3 :: { Expr }
Expr3
: Expr3Curly { $1 }
| Expr3NoCurly { $1 }
RecordAssignments :: { RecordAssignments }
RecordAssignments
: {- empty -} { [] }
| RecordAssignments1 { List1.toList $1 }
RecordAssignments1 :: { List1 RecordAssignment }
RecordAssignments1
: RecordAssignment { singleton $1 }
| RecordAssignment ';' RecordAssignments1 { $1 <| $3 }
RecordAssignment :: { RecordAssignment }
RecordAssignment
: FieldAssignment { Left $1 }
| ModuleAssignment { Right $1 }
ModuleAssignment :: { ModuleAssignment }
ModuleAssignment
: ModuleName OpenArgs ImportDirective { ModuleAssignment $1 $2 $3 }
FieldAssignments :: { [FieldAssignment] }
FieldAssignments
: {- empty -} { [] }
| FieldAssignments1 { List1.toList $1 }
FieldAssignments1 :: { List1 FieldAssignment }
FieldAssignments1
: FieldAssignment { singleton $1 }
| FieldAssignment ';' FieldAssignments1 { $1 <| $3 }
FieldAssignment :: { FieldAssignment }
FieldAssignment
: Id '=' Expr { FieldAssignment $1 $3 }
{--------------------------------------------------------------------------
Bindings
--------------------------------------------------------------------------}
-- "Delta ->" to avoid conflict between Delta -> Gamma and Delta -> A.
TeleArrow :: { Telescope1 }
TeleArrow : Telescope1 '->' { $1 }
Telescope1 :: { Telescope1 }
Telescope1 : TypedBindings { $1 }
TypedBindings :: { List1 TypedBinding }
TypedBindings
: TypedBinding TypedBindings { $1 <| $2 }
| TypedBinding { singleton $1 }
-- A typed binding is either (x1 .. xn : A) or {y1 .. ym : B}
-- Andreas, 2011-04-07: or .(x1 .. xn : A) or .{y1 .. ym : B}
-- Andreas, 2011-04-27: or ..(x1 .. xn : A) or ..{y1 .. ym : B}
TypedBinding :: { TypedBinding }
TypedBinding
: '.' '(' TBindWithHiding ')' { setRange (getRange ($2,$3,$4)) $
setRelevance Irrelevant $3 }
| '.' '{' TBind '}' { setRange (getRange ($2,$3,$4)) $
setHiding Hidden $
setRelevance Irrelevant $3 }
| '.' '{{' TBind DoubleCloseBrace
{ setRange (getRange ($2,$3,$4)) $
makeInstance $
setRelevance Irrelevant $3 }
| '..' '(' TBindWithHiding ')' { setRange (getRange ($2,$3,$4)) $
setRelevance NonStrict $3 }
| '..' '{' TBind '}' { setRange (getRange ($2,$3,$4)) $
setHiding Hidden $
setRelevance NonStrict $3 }
| '..' '{{' TBind DoubleCloseBrace
{ setRange (getRange ($2,$3,$4)) $
makeInstance $
setRelevance NonStrict $3 }
| '(' TBindWithHiding ')' { setRange (getRange ($1,$2,$3)) $2 }
| '(' ModalTBindWithHiding ')' { setRange (getRange ($1,$2,$3)) $2 }
| '{{' TBind DoubleCloseBrace
{ setRange (getRange ($1,$2,$3)) $
makeInstance $2 }
| '{{' ModalTBind DoubleCloseBrace
{ setRange (getRange ($1,$2,$3)) $
makeInstance $2 }
| '{' TBind '}' { setRange (getRange ($1,$2,$3)) $
setHiding Hidden $2 }
| '{' ModalTBind '}' { setRange (getRange ($1,$2,$3)) $
setHiding Hidden $2 }
| '(' Open ')' { TLet (getRange ($1,$3)) $2 }
| '(' 'let' Declarations ')' { TLet (getRange ($1,$4)) $3 }
-- x1 .. xn : A
-- x1 .. xn :{i1 i2 ..} A
TBind :: { TypedBinding }
TBind : CommaBIds ':' Expr {
let r = getRange ($1,$2,$3) -- the range is approximate only for TypedBindings
in TBind r $1 $3
}
ModalTBind :: { TypedBinding }
ModalTBind : Attributes1 CommaBIds ':' Expr {% do
let r = getRange ($1,$2,$3,$4) -- the range is approximate only for TypedBindings
xs <- mapM (applyAttrs1 $1 . setTacticAttr $1) $2
return $ TBind r xs $4
}
-- x {y z} _ {v} : A
TBindWithHiding :: { TypedBinding }
TBindWithHiding : BIdsWithHiding ':' Expr {
let r = getRange ($1,$2,$3) -- the range is approximate only for TypedBindings
in TBind r $1 $3
}
ModalTBindWithHiding :: { TypedBinding }
ModalTBindWithHiding : Attributes1 BIdsWithHiding ':' Expr {% do
let r = getRange ($1,$2,$3,$4) -- the range is approximate only for TypedBindings
xs <- mapM (applyAttrs1 $1 . setTacticAttr $1) $2
return $ TBind r xs $4
}
-- A non-empty sequence of lambda bindings.
LamBindings :: { List1 LamBinding }
LamBindings
: LamBinds '->' {%
case absurdBinding $1 of
Just{} -> parseError "Absurd lambda cannot have a body."
Nothing -> return $ List1.fromList $ lamBindings $1
}
AbsurdLamBindings :: { Either ([LamBinding], Hiding) (List1 Expr) }
AbsurdLamBindings
: LamBindsAbsurd {%
case $1 of
Left lb -> case absurdBinding lb of
Nothing -> parseError "Missing body for lambda"
Just h -> return $ Left (lamBindings lb, h)
Right es -> return $ Right es
}
-- absurd lambda is represented by @Left hiding@
LamBinds :: { LamBinds }
LamBinds
: DomainFreeBinding LamBinds { fmap (map DomainFree (List1.toList $1) ++) $2 }
| TypedBinding LamBinds { fmap (DomainFull $1 :) $2 }
| DomainFreeBinding { mkLamBinds $ map DomainFree $ List1.toList $1 }
| TypedBinding { mkLamBinds [DomainFull $1] }
| '(' ')' { mkAbsurdBinding NotHidden }
| '{' '}' { mkAbsurdBinding Hidden }
| '{{' DoubleCloseBrace { mkAbsurdBinding (Instance NoOverlap) }
-- Like LamBinds, but could also parse an absurd LHS of an extended lambda @{ p1 ... () }@
LamBindsAbsurd :: { Either LamBinds (List1 Expr) }
LamBindsAbsurd
: DomainFreeBinding LamBinds { Left $ fmap (map DomainFree (List1.toList $1) ++) $2 }
| TypedBinding LamBinds { Left $ fmap (DomainFull $1 :) $2 }
| DomainFreeBindingAbsurd { case $1 of
Left lb -> Left $ mkLamBinds (map DomainFree $ List1.toList lb)
Right es -> Right es }
| TypedBinding { Left $ mkLamBinds [DomainFull $1] }
| '(' ')' { Left $ mkAbsurdBinding NotHidden }
| '{' '}' { Left $ mkAbsurdBinding Hidden }
| '{{' DoubleCloseBrace { Left $ mkAbsurdBinding (Instance NoOverlap) }
-- FNF, 2011-05-05: No where-clauses in extended lambdas for now.
-- Andreas, 2020-03-28: And also not in sight either nine years later.
NonAbsurdLamClause :: { LamClause }
NonAbsurdLamClause
: Application3PossiblyEmpty '->' Expr {% mkLamClause False $1 (RHS $3) }
| CatchallPragma
Application3PossiblyEmpty '->' Expr {% mkLamClause True $2 (RHS $4) }
AbsurdLamClause :: { LamClause }
AbsurdLamClause
-- FNF, 2011-05-09: By being more liberal here, we avoid shift/reduce and reduce/reduce errors.
-- Later stages such as scope checking will complain if we let something through which we should not
: Application {% mkAbsurdLamClause False $1 }
| CatchallPragma Application {% mkAbsurdLamClause True $2 }
LamClause :: { LamClause }
LamClause
: NonAbsurdLamClause { $1 }
| AbsurdLamClause { $1 }
-- Parses all extended lambda clauses except for a single absurd clause, which is taken care of
-- in AbsurdLambda
LamClauses :: { List1 LamClause }
LamClauses
: LamClauses semi LamClause { $3 <| $1 }
| AbsurdLamClause semi LamClause { $3 <| singleton $1 }
| NonAbsurdLamClause { singleton $1 }
-- Parses all extended lambda clauses including a single absurd clause.
-- For lambda-where this is not[sic!, now?] taken care of in AbsurdLambda.
LamWhereClauses :: { List1 LamClause }
LamWhereClauses
: LamWhereClauses semi LamClause { $3 <| $1 }
| LamClause { singleton $1 }
ForallBindings :: { List1 LamBinding }
ForallBindings
: TypedUntypedBindings1 '->' { $1 }
-- A non-empty sequence of possibly untyped bindings.
TypedUntypedBindings1 :: { List1 LamBinding }
TypedUntypedBindings1
: DomainFreeBinding TypedUntypedBindings1 { fmap DomainFree $1 <> $2 }
| TypedBinding TypedUntypedBindings1 { DomainFull $1 <| $2 }
| DomainFreeBinding { fmap DomainFree $1 }
| TypedBinding { singleton $ DomainFull $1 }
-- A possibly empty sequence of possibly untyped bindings.
-- This is used as telescope in data and record decls.
TypedUntypedBindings :: { [LamBinding] }
TypedUntypedBindings
: DomainFreeBinding TypedUntypedBindings { map DomainFree (List1.toList $1) ++ $2 }
| TypedBinding TypedUntypedBindings { DomainFull $1 : $2 }
| { [] }
DomainFreeBindings :: { [NamedArg Binder] }
DomainFreeBindings
: {- empty -} { [] }
| DomainFreeBinding DomainFreeBindings { List1.toList $1 ++ $2 }
-- A domain free binding is either x or {x1 .. xn}
DomainFreeBinding :: { List1 (NamedArg Binder) }
DomainFreeBinding
: DomainFreeBindingAbsurd {% case $1 of
Left lbs -> return lbs
Right _ -> parseError "expected sequence of bound identifiers, not absurd pattern"
}
MaybeAsPattern :: { Maybe Pattern }
MaybeAsPattern
: '@' Expr3 {% fmap Just (exprToPattern $2) }
| {- empty -} { Nothing }
-- A domain free binding is either x or {x1 .. xn}
DomainFreeBindingAbsurd :: { Either (List1 (NamedArg Binder)) (List1 Expr)}
DomainFreeBindingAbsurd
: BId MaybeAsPattern { Left . singleton $ mkDomainFree_ id $2 $1 }
| '.' BId MaybeAsPattern { Left . singleton $ mkDomainFree_ (setRelevance Irrelevant) $3 $2 }
| '..' BId MaybeAsPattern { Left . singleton $ mkDomainFree_ (setRelevance NonStrict) $3 $2 }
| '(' Application ')' {% exprToPattern (rawApp $2) >>= \ p ->
pure . Left . singleton $ mkDomainFree_ id (Just p) $ simpleHole }
| '(' Attributes1 CommaBIdAndAbsurds ')'
{% applyAttrs1 $2 defaultArgInfo <&> \ ai ->
first (fmap (setTacticAttr $2 . setArgInfo ai)) $3 }
| '{' CommaBIdAndAbsurds '}'
{ first (fmap hide) $2 }
| '{' Attributes1 CommaBIdAndAbsurds '}'
{% applyAttrs1 $2 defaultArgInfo <&> \ ai ->
first (fmap (hide . setTacticAttr $2 . setArgInfo ai)) $3 }
| '{{' CommaBIds DoubleCloseBrace { Left $ fmap makeInstance $2 }
| '{{' Attributes1 CommaBIds DoubleCloseBrace
{% applyAttrs1 $2 defaultArgInfo <&> \ ai ->
Left $ fmap (makeInstance . setTacticAttr $2 . setArgInfo ai) $3 }
| '.' '{' CommaBIds '}' { Left $ fmap (hide . setRelevance Irrelevant) $3 }
| '.' '{{' CommaBIds DoubleCloseBrace { Left $ fmap (makeInstance . setRelevance Irrelevant) $3 }
| '..' '{' CommaBIds '}' { Left $ fmap (hide . setRelevance NonStrict) $3 }
| '..' '{{' CommaBIds DoubleCloseBrace { Left $ fmap (makeInstance . setRelevance NonStrict) $3 }
{--------------------------------------------------------------------------
Do-notation
--------------------------------------------------------------------------}
DoStmts :: { List1 DoStmt }
DoStmts : DoStmt { singleton $1 }
| DoStmt vsemi { singleton $1 } -- #3046
| DoStmt semi DoStmts { $1 <| $3 }
DoStmt :: { DoStmt }
DoStmt : Expr DoWhere {% buildDoStmt $1 $2 }