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 = var (COMMA var)* HASTYPE type # TypeAnnotation
37 | bexp rhs # ValueDefinition
38 | DATA ID+ (EQUALS constructor (BAR constructor)*)? # DataDefinition
39 | TYPE ID+ EQUALS type # TypeDefinition
42 (WHERE declarations)? # ClassDefinition
43 | INSTANCE context? ID atype+ (WHERE declarations)? # InstanceDefinition
44 | DERIVING INSTANCE context? ID atype+ # DerivingInstanceDefinition
45 | BEGIN_STRING END_STRING # DocumentationString
46 | ANNOTATION_ID aexp* # Annotation
47 | (INFIX | INFIXL | INFIXR) INTEGER var (COMMA var)* # PrecedenceDefinition
49 | IMPORTJAVA BEGIN_STRING END_STRING WHERE declarations # ImportJava
50 | EFFECT ID BEGIN_STRING END_STRING
51 BEGIN_STRING END_STRING # EffectDefinition
52 | (RULE | ABSTRACT_RULE) ID
53 (EXTENDS ID (COMMA ID)*)?
54 WHERE ruleDeclarations # RuleDefinition
55 | MAPPING_RELATION ID atype* # MappingRelationDefinition
56 | bexp FOLLOWS ruleDeclarations # RelationDefinition
61 BEGIN_STRING END_STRING
67 = LPAREN (importItem (COMMA importItem)*)? RPAREN # ImportShowing
68 | HIDING LPAREN (importItem (COMMA importItem)*)? RPAREN # ImportHiding
72 = ID # ImportValueItem
73 // | (TYPE | DATA) ID # ImportTypeItem
74 // | CLASS ID # ImportClassItem
79 = (ANNOTATION_ID aexp)* ID atype* # Constructor
80 | (ANNOTATION_ID aexp)* ID LBRACE
81 fieldDeclaration (COMMA fieldDeclaration)* RBRACE # RecordConstructor
85 = ID HASTYPE type # FieldDescription
88 rhs = EQUALS exp (WHERE statements)? # SimpleRhs
89 | guardedExpEq+ (WHERE statements)? # GuardedRhs
93 = BAR exp (COMMA exp)* EQUALS exp # GuardedExpEq
97 = ID+ ARROW ID # Fundep
101 = fundep (COMMA fundep)* # Fundeps
104 /******************************************************************************
109 = LBRACE (ruleDeclaration (SEMICOLON ruleDeclaration)*)? RBRACE # RuleDeclarations
113 = query # QueryRuleDeclaration
114 | ANNOTATION_ID aexp* # Annotation
117 /******************************************************************************
121 exp = bexp (HASTYPE type)? # LocalTypeAnnotation, shift HASTYPE, shift COLON
122 | bexp COLON ID WITH? queryBlock? # EntityTypeAnnotation, shift LBRACE, shift WITH
126 = MINUS? lexp (symbol lexp)* # Binary, shift MINUS, shift SYMBOL,
127 shift LESS, shift GREATER, shift SEPARATED_DOT,
132 = faexp+ # Apply, shift ID, shift LAMBDA, shift LAMBDA_MATCH,
133 shift LET, shift INTEGER, shift BEGIN_STRING,
134 shift IF, shift MATCH, shift DO,
135 shift MDO, shift ENFORCE, shift BLANK,
136 shift FLOAT, shift LPAREN, shift LBRACKET,
137 shift ESCAPED_SYMBOL, shift CHAR, shift LBRACE,
138 shift WHEN, shift ATTACHED_HASH,
139 shift SELECT, shift SELECT_FIRST, shift SELECT_DISTINCT,
140 shift TRANSFORMATION, shift EQ
144 = aexp ((ATTACHED_DOT | ATTACHED_HASH) accessor)* # FieldAccess, shift ATTACHED_DOT, shift ATTACHED_HASH
149 | BEGIN_STRING END_STRING # StringAccessor
150 | LPAREN exp RPAREN # ExpAccessor
154 = LAMBDA aexp+ ARROW exp # Lambda, shift HASTYPE
155 | LAMBDA_MATCH LBRACE case (SEMICOLON case)* RBRACE # LambdaMatch, shift HASTYPE
156 | LET statements IN exp # Let, shift HASTYPE
157 | IF exp THEN exp (ELSE exp)? # If, shift HASTYPE, shift ELSE
159 LBRACE case (SEMICOLON case)* RBRACE # Match
160 | (DO | MDO) statements # Do
161 | (SELECT | SELECT_FIRST | SELECT_DISTINCT)
162 exp WHERE queryBlock # Select
163 | ENFORCE queryBlock # Enforce
164 //| WHEN queryBlock SEMICOLON exp # When
166 | ATTACHED_HASH ID # HashedId
170 | stringLiteral # String
172 | LPAREN (exp (COMMA exp)*)? RPAREN # Tuple
173 | LPAREN exp ARROW exp RPAREN # ViewPattern
174 | LPAREN symbolWithoutMinus lexp RPAREN # RightSection
175 | LPAREN lexp symbol RPAREN # LeftSection
176 | LBRACKET (exp (COMMA exp)*)? RBRACKET # ListLiteral
177 | LBRACKET exp DOTDOT exp RBRACKET # Range
179 listQualifier (COMMA listQualifier)* RBRACKET # ListComprehension
181 | ID LBRACE (field (COMMA field)*)? RBRACE # Record
182 | TRANSFORMATION ID WHERE queryBlock # Transformation
183 | EQ LBRACE equationBlock RBRACE # Eq
187 = BEGIN_STRING (SUSPEND_STRING exp CONTINUE_STRING)*
188 END_STRING # StringLiteral
192 = LBRACE (statement (SEMICOLON statement)*)? RBRACE # Statements
196 = exp # GuardStatement
197 | exp rhs # LetStatement
198 | exp BINDS exp # BindStatement
199 | exp FOLLOWS queryBlock # RuleStatement
200 | chrQuery IMPLIES chrQuery # CHRStatement
201 | WHEN verboseChrQuery THEN_AFTER_WHEN verboseChrQuery # VerboseCHRStatement
202 | CONSTRAINT ID atype* # ConstraintStatement
206 = listQualifier (COMMA listQualifier)* # CHRQuery
210 = LBRACE listQualifier (SEMICOLON listQualifier)* RBRACE # VerboseCHRQuery
214 = exp # GuardQualifier
215 | exp EQUALS exp # LetQualifier
216 | exp BINDS exp # BindQualifier
217 | THEN exp (BY exp)? # ThenQualifier
225 = ARROW exp (WHERE statements)? # SimpleCaseRhs
226 | guardedExpArrow+ (WHERE statements)? # GuardedCaseRhs
230 = BAR exp (COMMA exp)* ARROW exp # GuardedExpArrow
234 = ID EQUALS exp # Field
235 | ID # FieldShorthand
238 /******************************************************************************
243 = LBRACE (query (SEMICOLON query)*)? RBRACE # QueryBlock
247 = exp # GuardQuery, shift BINDS, shift EQUALS
248 | exp EQUALS exp # EqualsQuery
249 | exp BINDS exp # BindQuery
250 | QUERY_OP queryBlock # CompositeQuery
253 /******************************************************************************
258 = (equation (SEMICOLON equation)*)? # EquationBlock
262 = exp # GuardEquation
263 | exp EQUALS exp # BasicEquation
266 /******************************************************************************
271 = LPAREN type (COMMA type)* RPAREN IMPLIES # Context
275 = etype ((ARROW | IMPLIES) etype)* # Arrow, shift ARROW, shift IMPLIES
279 = LESS ID (COMMA ID)* GREATER btype # Effect
281 | FORALL ID+ (SEPARATED_DOT | ATTACHED_DOT) type # ForAll
285 = atype+ # ApplyType, shift ID, shift LPAREN,
291 | LPAREN (type (COMMA type)*)? RPAREN # TupleType
292 | LBRACKET type RBRACKET # ListType
293 | LBRACKET RBRACKET # ListTypeConstructor
294 | LPAREN COMMA+ RPAREN # TupleTypeConstructor
297 /******************************************************************************
298 * Variables and symbols
302 | ESCAPED_SYMBOL # EscapedSymbol
303 | LPAREN COMMA+ RPAREN # TupleConstructor
308 | ESCAPED_ID # EscapedId
312 | SEPARATED_DOT # Dot
317 | ESCAPED_ID # EscapedId
320 | SEPARATED_DOT # Dot
323 /******************************************************************************
326 dummy = COMMENT EOL # Dummy