From dbe8e61acc616b8f5ac07e8df89eb98a7997c29d Mon Sep 17 00:00:00 2001 From: bringert Date: Fri, 25 Nov 2005 16:36:19 +0000 Subject: Move transfer into the GF repo. --- src/Transfer/Core/Core.cf | 98 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/Transfer/Core/Core.cf (limited to 'src/Transfer/Core/Core.cf') diff --git a/src/Transfer/Core/Core.cf b/src/Transfer/Core/Core.cf new file mode 100644 index 000000000..790b2815a --- /dev/null +++ b/src/Transfer/Core/Core.cf @@ -0,0 +1,98 @@ +-- This is a subset of the front-end language + +entrypoints Module, Exp ; + +comment "--" ; +comment "{-" "-}" ; + +Module. Module ::= [Decl] ; +separator Decl ";" ; + +DataDecl. Decl ::= "data" CIdent ":" Exp "where" "{" [ConsDecl] "}" ; +TypeDecl. Decl ::= CIdent ":" Exp ; +ValueDecl. Decl ::= CIdent "=" Exp ; + +ConsDecl. ConsDecl ::= CIdent ":" Exp ; +separator ConsDecl ";" ; + +separator Pattern ""; + +-- Constructor patterns. +PCons. Pattern ::= "(" CIdent [Pattern] ")" ; + +-- Variable patterns. Note that in the core language, +-- constructor patterns must have parantheses. +PVar. Pattern ::= PatternVariable ; +-- Record patterns. +PRec. Pattern ::= "{" [FieldPattern] "}"; +-- Patterns matching the constant Type. +PType. Pattern ::= "Type" ; +-- String literal patterns. +PStr. Pattern ::= String ; +-- Integer literal patterns. +PInt. Pattern ::= Integer ; + +FieldPattern. FieldPattern ::= CIdent "=" Pattern ; +separator FieldPattern ";" ; + +-- Variable patterns +PVVar. PatternVariable ::= CIdent ; +-- Wild card patterns +PVWild. PatternVariable ::= "_" ; + +-- Let expressions. +ELet. Exp ::= "let" "{" [LetDef] "}" "in" Exp ; +LetDef. LetDef ::= CIdent ":" Exp "=" Exp ; +separator LetDef ";" ; + +-- Case expressions. +ECase. Exp ::= "case" Exp "of" "{" [Case] "}" ; + +-- Lambda abstractions. +EAbs. Exp2 ::= "\\" PatternVariable "->" Exp ; +-- Function types. +EPi. Exp2 ::= "(" PatternVariable ":" Exp ")" "->" Exp ; + +-- Function application. +EApp. Exp3 ::= Exp3 Exp4 ; + +-- Record field projection. +EProj. Exp4 ::= Exp4 "." CIdent ; + +EEmptyRec. Exp5 ::= "{" "}" ; +-- Record types. +ERecType. Exp5 ::= "{" [FieldType] "}" ; +-- Record expressions. +ERec. Exp5 ::= "{" [FieldValue] "}" ; +-- Functions, constructors and local variables. +EVar. Exp5 ::= CIdent ; +-- The constant Type. +EType. Exp5 ::= "Type" ; +-- String literal expressions. +EStr. Exp5 ::= String ; +-- Integer literal expressions. +EInt. Exp5 ::= Integer ; + +coercions Exp 5 ; + +{- +-- Hack to make lists of function arguments not conflict with +-- application. +[]. [Exp] ::= ; +(:). [Exp] ::= Exp4 [Exp] ; +-} + +Case. Case ::= Pattern "->" Exp ; +separator Case ";" ; + + +FieldType. FieldType ::= CIdent ":" Exp ; +separator nonempty FieldType ";" ; + +FieldValue. FieldValue ::= CIdent "=" Exp ; +separator nonempty FieldValue ";" ; + + +-- Identifiers in core can start with underscore to allow +-- generating unique identifiers easily. +token CIdent ((letter | '_') (letter | digit | '_' | '\'')*) ; -- cgit v1.2.3