Listing: 1 (* Release 3.10 *) 2 (*-------------------------------------------------------------------------* 3 * * 4 * SCRIPTCO.MOD - COMMS Toolkit Script compiler * 5 * * 6 * COPYRIGHT (C) 1988..1992 Clarion Software Corporation. * 7 * All Rights Reserved * 8 * * 9 *--------------------------------------------------------------------------*) 10 11 IMPLEMENTATION MODULE ScriptCompiler; (* Compile a Procomm type Script *) 12 IMPORT CommUtil,FIO,IO,Lib,Scanner,Storage,Str; 13 FROM Scanner IMPORT Symbols; ***** ^ duplicate identifier 14 15 CONST 16 MaxStringLnth = 80; 17 MaxLabels = 20; 18 19 TYPE 20 SymSet = SET OF Scanner.Symbols; ***** ^ not supported yet 21 LabelDef = RECORD 22 Label : Scanner.Alpha; ***** ^ not supported yet 23 Defined : BOOLEAN; 24 Addr : CARDINAL; 25 END; ***** ^ not supported yet 26 27 VAR 28 StatBegSyms : SymSet; ***** ^ not supported yet 29 LblCnt : CARDINAL; 30 Labels : ARRAY[0..MaxLabels-1] OF LabelDef; ***** ^ not supported yet ***** ^ not supported yet 31 32 (*..............................................*) 33 34 PROCEDURE FindLabel(VAR Lbl:Scanner.Alpha; PC:CARDINAL):CARDINAL; ***** ^ not supported yet 35 VAR 36 Found : BOOLEAN; 37 i,a : CARDINAL; 38 BEGIN 39 i:=0; 40 Found:=FALSE; 41 WHILE (NOT Found) AND (i='0') AND (c<='9') THEN 84 x := x*10+ORD(c)-48; ***** ^ undeclared identifier ***** ^ not supported yet 85 END; 86 END; 87 RETURN x; 88 END Value; ***** ^ not supported yet 89 90 (*..............................................*) 91 92 PROCEDURE Gen(op:SHORTCARD); 93 BEGIN 94 CodeBuff^[PC] := op; ***** ^ undeclared identifier ***** ^ undeclared identifier 95 INC(PC); ***** ^ undeclared identifier ***** ^ undeclared identifier 96 END Gen; ***** ^ not supported yet 97 98 (*..............................................*) 99 100 PROCEDURE GenW(op:CARDINAL); 101 BEGIN 102 Gen(SHORTCARD(op MOD 100H)); ***** ^ not supported yet ***** ^ not supported yet 103 Gen(SHORTCARD(op DIV 100H)); ***** ^ not supported yet ***** ^ not supported yet 104 END GenW; ***** ^ not supported yet 105 106 (*..............................................*) 107 108 PROCEDURE PatchW(Addr,op:CARDINAL); 109 VAR 110 Temp : CARDINAL; 111 BEGIN 112 Temp:=PC; ***** ^ undeclared identifier 113 PC:=Addr; ***** ^ undeclared identifier 114 GenW(op); ***** ^ not supported yet ***** ^ not supported yet 115 PC:=Temp; ***** ^ undeclared identifier 116 END PatchW; ***** ^ not supported yet 117 118 (*..............................................*) 119 120 PROCEDURE GenS(VAR op:ARRAY OF CHAR); ***** ^ not supported yet 121 VAR 122 Lnth : CARDINAL; 123 BEGIN 124 Lnth := Str.Length(op)+1; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 125 Gen(255); ***** ^ not supported yet ***** ^ not supported yet 126 Lib.Move(ADR(op),ADR(CodeBuff^[PC]),Lnth); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet 127 INC(PC,Lnth); ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet 128 END GenS; ***** ^ not supported yet 129 130 (*..............................................*) 131 132 PROCEDURE StringVar(VAR StringNo:SHORTCARD):BOOLEAN; 133 VAR 134 c : CHAR; 135 BEGIN 136 IF (Scanner.Sy=Ident) AND (Str.Length(Scanner.Id)=2) AND (CAP(Scanner.Id[0])='S') THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 137 c := Scanner.Id[1]; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 138 IF (c>='0') AND (c<='9') THEN 139 StringNo:=SHORTCARD(ORD(c)-48); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 140 RETURN TRUE 141 END; 142 END; 143 RETURN FALSE; 144 END StringVar; ***** ^ not supported yet 145 146 (*..............................................*) 147 148 PROCEDURE String; 149 VAR 150 Sno : SHORTCARD; 151 BEGIN 152 IF StringVar(Sno) THEN ***** ^ not supported yet ***** ^ not supported yet 153 Gen(Sno) ***** ^ not supported yet ***** ^ not supported yet 154 ELSIF Scanner.Sy=StringConst THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 155 GenS(Scanner.LastStringConst) ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 156 ELSE 157 Scanner.Error(6); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 158 END; 159 Scanner.GetSym; ***** ^ not supported yet ***** ^ not supported yet 160 END String; ***** ^ not supported yet 161 162 (*..............................................*) 163 164 PROCEDURE DefineLabel(VAR Lbl:Scanner.Alpha; PC:CARDINAL); ***** ^ not supported yet 165 VAR 166 Found : BOOLEAN; 167 i,nextp,p : CARDINAL; 168 BEGIN 169 i:=0; 170 Found:=FALSE; 171 WHILE (NOT Found) AND (i0FFFFH DO 186 p:=nextp; 187 nextp := CARDINAL(CodeBuff^[p])+CARDINAL(CodeBuff^[p+1])*100H; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 188 PatchW(p,PC); ***** ^ not supported yet ***** ^ not supported yet 189 END; 190 END 191 ELSE 192 Label:=Lbl; ***** ^ undeclared identifier ***** ^ not supported yet 193 INC(LblCnt); ***** ^ undeclared identifier ***** ^ not supported yet 194 END; 195 Defined:=TRUE; ***** ^ undeclared identifier 196 Addr:=PC; ***** ^ undeclared identifier 197 END; ***** ^ not supported yet 198 END DefineLabel; ***** ^ not supported yet 199 200 (*..............................................*) 201 202 PROCEDURE Label; 203 BEGIN 204 IF Scanner.Sy=Colon THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 205 DefineLabel(Scanner.Id,PC); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 206 Scanner.GetSym; ***** ^ not supported yet ***** ^ not supported yet 207 ELSE 208 Scanner.Error(12); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 209 END; 210 END Label; ***** ^ not supported yet 211 212 (*..............................................*) 213 214 PROCEDURE SimpleCommand(Op,Default:SHORTCARD); 215 VAR 216 x : CARDINAL; 217 BEGIN 218 Gen(Op); ***** ^ undeclared identifier ***** ^ not supported yet 219 IF Scanner.Sy=IntConst THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 220 x := Value(Scanner.LastNumConst); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 221 IF x<=255 THEN 222 Gen(SHORTCARD(x)); ***** ^ undeclared identifier ***** ^ not supported yet 223 ELSE 224 Scanner.Error(4); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 225 END; 226 Scanner.GetSym; ***** ^ not supported yet ***** ^ not supported yet 227 ELSE 228 Gen(Default); (* default to three second alarm *) ***** ^ undeclared identifier ***** ^ not supported yet 229 END; 230 END SimpleCommand; ***** ^ not supported yet 231 232 (*..............................................*) 233 234 PROCEDURE Assign; 235 VAR 236 SNo : SHORTCARD; 237 BEGIN 238 IF StringVar(SNo) THEN ***** ^ undeclared identifier ***** ^ not supported yet 239 Gen(1); ***** ^ undeclared identifier ***** ^ not supported yet 240 Gen(SNo); ***** ^ undeclared identifier ***** ^ not supported yet 241 Scanner.GetSym; ***** ^ not supported yet ***** ^ not supported yet 242 String; ***** ^ undeclared identifier 243 ELSE 244 Scanner.Error(5); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 245 END; 246 END Assign; ***** ^ not supported yet 247 248 (*..............................................*) 249 250 PROCEDURE Clear; 251 VAR 252 Bg,Fg : CARDINAL; 253 BEGIN 254 IF Scanner.Sy=IntConst THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 255 Bg := Value(Scanner.LastNumConst); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 256 IF Bg<=7 THEN 257 Scanner.GetSym; ***** ^ not supported yet ***** ^ not supported yet 258 IF Scanner.Sy=IntConst THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 259 Fg:=Value(Scanner.LastNumConst); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 260 IF Fg<=15 THEN 261 Gen(7); ***** ^ undeclared identifier ***** ^ not supported yet 262 Gen(SHORTCARD(Bg*16+Fg)); ***** ^ undeclared identifier ***** ^ not supported yet 263 ELSE 264 Scanner.Error(7); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 265 END; 266 ELSE 267 Scanner.Error(8); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 268 END; 269 ELSE 270 Scanner.Error(7); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 271 END; 272 Scanner.GetSym; ***** ^ not supported yet ***** ^ not supported yet 273 ELSE 274 Gen(6); ***** ^ undeclared identifier ***** ^ not supported yet 275 END; 276 END Clear; ***** ^ not supported yet 277 278 (*..............................................*) 279 280 PROCEDURE Locate; 281 VAR 282 y,x : CARDINAL; 283 BEGIN 284 IF Scanner.Sy=IntConst THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 285 y := Value(Scanner.LastNumConst); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 286 IF y<=23 THEN 287 Scanner.GetSym; ***** ^ not supported yet ***** ^ not supported yet 288 IF Scanner.Sy=IntConst THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 289 x:=Value(Scanner.LastNumConst); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 290 IF x<=79 THEN 291 Gen(35); ***** ^ undeclared identifier ***** ^ not supported yet 292 Gen(SHORTCARD(y)); ***** ^ undeclared identifier ***** ^ not supported yet 293 Gen(SHORTCARD(x)); ***** ^ undeclared identifier ***** ^ not supported yet 294 ELSE 295 Scanner.Error(7); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 296 END; 297 ELSE 298 Scanner.Error(8); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 299 END; 300 ELSE 301 Scanner.Error(7); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 302 END; 303 Scanner.GetSym; ***** ^ not supported yet ***** ^ not supported yet 304 ELSE 305 Scanner.Error(8); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 306 END; 307 END Locate; ***** ^ not supported yet 308 309 (*..............................................*) 310 311 PROCEDURE DosOrRun(op:SHORTCARD); 312 VAR 313 SNo : SHORTCARD; 314 BEGIN 315 Gen(op); ***** ^ undeclared identifier ***** ^ not supported yet 316 IF NOT StringVar(SNo) THEN ***** ^ undeclared identifier ***** ^ not supported yet 317 SNo:=255; 318 END; 319 Scanner.GetSym; ***** ^ not supported yet ***** ^ not supported yet 320 IF Scanner.Sy=WaitSy THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 321 Gen(1); ***** ^ undeclared identifier ***** ^ not supported yet 322 ELSE 323 Gen(0); ***** ^ undeclared identifier ***** ^ not supported yet 324 END; 325 IF SNo=255 THEN 326 GenS(Scanner.LastStringConst); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 327 ELSE 328 Gen(SNo); ***** ^ undeclared identifier ***** ^ not supported yet 329 END; 330 IF Scanner.Sy=WaitSy THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 331 Scanner.GetSym; ***** ^ not supported yet ***** ^ not supported yet 332 END; 333 END DosOrRun; ***** ^ not supported yet 334 335 (*..............................................*) 336 337 PROCEDURE WaitFor; 338 VAR 339 SNo : SHORTCARD; 340 x : CARDINAL; 341 BEGIN 342 Gen(11); ***** ^ undeclared identifier ***** ^ not supported yet 343 IF NOT StringVar(SNo) THEN ***** ^ undeclared identifier ***** ^ not supported yet 344 SNo:=255; 345 END; 346 Scanner.GetSym; ***** ^ not supported yet ***** ^ not supported yet 347 IF Scanner.Sy=IntConst THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 348 x := Value(Scanner.LastNumConst); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 349 IF x<=255 THEN 350 Gen(SHORTCARD(x)); ***** ^ undeclared identifier ***** ^ not supported yet 351 ELSE 352 Scanner.Error(4); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 353 END; 354 ELSE 355 Gen(30); ***** ^ undeclared identifier ***** ^ not supported yet 356 END; 357 IF SNo=255 THEN 358 GenS(Scanner.LastStringConst); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 359 ELSE 360 Gen(SNo); ***** ^ undeclared identifier ***** ^ not supported yet 361 END; 362 IF Scanner.Sy=IntConst THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 363 Scanner.GetSym; ***** ^ not supported yet ***** ^ not supported yet 364 END; 365 END WaitFor; ***** ^ not supported yet 366 367 (*..............................................*) 368 369 PROCEDURE If; 370 VAR 371 ElseAllowed : BOOLEAN; 372 JumpOp : SHORTCARD; 373 StartPC,JumpPC : CARDINAL; 374 BEGIN 375 StartPC := PC; ***** ^ undeclared identifier 376 IF Scanner.Sy=NotSy THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 377 JumpOp:=18; 378 Scanner.GetSym; ***** ^ not supported yet ***** ^ not supported yet 379 ELSE 380 JumpOp:=19; 381 END; 382 CASE Scanner.Sy OF ***** ^ not supported yet ***** ^ not supported yet 383 LinkedSy : Gen(12); | ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet 384 SuccessSy : Gen(13); | ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet 385 FailureSy : Gen(14); | ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet 386 FoundSy : Gen(15); | ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet 387 ConnectSy : Gen(16); | ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet 388 WaitForSy : Gen(17); | ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet 389 ELSE 390 Scanner.Error(3); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 391 END; 392 Scanner.GetSym; ***** ^ not supported yet ***** ^ not supported yet 393 ElseAllowed := (Scanner.Sy<>ElseSy); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 394 IF Scanner.Sy=ElseSy THEN (* Empty if, but we have an else clause *) ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 395 IF JumpOp=18 THEN 396 JumpOp:=19; 397 ELSE 398 JumpOp:=18; 399 END; 400 Scanner.GetSym; ***** ^ not supported yet ***** ^ not supported yet 401 END; 402 IF Scanner.Sy=EndifSy THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 403 PC := StartPC; (* completely empty if statement - optimise out *) ***** ^ undeclared identifier 404 ELSE 405 Gen(JumpOp); ***** ^ undeclared identifier ***** ^ not supported yet 406 JumpPC:=PC; ***** ^ undeclared identifier 407 GenW(0); ***** ^ undeclared identifier ***** ^ not supported yet 408 Statement(SymSet{ElseSy,EndifSy}); ***** ^ not supported yet ***** ^ 'CASE' expected 409 IF Scanner.GotError THEN 410 RETURN; 411 END; 412 IF (ElseAllowed) AND (Scanner.Sy=ElseSy) THEN 413 Scanner.GetSym; 414 IF Scanner.Sy<>EndifSy THEN 415 PatchW(JumpPC,PC+3); 416 Gen(3); 417 JumpPC:=PC; 418 GenW(0); 419 Statement(SymSet{ElseSy,EndifSy}); 420 IF Scanner.GotError THEN 421 RETURN; 422 END; 423 PatchW(JumpPC,PC); 424 END 425 ELSE 426 PatchW(JumpPC,PC); 427 END; 428 END; 429 IF Scanner.Sy=EndifSy THEN 430 Scanner.GetSym; 431 ELSE 432 Scanner.Error(3); 433 END; 434 END If; 435 436 (*..............................................*) 437 438 PROCEDURE Emulate; 439 BEGIN 440 Gen(22); 441 IF Scanner.Sy=Ident THEN 442 GenS(Scanner.Id); 443 Scanner.GetSym; 444 ELSE 445 String; 446 END; 447 END Emulate; 448 449 (*..............................................*) 450 451 PROCEDURE Find; 452 VAR 453 sno : SHORTCARD; 454 BEGIN 455 Gen(24); 456 IF StringVar(sno) THEN 457 Gen(sno); 458 Scanner.GetSym; 459 String; 460 ELSE 461 Scanner.Error(5); 462 END; 463 END Find; 464 465 (*..............................................*) 466 467 PROCEDURE Get(op:SHORTCARD); 468 VAR 469 sno : SHORTCARD; 470 x : CARDINAL; 471 BEGIN 472 Gen(op); 473 IF StringVar(sno) THEN 474 Gen(sno); 475 Scanner.GetSym; 476 IF Scanner.Sy=IntConst THEN 477 x := Value(Scanner.LastNumConst); 478 IF x<256 THEN 479 Gen(SHORTCARD(x)); 480 ELSE 481 Scanner.Error(4); 482 END; 483 Scanner.GetSym; 484 ELSE 485 Gen(80); 486 END; 487 ELSE 488 Scanner.Error(5); 489 END; 490 END Get; 491 492 (*..............................................*) 493 494 PROCEDURE RGet; 495 VAR 496 x : CARDINAL; 497 BEGIN 498 Get(47); 499 IF Scanner.Sy=IntConst THEN 500 x:=Value(Scanner.LastNumConst); 501 Scanner.GetSym; 502 IF x<256 THEN 503 Gen(SHORTCARD(x)); 504 ELSE 505 Scanner.Error(4); 506 END; 507 ELSE 508 Gen(30); 509 END; 510 END RGet; 511 512 (*..............................................*) 513 514 PROCEDURE FileTransfer(op:SHORTCARD; FileRequired:BOOLEAN); 515 VAR 516 sno : SHORTCARD; 517 Dummy : ARRAY[0..1] OF CHAR; 518 BEGIN 519 Gen(op); 520 IF (Scanner.Sy>=FTAscii) AND (Scanner.Sy<=FTBYmodem) THEN 521 Gen(SHORTCARD(ORD(Scanner.Sy)-ORD(FTAscii))); 522 Scanner.GetSym; 523 IF StringVar(sno) OR (Scanner.Sy=StringConst) THEN 524 String 525 ELSIF FileRequired THEN 526 Scanner.Error(6); 527 ELSE 528 Dummy[0]:=0C; 529 GenS(Dummy); 530 (**** Scanner.GetSym; shouldn't advance here ****) 531 END; 532 ELSE 533 Scanner.Error(10); 534 END; 535 END FileTransfer; 536 537 (*..............................................*) 538 539 PROCEDURE ReferenceLabel(op:SHORTCARD); 540 BEGIN 541 Gen(op); 542 IF Scanner.Sy=Ident THEN 543 GenW(FindLabel(Scanner.Id,PC)); 544 Scanner.GetSym; 545 ELSE 546 Scanner.Error(13); 547 END; 548 END ReferenceLabel; 549 550 (*..............................................*) 551 552 PROCEDURE Log; 553 VAR 554 sno : SHORTCARD; 555 Dummy : ARRAY[0..1] OF CHAR; 556 BEGIN 557 Dummy[0] := 0C; 558 CASE Scanner.Sy OF 559 OpenSy : Gen(36); 560 Scanner.GetSym; 561 IF StringVar(sno) OR (Scanner.Sy=StringConst) THEN 562 String 563 ELSE 564 GenS(Dummy); 565 END; | 566 CloseSy : Gen(37); 567 Scanner.GetSym; | 568 SuspendSy : Gen(38); 569 Scanner.GetSym; | 570 ResumeSy : Gen(39); 571 Scanner.GetSym; | 572 ELSE 573 Scanner.Error(3); 574 END; 575 END Log; 576 577 (*..............................................*) 578 579 PROCEDURE Macro; 580 VAR 581 x : CARDINAL; 582 BEGIN 583 IF Scanner.Sy=IntConst THEN 584 Gen(40); 585 x:=Value(Scanner.LastNumConst); 586 IF x<10 THEN 587 Gen(SHORTCARD(x)); 588 ELSE 589 Scanner.Error(7); 590 END; 591 Scanner.GetSym; 592 ELSE 593 Gen(41); 594 String; 595 END; 596 END Macro; 597 598 (*..............................................*) 599 600 PROCEDURE OnOff(opOn,opOff:SHORTCARD); 601 BEGIN 602 IF Scanner.Sy=OnSy THEN 603 Gen(opOn); 604 ELSIF Scanner.Sy=OffSy THEN 605 Gen(opOff); 606 ELSE 607 Scanner.Error(3); 608 END; 609 Scanner.GetSym; 610 END OnOff; 611 612 (*..............................................*) 613 614 PROCEDURE Switch; 615 VAR 616 sno : SHORTCARD; 617 GotDefault : BOOLEAN; 618 619 (*. . . . . . . . . . . . . . . . . . . . . . . *) 620 621 PROCEDURE CaseSelection; 622 VAR 623 PatchLoc : CARDINAL; 624 BEGIN 625 IF (NOT GotDefault) AND (Scanner.Sy=CaseSy) THEN 626 Scanner.GetSym; 627 Gen(52); 628 Gen(sno); 629 String; 630 IF NOT Scanner.GotError THEN 631 Gen(19); 632 PatchLoc:=PC; 633 GenW(0); 634 Statement(SymSet{EndCaseSy}); 635 IF Scanner.Sy=EndCaseSy THEN 636 Scanner.GetSym; 637 ELSE 638 Scanner.Error(3); 639 END; 640 PatchW(PatchLoc,PC+3); 641 Gen(3); 642 PatchLoc:=PC; 643 GenW(0); 644 CaseSelection; 645 PatchW(PatchLoc,PC); 646 END 647 ELSIF Scanner.Sy=DefaultSy THEN 648 IF GotDefault THEN 649 Scanner.Error(14); 650 RETURN; 651 END; 652 GotDefault := TRUE; 653 Scanner.GetSym; 654 Statement(SymSet{EndCaseSy}); 655 IF Scanner.Sy=EndCaseSy THEN 656 Scanner.GetSym; 657 ELSE 658 Scanner.Error(3); 659 END; 660 END; 661 END CaseSelection; 662 663 (*. . . . . . . . . . . . . . . . . . . . . . . *) 664 665 BEGIN (* Switch *) 666 GotDefault := FALSE; 667 IF StringVar(sno) THEN 668 Scanner.GetSym; 669 CaseSelection; 670 IF Scanner.Sy=EndSwitchSy THEN 671 Scanner.GetSym; 672 ELSE 673 Scanner.Error(3); 674 END; 675 ELSE 676 Scanner.Error(5); 677 END; 678 END Switch; 679 680 (*..............................................*) 681 682 VAR 683 Sym : Scanner.Symbols; 684 BEGIN (* Statement *) 685 WHILE (NOT Scanner.GotError) AND (Scanner.Sy IN StatBegSyms) DO 686 Sym:=Scanner.Sy; 687 Scanner.GetSym; 688 CASE Sym OF 689 Ident : Label; | 690 AlarmSy : SimpleCommand(0,3); | 691 AssignSy : Assign; | 692 BreakSy : SimpleCommand(4,1); | 693 ChDirSy : Gen(5); 694 String; | 695 ClearSy : Clear; | 696 CWhenSy : Gen(54); | 697 DialSy : Scanner.Error(9); | 698 DosSy : DosOrRun(8); | 699 EmulateSy : Emulate; | 700 ExecuteSy : Gen(23); 701 String; | 702 ExitSy : Gen(20); | 703 FindSy : Find; | 704 GetSy : Get(25); | 705 MGetSy : Get(26); | 706 GetFileSy : FileTransfer(27,FALSE); | 707 GosubSy : ReferenceLabel(29); | 708 GotoSy : ReferenceLabel(30); | 709 HangupSy : Gen(31); | 710 IfSy : If; | 711 IsFileSy : Gen(33); 712 String; | 713 KermServSy : | 714 KFlushSy : Gen(34); | 715 LocateSy : Locate; | 716 LogSy : Log; | 717 MacroSy : Macro; | 718 MessageSy : Gen(9); 719 String; | 720 MLoadSy : Gen(42); 721 String; | 722 PauseSy : SimpleCommand(21,1); | 723 PrinterSy : OnOff(43,44); | 724 QuitSy : Gen(45); | 725 ReturnSy : Gen(32); | 726 RFlushSy : Gen(46); | 727 RGetSy : RGet; | 728 RunSy : DosOrRun(48); | 729 SendFileSy : FileTransfer(28,TRUE); | 730 SetSy : | 731 SnapshotSy : Gen(49); | 732 SwitchSy : Switch; | 733 TraceSy : OnOff(50,51); | 734 TransmitSy : Gen(10); 735 String; | 736 WaitForSy : WaitFor; | 737 WhenSy : Gen(53); 738 String; 739 String; | 740 END; 741 END; 742 IF NOT (Scanner.Sy IN TermSyms) THEN 743 Scanner.Error(3); 744 END; 745 END Statement; 746 747 (************************************************) 748 749 PROCEDURE Initialise; 750 BEGIN 751 PC := 0; 752 Scanner.InitScanner; 753 Scanner.GetSym; 754 LblCnt := 0; 755 StatBegSyms := SymSet{Ident,AlarmSy,AssignSy,BreakSy,ChDirSy,ClearSy,CWhenSy,DialSy, 756 DosSy,EmulateSy,ExecuteSy,ExitSy,FindSy,GetSy,MGetSy,GetFileSy, 757 GosubSy,GotoSy,HangupSy,IfSy,IsFileSy,KermServSy,KFlushSy,LocateSy, 758 LogSy,MacroSy,MessageSy,MLoadSy,PauseSy,PrinterSy,QuitSy,ReturnSy, 759 RFlushSy,RGetSy,RunSy,SendFileSy,SetSy,SnapshotSy,SwitchSy,TraceSy, 760 TransmitSy,WaitForSy,WhenSy}; 761 END Initialise; 762 763 (*..............................................*) 764 765 PROCEDURE CheckLabels; 766 VAR 767 i : CARDINAL; 768 BEGIN 769 i:=0; 770 WHILE iEndOfFile THEN 802 Statement(SymSet{EndOfFile}) 803 ELSE 804 Scanner.Error(3); 805 END; 806 CodeBuff^[PC]:=20; 807 INC(PC); (* insert an EXIT command *) 808 FIO.Close(Scanner.infile); 809 IF NOT Scanner.GotError THEN 810 CheckLabels; 811 END; 812 IF Scanner.GotError THEN 813 Storage.DEALLOCATE(CodeBuff,MaxCodeBytes); 814 CodeBuff := NIL; 815 END; 816 RETURN (NOT Scanner.GotError); 817 ELSE 818 CommUtil.ErrorMessage('Script File not found!'); 819 RETURN FALSE; 820 END; 821 END Compile; 822 823 (*..............................................*) 824 825 BEGIN 826 CodeBuff := NIL; 827 END ScriptCompiler. 828 351 errors