// // start ::= (FixityDeclaration)* // (DataDeclaration | FunctionDeclaration)* // (diagram start (sequence (zero-or-more (nonterminal FixityDeclaration)) (zero-or-more (choice (nonterminal DataDeclaration) (nonterminal FunctionDeclaration))) (terminal EOF))) // // DataDeclaration ::= "data" (TypeDeclaration ( "," TypeDeclaration)* ) ";" // (diagram DataDeclaration (sequence (terminal "data") (loop (nonterminal TypeDeclaration) (terminal ",")) (terminal ";"))) // // Identifier ::= // (diagram Identifier (sequence (terminal IDENTIFIER))) // // Operator ::= ( | ":") // (diagram Operator (sequence (choice (terminal INFIXOPID) (terminal ":")))) // // TypeDeclaration ::= Identifier (Identifier)* "=" // ConstrDeclaration ("|" ConstrDeclaration)* // (diagram TypeDeclaration (sequence (one-or-more (nonterminal Identifier)) (terminal "=") (loop (nonterminal ConstrDeclaration) (terminal "|")))) // // ConstrDeclaration ::= Identifier (ApplicTypeExpr)* // (diagram ConstrDeclaration (sequence (nonterminal Identifier) (zero-or-more (nonterminal ApplicTypeExpr)))) // // TypeExpr ::= ApplicTypeExpr ("->" ApplicTypeExpr)* // (diagram TypeExpr (sequence (loop (nonterminal ApplicTypeExpr) (terminal "->")))) // // ApplicTypeExpr ::= (AtomicType (TypeExpr)* ) // | "[" TypeExpr "]" // | ("(" TypeExpr ("," TypeExpr)* ")") // (diagram ApplicTypeExpr (sequence (choice (sequence (nonterminal AtomicType) (zero-or-more (nonterminal TypeExpr))) (sequence (terminal "[") (nonterminal TypeExpr) (terminal "]")) (sequence (terminal "(") (loop (nonterminal TypeExpr) (terminal ",")) (terminal ")"))))) // // AtomicType ::= "_" // | // | // | // | // | // | // | Identifier // (diagram AtomicType (sequence (choice (terminal "-") (terminal "UNIT") (terminal "BOOLTYPE") (terminal "INTTYPE") (terminal "CHARTYPE") (terminal "STRINGTYPE") (terminal "FLOATTYPE") (nonterminal "Identifier")))) // // FixityDeclaration ::= ("infix" | "infixr" | "infixl") // (() (Operator)+)+ ";" // (diagram FixityDeclaration (sequence (choice (terminal "infix") (terminal "infixr") (terminal "infixl")) (one-or-more (sequence (terminal "INTEGER_LITERAL") (one-or-more (nonterminal "Operator")))) (terminal ";"))) // // FunctionDeclaration ::= (Identifier | Operator) // ((","(Identifier | Operator))* "::" // TypeExpr | "eval" Annotation | HeadLessEquation) // ";" // (diagram FunctionDeclaration (sequence (loop (choice (nonterminal "Identifier") (nonterminal "Operator")) (terminal ",")) (terminal "::") (choice (nonterminal "TypeExpr") (sequence (terminal "eval") (nonterminal "Annotation")) (nonterminal "HeadLessEquation")) (terminal ";"))) // // Annotation ::= SimpleAnnotation // ("and" SimpleAnnotation | "or" SimpleAnnotation)* // (diagram Annotation (sequence (loop (nonterminal "SimpleAnnotation") (choice (terminal "and") (terminal "or"))))) // // SimpleAnnotation ::= ( FlexOrRigid) | "rule" // (diagram SimpleAnnotation (sequence (choice (sequence (terminal "POSITION") (nonterminal "FlexOrRigid")) (terminal "rule")))) // // FlexOrRigid ::= ("flex" | "rigid") ( "(" (ConstrAnnotation)+ ")" )? // (diagram FlexOrRigid (sequence (choice (terminal "flex") (terminal "rigid")) (optional (sequence (terminal "(") (one-or-more (nonterminal "ConstrAnnotation")) (terminal ")"))))) // // ConstrAnnotation ::= Atomic "=>" Annotation // (diagram ConstrAnnotation (sequence (nonterminal "Atomic") (terminal "=>") (nonterminal "Annotation"))) // // HeadLessEquation ::= (Pattern)* ("=" Expr | ("|" Expr "=" Expr)*) // (WhereClause)? // (diagram HeadLessEquation (sequence (zero-or-more (nonterminal "Pattern")) (loop (sequence (terminal "=") (nonterminal "Expr")) (sequence-loop (terminal "|") (nonterminal "Expr"))) (optional (nonterminal "WhereClause")))) // // WhereClause ::= "where" (LocalDecl ("," LocalDecl)*) // (diagram WhereClause (sequence (terminal "where") (loop (nonterminal "LocalDecl") (terminal ",")))) // // Atomic ::= "_" // | // | // | Identifier // | // | // | // | // | // (diagram Atomic (sequence (choice (terminal "_") (terminal "UNIT") (terminal "NIL") (nonterminal "Identifier") (terminal "INTEGER_LITERAL") (terminal "BOOL_LITERAL") (terminal "FLOAT_LITERAL") (terminal "CHAR_LITERAL") (terminal "STRING_LITERAL")))) // // Pattern ::= Atomic // | ("[" ListPattern ("," ListPattern)* "]" ) // | ("(" ListPattern ("," ListPattern)* ")" ) // (diagram Pattern (sequence (choice (nonterminal "Atomic") (sequence (terminal "[") (loop (nonterminal "ListPattern") (terminal ",")) (terminal "]")) (sequence (terminal "(") (loop (nonterminal "ListPattern") (terminal ",")) (terminal ")"))))) // // ListPattern ::= ((ApplicPattern (":" ApplicPattern)*)) // (diagram ListPattern (sequence (loop (nonterminal "ApplicPattern") (terminal ":")))) // // ApplicPattern ::= (Pattern)+ // (diagram ApplicPattern (sequence (one-or-more (nonterminal "Pattern")))) // // LocalDecl ::= (Pattern)+ "=" Expr (WhereClause)? // (diagram LocalDecl (sequence (one-or-more (nonterminal "Pattern")) (terminal "=") (nonterminal "Expr") (optional (nonterminal "WhereClause")))) // // Expr ::= (((Operator)? (Operand)+ (Operator (Operand)+ )* )) // ("::" TypeExxpr )? // (diagram Expr (sequence (optional (nonterminal "Operator")) (one-or-more (nonterminal "Operand")) (zero-or-more (sequence-loop (nonterminal "Operator") (one-or-more (nonterminal "Operand")))) (optional (sequence (terminal "::") (nonterminal "TypeExpr"))))) // // Operand ::= Atomic // | ("\\" (Pattern)+ "->" Expr) // | ("let" LocalDecl ("," LocalDecl)* "in" Expr) // | ("if" Expr "then" Expr "else" Expr) // | ("[" (Expr ("," Expr)* )? "]" ) // | ("(" Expr ("," Expr)* ")" ) // (diagram Operand (sequence (choice (nonterminal "Atomic") (sequence (terminal "\\\\") (one-or-more (nonterminal "Pattern")) (terminal "->") (nonterminal "Expr")) (sequence (terminal "let") (loop (nonterminal "LocalDecl") (terminal ",")) (terminal "in") (nonterminal "Expr")) (sequence (terminal "if") (nonterminal "Expr") (terminal "then") (nonterminal "Expr") (terminal "else") (nonterminal "Expr")) (sequence (terminal "[") (optional (loop (nonterminal "Expr") (terminal ","))) (terminal "]")) (sequence (terminal "(") (loop (nonterminal "Expr") (terminal ",")) (terminal ")")))))