Transfer added guards and Eq derivation.

This commit is contained in:
bringert
2005-12-02 18:33:08 +00:00
parent dea5158cbf
commit 983aef132b
21 changed files with 1320 additions and 1168 deletions

View File

@@ -19,6 +19,7 @@ import Transfer.ErrM
'{' { PT _ (TS "{") }
'}' { PT _ (TS "}") }
'=' { PT _ (TS "=") }
'|' { PT _ (TS "|") }
'||' { PT _ (TS "||") }
'::' { PT _ (TS "::") }
'(' { PT _ (TS "(") }
@@ -28,8 +29,8 @@ import Transfer.ErrM
',' { PT _ (TS ",") }
'_' { PT _ (TS "_") }
'->' { PT _ (TS "->") }
'<-' { PT _ (TS "<-") }
'\\' { PT _ (TS "\\") }
'<-' { PT _ (TS "<-") }
'>>=' { PT _ (TS ">>=") }
'>>' { PT _ (TS ">>") }
'&&' { PT _ (TS "&&") }
@@ -93,7 +94,7 @@ ListImport : {- empty -} { [] }
Decl :: { Decl }
Decl : 'data' Ident ':' Exp 'where' '{' ListConsDecl '}' { DataDecl $2 $4 $7 }
| Ident ':' Exp { TypeDecl $1 $3 }
| Ident ListPattern '=' Exp { ValueDecl $1 (reverse $2) $4 }
| Ident ListPattern Guard '=' Exp { ValueDecl $1 (reverse $2) $3 $5 }
| 'derive' Ident Ident { DeriveDecl $2 $3 }
@@ -113,6 +114,11 @@ ListConsDecl : {- empty -} { [] }
| ConsDecl ';' ListConsDecl { (:) $1 $3 }
Guard :: { Guard }
Guard : '|' Exp1 { GuardExp $2 }
| {- empty -} { GuardNo }
Pattern :: { Pattern }
Pattern : Pattern1 '||' Pattern { POr $1 $3 }
| Pattern1 { $1 }
@@ -165,13 +171,25 @@ ListFieldPattern : {- empty -} { [] }
Exp :: { Exp }
Exp : 'let' '{' ListLetDef '}' 'in' Exp { ELet $3 $6 }
| 'case' Exp 'of' '{' ListCase '}' { ECase $2 $5 }
| 'if' Exp 'then' Exp 'else' Exp { EIf $2 $4 $6 }
| 'do' '{' ListBind Exp '}' { EDo (reverse $3) $4 }
Exp : '(' VarOrWild ':' Exp ')' '->' Exp { EPi $2 $4 $7 }
| Exp1 '->' Exp { EPiNoVar $1 $3 }
| Exp1 { $1 }
VarOrWild :: { VarOrWild }
VarOrWild : Ident { VVar $1 }
| '_' { VWild }
Exp1 :: { Exp }
Exp1 : '\\' VarOrWild '->' Exp1 { EAbs $2 $4 }
| 'let' '{' ListLetDef '}' 'in' Exp1 { ELet $3 $6 }
| 'case' Exp 'of' '{' ListCase '}' { ECase $2 $5 }
| 'if' Exp 'then' Exp 'else' Exp1 { EIf $2 $4 $6 }
| 'do' '{' ListBind Exp '}' { EDo (reverse $3) $4 }
| Exp2 { $1 }
LetDef :: { LetDef }
LetDef : Ident ':' Exp '=' Exp { LetDef $1 $3 $5 }
@@ -183,7 +201,7 @@ ListLetDef : {- empty -} { [] }
Case :: { Case }
Case : Pattern '->' Exp { Case $1 $3 }
Case : Pattern Guard '->' Exp { Case $1 $2 $4 }
ListCase :: { [Case] }
@@ -202,18 +220,6 @@ ListBind : {- empty -} { [] }
| ListBind Bind ';' { flip (:) $1 $2 }
Exp2 :: { Exp }
Exp2 : '\\' VarOrWild '->' Exp { EAbs $2 $4 }
| '(' VarOrWild ':' Exp ')' '->' Exp { EPi $2 $4 $7 }
| Exp3 '->' Exp { EPiNoVar $1 $3 }
| Exp3 { $1 }
VarOrWild :: { VarOrWild }
VarOrWild : Ident { VVar $1 }
| '_' { VWild }
Exp3 :: { Exp }
Exp3 : Exp3 '>>=' Exp4 { EBind $1 $3 }
| Exp3 '>>' Exp4 { EBindC $1 $3 }
@@ -306,8 +312,8 @@ ListFieldValue : {- empty -} { [] }
| FieldValue ';' ListFieldValue { (:) $1 $3 }
Exp1 :: { Exp }
Exp1 : Exp2 { $1 }
Exp2 :: { Exp }
Exp2 : Exp3 { $1 }
ListExp :: { [Exp] }