summaryrefslogtreecommitdiff
path: root/src/Transfer/Core/Core.cf
diff options
context:
space:
mode:
Diffstat (limited to 'src/Transfer/Core/Core.cf')
-rw-r--r--src/Transfer/Core/Core.cf98
1 files changed, 98 insertions, 0 deletions
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 | '_' | '\'')*) ;