mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-04 08:42:50 -06:00
Working with interfaces and incomplete modules.
This commit is contained in:
151
src/GF/Canon/GFC.cf
Normal file
151
src/GF/Canon/GFC.cf
Normal file
@@ -0,0 +1,151 @@
|
||||
-- top-level grammar
|
||||
|
||||
-- Canonical GF. AR 27/4/2003
|
||||
|
||||
entrypoints Canon ;
|
||||
|
||||
Gr. Canon ::= [Module] ;
|
||||
|
||||
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 ::= ;
|
||||
|
||||
NoOpens. Open ::= ;
|
||||
Opens. Open ::= "open" [Ident] "in" ;
|
||||
|
||||
|
||||
-- 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 ;
|
||||
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" ;
|
||||
|
||||
Lbg. Labelling ::= Label ":" CType ;
|
||||
|
||||
Arg. Term2 ::= ArgVar ;
|
||||
I. Term2 ::= CIdent ; -- from resources
|
||||
Con. Term2 ::= "<" CIdent [Term2] ">" ;
|
||||
LI. Term2 ::= "$" Ident ; -- from pattern variables
|
||||
|
||||
R. Term2 ::= "{" [Assign] "}" ;
|
||||
P. Term1 ::= Term2 "." Label ;
|
||||
T. Term1 ::= "table" CType "{" [Case] "}" ;
|
||||
S. Term1 ::= Term1 "!" Term2 ;
|
||||
C. Term ::= Term "++" Term1 ;
|
||||
FV. Term1 ::= "variants" "{" [Term2] "}" ; --- no separator!
|
||||
|
||||
K. Term2 ::= Tokn ;
|
||||
E. Term2 ::= "[" "]" ;
|
||||
|
||||
KS. Tokn ::= String ;
|
||||
KP. Tokn ::= "[" "pre" [String] "{" [Variant] "}" "]" ;
|
||||
|
||||
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] "}" ;
|
||||
|
||||
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 "," ;
|
||||
|
||||
Reference in New Issue
Block a user