summaryrefslogtreecommitdiff
path: root/src-3.0/GF/Canon/GFC.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/GF/Canon/GFC.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/GF/Canon/GFC.cf')
-rw-r--r--src-3.0/GF/Canon/GFC.cf170
1 files changed, 170 insertions, 0 deletions
diff --git a/src-3.0/GF/Canon/GFC.cf b/src-3.0/GF/Canon/GFC.cf
new file mode 100644
index 000000000..d9385a49f
--- /dev/null
+++ b/src-3.0/GF/Canon/GFC.cf
@@ -0,0 +1,170 @@
+-- top-level grammar
+
+-- Canonical GF. AR 27/4/2003
+
+entrypoints Canon, Line ;
+
+-- old approach: read in a whole grammar
+
+MGr. Canon ::= "grammar" [Ident] "of" Ident ";" [Module] ;
+Gr. Canon ::= [Module] ;
+
+-- new approach: read line by line
+
+LMulti. Line ::= "grammar" [Ident] "of" Ident ";" ;
+LHeader. Line ::= ModType "=" Extend Open "{" ;
+LFlag. Line ::= Flag ";" ;
+LDef. Line ::= Def ";" ;
+LEnd. Line ::= "}" ;
+
+Mod. Module ::= ModType "=" Extend Open "{" [Flag] [Def] "}" ;
+
+MTAbs. ModType ::= "abstract" Ident ;
+MTCnc. ModType ::= "concrete" Ident "of" Ident ;
+MTRes. ModType ::= "resource" Ident ;
+MTTrans. ModType ::= "transfer" Ident ":" Ident "->" Ident ;
+
+separator Module "" ;
+
+Ext. Extend ::= [Ident] "**" ;
+NoExt. Extend ::= ;
+
+Opens. Open ::= "open" [Ident] "in" ;
+NoOpens. Open ::= ;
+
+
+-- judgements
+
+Flg. Flag ::= "flags" Ident "=" Ident ; --- to have the same res word as in GF
+
+AbsDCat. Def ::= "cat" Ident "[" [Decl] "]" "=" [CIdent] ;
+AbsDFun. Def ::= "fun" Ident ":" Exp "=" Exp ;
+AbsDTrans. Def ::= "transfer" Ident "=" Exp ;
+
+ResDPar. Def ::= "param" Ident "=" [ParDef] ;
+ResDOper. Def ::= "oper" Ident ":" CType "=" Term ;
+
+CncDCat. Def ::= "lincat" Ident "=" CType "=" Term ";" Term ;
+CncDFun. Def ::= "lin" Ident ":" CIdent "=" "\\" [ArgVar] "->" Term ";" Term ;
+
+AnyDInd. Def ::= Ident Status "in" Ident ;
+
+ParD. ParDef ::= Ident [CType] ;
+
+-- the canonicity of an indirected constant
+
+Canon. Status ::= "data" ;
+NonCan. Status ::= ;
+
+-- names originating from resource modules: prefixed by the module name
+
+CIQ. CIdent ::= Ident "." Ident ;
+
+-- types and terms in abstract syntax; no longer type-annotated
+
+EApp. Exp1 ::= Exp1 Exp2 ;
+EProd. Exp ::= "(" Ident ":" Exp ")" "->" Exp ;
+EAbs. Exp ::= "\\" Ident "->" Exp ;
+EAtom. Exp2 ::= Atom ;
+EData. Exp2 ::= "data" ;
+
+EEq. Exp ::= "{" [Equation] "}" ; -- list of pattern eqs; primitive notion: []
+
+coercions Exp 2 ;
+
+SType. Sort ::= "Type" ;
+
+Equ. Equation ::= [APatt] "->" Exp ;
+
+APC. APatt ::= "(" CIdent [APatt] ")" ;
+APV. APatt ::= Ident ;
+APS. APatt ::= String ;
+API. APatt ::= Integer ;
+APF. APatt ::= Double ;
+APW. APatt ::= "_" ;
+
+separator Decl ";" ;
+terminator APatt "" ;
+terminator Equation ";" ;
+
+AC. Atom ::= CIdent ;
+AD. Atom ::= "<" CIdent ">" ;
+AV. Atom ::= "$" Ident ;
+AM. Atom ::= "?" Integer ;
+AS. Atom ::= String ;
+AI. Atom ::= Integer ;
+AT. Atom ::= Sort ;
+
+Decl. Decl ::= Ident ":" Exp ;
+
+
+-- types, terms, and patterns in concrete syntax
+
+RecType. CType ::= "{" [Labelling] "}" ;
+Table. CType ::= "(" CType "=>" CType ")" ;
+Cn. CType ::= CIdent ;
+TStr. CType ::= "Str" ;
+TInts. CType ::= "Ints" Integer ;
+
+Lbg. Labelling ::= Label ":" CType ;
+
+Arg. Term2 ::= ArgVar ;
+I. Term2 ::= CIdent ; -- from resources
+Par. Term2 ::= "<" CIdent [Term2] ">" ;
+LI. Term2 ::= "$" Ident ; -- from pattern variables
+
+R. Term2 ::= "{" [Assign] "}" ;
+P. Term1 ::= Term2 "." Label ;
+T. Term1 ::= "table" CType "{" [Case] "}" ;
+V. Term1 ::= "table" CType "[" [Term2] "]" ;
+S. Term1 ::= Term1 "!" Term2 ;
+C. Term ::= Term "++" Term1 ;
+FV. Term1 ::= "variants" "{" [Term2] "}" ; --- no separator!
+
+EInt. Term2 ::= Integer ;
+EFloat. Term2 ::= Double ;
+K. Term2 ::= Tokn ;
+E. Term2 ::= "[" "]" ;
+
+KS. Tokn ::= String ;
+KP. Tokn ::= "[" "pre" [String] "{" [Variant] "}" "]" ;
+internal KM. Tokn ::= String ; -- mark-up
+
+Ass. Assign ::= Label "=" Term ;
+Cas. Case ::= [Patt] "=>" Term ;
+Var. Variant ::= [String] "/" [String] ;
+
+coercions Term 2 ;
+
+L. Label ::= Ident ;
+LV. Label ::= "$" Integer ;
+A. ArgVar ::= Ident "@" Integer ; -- no bindings
+AB. ArgVar ::= Ident "+" Integer "@" Integer ; -- with a number of bindings
+
+PC. Patt ::= "(" CIdent [Patt] ")" ;
+PV. Patt ::= Ident ;
+PW. Patt ::= "_" ;
+PR. Patt ::= "{" [PattAssign] "}" ;
+PI. Patt ::= Integer ;
+PF. Patt ::= Double ;
+
+PAss. PattAssign ::= Label "=" Patt ;
+
+--- here we use the new pragmas to generate list rules
+
+terminator Flag ";" ;
+terminator Def ";" ;
+separator ParDef "|" ;
+separator CType "" ;
+separator CIdent "" ;
+separator Assign ";" ;
+separator ArgVar "," ;
+separator Labelling ";" ;
+separator Case ";" ;
+separator Term2 "" ;
+separator String "" ;
+separator Variant ";" ;
+separator PattAssign ";" ;
+separator Patt "" ;
+separator Ident "," ;
+