summaryrefslogtreecommitdiff
path: root/src-3.0/Transfer/Core/Core.cf
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2008-05-21 09:26:44 +0000
committeraarne <aarne@cs.chalmers.se>2008-05-21 09:26:44 +0000
commit055c0d0d5a5bb0dc75904fe53df7f2e4f5732a8f (patch)
tree0e63fb68c69c8f6ad0f78893c63420f0a3600e1c /src-3.0/Transfer/Core/Core.cf
parent915a1de71783ab8446b1af9e72c7ba7dfbc12d3f (diff)
GF/src is now for 2.9, and the new sources are in src-3.0 - keep it this way until the release of GF 3
Diffstat (limited to 'src-3.0/Transfer/Core/Core.cf')
-rw-r--r--src-3.0/Transfer/Core/Core.cf93
1 files changed, 93 insertions, 0 deletions
diff --git a/src-3.0/Transfer/Core/Core.cf b/src-3.0/Transfer/Core/Core.cf
new file mode 100644
index 000000000..cd4c20569
--- /dev/null
+++ b/src-3.0/Transfer/Core/Core.cf
@@ -0,0 +1,93 @@
+-- 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 ::= "rec" "{" [FieldPattern] "}";
+-- 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 ;
+separator LetDef ";" ;
+
+-- Case expressions.
+ECase. Exp ::= "case" Exp "of" "{" [Case] "}" ;
+Case. Case ::= Pattern "|" Exp "->" Exp ;
+separator Case ";" ;
+
+-- Lambda abstractions.
+EAbs. Exp1 ::= "\\" PatternVariable "->" Exp ;
+-- Function types.
+EPi. Exp1 ::= "(" PatternVariable ":" Exp ")" "->" Exp ;
+
+-- Function application.
+EApp. Exp3 ::= Exp3 Exp4 ;
+
+-- Record field projection.
+EProj. Exp4 ::= Exp4 "." CIdent ;
+
+-- Record types.
+ERecType. Exp5 ::= "sig" "{" [FieldType] "}" ;
+FieldType. FieldType ::= CIdent ":" Exp ;
+separator FieldType ";" ;
+
+-- Record expressions.
+ERec. Exp5 ::= "rec" "{" [FieldValue] "}" ;
+FieldValue.FieldValue ::= CIdent "=" Exp ;
+separator FieldValue ";" ;
+
+
+-- Functions, constructors and local variables.
+EVar. Exp5 ::= CIdent ;
+-- The constant Type.
+EType. Exp5 ::= "Type" ;
+-- String literal expressions.
+EStr. Exp5 ::= String ;
+-- Integer literal expressions.
+EInteger. Exp5 ::= Integer ;
+-- Double literal expressions.
+EDouble. Exp5 ::= Double ;
+-- Meta variables
+EMeta. Exp5 ::= TMeta ;
+
+token TMeta ('?' digit+) ;
+
+coercions Exp 5 ;
+
+
+-- Identifiers in core can start with underscore to allow
+-- generating unique identifiers easily.
+token CIdent ((letter | '_') (letter | digit | '_' | '\'')*) ;