Анимация
JavaScript


Главная  Библионтека 

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 [ 53 ] 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97

{ Set D0 If Compare was >= } procedure SetGreaterOrEqual; begin

EmitLnCSLE D0);

EmitLnCEXT D0); end;

{ Store Primary to Variable } procedure Store(Name: string); begin

if not InTable(Name) then Undefined(Name); EmitLnCLEA + Name + (PC),A0); EmitLnCMOVE D0,(A0)) end;

{ Branch Unconditional } procedure Branch(L: string); begin

EmitLnCBRA + L); end;

{ Branch False }

procedure BranchFalse(L: string); begin

EmitLnCTST D0);

EmitLnCBEQ + L); end;

{ Read Variable to Primary Register }

procedure ReadVar;

begin

EmitLnCBSR READ);

Store(Value[1]); end;

{ Write Variable from Primary Register }

procedure WriteVar;

begin

EmitLnCBSR WRITE); end;

{ Write Header Info } procedure Header; begin

WriteLn(WARMST, TAB, EQU $A01E); end;

{ Write the Prolog } procedure Prolog; begin

PostLabel(MAIN); end;



{ Write the Epilog } procedure Epilog; begin

EmitLnCDC WARMST);

EmitLnCEND MAIN); end;

{ Parse and Translate a Math Factor } procedure BoolExpression; Forward; procedure Factor; begin

if Look = ( then begin MatchCC); BoolExpression; Match()); end

else if IsAlpha(Look) then begin GetName;

LoadVar(Value);

end else

LoadConst(GetNum);

end;

{ Parse and Translate a Negative Factor }

procedure NegFactor;

begin

MatchC-); if IsDigit(Look) then LoadConst(-GetNum) else begin Factor; Negate; end; end;

{ Parse and Translate a Leading Factor }

procedure FirstFactor;

begin

case Look of +: begin

Match(+); Factor; end;

-: NegFactor; else Factor; end; end;

{ Recognize and Translate a Multiply }

procedure Multiply;

begin

Match(*);

Factor;

PopMul; end;



{ Recognize and Translate a Divide }

procedure Divide;

begin

Match(/);

Factor;

PopDiv; end;

{ Common Code Used by Term and FirstTerm }

procedure Term1;

begin

while IsMulop(Look) do begin Push;

case Look of

*: Multiply; /: Divide; end; end; end;

{ Parse and Translate a Math Term }

procedure Term;

begin

Factor;

Term1; end;

{ Parse and Translate a Leading Term }

procedure FirstTerm;

begin

FirstFactor;

Term1; end;

{ Recognize and Translate an Add }

procedure Add;

begin

Match(+);

Term;

PopAdd; end;

{ Recognize and Translate a Subtract }

procedure Subtract;

begin

Match(-);

Term;

PopSub; end;



0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 [ 53 ] 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97