Анимация
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

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 ReadIt(Name: string); begin

EmitLnCBSR READ);

Store(Name); end;

{ Write from Primary Register }

procedure WriteIt;

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;

{ Allocate Storage for a Static Variable } procedure Allocate(Name, Val: string); begin

WriteLn(Name, :, TAB, DC , Val); end;

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

if Token = ( then begin

Next;

BoolExpression; MatchStringC)); end else begin

if Token = x then



LoadVar(Value) else if Token = # then

LoadConst(Value) else Expected(Math Factor);

Next; end; end;

{ Recognize and Translate a Multiply }

procedure Multiply;

begin

Next;

Factor;

PopMul; end;

{ Recognize and Translate a Divide }

procedure Divide;

begin

Next;

Factor;

PopDiv; end;

{ Parse and Translate a Math Term }

procedure Term;

begin

Factor;

while IsMulop(Token) do begin Push;

case Token of

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

{ Recognize and Translate an Add }

procedure Add;

begin

Next;

Term;

PopAdd; end;

{ Recognize and Translate a Subtract }

procedure Subtract;

begin

Next;

Term;

PopSub; end;

{ Parse and Translate an Expression }

procedure Expression;

begin

if IsAddop(Token) then

Clear else

Term;



while IsAddop(Token) do begin Push;

case Token of

+: Add;

Subtract;

end; end; end;

{ Get Another Expression and Compare }

procedure CompareExpression;

begin

Expression;

PopCompare; end;

{ Get The Next Expression and Compare }

procedure NextExpression;

begin

Next;

CompareExpression; end;

{ Recognize and Translate a Relational "Equals" }

procedure Equal;

begin

NextExpression;

SetEqual; end;

{ Recognize and Translate a Relational "Less Than or Equal" }

procedure LessOrEqual;

begin

NextExpression;

SetLessOrEqual; end;

{ Recognize and Translate a Relational "Not Equals" }

procedure NotEqual;

begin

NextExpression;

SetNEqual; end;

{ Recognize and Translate a Relational "Less Than" } procedure Less; begin Next;

case Token of

=: LessOrEqual; >: NotEqual; else begin

CompareExpression; SetLess; end;

end; 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