diff --git a/Grammar.cf b/Grammar.cf index 3f89e86..f422fd7 100644 --- a/Grammar.cf +++ b/Grammar.cf @@ -14,7 +14,7 @@ DSig. Def ::= Sig; DData. Def ::= Data; internal Sig. Sig ::= LIdent ":" Type; - SigS. Sig ::= VarName ":" Type; + SigS. Sig ::= VarName ":" Type; internal Bind. Bind ::= LIdent [LIdent] "=" Exp; BindS. Bind ::= VarName [LIdent] "=" Exp; @@ -42,6 +42,18 @@ Data. Data ::= "data" Type "where" "{" [Inj] "}" ; Inj. Inj ::= UIdent ":" Type ; +------------------------------------------------------------------------------- +-- * PATTERN MATCHING +------------------------------------------------------------------------------- + +Branch. Branch ::= Pattern "=>" Exp ; + +PVar. Pattern1 ::= LIdent; +PLit. Pattern1 ::= Lit; +PCatch. Pattern1 ::= "_"; +PEnum. Pattern1 ::= UIdent; +PInj. Pattern ::= UIdent [Pattern1]; + ------------------------------------------------------------------------------- -- * Expressions ------------------------------------------------------------------------------- @@ -70,18 +82,6 @@ define infixSymbol e1 vn e3 = EApp (EApp (EVarS (VSymbol vn)) e1) e3; LInt. Lit ::= Integer; LChar. Lit ::= Char; -------------------------------------------------------------------------------- --- * PATTERN MATCHING -------------------------------------------------------------------------------- - -Branch. Branch ::= Pattern "=>" Exp ; - -PVar. Pattern1 ::= LIdent; -PLit. Pattern1 ::= Lit; -PCatch. Pattern1 ::= "_"; -PEnum. Pattern1 ::= UIdent; -PInj. Pattern ::= UIdent [Pattern1]; - ------------------------------------------------------------------------------- -- * AUX -------------------------------------------------------------------------------