如何正确使用强制转换而不需要括号?
How to correctly use coercions such that no parenthesis are needed?
为什么以下语法无法识别 nat -> nat
但可以识别 (nat -> nat)
,我该如何解决?
TNat . Typ4 ::= "nat" ;
TVoid . Typ4 ::= "<>" ;
TProd . Typ3 ::= SumType;
TProd . Typ2 ::= Typ2 "*" Typ3;
TArrow . Typ1 ::= Typ1 "->" Typ2;
coercions Typ 4;
颠倒声明顺序解决了问题
TArrow . Typ ::= Typ "->" Typ1;
TSum . Typ1 ::= SumType;
TProd . Typ2 ::= Typ2 "*" Typ3;
TNat . Typ3 ::= "nat" ;
TVoid . Typ3 ::= "<>" ;
coercions Typ 3;
为什么以下语法无法识别 nat -> nat
但可以识别 (nat -> nat)
,我该如何解决?
TNat . Typ4 ::= "nat" ;
TVoid . Typ4 ::= "<>" ;
TProd . Typ3 ::= SumType;
TProd . Typ2 ::= Typ2 "*" Typ3;
TArrow . Typ1 ::= Typ1 "->" Typ2;
coercions Typ 4;
颠倒声明顺序解决了问题
TArrow . Typ ::= Typ "->" Typ1;
TSum . Typ1 ::= SumType;
TProd . Typ2 ::= Typ2 "*" Typ3;
TNat . Typ3 ::= "nat" ;
TVoid . Typ3 ::= "<>" ;
coercions Typ 3;