2 /******************************************************************************
11 initial equationBlock ;
14 = (declaration (SEMICOLON declaration)*)? # Module
18 = command? # OneCommand
19 | commands SEMICOLON command # ManyCommands
23 = statement # StatementCommand
24 | import # ImportCommand
27 /******************************************************************************
32 = LBRACE (declaration (SEMICOLON declaration)*)? RBRACE # Declarations
36 = MODULE LBRACE (field (COMMA field)*)? RBRACE # ModuleHeader
37 | var (COMMA var)* HASTYPE type # TypeAnnotation
38 | bexp rhs # ValueDefinition
39 | DATA ID+ (EQUALS constructor (BAR constructor)*)? # DataDefinition
40 | TYPE ID+ EQUALS type # TypeDefinition
43 (WHERE declarations)? # ClassDefinition
44 | INSTANCE context? ID atype+ (WHERE declarations)? # InstanceDefinition
45 | DERIVING INSTANCE context? ID atype+ # DerivingInstanceDefinition
46 | BEGIN_STRING END_STRING # DocumentationString
47 | ANNOTATION_ID aexp* # Annotation
48 | (INFIX | INFIXL | INFIXR) INTEGER var (COMMA var)* # PrecedenceDefinition
50 | IMPORTJAVA BEGIN_STRING END_STRING WHERE declarations # ImportJava
51 | EFFECT ID BEGIN_STRING END_STRING
52 BEGIN_STRING END_STRING # EffectDefinition
53 | (RULE | ABSTRACT_RULE) ID
54 (EXTENDS ID (COMMA ID)*)?
55 WHERE ruleDeclarations # RuleDefinition
56 | MAPPING_RELATION ID atype* # MappingRelationDefinition
57 | bexp FOLLOWS ruleDeclarations # RelationDefinition
58 | RULESET ID WHERE statements # RulesetDefinition
63 BEGIN_STRING END_STRING
69 = LPAREN (importItem (COMMA importItem)*)? RPAREN # ImportShowing
70 | HIDING LPAREN (importItem (COMMA importItem)*)? RPAREN # ImportHiding
74 = ID # ImportValueItem
75 // | (TYPE | DATA) ID # ImportTypeItem
76 // | CLASS ID # ImportClassItem
81 = (ANNOTATION_ID aexp)* ID atype* # Constructor
82 | (ANNOTATION_ID aexp)* ID LBRACE
83 fieldDeclaration (COMMA fieldDeclaration)* RBRACE # RecordConstructor
87 = ID HASTYPE type # FieldDescription
90 rhs = EQUALS exp (WHERE statements)? # SimpleRhs
91 | guardedExpEq+ (WHERE statements)? # GuardedRhs
95 = BAR exp (COMMA exp)* EQUALS exp # GuardedExpEq
99 = ID+ ARROW ID # Fundep
103 = fundep (COMMA fundep)* # Fundeps
106 /******************************************************************************
111 = LBRACE (ruleDeclaration (SEMICOLON ruleDeclaration)*)? RBRACE # RuleDeclarations
115 = query # QueryRuleDeclaration
116 | ANNOTATION_ID aexp* # Annotation
119 /******************************************************************************
123 exp = bexp (HASTYPE type)? # LocalTypeAnnotation, shift HASTYPE, shift COLON
127 = MINUS? lexp (symbol lexp)* # Binary, shift MINUS, shift SYMBOL,
128 shift LESS, shift GREATER, shift SEPARATED_DOT,
133 = faexp+ # Apply, shift ID, shift LAMBDA, shift LAMBDA_MATCH,
134 shift LET, shift INTEGER, shift BEGIN_STRING,
135 shift IF, shift MATCH, shift DO,
136 shift MDO, shift ENFORCE, shift BLANK,
137 shift FLOAT, shift LPAREN, shift LBRACKET,
138 shift ESCAPED_SYMBOL, shift CHAR, shift LBRACE,
139 shift WHEN, shift ATTACHED_HASH,
140 shift SELECT, shift SELECT_FIRST, shift SELECT_DISTINCT,
141 shift TRANSFORMATION, shift EQ, shift CHR_SELECT
145 = aexp ((ATTACHED_DOT | ATTACHED_HASH) accessor)* # FieldAccess, shift ATTACHED_DOT, shift ATTACHED_HASH
150 | BEGIN_STRING END_STRING # StringAccessor
151 | LPAREN exp RPAREN # ExpAccessor
155 = LAMBDA aexp+ ARROW exp # Lambda, shift HASTYPE
156 | LAMBDA_MATCH LBRACE case (SEMICOLON case)* RBRACE # LambdaMatch, shift HASTYPE
157 | LET statements IN exp # Let, shift HASTYPE
158 | IF exp THEN exp (ELSE exp)? # If, shift HASTYPE, shift ELSE
160 LBRACE case (SEMICOLON case)* RBRACE # Match
161 | (DO | MDO) statements # Do
162 | (SELECT | SELECT_FIRST | SELECT_DISTINCT)
163 exp WHERE queryBlock # Select
165 exp WHERE verboseChrQuery # CHRSelect
166 | ENFORCE queryBlock # Enforce
167 //| WHEN queryBlock SEMICOLON exp # When
169 | ATTACHED_HASH ID # HashedId
173 | stringLiteral # String
175 | LPAREN (exp (COMMA exp)*)? RPAREN # Tuple
176 | LPAREN exp ARROW exp RPAREN # ViewPattern
177 | LPAREN symbolWithoutMinus lexp RPAREN # RightSection
178 | LPAREN lexp symbol RPAREN # LeftSection
179 | LBRACKET (exp (COMMA exp)*)? RBRACKET # ListLiteral
180 | LBRACKET exp DOTDOT exp RBRACKET # Range
182 listQualifier (COMMA listQualifier)* RBRACKET # ListComprehension
184 | ID LBRACE (field (COMMA field)*)? RBRACE # Record
185 | TRANSFORMATION ID WHERE queryBlock # Transformation
186 | EQ LBRACE equationBlock RBRACE # Eq
190 = BEGIN_STRING (SUSPEND_STRING exp CONTINUE_STRING)*
191 END_STRING # StringLiteral
195 = LBRACE (statement (SEMICOLON statement)*)? RBRACE # Statements
199 = exp # GuardStatement
200 | exp rhs # LetStatement
201 | exp BINDS exp # BindStatement
202 | exp FOLLOWS queryBlock # RuleStatement
203 | chrQuery IMPLIES chrQuery # CHRStatement
204 | WHEN verboseChrQuery THEN_AFTER_WHEN verboseChrQuery # VerboseCHRStatement
205 | CONSTRAINT constructor # ConstraintStatement
206 | INCLUDE ID aexp # LocalInclude
210 = listQualifier (COMMA listQualifier)* # CHRQuery
214 = LBRACE listQualifier (SEMICOLON listQualifier)* RBRACE # VerboseCHRQuery
218 = exp # GuardQualifier
219 | exp EQUALS exp # LetQualifier
220 | exp BINDS exp # BindQualifier
221 | THEN exp (BY exp)? # ThenQualifier
229 = ARROW exp (WHERE statements)? # SimpleCaseRhs
230 | guardedExpArrow+ (WHERE statements)? # GuardedCaseRhs
234 = BAR exp (COMMA exp)* ARROW exp # GuardedExpArrow
238 = ID EQUALS exp # Field
239 | ID # FieldShorthand
242 /******************************************************************************
247 = LBRACE (query (SEMICOLON query)*)? RBRACE # QueryBlock
251 = exp # GuardQuery, shift BINDS, shift EQUALS
252 | exp EQUALS exp # EqualsQuery
253 | exp BINDS exp # BindQuery
254 | QUERY_OP queryBlock # CompositeQuery
257 /******************************************************************************
262 = (equation (SEMICOLON equation)*)? # EquationBlock
266 = exp # GuardEquation
267 | exp EQUALS exp # BasicEquation
270 /******************************************************************************
275 = LPAREN type (COMMA type)* RPAREN IMPLIES # Context
279 = etype ((ARROW | IMPLIES) etype)* # Arrow, shift ARROW, shift IMPLIES
283 = LESS ID (COMMA ID)* GREATER btype # Effect
285 | FORALL ID+ (SEPARATED_DOT | ATTACHED_DOT) type # ForAll
289 = atype+ # ApplyType, shift ID, shift LPAREN,
295 | LPAREN (type (COMMA type)*)? RPAREN # TupleType
296 | LBRACKET type RBRACKET # ListType
297 | LBRACKET RBRACKET # ListTypeConstructor
298 | LPAREN COMMA+ RPAREN # TupleTypeConstructor
301 /******************************************************************************
302 * Variables and symbols
306 | ESCAPED_SYMBOL # EscapedSymbol
307 | LPAREN COMMA+ RPAREN # TupleConstructor
312 | ESCAPED_ID # EscapedId
316 | SEPARATED_DOT # Dot
321 | ESCAPED_ID # EscapedId
324 | SEPARATED_DOT # Dot
327 /******************************************************************************
330 dummy = COMMENT EOL # Dummy