| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185 |
- 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<LblCnt) DO
- 42 IF Scanner.StrCompare(Lbl,Labels[i].Label)=0 THEN
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 43 Found:=TRUE;
- 44 ELSE
- 45 INC(i);
- ***** ^ undeclared identifier
- ***** ^ not supported yet
- 46 END;
- 47 END;
- 48 WITH Labels[i] DO
- ***** ^ not supported yet
- ***** ^ not supported yet
- 49 IF Found THEN
- 50 IF Defined THEN
- ***** ^ undeclared identifier
- 51 RETURN Addr;
- ***** ^ undeclared identifier
- 52 ELSE
- 53 a := Addr;
- ***** ^ undeclared identifier
- 54 Addr := PC;
- ***** ^ undeclared identifier
- 55 RETURN a;
- 56 END
- 57 ELSE
- 58 Label := Lbl;
- ***** ^ undeclared identifier
- ***** ^ not supported yet
- 59 Defined:=FALSE;
- ***** ^ undeclared identifier
- 60 Addr:=PC;
- ***** ^ undeclared identifier
- 61 INC(LblCnt);
- ***** ^ undeclared identifier
- ***** ^ not supported yet
- 62 RETURN 0FFFFH;
- 63 END;
- 64 END;
- ***** ^ not supported yet
- 65 END FindLabel;
- ***** ^ not supported yet
- 66
- 67 (************************************************)
- 68
- 69 PROCEDURE Statement(TermSyms:SymSet);
- 70
- 71 (*..............................................*)
- 72
- 73 PROCEDURE Value(VAR s:ARRAY OF CHAR):CARDINAL;
- ***** ^ not supported yet
- 74 VAR
- 75 i,x : CARDINAL;
- 76 c : CHAR;
- 77 BEGIN
- 78 x := 0;
- 79 FOR i:=0 TO HIGH(s) DO
- ***** ^ undeclared identifier
- ***** ^ not supported yet
- 80 c := s[i];
- ***** ^ not supported yet
- ***** ^ not supported yet
- 81 IF c=0C THEN
- 82 RETURN x
- 83 ELSIF (c>='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 (i<LblCnt) DO
- 172 IF Scanner.StrCompare(Lbl,Labels[i].Label)=0 THEN
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 173 Found:=TRUE;
- 174 ELSE
- 175 INC(i);
- ***** ^ undeclared identifier
- ***** ^ not supported yet
- 176 END;
- 177 END;
- 178 WITH Labels[i] DO
- ***** ^ not supported yet
- ***** ^ not supported yet
- 179 IF Found THEN
- 180 IF Defined THEN
- ***** ^ undeclared identifier
- 181 Scanner.Error(11);
- ***** ^ not supported yet
- ***** ^ not supported yet
- ***** ^ not supported yet
- 182 ELSE
- 183 (* Chain through patch list, fixing addresses *)
- 184 nextp := Addr;
- ***** ^ undeclared identifier
- 185 WHILE nextp<>0FFFFH 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 i<LblCnt DO
- 771 WITH Labels[i] DO
- 772 IF NOT Defined THEN
- 773 IO.WrStr('Label "');
- 774 IO.WrStr(Label);
- 775 IO.WrStr('" is not defined');
- 776 IO.WrLn;
- 777 Scanner.GotError := TRUE;
- 778 END;
- 779 INC(i);
- 780 END;
- 781 END;
- 782 END CheckLabels;
- 783
- 784 (*..............................................*)
- 785
- 786 PROCEDURE Compile(VAR Filename:ARRAY OF CHAR):BOOLEAN;
- 787 BEGIN
- 788 FIO.IOcheck := FALSE;
- 789 Scanner.infile := FIO.Open(Filename);
- 790 IF FIO.IOresult()=0 THEN
- 791 FIO.EOF := FALSE;
- 792 IF CodeBuff=NIL THEN
- 793 IF NOT Storage.Available(MaxCodeBytes) THEN
- 794 FIO.Close(Scanner.infile);
- 795 CommUtil.ErrorMessage('Not enough memory to compile script!!');
- 796 RETURN(FALSE)
- 797 END;
- 798 Storage.ALLOCATE(CodeBuff,MaxCodeBytes);
- 799 END;
- 800 Initialise;
- 801 IF Scanner.Sy<>EndOfFile 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
|