4-2-6

Условный оператор If-Then-Else

Fact  {
    sN = <Int N':='('"'sN)';'
              If (N'='0) Then (1)
                         Else (N'*'Fact(N'-'1))
         >;
}

Int { eX = <Eval () eX>; }

Eval {
   (eE) sV ':='tX';'eY   = <Eval (eE (sV <Eval (eE) tX>)) eY>;
    tE  sN               = <Subst tE sN>;
    tE  ('"'eX)          = eX;
    tE  (eX)             = <Eval tE eX>;
    tE  eX '=' eY        = <Equ (<Eval tE eX>) <Eval tE eY>>;
    tE  eX '+' eY        = <ADD (<Eval tE eX>) <Eval tE eY>>;
    tE  eX '-' eY '-' eZ = <Eval tE (eX '-' eY) '-' eZ>;
    tE  eX '-' eY        = <SUB (<Eval tE eX>) <Eval tE eY>>;
    tE  eX '*' eY        = <MUL (<Eval tE eX>) <Eval tE eY>>;
    tE  sF (eX)          = <Apply sF <Eval tE eX>>;
    tE  If tC Then tT
              Else tF    = <Eval tE <If <Eval tE tC> tT tF>>;
}
If {
    T tT tF = tT;
    F tT tF = tF;
}
Equ {
    (sX) sX = T;
    (sX) sY = F;
}
...