mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-22 19:22:50 -06:00
record labels in compiler experiment
This commit is contained in:
@@ -52,8 +52,6 @@ eval e = case e of
|
|||||||
---- pattern match first
|
---- pattern match first
|
||||||
return $ compVal [] $ VPro t' v' ---- []
|
return $ compVal [] $ VPro t' v' ---- []
|
||||||
|
|
||||||
EPro t v -> do
|
EPro t v@(Lab _ i) -> do
|
||||||
t' <- eval t
|
t' <- eval t
|
||||||
---- project first
|
return $ compVal [] $ VPro t' (VPar i)
|
||||||
return $ VPro t' (VPar 666) ---- lookup label
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,10 +20,12 @@ coercions Type 1 ;
|
|||||||
|
|
||||||
terminator Type "" ;
|
terminator Type "" ;
|
||||||
|
|
||||||
FTyp. Typing ::= Ident ":" Type ;
|
FTyp. Typing ::= Label ":" Type ;
|
||||||
|
|
||||||
separator Typing ";" ;
|
separator Typing ";" ;
|
||||||
|
|
||||||
|
Lab. Label ::= Ident "#" Integer ;
|
||||||
|
|
||||||
EVar. Exp2 ::= "$" Ident ;
|
EVar. Exp2 ::= "$" Ident ;
|
||||||
EOpr. Exp2 ::= "&" Ident ;
|
EOpr. Exp2 ::= "&" Ident ;
|
||||||
ECon. Exp2 ::= Ident ;
|
ECon. Exp2 ::= Ident ;
|
||||||
@@ -33,7 +35,7 @@ ECst. Exp2 ::= "(" Ident "@" [Exp] ")" ;
|
|||||||
ERec. Exp2 ::= "{" [Assign] "}" ;
|
ERec. Exp2 ::= "{" [Assign] "}" ;
|
||||||
EApp. Exp1 ::= Exp1 Exp2 ;
|
EApp. Exp1 ::= Exp1 Exp2 ;
|
||||||
ESel. Exp1 ::= Exp1 "!" Exp2 ;
|
ESel. Exp1 ::= Exp1 "!" Exp2 ;
|
||||||
EPro. Exp1 ::= Exp1 "." Exp2 ;
|
EPro. Exp1 ::= Exp1 "." Label ;
|
||||||
ETab. Exp1 ::= "table" Type "{" [Case] "}" ;
|
ETab. Exp1 ::= "table" Type "{" [Case] "}" ;
|
||||||
ECat. Exp ::= Exp "++" Exp1 ;
|
ECat. Exp ::= Exp "++" Exp1 ;
|
||||||
EAbs. Exp ::= "\\" Ident "->" Exp ;
|
EAbs. Exp ::= "\\" Ident "->" Exp ;
|
||||||
@@ -42,7 +44,7 @@ coercions Exp 2 ;
|
|||||||
|
|
||||||
separator Exp "," ;
|
separator Exp "," ;
|
||||||
|
|
||||||
FExp. Assign ::= Ident "=" Exp ;
|
FExp. Assign ::= Label "=" Exp ;
|
||||||
|
|
||||||
separator Assign ";" ;
|
separator Assign ";" ;
|
||||||
|
|
||||||
@@ -57,7 +59,7 @@ PCon. Patt ::= "(" Ident [Patt] ")" ;
|
|||||||
|
|
||||||
terminator Patt "" ;
|
terminator Patt "" ;
|
||||||
|
|
||||||
FPatt. AssPatt ::= Ident "=" Patt ;
|
FPatt. AssPatt ::= Label "=" Patt ;
|
||||||
|
|
||||||
separator AssPatt ";" ;
|
separator AssPatt ";" ;
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ param Gen = Masc | Fem ;
|
|||||||
|
|
||||||
param AG = A Num Gen ;
|
param AG = A Num Gen ;
|
||||||
|
|
||||||
oper Agr = {g : Gen ; n : Num} ;
|
oper Agr = {g#0 : Gen ; n#1 : Num} ;
|
||||||
|
|
||||||
oper CN = {s : Num -> Str ; g : Gen} ;
|
oper CN = {s#1 : Num -> Str ; g#0 : Gen} ;
|
||||||
oper NP = {s : Str ; a : Agr} ;
|
oper NP = {s#1 : Str ; a#0 : Agr} ;
|
||||||
|
|
||||||
oper artDef : Gen -> Str = \g -> table Gen {
|
oper artDef : Gen -> Str = \g -> table Gen {
|
||||||
(Masc) => "le" ;
|
(Masc) => "le" ;
|
||||||
@@ -14,29 +14,32 @@ oper artDef : Gen -> Str = \g -> table Gen {
|
|||||||
} ! $g ;
|
} ! $g ;
|
||||||
|
|
||||||
lin Voiture : CN = {
|
lin Voiture : CN = {
|
||||||
s = table Num {
|
s#1 = table Num {
|
||||||
(Sg) => "voiture" ;
|
(Sg) => "voiture" ;
|
||||||
(Pl) => "voitures"
|
(Pl) => "voitures"
|
||||||
} ;
|
} ;
|
||||||
g = (Fem@)
|
g#0 = (Fem@)
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
lin Bus : CN = {
|
lin Bus : CN = {
|
||||||
s = table Num {$x => "bus"} ;
|
s#1 = table Num {$x => "bus"} ;
|
||||||
g = (Masc@)
|
g#0 = (Masc@)
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
lin Indef : CN -> NP = \cn -> {
|
lin Indef : CN -> NP = \cn -> {
|
||||||
s = table Gen {
|
s#1 = table Gen {
|
||||||
(Masc) => "un" ;
|
(Masc) => "un" ;
|
||||||
$x => "une"
|
$x => "une"
|
||||||
} ! $cn.g ++ $cn.s ! (Sg@) ;
|
} ! $cn.g#0 ++ $cn.s#1 ! (Sg@) ;
|
||||||
a = {g = $cn.g ; n = (Sg@)}
|
a#0 = {g#0 = $cn.g#0 ; n#1 = (Sg@)}
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
lin Def : CN -> NP = \cn -> {
|
lin Def : CN -> NP = \cn -> {
|
||||||
s = &artDef $cn.g ++ $cn.s ! (Sg@) ;
|
s#1 = &artDef $cn.g#0 ++ $cn.s#1 ! (Sg@) ;
|
||||||
a = {g = $cn.g ; n = (Sg@)}
|
a#0 = {g#0 = $cn.g#0 ; n#1 = (Sg@)}
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
lin UneVoiture : NP = Indef Voiture ;
|
||||||
|
lin LaVoiture : NP = Def Voiture ;
|
||||||
|
|||||||
Reference in New Issue
Block a user