SCRIPTCO.LST 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185
  1. Listing:
  2. 1 (* Release 3.10 *)
  3. 2 (*-------------------------------------------------------------------------*
  4. 3 * *
  5. 4 * SCRIPTCO.MOD - COMMS Toolkit Script compiler *
  6. 5 * *
  7. 6 * COPYRIGHT (C) 1988..1992 Clarion Software Corporation. *
  8. 7 * All Rights Reserved *
  9. 8 * *
  10. 9 *--------------------------------------------------------------------------*)
  11. 10
  12. 11 IMPLEMENTATION MODULE ScriptCompiler; (* Compile a Procomm type Script *)
  13. 12 IMPORT CommUtil,FIO,IO,Lib,Scanner,Storage,Str;
  14. 13 FROM Scanner IMPORT Symbols;
  15. ***** ^ duplicate identifier
  16. 14
  17. 15 CONST
  18. 16 MaxStringLnth = 80;
  19. 17 MaxLabels = 20;
  20. 18
  21. 19 TYPE
  22. 20 SymSet = SET OF Scanner.Symbols;
  23. ***** ^ not supported yet
  24. 21 LabelDef = RECORD
  25. 22 Label : Scanner.Alpha;
  26. ***** ^ not supported yet
  27. 23 Defined : BOOLEAN;
  28. 24 Addr : CARDINAL;
  29. 25 END;
  30. ***** ^ not supported yet
  31. 26
  32. 27 VAR
  33. 28 StatBegSyms : SymSet;
  34. ***** ^ not supported yet
  35. 29 LblCnt : CARDINAL;
  36. 30 Labels : ARRAY[0..MaxLabels-1] OF LabelDef;
  37. ***** ^ not supported yet
  38. ***** ^ not supported yet
  39. 31
  40. 32 (*..............................................*)
  41. 33
  42. 34 PROCEDURE FindLabel(VAR Lbl:Scanner.Alpha; PC:CARDINAL):CARDINAL;
  43. ***** ^ not supported yet
  44. 35 VAR
  45. 36 Found : BOOLEAN;
  46. 37 i,a : CARDINAL;
  47. 38 BEGIN
  48. 39 i:=0;
  49. 40 Found:=FALSE;
  50. 41 WHILE (NOT Found) AND (i<LblCnt) DO
  51. 42 IF Scanner.StrCompare(Lbl,Labels[i].Label)=0 THEN
  52. ***** ^ not supported yet
  53. ***** ^ not supported yet
  54. ***** ^ not supported yet
  55. ***** ^ not supported yet
  56. ***** ^ not supported yet
  57. ***** ^ not supported yet
  58. 43 Found:=TRUE;
  59. 44 ELSE
  60. 45 INC(i);
  61. ***** ^ undeclared identifier
  62. ***** ^ not supported yet
  63. 46 END;
  64. 47 END;
  65. 48 WITH Labels[i] DO
  66. ***** ^ not supported yet
  67. ***** ^ not supported yet
  68. 49 IF Found THEN
  69. 50 IF Defined THEN
  70. ***** ^ undeclared identifier
  71. 51 RETURN Addr;
  72. ***** ^ undeclared identifier
  73. 52 ELSE
  74. 53 a := Addr;
  75. ***** ^ undeclared identifier
  76. 54 Addr := PC;
  77. ***** ^ undeclared identifier
  78. 55 RETURN a;
  79. 56 END
  80. 57 ELSE
  81. 58 Label := Lbl;
  82. ***** ^ undeclared identifier
  83. ***** ^ not supported yet
  84. 59 Defined:=FALSE;
  85. ***** ^ undeclared identifier
  86. 60 Addr:=PC;
  87. ***** ^ undeclared identifier
  88. 61 INC(LblCnt);
  89. ***** ^ undeclared identifier
  90. ***** ^ not supported yet
  91. 62 RETURN 0FFFFH;
  92. 63 END;
  93. 64 END;
  94. ***** ^ not supported yet
  95. 65 END FindLabel;
  96. ***** ^ not supported yet
  97. 66
  98. 67 (************************************************)
  99. 68
  100. 69 PROCEDURE Statement(TermSyms:SymSet);
  101. 70
  102. 71 (*..............................................*)
  103. 72
  104. 73 PROCEDURE Value(VAR s:ARRAY OF CHAR):CARDINAL;
  105. ***** ^ not supported yet
  106. 74 VAR
  107. 75 i,x : CARDINAL;
  108. 76 c : CHAR;
  109. 77 BEGIN
  110. 78 x := 0;
  111. 79 FOR i:=0 TO HIGH(s) DO
  112. ***** ^ undeclared identifier
  113. ***** ^ not supported yet
  114. 80 c := s[i];
  115. ***** ^ not supported yet
  116. ***** ^ not supported yet
  117. 81 IF c=0C THEN
  118. 82 RETURN x
  119. 83 ELSIF (c>='0') AND (c<='9') THEN
  120. 84 x := x*10+ORD(c)-48;
  121. ***** ^ undeclared identifier
  122. ***** ^ not supported yet
  123. 85 END;
  124. 86 END;
  125. 87 RETURN x;
  126. 88 END Value;
  127. ***** ^ not supported yet
  128. 89
  129. 90 (*..............................................*)
  130. 91
  131. 92 PROCEDURE Gen(op:SHORTCARD);
  132. 93 BEGIN
  133. 94 CodeBuff^[PC] := op;
  134. ***** ^ undeclared identifier
  135. ***** ^ undeclared identifier
  136. 95 INC(PC);
  137. ***** ^ undeclared identifier
  138. ***** ^ undeclared identifier
  139. 96 END Gen;
  140. ***** ^ not supported yet
  141. 97
  142. 98 (*..............................................*)
  143. 99
  144. 100 PROCEDURE GenW(op:CARDINAL);
  145. 101 BEGIN
  146. 102 Gen(SHORTCARD(op MOD 100H));
  147. ***** ^ not supported yet
  148. ***** ^ not supported yet
  149. 103 Gen(SHORTCARD(op DIV 100H));
  150. ***** ^ not supported yet
  151. ***** ^ not supported yet
  152. 104 END GenW;
  153. ***** ^ not supported yet
  154. 105
  155. 106 (*..............................................*)
  156. 107
  157. 108 PROCEDURE PatchW(Addr,op:CARDINAL);
  158. 109 VAR
  159. 110 Temp : CARDINAL;
  160. 111 BEGIN
  161. 112 Temp:=PC;
  162. ***** ^ undeclared identifier
  163. 113 PC:=Addr;
  164. ***** ^ undeclared identifier
  165. 114 GenW(op);
  166. ***** ^ not supported yet
  167. ***** ^ not supported yet
  168. 115 PC:=Temp;
  169. ***** ^ undeclared identifier
  170. 116 END PatchW;
  171. ***** ^ not supported yet
  172. 117
  173. 118 (*..............................................*)
  174. 119
  175. 120 PROCEDURE GenS(VAR op:ARRAY OF CHAR);
  176. ***** ^ not supported yet
  177. 121 VAR
  178. 122 Lnth : CARDINAL;
  179. 123 BEGIN
  180. 124 Lnth := Str.Length(op)+1;
  181. ***** ^ not supported yet
  182. ***** ^ not supported yet
  183. ***** ^ not supported yet
  184. 125 Gen(255);
  185. ***** ^ not supported yet
  186. ***** ^ not supported yet
  187. 126 Lib.Move(ADR(op),ADR(CodeBuff^[PC]),Lnth);
  188. ***** ^ not supported yet
  189. ***** ^ not supported yet
  190. ***** ^ undeclared identifier
  191. ***** ^ not supported yet
  192. ***** ^ undeclared identifier
  193. ***** ^ undeclared identifier
  194. ***** ^ undeclared identifier
  195. ***** ^ not supported yet
  196. 127 INC(PC,Lnth);
  197. ***** ^ undeclared identifier
  198. ***** ^ undeclared identifier
  199. ***** ^ not supported yet
  200. 128 END GenS;
  201. ***** ^ not supported yet
  202. 129
  203. 130 (*..............................................*)
  204. 131
  205. 132 PROCEDURE StringVar(VAR StringNo:SHORTCARD):BOOLEAN;
  206. 133 VAR
  207. 134 c : CHAR;
  208. 135 BEGIN
  209. 136 IF (Scanner.Sy=Ident) AND (Str.Length(Scanner.Id)=2) AND (CAP(Scanner.Id[0])='S') THEN
  210. ***** ^ not supported yet
  211. ***** ^ not supported yet
  212. ***** ^ undeclared identifier
  213. ***** ^ not supported yet
  214. ***** ^ not supported yet
  215. ***** ^ not supported yet
  216. ***** ^ not supported yet
  217. ***** ^ undeclared identifier
  218. ***** ^ not supported yet
  219. ***** ^ not supported yet
  220. ***** ^ not supported yet
  221. 137 c := Scanner.Id[1];
  222. ***** ^ not supported yet
  223. ***** ^ not supported yet
  224. ***** ^ not supported yet
  225. 138 IF (c>='0') AND (c<='9') THEN
  226. 139 StringNo:=SHORTCARD(ORD(c)-48);
  227. ***** ^ undeclared identifier
  228. ***** ^ not supported yet
  229. ***** ^ not supported yet
  230. 140 RETURN TRUE
  231. 141 END;
  232. 142 END;
  233. 143 RETURN FALSE;
  234. 144 END StringVar;
  235. ***** ^ not supported yet
  236. 145
  237. 146 (*..............................................*)
  238. 147
  239. 148 PROCEDURE String;
  240. 149 VAR
  241. 150 Sno : SHORTCARD;
  242. 151 BEGIN
  243. 152 IF StringVar(Sno) THEN
  244. ***** ^ not supported yet
  245. ***** ^ not supported yet
  246. 153 Gen(Sno)
  247. ***** ^ not supported yet
  248. ***** ^ not supported yet
  249. 154 ELSIF Scanner.Sy=StringConst THEN
  250. ***** ^ not supported yet
  251. ***** ^ not supported yet
  252. ***** ^ undeclared identifier
  253. 155 GenS(Scanner.LastStringConst)
  254. ***** ^ not supported yet
  255. ***** ^ not supported yet
  256. ***** ^ not supported yet
  257. 156 ELSE
  258. 157 Scanner.Error(6);
  259. ***** ^ not supported yet
  260. ***** ^ not supported yet
  261. ***** ^ not supported yet
  262. 158 END;
  263. 159 Scanner.GetSym;
  264. ***** ^ not supported yet
  265. ***** ^ not supported yet
  266. 160 END String;
  267. ***** ^ not supported yet
  268. 161
  269. 162 (*..............................................*)
  270. 163
  271. 164 PROCEDURE DefineLabel(VAR Lbl:Scanner.Alpha; PC:CARDINAL);
  272. ***** ^ not supported yet
  273. 165 VAR
  274. 166 Found : BOOLEAN;
  275. 167 i,nextp,p : CARDINAL;
  276. 168 BEGIN
  277. 169 i:=0;
  278. 170 Found:=FALSE;
  279. 171 WHILE (NOT Found) AND (i<LblCnt) DO
  280. 172 IF Scanner.StrCompare(Lbl,Labels[i].Label)=0 THEN
  281. ***** ^ not supported yet
  282. ***** ^ not supported yet
  283. ***** ^ not supported yet
  284. ***** ^ not supported yet
  285. ***** ^ not supported yet
  286. ***** ^ not supported yet
  287. 173 Found:=TRUE;
  288. 174 ELSE
  289. 175 INC(i);
  290. ***** ^ undeclared identifier
  291. ***** ^ not supported yet
  292. 176 END;
  293. 177 END;
  294. 178 WITH Labels[i] DO
  295. ***** ^ not supported yet
  296. ***** ^ not supported yet
  297. 179 IF Found THEN
  298. 180 IF Defined THEN
  299. ***** ^ undeclared identifier
  300. 181 Scanner.Error(11);
  301. ***** ^ not supported yet
  302. ***** ^ not supported yet
  303. ***** ^ not supported yet
  304. 182 ELSE
  305. 183 (* Chain through patch list, fixing addresses *)
  306. 184 nextp := Addr;
  307. ***** ^ undeclared identifier
  308. 185 WHILE nextp<>0FFFFH DO
  309. 186 p:=nextp;
  310. 187 nextp := CARDINAL(CodeBuff^[p])+CARDINAL(CodeBuff^[p+1])*100H;
  311. ***** ^ undeclared identifier
  312. ***** ^ not supported yet
  313. ***** ^ undeclared identifier
  314. ***** ^ not supported yet
  315. 188 PatchW(p,PC);
  316. ***** ^ not supported yet
  317. ***** ^ not supported yet
  318. 189 END;
  319. 190 END
  320. 191 ELSE
  321. 192 Label:=Lbl;
  322. ***** ^ undeclared identifier
  323. ***** ^ not supported yet
  324. 193 INC(LblCnt);
  325. ***** ^ undeclared identifier
  326. ***** ^ not supported yet
  327. 194 END;
  328. 195 Defined:=TRUE;
  329. ***** ^ undeclared identifier
  330. 196 Addr:=PC;
  331. ***** ^ undeclared identifier
  332. 197 END;
  333. ***** ^ not supported yet
  334. 198 END DefineLabel;
  335. ***** ^ not supported yet
  336. 199
  337. 200 (*..............................................*)
  338. 201
  339. 202 PROCEDURE Label;
  340. 203 BEGIN
  341. 204 IF Scanner.Sy=Colon THEN
  342. ***** ^ not supported yet
  343. ***** ^ not supported yet
  344. ***** ^ undeclared identifier
  345. 205 DefineLabel(Scanner.Id,PC);
  346. ***** ^ undeclared identifier
  347. ***** ^ not supported yet
  348. ***** ^ not supported yet
  349. ***** ^ undeclared identifier
  350. 206 Scanner.GetSym;
  351. ***** ^ not supported yet
  352. ***** ^ not supported yet
  353. 207 ELSE
  354. 208 Scanner.Error(12);
  355. ***** ^ not supported yet
  356. ***** ^ not supported yet
  357. ***** ^ not supported yet
  358. 209 END;
  359. 210 END Label;
  360. ***** ^ not supported yet
  361. 211
  362. 212 (*..............................................*)
  363. 213
  364. 214 PROCEDURE SimpleCommand(Op,Default:SHORTCARD);
  365. 215 VAR
  366. 216 x : CARDINAL;
  367. 217 BEGIN
  368. 218 Gen(Op);
  369. ***** ^ undeclared identifier
  370. ***** ^ not supported yet
  371. 219 IF Scanner.Sy=IntConst THEN
  372. ***** ^ not supported yet
  373. ***** ^ not supported yet
  374. ***** ^ undeclared identifier
  375. 220 x := Value(Scanner.LastNumConst);
  376. ***** ^ undeclared identifier
  377. ***** ^ not supported yet
  378. ***** ^ not supported yet
  379. 221 IF x<=255 THEN
  380. 222 Gen(SHORTCARD(x));
  381. ***** ^ undeclared identifier
  382. ***** ^ not supported yet
  383. 223 ELSE
  384. 224 Scanner.Error(4);
  385. ***** ^ not supported yet
  386. ***** ^ not supported yet
  387. ***** ^ not supported yet
  388. 225 END;
  389. 226 Scanner.GetSym;
  390. ***** ^ not supported yet
  391. ***** ^ not supported yet
  392. 227 ELSE
  393. 228 Gen(Default); (* default to three second alarm *)
  394. ***** ^ undeclared identifier
  395. ***** ^ not supported yet
  396. 229 END;
  397. 230 END SimpleCommand;
  398. ***** ^ not supported yet
  399. 231
  400. 232 (*..............................................*)
  401. 233
  402. 234 PROCEDURE Assign;
  403. 235 VAR
  404. 236 SNo : SHORTCARD;
  405. 237 BEGIN
  406. 238 IF StringVar(SNo) THEN
  407. ***** ^ undeclared identifier
  408. ***** ^ not supported yet
  409. 239 Gen(1);
  410. ***** ^ undeclared identifier
  411. ***** ^ not supported yet
  412. 240 Gen(SNo);
  413. ***** ^ undeclared identifier
  414. ***** ^ not supported yet
  415. 241 Scanner.GetSym;
  416. ***** ^ not supported yet
  417. ***** ^ not supported yet
  418. 242 String;
  419. ***** ^ undeclared identifier
  420. 243 ELSE
  421. 244 Scanner.Error(5);
  422. ***** ^ not supported yet
  423. ***** ^ not supported yet
  424. ***** ^ not supported yet
  425. 245 END;
  426. 246 END Assign;
  427. ***** ^ not supported yet
  428. 247
  429. 248 (*..............................................*)
  430. 249
  431. 250 PROCEDURE Clear;
  432. 251 VAR
  433. 252 Bg,Fg : CARDINAL;
  434. 253 BEGIN
  435. 254 IF Scanner.Sy=IntConst THEN
  436. ***** ^ not supported yet
  437. ***** ^ not supported yet
  438. ***** ^ undeclared identifier
  439. 255 Bg := Value(Scanner.LastNumConst);
  440. ***** ^ undeclared identifier
  441. ***** ^ not supported yet
  442. ***** ^ not supported yet
  443. 256 IF Bg<=7 THEN
  444. 257 Scanner.GetSym;
  445. ***** ^ not supported yet
  446. ***** ^ not supported yet
  447. 258 IF Scanner.Sy=IntConst THEN
  448. ***** ^ not supported yet
  449. ***** ^ not supported yet
  450. ***** ^ undeclared identifier
  451. 259 Fg:=Value(Scanner.LastNumConst);
  452. ***** ^ undeclared identifier
  453. ***** ^ not supported yet
  454. ***** ^ not supported yet
  455. 260 IF Fg<=15 THEN
  456. 261 Gen(7);
  457. ***** ^ undeclared identifier
  458. ***** ^ not supported yet
  459. 262 Gen(SHORTCARD(Bg*16+Fg));
  460. ***** ^ undeclared identifier
  461. ***** ^ not supported yet
  462. 263 ELSE
  463. 264 Scanner.Error(7);
  464. ***** ^ not supported yet
  465. ***** ^ not supported yet
  466. ***** ^ not supported yet
  467. 265 END;
  468. 266 ELSE
  469. 267 Scanner.Error(8);
  470. ***** ^ not supported yet
  471. ***** ^ not supported yet
  472. ***** ^ not supported yet
  473. 268 END;
  474. 269 ELSE
  475. 270 Scanner.Error(7);
  476. ***** ^ not supported yet
  477. ***** ^ not supported yet
  478. ***** ^ not supported yet
  479. 271 END;
  480. 272 Scanner.GetSym;
  481. ***** ^ not supported yet
  482. ***** ^ not supported yet
  483. 273 ELSE
  484. 274 Gen(6);
  485. ***** ^ undeclared identifier
  486. ***** ^ not supported yet
  487. 275 END;
  488. 276 END Clear;
  489. ***** ^ not supported yet
  490. 277
  491. 278 (*..............................................*)
  492. 279
  493. 280 PROCEDURE Locate;
  494. 281 VAR
  495. 282 y,x : CARDINAL;
  496. 283 BEGIN
  497. 284 IF Scanner.Sy=IntConst THEN
  498. ***** ^ not supported yet
  499. ***** ^ not supported yet
  500. ***** ^ undeclared identifier
  501. 285 y := Value(Scanner.LastNumConst);
  502. ***** ^ undeclared identifier
  503. ***** ^ not supported yet
  504. ***** ^ not supported yet
  505. 286 IF y<=23 THEN
  506. 287 Scanner.GetSym;
  507. ***** ^ not supported yet
  508. ***** ^ not supported yet
  509. 288 IF Scanner.Sy=IntConst THEN
  510. ***** ^ not supported yet
  511. ***** ^ not supported yet
  512. ***** ^ undeclared identifier
  513. 289 x:=Value(Scanner.LastNumConst);
  514. ***** ^ undeclared identifier
  515. ***** ^ not supported yet
  516. ***** ^ not supported yet
  517. 290 IF x<=79 THEN
  518. 291 Gen(35);
  519. ***** ^ undeclared identifier
  520. ***** ^ not supported yet
  521. 292 Gen(SHORTCARD(y));
  522. ***** ^ undeclared identifier
  523. ***** ^ not supported yet
  524. 293 Gen(SHORTCARD(x));
  525. ***** ^ undeclared identifier
  526. ***** ^ not supported yet
  527. 294 ELSE
  528. 295 Scanner.Error(7);
  529. ***** ^ not supported yet
  530. ***** ^ not supported yet
  531. ***** ^ not supported yet
  532. 296 END;
  533. 297 ELSE
  534. 298 Scanner.Error(8);
  535. ***** ^ not supported yet
  536. ***** ^ not supported yet
  537. ***** ^ not supported yet
  538. 299 END;
  539. 300 ELSE
  540. 301 Scanner.Error(7);
  541. ***** ^ not supported yet
  542. ***** ^ not supported yet
  543. ***** ^ not supported yet
  544. 302 END;
  545. 303 Scanner.GetSym;
  546. ***** ^ not supported yet
  547. ***** ^ not supported yet
  548. 304 ELSE
  549. 305 Scanner.Error(8);
  550. ***** ^ not supported yet
  551. ***** ^ not supported yet
  552. ***** ^ not supported yet
  553. 306 END;
  554. 307 END Locate;
  555. ***** ^ not supported yet
  556. 308
  557. 309 (*..............................................*)
  558. 310
  559. 311 PROCEDURE DosOrRun(op:SHORTCARD);
  560. 312 VAR
  561. 313 SNo : SHORTCARD;
  562. 314 BEGIN
  563. 315 Gen(op);
  564. ***** ^ undeclared identifier
  565. ***** ^ not supported yet
  566. 316 IF NOT StringVar(SNo) THEN
  567. ***** ^ undeclared identifier
  568. ***** ^ not supported yet
  569. 317 SNo:=255;
  570. 318 END;
  571. 319 Scanner.GetSym;
  572. ***** ^ not supported yet
  573. ***** ^ not supported yet
  574. 320 IF Scanner.Sy=WaitSy THEN
  575. ***** ^ not supported yet
  576. ***** ^ not supported yet
  577. ***** ^ undeclared identifier
  578. 321 Gen(1);
  579. ***** ^ undeclared identifier
  580. ***** ^ not supported yet
  581. 322 ELSE
  582. 323 Gen(0);
  583. ***** ^ undeclared identifier
  584. ***** ^ not supported yet
  585. 324 END;
  586. 325 IF SNo=255 THEN
  587. 326 GenS(Scanner.LastStringConst);
  588. ***** ^ undeclared identifier
  589. ***** ^ not supported yet
  590. ***** ^ not supported yet
  591. 327 ELSE
  592. 328 Gen(SNo);
  593. ***** ^ undeclared identifier
  594. ***** ^ not supported yet
  595. 329 END;
  596. 330 IF Scanner.Sy=WaitSy THEN
  597. ***** ^ not supported yet
  598. ***** ^ not supported yet
  599. ***** ^ undeclared identifier
  600. 331 Scanner.GetSym;
  601. ***** ^ not supported yet
  602. ***** ^ not supported yet
  603. 332 END;
  604. 333 END DosOrRun;
  605. ***** ^ not supported yet
  606. 334
  607. 335 (*..............................................*)
  608. 336
  609. 337 PROCEDURE WaitFor;
  610. 338 VAR
  611. 339 SNo : SHORTCARD;
  612. 340 x : CARDINAL;
  613. 341 BEGIN
  614. 342 Gen(11);
  615. ***** ^ undeclared identifier
  616. ***** ^ not supported yet
  617. 343 IF NOT StringVar(SNo) THEN
  618. ***** ^ undeclared identifier
  619. ***** ^ not supported yet
  620. 344 SNo:=255;
  621. 345 END;
  622. 346 Scanner.GetSym;
  623. ***** ^ not supported yet
  624. ***** ^ not supported yet
  625. 347 IF Scanner.Sy=IntConst THEN
  626. ***** ^ not supported yet
  627. ***** ^ not supported yet
  628. ***** ^ undeclared identifier
  629. 348 x := Value(Scanner.LastNumConst);
  630. ***** ^ undeclared identifier
  631. ***** ^ not supported yet
  632. ***** ^ not supported yet
  633. 349 IF x<=255 THEN
  634. 350 Gen(SHORTCARD(x));
  635. ***** ^ undeclared identifier
  636. ***** ^ not supported yet
  637. 351 ELSE
  638. 352 Scanner.Error(4);
  639. ***** ^ not supported yet
  640. ***** ^ not supported yet
  641. ***** ^ not supported yet
  642. 353 END;
  643. 354 ELSE
  644. 355 Gen(30);
  645. ***** ^ undeclared identifier
  646. ***** ^ not supported yet
  647. 356 END;
  648. 357 IF SNo=255 THEN
  649. 358 GenS(Scanner.LastStringConst);
  650. ***** ^ undeclared identifier
  651. ***** ^ not supported yet
  652. ***** ^ not supported yet
  653. 359 ELSE
  654. 360 Gen(SNo);
  655. ***** ^ undeclared identifier
  656. ***** ^ not supported yet
  657. 361 END;
  658. 362 IF Scanner.Sy=IntConst THEN
  659. ***** ^ not supported yet
  660. ***** ^ not supported yet
  661. ***** ^ undeclared identifier
  662. 363 Scanner.GetSym;
  663. ***** ^ not supported yet
  664. ***** ^ not supported yet
  665. 364 END;
  666. 365 END WaitFor;
  667. ***** ^ not supported yet
  668. 366
  669. 367 (*..............................................*)
  670. 368
  671. 369 PROCEDURE If;
  672. 370 VAR
  673. 371 ElseAllowed : BOOLEAN;
  674. 372 JumpOp : SHORTCARD;
  675. 373 StartPC,JumpPC : CARDINAL;
  676. 374 BEGIN
  677. 375 StartPC := PC;
  678. ***** ^ undeclared identifier
  679. 376 IF Scanner.Sy=NotSy THEN
  680. ***** ^ not supported yet
  681. ***** ^ not supported yet
  682. ***** ^ undeclared identifier
  683. 377 JumpOp:=18;
  684. 378 Scanner.GetSym;
  685. ***** ^ not supported yet
  686. ***** ^ not supported yet
  687. 379 ELSE
  688. 380 JumpOp:=19;
  689. 381 END;
  690. 382 CASE Scanner.Sy OF
  691. ***** ^ not supported yet
  692. ***** ^ not supported yet
  693. 383 LinkedSy : Gen(12); |
  694. ***** ^ undeclared identifier
  695. ***** ^ undeclared identifier
  696. ***** ^ not supported yet
  697. 384 SuccessSy : Gen(13); |
  698. ***** ^ undeclared identifier
  699. ***** ^ undeclared identifier
  700. ***** ^ not supported yet
  701. 385 FailureSy : Gen(14); |
  702. ***** ^ undeclared identifier
  703. ***** ^ undeclared identifier
  704. ***** ^ not supported yet
  705. 386 FoundSy : Gen(15); |
  706. ***** ^ undeclared identifier
  707. ***** ^ undeclared identifier
  708. ***** ^ not supported yet
  709. 387 ConnectSy : Gen(16); |
  710. ***** ^ undeclared identifier
  711. ***** ^ undeclared identifier
  712. ***** ^ not supported yet
  713. 388 WaitForSy : Gen(17); |
  714. ***** ^ undeclared identifier
  715. ***** ^ undeclared identifier
  716. ***** ^ not supported yet
  717. 389 ELSE
  718. 390 Scanner.Error(3);
  719. ***** ^ not supported yet
  720. ***** ^ not supported yet
  721. ***** ^ not supported yet
  722. 391 END;
  723. 392 Scanner.GetSym;
  724. ***** ^ not supported yet
  725. ***** ^ not supported yet
  726. 393 ElseAllowed := (Scanner.Sy<>ElseSy);
  727. ***** ^ not supported yet
  728. ***** ^ not supported yet
  729. ***** ^ undeclared identifier
  730. 394 IF Scanner.Sy=ElseSy THEN (* Empty if, but we have an else clause *)
  731. ***** ^ not supported yet
  732. ***** ^ not supported yet
  733. ***** ^ undeclared identifier
  734. 395 IF JumpOp=18 THEN
  735. 396 JumpOp:=19;
  736. 397 ELSE
  737. 398 JumpOp:=18;
  738. 399 END;
  739. 400 Scanner.GetSym;
  740. ***** ^ not supported yet
  741. ***** ^ not supported yet
  742. 401 END;
  743. 402 IF Scanner.Sy=EndifSy THEN
  744. ***** ^ not supported yet
  745. ***** ^ not supported yet
  746. ***** ^ undeclared identifier
  747. 403 PC := StartPC; (* completely empty if statement - optimise out *)
  748. ***** ^ undeclared identifier
  749. 404 ELSE
  750. 405 Gen(JumpOp);
  751. ***** ^ undeclared identifier
  752. ***** ^ not supported yet
  753. 406 JumpPC:=PC;
  754. ***** ^ undeclared identifier
  755. 407 GenW(0);
  756. ***** ^ undeclared identifier
  757. ***** ^ not supported yet
  758. 408 Statement(SymSet{ElseSy,EndifSy});
  759. ***** ^ not supported yet
  760. ***** ^ 'CASE' expected
  761. 409 IF Scanner.GotError THEN
  762. 410 RETURN;
  763. 411 END;
  764. 412 IF (ElseAllowed) AND (Scanner.Sy=ElseSy) THEN
  765. 413 Scanner.GetSym;
  766. 414 IF Scanner.Sy<>EndifSy THEN
  767. 415 PatchW(JumpPC,PC+3);
  768. 416 Gen(3);
  769. 417 JumpPC:=PC;
  770. 418 GenW(0);
  771. 419 Statement(SymSet{ElseSy,EndifSy});
  772. 420 IF Scanner.GotError THEN
  773. 421 RETURN;
  774. 422 END;
  775. 423 PatchW(JumpPC,PC);
  776. 424 END
  777. 425 ELSE
  778. 426 PatchW(JumpPC,PC);
  779. 427 END;
  780. 428 END;
  781. 429 IF Scanner.Sy=EndifSy THEN
  782. 430 Scanner.GetSym;
  783. 431 ELSE
  784. 432 Scanner.Error(3);
  785. 433 END;
  786. 434 END If;
  787. 435
  788. 436 (*..............................................*)
  789. 437
  790. 438 PROCEDURE Emulate;
  791. 439 BEGIN
  792. 440 Gen(22);
  793. 441 IF Scanner.Sy=Ident THEN
  794. 442 GenS(Scanner.Id);
  795. 443 Scanner.GetSym;
  796. 444 ELSE
  797. 445 String;
  798. 446 END;
  799. 447 END Emulate;
  800. 448
  801. 449 (*..............................................*)
  802. 450
  803. 451 PROCEDURE Find;
  804. 452 VAR
  805. 453 sno : SHORTCARD;
  806. 454 BEGIN
  807. 455 Gen(24);
  808. 456 IF StringVar(sno) THEN
  809. 457 Gen(sno);
  810. 458 Scanner.GetSym;
  811. 459 String;
  812. 460 ELSE
  813. 461 Scanner.Error(5);
  814. 462 END;
  815. 463 END Find;
  816. 464
  817. 465 (*..............................................*)
  818. 466
  819. 467 PROCEDURE Get(op:SHORTCARD);
  820. 468 VAR
  821. 469 sno : SHORTCARD;
  822. 470 x : CARDINAL;
  823. 471 BEGIN
  824. 472 Gen(op);
  825. 473 IF StringVar(sno) THEN
  826. 474 Gen(sno);
  827. 475 Scanner.GetSym;
  828. 476 IF Scanner.Sy=IntConst THEN
  829. 477 x := Value(Scanner.LastNumConst);
  830. 478 IF x<256 THEN
  831. 479 Gen(SHORTCARD(x));
  832. 480 ELSE
  833. 481 Scanner.Error(4);
  834. 482 END;
  835. 483 Scanner.GetSym;
  836. 484 ELSE
  837. 485 Gen(80);
  838. 486 END;
  839. 487 ELSE
  840. 488 Scanner.Error(5);
  841. 489 END;
  842. 490 END Get;
  843. 491
  844. 492 (*..............................................*)
  845. 493
  846. 494 PROCEDURE RGet;
  847. 495 VAR
  848. 496 x : CARDINAL;
  849. 497 BEGIN
  850. 498 Get(47);
  851. 499 IF Scanner.Sy=IntConst THEN
  852. 500 x:=Value(Scanner.LastNumConst);
  853. 501 Scanner.GetSym;
  854. 502 IF x<256 THEN
  855. 503 Gen(SHORTCARD(x));
  856. 504 ELSE
  857. 505 Scanner.Error(4);
  858. 506 END;
  859. 507 ELSE
  860. 508 Gen(30);
  861. 509 END;
  862. 510 END RGet;
  863. 511
  864. 512 (*..............................................*)
  865. 513
  866. 514 PROCEDURE FileTransfer(op:SHORTCARD; FileRequired:BOOLEAN);
  867. 515 VAR
  868. 516 sno : SHORTCARD;
  869. 517 Dummy : ARRAY[0..1] OF CHAR;
  870. 518 BEGIN
  871. 519 Gen(op);
  872. 520 IF (Scanner.Sy>=FTAscii) AND (Scanner.Sy<=FTBYmodem) THEN
  873. 521 Gen(SHORTCARD(ORD(Scanner.Sy)-ORD(FTAscii)));
  874. 522 Scanner.GetSym;
  875. 523 IF StringVar(sno) OR (Scanner.Sy=StringConst) THEN
  876. 524 String
  877. 525 ELSIF FileRequired THEN
  878. 526 Scanner.Error(6);
  879. 527 ELSE
  880. 528 Dummy[0]:=0C;
  881. 529 GenS(Dummy);
  882. 530 (**** Scanner.GetSym; shouldn't advance here ****)
  883. 531 END;
  884. 532 ELSE
  885. 533 Scanner.Error(10);
  886. 534 END;
  887. 535 END FileTransfer;
  888. 536
  889. 537 (*..............................................*)
  890. 538
  891. 539 PROCEDURE ReferenceLabel(op:SHORTCARD);
  892. 540 BEGIN
  893. 541 Gen(op);
  894. 542 IF Scanner.Sy=Ident THEN
  895. 543 GenW(FindLabel(Scanner.Id,PC));
  896. 544 Scanner.GetSym;
  897. 545 ELSE
  898. 546 Scanner.Error(13);
  899. 547 END;
  900. 548 END ReferenceLabel;
  901. 549
  902. 550 (*..............................................*)
  903. 551
  904. 552 PROCEDURE Log;
  905. 553 VAR
  906. 554 sno : SHORTCARD;
  907. 555 Dummy : ARRAY[0..1] OF CHAR;
  908. 556 BEGIN
  909. 557 Dummy[0] := 0C;
  910. 558 CASE Scanner.Sy OF
  911. 559 OpenSy : Gen(36);
  912. 560 Scanner.GetSym;
  913. 561 IF StringVar(sno) OR (Scanner.Sy=StringConst) THEN
  914. 562 String
  915. 563 ELSE
  916. 564 GenS(Dummy);
  917. 565 END; |
  918. 566 CloseSy : Gen(37);
  919. 567 Scanner.GetSym; |
  920. 568 SuspendSy : Gen(38);
  921. 569 Scanner.GetSym; |
  922. 570 ResumeSy : Gen(39);
  923. 571 Scanner.GetSym; |
  924. 572 ELSE
  925. 573 Scanner.Error(3);
  926. 574 END;
  927. 575 END Log;
  928. 576
  929. 577 (*..............................................*)
  930. 578
  931. 579 PROCEDURE Macro;
  932. 580 VAR
  933. 581 x : CARDINAL;
  934. 582 BEGIN
  935. 583 IF Scanner.Sy=IntConst THEN
  936. 584 Gen(40);
  937. 585 x:=Value(Scanner.LastNumConst);
  938. 586 IF x<10 THEN
  939. 587 Gen(SHORTCARD(x));
  940. 588 ELSE
  941. 589 Scanner.Error(7);
  942. 590 END;
  943. 591 Scanner.GetSym;
  944. 592 ELSE
  945. 593 Gen(41);
  946. 594 String;
  947. 595 END;
  948. 596 END Macro;
  949. 597
  950. 598 (*..............................................*)
  951. 599
  952. 600 PROCEDURE OnOff(opOn,opOff:SHORTCARD);
  953. 601 BEGIN
  954. 602 IF Scanner.Sy=OnSy THEN
  955. 603 Gen(opOn);
  956. 604 ELSIF Scanner.Sy=OffSy THEN
  957. 605 Gen(opOff);
  958. 606 ELSE
  959. 607 Scanner.Error(3);
  960. 608 END;
  961. 609 Scanner.GetSym;
  962. 610 END OnOff;
  963. 611
  964. 612 (*..............................................*)
  965. 613
  966. 614 PROCEDURE Switch;
  967. 615 VAR
  968. 616 sno : SHORTCARD;
  969. 617 GotDefault : BOOLEAN;
  970. 618
  971. 619 (*. . . . . . . . . . . . . . . . . . . . . . . *)
  972. 620
  973. 621 PROCEDURE CaseSelection;
  974. 622 VAR
  975. 623 PatchLoc : CARDINAL;
  976. 624 BEGIN
  977. 625 IF (NOT GotDefault) AND (Scanner.Sy=CaseSy) THEN
  978. 626 Scanner.GetSym;
  979. 627 Gen(52);
  980. 628 Gen(sno);
  981. 629 String;
  982. 630 IF NOT Scanner.GotError THEN
  983. 631 Gen(19);
  984. 632 PatchLoc:=PC;
  985. 633 GenW(0);
  986. 634 Statement(SymSet{EndCaseSy});
  987. 635 IF Scanner.Sy=EndCaseSy THEN
  988. 636 Scanner.GetSym;
  989. 637 ELSE
  990. 638 Scanner.Error(3);
  991. 639 END;
  992. 640 PatchW(PatchLoc,PC+3);
  993. 641 Gen(3);
  994. 642 PatchLoc:=PC;
  995. 643 GenW(0);
  996. 644 CaseSelection;
  997. 645 PatchW(PatchLoc,PC);
  998. 646 END
  999. 647 ELSIF Scanner.Sy=DefaultSy THEN
  1000. 648 IF GotDefault THEN
  1001. 649 Scanner.Error(14);
  1002. 650 RETURN;
  1003. 651 END;
  1004. 652 GotDefault := TRUE;
  1005. 653 Scanner.GetSym;
  1006. 654 Statement(SymSet{EndCaseSy});
  1007. 655 IF Scanner.Sy=EndCaseSy THEN
  1008. 656 Scanner.GetSym;
  1009. 657 ELSE
  1010. 658 Scanner.Error(3);
  1011. 659 END;
  1012. 660 END;
  1013. 661 END CaseSelection;
  1014. 662
  1015. 663 (*. . . . . . . . . . . . . . . . . . . . . . . *)
  1016. 664
  1017. 665 BEGIN (* Switch *)
  1018. 666 GotDefault := FALSE;
  1019. 667 IF StringVar(sno) THEN
  1020. 668 Scanner.GetSym;
  1021. 669 CaseSelection;
  1022. 670 IF Scanner.Sy=EndSwitchSy THEN
  1023. 671 Scanner.GetSym;
  1024. 672 ELSE
  1025. 673 Scanner.Error(3);
  1026. 674 END;
  1027. 675 ELSE
  1028. 676 Scanner.Error(5);
  1029. 677 END;
  1030. 678 END Switch;
  1031. 679
  1032. 680 (*..............................................*)
  1033. 681
  1034. 682 VAR
  1035. 683 Sym : Scanner.Symbols;
  1036. 684 BEGIN (* Statement *)
  1037. 685 WHILE (NOT Scanner.GotError) AND (Scanner.Sy IN StatBegSyms) DO
  1038. 686 Sym:=Scanner.Sy;
  1039. 687 Scanner.GetSym;
  1040. 688 CASE Sym OF
  1041. 689 Ident : Label; |
  1042. 690 AlarmSy : SimpleCommand(0,3); |
  1043. 691 AssignSy : Assign; |
  1044. 692 BreakSy : SimpleCommand(4,1); |
  1045. 693 ChDirSy : Gen(5);
  1046. 694 String; |
  1047. 695 ClearSy : Clear; |
  1048. 696 CWhenSy : Gen(54); |
  1049. 697 DialSy : Scanner.Error(9); |
  1050. 698 DosSy : DosOrRun(8); |
  1051. 699 EmulateSy : Emulate; |
  1052. 700 ExecuteSy : Gen(23);
  1053. 701 String; |
  1054. 702 ExitSy : Gen(20); |
  1055. 703 FindSy : Find; |
  1056. 704 GetSy : Get(25); |
  1057. 705 MGetSy : Get(26); |
  1058. 706 GetFileSy : FileTransfer(27,FALSE); |
  1059. 707 GosubSy : ReferenceLabel(29); |
  1060. 708 GotoSy : ReferenceLabel(30); |
  1061. 709 HangupSy : Gen(31); |
  1062. 710 IfSy : If; |
  1063. 711 IsFileSy : Gen(33);
  1064. 712 String; |
  1065. 713 KermServSy : |
  1066. 714 KFlushSy : Gen(34); |
  1067. 715 LocateSy : Locate; |
  1068. 716 LogSy : Log; |
  1069. 717 MacroSy : Macro; |
  1070. 718 MessageSy : Gen(9);
  1071. 719 String; |
  1072. 720 MLoadSy : Gen(42);
  1073. 721 String; |
  1074. 722 PauseSy : SimpleCommand(21,1); |
  1075. 723 PrinterSy : OnOff(43,44); |
  1076. 724 QuitSy : Gen(45); |
  1077. 725 ReturnSy : Gen(32); |
  1078. 726 RFlushSy : Gen(46); |
  1079. 727 RGetSy : RGet; |
  1080. 728 RunSy : DosOrRun(48); |
  1081. 729 SendFileSy : FileTransfer(28,TRUE); |
  1082. 730 SetSy : |
  1083. 731 SnapshotSy : Gen(49); |
  1084. 732 SwitchSy : Switch; |
  1085. 733 TraceSy : OnOff(50,51); |
  1086. 734 TransmitSy : Gen(10);
  1087. 735 String; |
  1088. 736 WaitForSy : WaitFor; |
  1089. 737 WhenSy : Gen(53);
  1090. 738 String;
  1091. 739 String; |
  1092. 740 END;
  1093. 741 END;
  1094. 742 IF NOT (Scanner.Sy IN TermSyms) THEN
  1095. 743 Scanner.Error(3);
  1096. 744 END;
  1097. 745 END Statement;
  1098. 746
  1099. 747 (************************************************)
  1100. 748
  1101. 749 PROCEDURE Initialise;
  1102. 750 BEGIN
  1103. 751 PC := 0;
  1104. 752 Scanner.InitScanner;
  1105. 753 Scanner.GetSym;
  1106. 754 LblCnt := 0;
  1107. 755 StatBegSyms := SymSet{Ident,AlarmSy,AssignSy,BreakSy,ChDirSy,ClearSy,CWhenSy,DialSy,
  1108. 756 DosSy,EmulateSy,ExecuteSy,ExitSy,FindSy,GetSy,MGetSy,GetFileSy,
  1109. 757 GosubSy,GotoSy,HangupSy,IfSy,IsFileSy,KermServSy,KFlushSy,LocateSy,
  1110. 758 LogSy,MacroSy,MessageSy,MLoadSy,PauseSy,PrinterSy,QuitSy,ReturnSy,
  1111. 759 RFlushSy,RGetSy,RunSy,SendFileSy,SetSy,SnapshotSy,SwitchSy,TraceSy,
  1112. 760 TransmitSy,WaitForSy,WhenSy};
  1113. 761 END Initialise;
  1114. 762
  1115. 763 (*..............................................*)
  1116. 764
  1117. 765 PROCEDURE CheckLabels;
  1118. 766 VAR
  1119. 767 i : CARDINAL;
  1120. 768 BEGIN
  1121. 769 i:=0;
  1122. 770 WHILE i<LblCnt DO
  1123. 771 WITH Labels[i] DO
  1124. 772 IF NOT Defined THEN
  1125. 773 IO.WrStr('Label "');
  1126. 774 IO.WrStr(Label);
  1127. 775 IO.WrStr('" is not defined');
  1128. 776 IO.WrLn;
  1129. 777 Scanner.GotError := TRUE;
  1130. 778 END;
  1131. 779 INC(i);
  1132. 780 END;
  1133. 781 END;
  1134. 782 END CheckLabels;
  1135. 783
  1136. 784 (*..............................................*)
  1137. 785
  1138. 786 PROCEDURE Compile(VAR Filename:ARRAY OF CHAR):BOOLEAN;
  1139. 787 BEGIN
  1140. 788 FIO.IOcheck := FALSE;
  1141. 789 Scanner.infile := FIO.Open(Filename);
  1142. 790 IF FIO.IOresult()=0 THEN
  1143. 791 FIO.EOF := FALSE;
  1144. 792 IF CodeBuff=NIL THEN
  1145. 793 IF NOT Storage.Available(MaxCodeBytes) THEN
  1146. 794 FIO.Close(Scanner.infile);
  1147. 795 CommUtil.ErrorMessage('Not enough memory to compile script!!');
  1148. 796 RETURN(FALSE)
  1149. 797 END;
  1150. 798 Storage.ALLOCATE(CodeBuff,MaxCodeBytes);
  1151. 799 END;
  1152. 800 Initialise;
  1153. 801 IF Scanner.Sy<>EndOfFile THEN
  1154. 802 Statement(SymSet{EndOfFile})
  1155. 803 ELSE
  1156. 804 Scanner.Error(3);
  1157. 805 END;
  1158. 806 CodeBuff^[PC]:=20;
  1159. 807 INC(PC); (* insert an EXIT command *)
  1160. 808 FIO.Close(Scanner.infile);
  1161. 809 IF NOT Scanner.GotError THEN
  1162. 810 CheckLabels;
  1163. 811 END;
  1164. 812 IF Scanner.GotError THEN
  1165. 813 Storage.DEALLOCATE(CodeBuff,MaxCodeBytes);
  1166. 814 CodeBuff := NIL;
  1167. 815 END;
  1168. 816 RETURN (NOT Scanner.GotError);
  1169. 817 ELSE
  1170. 818 CommUtil.ErrorMessage('Script File not found!');
  1171. 819 RETURN FALSE;
  1172. 820 END;
  1173. 821 END Compile;
  1174. 822
  1175. 823 (*..............................................*)
  1176. 824
  1177. 825 BEGIN
  1178. 826 CodeBuff := NIL;
  1179. 827 END ScriptCompiler.
  1180. 828
  1181. 351 errors