PARSER.LST 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  1. Listing:
  2. 1 IMPLEMENTATION MODULE Parser;
  3. 2 (*
  4. 3 * REPERTOIRE
  5. 4 * Release 1.6
  6. 5 * By Charles Bradford and Cole Brecheen
  7. 6 * (c) Copyright 1985-1992 PMI
  8. 7 * Green Bay, Wisconsin
  9. 8 * All rights reserved
  10. 9 * (414) 468-6040
  11. 10 *
  12. 11 * $Header: D:/logfiles/mods/parser.mov 1.9 17 Mar 1991 17:57:48 coleb $
  13. 12 *
  14. 13 *)
  15. 14
  16. 15
  17. 16 (*EntryDiag:
  18. 17 IMPORT Diagnostics;
  19. 18 :EntryDiag*)
  20. 19
  21. 20 IMPORT GenLists;
  22. 21 IMPORT ListUtils;
  23. 22 IMPORT M2Strings;
  24. 23 IMPORT PosUtils;
  25. 24 IMPORT StrEdit;
  26. 25 IMPORT SYSTEM;
  27. 26
  28. 27 VAR
  29. 28 Initialized : BOOLEAN;
  30. 29
  31. 30 CONST
  32. 31 space = 40C;
  33. 32
  34. 33 VAR
  35. 34 LineLngth: CARDINAL;
  36. 35
  37. 36 PROCEDURE GetNxtLstChr(InList: GenLists.GenList; VAR currentLine,
  38. ***** ^ not supported yet
  39. 37 currentIndex: CARDINAL; VAR TheChar: CHAR);
  40. 38 (* On entry, currentIndex should identify a character that has
  41. 39 already been gotten. On exit, it will identify the character
  42. 40 just returned; currentLine will identify the line from which
  43. 41 it was gotten, even if it was the last character on the line. *)
  44. 42 VAR
  45. 43 typeCode : CARDINAL;
  46. 44 BEGIN
  47. 45 LineLngth := M2Strings.Length(TheLine);
  48. ***** ^ not supported yet
  49. ***** ^ not supported yet
  50. ***** ^ undeclared identifier
  51. 46 IF (currentIndex + 1) >= LineLngth THEN
  52. 47 (* we are at a line end *)
  53. 48 currentIndex := 0;
  54. 49 IF currentLine < GenLists.ListLength(InList) THEN
  55. ***** ^ not supported yet
  56. ***** ^ not supported yet
  57. ***** ^ not supported yet
  58. 50 INC(currentLine);
  59. ***** ^ undeclared identifier
  60. ***** ^ not supported yet
  61. 51 GenLists.GetElmt(InList, currentLine, TheLine, typeCode);
  62. ***** ^ not supported yet
  63. ***** ^ not supported yet
  64. ***** ^ not supported yet
  65. ***** ^ undeclared identifier
  66. ***** ^ not supported yet
  67. 52 (*read next line*)
  68. 53 LineLngth := M2Strings.Length(TheLine);
  69. ***** ^ not supported yet
  70. ***** ^ not supported yet
  71. ***** ^ undeclared identifier
  72. 54 TheChar := TheLine[currentIndex];
  73. ***** ^ undeclared identifier
  74. ***** ^ not supported yet
  75. 55 ELSE
  76. 56 TheChar := EOF;
  77. ***** ^ undeclared identifier
  78. 57 (* we are at file end *)
  79. 58 END;
  80. 59 ELSE
  81. 60 INC(currentIndex);
  82. ***** ^ undeclared identifier
  83. ***** ^ not supported yet
  84. 61 TheChar := TheLine[currentIndex];
  85. ***** ^ undeclared identifier
  86. ***** ^ not supported yet
  87. 62 END;
  88. 63 END GetNxtLstChr;
  89. ***** ^ not supported yet
  90. 64
  91. 65
  92. 66 PROCEDURE SkipComments(VAR inList: GenLists.GenList;
  93. ***** ^ not supported yet
  94. 67 VAR currentIndex, currentLine: CARDINAL);
  95. 68 (* Handles nested comments
  96. 69 currentIndex passed in points to first char of a StartComment
  97. 70 currentIndex passed out points to the char after EndComment *)
  98. 71 VAR
  99. 72 terminator: CHAR;
  100. 73 tmpLst: GenLists.GenList;
  101. ***** ^ not supported yet
  102. 74 BEGIN
  103. 75 GenLists.NewList(tmpLst);
  104. ***** ^ not supported yet
  105. ***** ^ not supported yet
  106. ***** ^ not supported yet
  107. 76 GetLogicalLst(
  108. ***** ^ undeclared identifier
  109. 77 inList,
  110. ***** ^ not supported yet
  111. 78 StartComment,
  112. ***** ^ undeclared identifier
  113. 79 EndComment,
  114. ***** ^ undeclared identifier
  115. 80 currentLine,
  116. 81 currentIndex,
  117. 82 tmpLst,
  118. ***** ^ not supported yet
  119. 83 terminator);
  120. ***** ^ not supported yet
  121. 84 GenLists.DisposeList(tmpLst);
  122. ***** ^ not supported yet
  123. ***** ^ not supported yet
  124. ***** ^ not supported yet
  125. 85 END SkipComments;
  126. ***** ^ not supported yet
  127. 86
  128. 87
  129. 88 PROCEDURE ReadComments(VAR InList, OutList: GenLists.GenList;
  130. ***** ^ not supported yet
  131. 89 NewStartComment, NewEndComment: ARRAY OF CHAR;
  132. ***** ^ not supported yet
  133. 90 VAR currentIndex, currentLine: CARDINAL);
  134. 91 (* Extracts comments from InList and appends them to OutList.
  135. 92 OutList must be initialized before it gets here. If it has
  136. 93 at least one element, we append the first line of the comment
  137. 94 to the last line of OutList. Handles nested comments;
  138. 95 currentIndex passed in points to first char of a StartComment;
  139. 96 currentIndex passed out points to the char after EndComment. *)
  140. 97 VAR
  141. 98 StartCmtIndex, EndCmtIndex, TypeCode,
  142. 99 NestingLevel, CommentLength, NewCommentLength,
  143. 100 outListLngth: CARDINAL;
  144. 101 tmpch: CHAR;
  145. 102 BEGIN
  146. 103 CommentLength := M2Strings.Length(StartComment);
  147. ***** ^ not supported yet
  148. ***** ^ not supported yet
  149. ***** ^ undeclared identifier
  150. 104 NewCommentLength := M2Strings.Length(NewStartComment);
  151. ***** ^ not supported yet
  152. ***** ^ not supported yet
  153. ***** ^ not supported yet
  154. 105 NestingLevel := 1;
  155. 106
  156. 107 StartCmtIndex := PosUtils.Positn(StartComment, TheLine, currentIndex);
  157. ***** ^ not supported yet
  158. ***** ^ not supported yet
  159. ***** ^ undeclared identifier
  160. ***** ^ undeclared identifier
  161. ***** ^ not supported yet
  162. 108 IF currentIndex # StartCmtIndex THEN
  163. 109 (*We weren't on a StartComment.*)
  164. 110 RETURN;
  165. 111 END;
  166. 112 INC(currentIndex, CommentLength);
  167. ***** ^ undeclared identifier
  168. ***** ^ not supported yet
  169. 113 (* get currentIndex past the opening comment *)
  170. 114 outListLngth := GenLists.ListLength(OutList);
  171. ***** ^ not supported yet
  172. ***** ^ not supported yet
  173. ***** ^ not supported yet
  174. 115 IF outListLngth > 0 THEN
  175. 116 ListUtils.InsertIntoElmt(OutList, outListLngth,
  176. ***** ^ not supported yet
  177. ***** ^ not supported yet
  178. ***** ^ not supported yet
  179. 117 SYSTEM.ADR(NewStartComment), NewCommentLength, 65535);
  180. ***** ^ not supported yet
  181. ***** ^ not supported yet
  182. ***** ^ not supported yet
  183. ***** ^ not supported yet
  184. 118 ELSE
  185. 119 INC(outListLngth);
  186. ***** ^ undeclared identifier
  187. ***** ^ not supported yet
  188. 120 GenLists.ListInsert(NewStartComment, GenLists.StrCode, OutList,
  189. ***** ^ not supported yet
  190. ***** ^ not supported yet
  191. ***** ^ not supported yet
  192. ***** ^ not supported yet
  193. ***** ^ not supported yet
  194. ***** ^ not supported yet
  195. 121 outListLngth);
  196. ***** ^ not supported yet
  197. 122 END;
  198. 123 LOOP
  199. 124 GetNxtLstChr(InList, currentLine, currentIndex, tmpch);
  200. ***** ^ not supported yet
  201. ***** ^ not supported yet
  202. ***** ^ not supported yet
  203. 125 IF tmpch = StartComment[0] THEN
  204. ***** ^ undeclared identifier
  205. ***** ^ not supported yet
  206. 126 StartCmtIndex := PosUtils.Positn(StartComment, TheLine,
  207. ***** ^ not supported yet
  208. ***** ^ not supported yet
  209. ***** ^ undeclared identifier
  210. ***** ^ undeclared identifier
  211. 127 currentIndex);
  212. ***** ^ not supported yet
  213. 128 IF currentIndex = StartCmtIndex THEN
  214. 129 (*We were on a StartComment.*)
  215. 130 INC(NestingLevel);
  216. ***** ^ undeclared identifier
  217. ***** ^ not supported yet
  218. 131 END;
  219. 132 END;
  220. 133 IF tmpch = EndComment[0] THEN
  221. ***** ^ undeclared identifier
  222. ***** ^ not supported yet
  223. 134 EndCmtIndex := PosUtils.Positn(EndComment, TheLine, currentIndex);
  224. ***** ^ not supported yet
  225. ***** ^ not supported yet
  226. ***** ^ undeclared identifier
  227. ***** ^ undeclared identifier
  228. ***** ^ not supported yet
  229. 135 IF currentIndex = EndCmtIndex THEN
  230. 136 (*We were on an EndComment.*)
  231. 137 DEC(NestingLevel);
  232. ***** ^ undeclared identifier
  233. ***** ^ not supported yet
  234. 138 END;
  235. 139 IF NestingLevel = 0 THEN
  236. 140 INC(currentIndex, CommentLength);
  237. ***** ^ undeclared identifier
  238. ***** ^ not supported yet
  239. 141 ListUtils.InsertIntoElmt(OutList, outListLngth,
  240. ***** ^ not supported yet
  241. ***** ^ not supported yet
  242. ***** ^ not supported yet
  243. 142 SYSTEM.ADR(NewEndComment), NewCommentLength, 65535);
  244. ***** ^ not supported yet
  245. ***** ^ not supported yet
  246. ***** ^ not supported yet
  247. ***** ^ not supported yet
  248. 143 EXIT;
  249. 144 END;
  250. 145 END;
  251. 146 IF currentIndex > 0 THEN
  252. 147 ListUtils.InsertIntoElmt(OutList, outListLngth,
  253. ***** ^ not supported yet
  254. ***** ^ not supported yet
  255. ***** ^ not supported yet
  256. 148 SYSTEM.ADR(tmpch), 1, 65535);
  257. ***** ^ not supported yet
  258. ***** ^ not supported yet
  259. ***** ^ not supported yet
  260. ***** ^ not supported yet
  261. 149 ELSE
  262. 150 (* Every time currentIndex goes to zero we start a new
  263. 151 line in the OutList. *)
  264. 152 INC(outListLngth);
  265. ***** ^ undeclared identifier
  266. ***** ^ not supported yet
  267. 153 GenLists.ListInsert(tmpch, GenLists.StrCode, OutList,
  268. ***** ^ not supported yet
  269. ***** ^ not supported yet
  270. ***** ^ not supported yet
  271. ***** ^ not supported yet
  272. ***** ^ not supported yet
  273. 154 outListLngth);
  274. ***** ^ not supported yet
  275. 155 END;
  276. 156 END;
  277. 157 END ReadComments;
  278. ***** ^ not supported yet
  279. 158
  280. 159
  281. 160 PROCEDURE GetLogicalLst(
  282. 161 inList: GenLists.GenList;
  283. ***** ^ not supported yet
  284. 162 opener, closer: ARRAY OF CHAR;
  285. ***** ^ not supported yet
  286. 163 VAR currentLine, currentIndex: CARDINAL;
  287. 164 VAR outList: GenLists.GenList;
  288. ***** ^ not supported yet
  289. 165 VAR terminator: CHAR);
  290. 166 (* On entry, currentIndex should identify a character that has
  291. 167 * already been gotten (opener). On exit, it will identify the
  292. 168 * character just returned (closer or Parser.EOF); currentLine
  293. 169 * will identify the line from which it was gotten, even if it
  294. 170 * was the last character on the line. outList should be
  295. 171 * initialized on entry, and will be bracketed by opener and
  296. 172 * closer on exit.
  297. 173 *)
  298. 174 VAR
  299. 175 openerIndex, closerIndex,
  300. 176 NestingLevel, openerLngth,
  301. 177 outListLngth: CARDINAL;
  302. 178 tmpch: CHAR;
  303. 179 BEGIN
  304. 180 openerLngth := M2Strings.Length(opener);
  305. ***** ^ not supported yet
  306. ***** ^ not supported yet
  307. ***** ^ not supported yet
  308. 181 NestingLevel := 1;
  309. 182
  310. 183 openerIndex := PosUtils.Positn(opener, TheLine, currentIndex);
  311. ***** ^ not supported yet
  312. ***** ^ not supported yet
  313. ***** ^ not supported yet
  314. ***** ^ undeclared identifier
  315. ***** ^ not supported yet
  316. 184 IF currentIndex # openerIndex THEN
  317. 185 (*We weren't on a opener.*)
  318. 186 RETURN;
  319. 187 END;
  320. 188 outListLngth := GenLists.ListLength(outList);
  321. ***** ^ not supported yet
  322. ***** ^ not supported yet
  323. ***** ^ not supported yet
  324. 189 IF outListLngth > 0 THEN
  325. 190 ListUtils.InsertIntoElmt(outList, outListLngth,
  326. ***** ^ not supported yet
  327. ***** ^ not supported yet
  328. ***** ^ not supported yet
  329. 191 SYSTEM.ADR(opener), openerLngth, 65535);
  330. ***** ^ not supported yet
  331. ***** ^ not supported yet
  332. ***** ^ not supported yet
  333. ***** ^ not supported yet
  334. 192 ELSE
  335. 193 INC(outListLngth);
  336. ***** ^ undeclared identifier
  337. ***** ^ not supported yet
  338. 194 GenLists.ListInsert(opener, GenLists.StrCode, outList,
  339. ***** ^ not supported yet
  340. ***** ^ not supported yet
  341. ***** ^ not supported yet
  342. ***** ^ not supported yet
  343. ***** ^ not supported yet
  344. ***** ^ not supported yet
  345. 195 outListLngth);
  346. ***** ^ not supported yet
  347. 196 END;
  348. 197 LOOP
  349. 198 GetNxtLstChr(inList, currentLine, currentIndex, tmpch);
  350. ***** ^ not supported yet
  351. ***** ^ not supported yet
  352. ***** ^ not supported yet
  353. 199 IF tmpch = opener[0] THEN
  354. ***** ^ not supported yet
  355. ***** ^ not supported yet
  356. 200 openerIndex := PosUtils.Positn(opener, TheLine,
  357. ***** ^ not supported yet
  358. ***** ^ not supported yet
  359. ***** ^ not supported yet
  360. ***** ^ undeclared identifier
  361. 201 currentIndex);
  362. ***** ^ not supported yet
  363. 202 IF currentIndex = openerIndex THEN
  364. 203 (* We were on an opener. We don't increment currentIndex
  365. 204 * past it because, if opener contains more than one
  366. 205 * character, we want them all copied into outList.
  367. 206 *)
  368. 207 INC(NestingLevel);
  369. ***** ^ undeclared identifier
  370. ***** ^ not supported yet
  371. 208 END;
  372. 209 END;
  373. 210 IF tmpch = closer[0] THEN
  374. ***** ^ not supported yet
  375. ***** ^ not supported yet
  376. 211 closerIndex := PosUtils.Positn(closer, TheLine, currentIndex);
  377. ***** ^ not supported yet
  378. ***** ^ not supported yet
  379. ***** ^ not supported yet
  380. ***** ^ undeclared identifier
  381. ***** ^ not supported yet
  382. 212 IF currentIndex = closerIndex THEN
  383. 213 (*We were on a closer.*)
  384. 214 DEC(NestingLevel);
  385. ***** ^ undeclared identifier
  386. ***** ^ not supported yet
  387. 215 END;
  388. 216 IF NestingLevel = 0 THEN
  389. 217 INC(currentIndex, openerLngth);
  390. ***** ^ undeclared identifier
  391. ***** ^ not supported yet
  392. 218 ListUtils.InsertIntoElmt(outList, outListLngth,
  393. ***** ^ not supported yet
  394. ***** ^ not supported yet
  395. ***** ^ not supported yet
  396. 219 SYSTEM.ADR(closer), openerLngth, 65535);
  397. ***** ^ not supported yet
  398. ***** ^ not supported yet
  399. ***** ^ not supported yet
  400. ***** ^ not supported yet
  401. 220 EXIT;
  402. 221 END;
  403. 222 END;
  404. 223 IF currentIndex > 0 THEN
  405. 224 ListUtils.InsertIntoElmt(outList, outListLngth,
  406. ***** ^ not supported yet
  407. ***** ^ not supported yet
  408. ***** ^ not supported yet
  409. 225 SYSTEM.ADR(tmpch), 1, 65535);
  410. ***** ^ not supported yet
  411. ***** ^ not supported yet
  412. ***** ^ not supported yet
  413. ***** ^ not supported yet
  414. 226 ELSE
  415. 227 (* Every time currentIndex goes to zero we start a new
  416. 228 line in the OutList. *)
  417. 229 INC(outListLngth);
  418. ***** ^ undeclared identifier
  419. ***** ^ not supported yet
  420. 230 GenLists.ListInsert(tmpch, GenLists.StrCode, outList,
  421. ***** ^ not supported yet
  422. ***** ^ not supported yet
  423. ***** ^ not supported yet
  424. ***** ^ not supported yet
  425. ***** ^ not supported yet
  426. 231 outListLngth);
  427. ***** ^ not supported yet
  428. 232 END;
  429. 233 END;
  430. 234 END GetLogicalLst;
  431. ***** ^ not supported yet
  432. 235
  433. 236
  434. 237 PROCEDURE GetLogicalStr(
  435. 238 inList: GenLists.GenList;
  436. ***** ^ not supported yet
  437. 239 opener, closer: ARRAY OF CHAR;
  438. ***** ^ not supported yet
  439. 240 VAR currentLine, currentIndex: CARDINAL;
  440. 241 VAR outStr: ARRAY OF CHAR;
  441. ***** ^ not supported yet
  442. 242 VAR terminator: CHAR);
  443. 243 VAR
  444. 244 tmpLst: GenLists.GenList;
  445. ***** ^ not supported yet
  446. 245 BEGIN
  447. 246 GenLists.NewList(tmpLst);
  448. ***** ^ not supported yet
  449. ***** ^ not supported yet
  450. ***** ^ not supported yet
  451. 247 GetLogicalLst(inList, opener, closer, currentLine, currentIndex,
  452. ***** ^ not supported yet
  453. ***** ^ not supported yet
  454. ***** ^ not supported yet
  455. ***** ^ not supported yet
  456. 248 tmpLst, terminator);
  457. ***** ^ not supported yet
  458. ***** ^ not supported yet
  459. 249 ListUtils.ListToString(tmpLst, outStr);
  460. ***** ^ not supported yet
  461. ***** ^ not supported yet
  462. ***** ^ not supported yet
  463. ***** ^ not supported yet
  464. 250 GenLists.DisposeList(tmpLst);
  465. ***** ^ not supported yet
  466. ***** ^ not supported yet
  467. ***** ^ not supported yet
  468. 251 END GetLogicalStr;
  469. ***** ^ not supported yet
  470. 252
  471. 253
  472. 254 PROCEDURE GetNextWord(
  473. 255 InList: GenLists.GenList;
  474. ***** ^ not supported yet
  475. 256 VAR CurrentLine, CurrentIndex: CARDINAL;
  476. 257 VAR NextWord: ARRAY OF CHAR;
  477. ***** ^ not supported yet
  478. 258 VAR Terminator: CHAR);
  479. 259 (* To make this start at the beginning of the first line,
  480. 260 you have to pass 0 to both CurrentLine and CurrentIndex.
  481. 261 Algorithm is:
  482. 262 starting from position CurrentIndex in line CurrentLine:
  483. 263 skip over any blanks
  484. 264 if at end of line, get a new line
  485. 265 NextWord := text up to next delimiter
  486. 266 If delimiter found = StartComment[0], skip any comments
  487. 267 skip over any blanks
  488. 268 leave index on next character
  489. 269 that next character will normally not be a delimiter;
  490. 270 Weird conditions:
  491. 271 if next char is a delimiter other than a blank,
  492. 272 a null nextword will be returned next time
  493. 273 if get last word on a line, index is left at the end of line
  494. 274 *)
  495. 275 VAR
  496. 276 NextDelim, TypeCode: CARDINAL;
  497. 277 dumstr: ARRAY [0..191] OF CHAR;
  498. ***** ^ not supported yet
  499. ***** ^ not supported yet
  500. 278 QuoteChar: CHAR;
  501. 279 DelimFound : BOOLEAN;
  502. 280
  503. 281 BEGIN
  504. 282 StrEdit.SetLength(NextWord, 0);
  505. ***** ^ not supported yet
  506. ***** ^ not supported yet
  507. ***** ^ not supported yet
  508. ***** ^ not supported yet
  509. 283 LineLngth := M2Strings.Length(TheLine);
  510. ***** ^ not supported yet
  511. ***** ^ not supported yet
  512. ***** ^ undeclared identifier
  513. 284 LOOP
  514. 285 (* We do this first loop just to make sure we have a line to
  515. 286 work with (we might need to read another one) and to get
  516. 287 to the next nonblank character (which might be a nonblank
  517. 288 delimiter. *)
  518. 289 IF CurrentIndex >= LineLngth THEN
  519. 290 (* we are at a line end *)
  520. 291 CurrentIndex := 0;
  521. 292 IF CurrentLine < GenLists.ListLength(InList) THEN
  522. ***** ^ not supported yet
  523. ***** ^ not supported yet
  524. ***** ^ not supported yet
  525. 293 (* We aren't at the end of the file. *)
  526. 294 INC(CurrentLine);
  527. ***** ^ undeclared identifier
  528. ***** ^ not supported yet
  529. 295 GenLists.GetElmt(InList, CurrentLine, TheLine, TypeCode);
  530. ***** ^ not supported yet
  531. ***** ^ not supported yet
  532. ***** ^ not supported yet
  533. ***** ^ undeclared identifier
  534. ***** ^ not supported yet
  535. 296 (*read next line*)
  536. 297 LineLngth := M2Strings.Length(TheLine);
  537. ***** ^ not supported yet
  538. ***** ^ not supported yet
  539. ***** ^ undeclared identifier
  540. 298 ELSE
  541. 299 Terminator := EOF;
  542. ***** ^ undeclared identifier
  543. 300 (* We are at file end; EOF as Terminator is what
  544. 301 the caller is supposed to look for to know that the
  545. 302 end has been reached. *)
  546. 303 RETURN;
  547. 304 END;
  548. 305 ELSIF PosUtils.Present(TheLine[CurrentIndex], whitespace) THEN
  549. ***** ^ not supported yet
  550. ***** ^ not supported yet
  551. ***** ^ undeclared identifier
  552. ***** ^ not supported yet
  553. ***** ^ undeclared identifier
  554. 306 (* skip the character if it's a blank and loop again *)
  555. 307 INC(CurrentIndex);
  556. ***** ^ undeclared identifier
  557. ***** ^ not supported yet
  558. 308 ELSE
  559. 309 EXIT;
  560. 310 (* We are on a non-blank, but notice that it might be
  561. 311 a delimiter. *)
  562. 312 END;
  563. 313 END;
  564. 314 LastIndex := CurrentIndex;
  565. ***** ^ undeclared identifier
  566. 315 NextDelim := CurrentIndex;
  567. 316 IF ((TheLine[NextDelim] = '"') OR (TheLine[NextDelim] = "'"))
  568. ***** ^ undeclared identifier
  569. ***** ^ not supported yet
  570. ***** ^ undeclared identifier
  571. ***** ^ not supported yet
  572. 317 AND PosUtils.Present(TheLine[NextDelim], delimiters) THEN
  573. ***** ^ not supported yet
  574. ***** ^ not supported yet
  575. ***** ^ undeclared identifier
  576. ***** ^ not supported yet
  577. ***** ^ undeclared identifier
  578. 318 (*Looks like beginning of a string literal. Find end of it.*)
  579. 319 INC(CurrentIndex);
  580. ***** ^ undeclared identifier
  581. ***** ^ not supported yet
  582. 320 (*Prevents copying opening quote into NextWord.*)
  583. 321 QuoteChar := TheLine[NextDelim];
  584. ***** ^ undeclared identifier
  585. ***** ^ not supported yet
  586. 322 REPEAT
  587. 323 (* skip until come to next delimiter *)
  588. 324 INC(NextDelim);
  589. ***** ^ undeclared identifier
  590. ***** ^ not supported yet
  591. 325 UNTIL (NextDelim >= LineLngth) OR
  592. 326 (TheLine[NextDelim] = QuoteChar);
  593. ***** ^ undeclared identifier
  594. ***** ^ not supported yet
  595. 327 ELSIF ((TheLine[NextDelim] = StartComment[0]) AND
  596. ***** ^ undeclared identifier
  597. ***** ^ not supported yet
  598. ***** ^ undeclared identifier
  599. ***** ^ not supported yet
  600. 328 (TheLine[NextDelim + 1] = StartComment[1])) THEN
  601. ***** ^ undeclared identifier
  602. ***** ^ not supported yet
  603. ***** ^ undeclared identifier
  604. ***** ^ not supported yet
  605. 329 StrEdit.AssignStr(StartComment, NextWord);
  606. ***** ^ not supported yet
  607. ***** ^ not supported yet
  608. ***** ^ undeclared identifier
  609. ***** ^ not supported yet
  610. 330 CurrentIndex := NextDelim;
  611. 331 (* We want to give the user a choice between reading or
  612. 332 skipping the comment. We do that by telling them that
  613. 333 NextWord = StartComment. If they want to skip it, they
  614. 334 call SkipComments. If they want it, they call
  615. 335 ReadComments. *)
  616. 336 Terminator := space;
  617. 337 (* Notice that this is the only case where we exit with
  618. 338 CurrentIndex pointing to the word itself rather than
  619. 339 to the first nonblank character following the word. *)
  620. 340 RETURN;
  621. 341 ELSE
  622. 342 DelimFound := FALSE;
  623. 343 WHILE (NextDelim < LineLngth) AND (NOT DelimFound) DO
  624. 344 IF (PosUtils.Present(TheLine[NextDelim], delimiters)) THEN
  625. ***** ^ not supported yet
  626. ***** ^ not supported yet
  627. ***** ^ undeclared identifier
  628. ***** ^ not supported yet
  629. ***** ^ undeclared identifier
  630. 345 DelimFound := TRUE;
  631. 346 ELSE
  632. 347 (* skip until we come to next delimiter *)
  633. 348 INC(NextDelim);
  634. ***** ^ undeclared identifier
  635. ***** ^ not supported yet
  636. 349 END;
  637. 350 END;
  638. 351 END;
  639. 352 M2Strings.Copy(TheLine, CurrentIndex, NextDelim - CurrentIndex,
  640. ***** ^ not supported yet
  641. ***** ^ not supported yet
  642. ***** ^ undeclared identifier
  643. 353 NextWord);
  644. ***** ^ not supported yet
  645. 354 (* NextWord now contains everything between CurrentIndex and
  646. 355 NextDelim -- not including the delimiter itself. *)
  647. 356 CurrentIndex := NextDelim;
  648. 357 (* Now we need to tell them what the terminating character was.
  649. 358 If there was whitespace between the end of the word and the
  650. 359 next item, we'll only tell them that the Terminator was a space
  651. 360 if the space was required (i.e., if the next item began with
  652. 361 something other than a delimiter. Otherwise we'll let them
  653. 362 assume that everything was jammed together with the least
  654. 363 possible amount of whitespace. *)
  655. 364 WHILE (CurrentIndex < LineLngth) AND
  656. 365 (PosUtils.Present(TheLine[CurrentIndex], whitespace)) DO
  657. ***** ^ not supported yet
  658. ***** ^ not supported yet
  659. ***** ^ undeclared identifier
  660. ***** ^ not supported yet
  661. ***** ^ undeclared identifier
  662. 366 INC(CurrentIndex);
  663. ***** ^ undeclared identifier
  664. ***** ^ not supported yet
  665. 367 (* skip over blanks *)
  666. 368 END;
  667. 369 IF (CurrentIndex < LineLngth) AND
  668. 370 (* if on a delimiter *)
  669. 371 (PosUtils.Present(TheLine[CurrentIndex], delimiters)) THEN
  670. ***** ^ not supported yet
  671. ***** ^ not supported yet
  672. ***** ^ undeclared identifier
  673. ***** ^ not supported yet
  674. ***** ^ undeclared identifier
  675. 372 Terminator := TheLine[CurrentIndex];
  676. ***** ^ undeclared identifier
  677. ***** ^ not supported yet
  678. 373 (* return delimiter after word *)
  679. 374 IF ((TheLine[CurrentIndex] # StartComment[0]) OR
  680. ***** ^ undeclared identifier
  681. ***** ^ not supported yet
  682. ***** ^ undeclared identifier
  683. ***** ^ not supported yet
  684. 375 (TheLine[CurrentIndex + 1] # StartComment[1])) THEN
  685. ***** ^ undeclared identifier
  686. ***** ^ not supported yet
  687. ***** ^ undeclared identifier
  688. ***** ^ not supported yet
  689. 376 (* We have a kludgy convention that for comments, and nothing
  690. 377 else, we leave CurrentIndex pointing to the first character
  691. 378 of the comment. *)
  692. 379 INC(CurrentIndex);
  693. ***** ^ undeclared identifier
  694. ***** ^ not supported yet
  695. 380 END;
  696. 381 (* skip over delimiter before exit *)
  697. 382 ELSIF CurrentIndex >= LineLngth THEN
  698. 383 (* if at end of line *)
  699. 384 Terminator := EOL;
  700. ***** ^ undeclared identifier
  701. 385 ELSE
  702. 386 (* We know we aren't sitting on a delimiter, and we're not at
  703. 387 the end of the line, so we must have been terminated by a
  704. 388 blank between words *)
  705. 389 Terminator := space;
  706. 390 END;
  707. 391 END GetNextWord;
  708. ***** ^ not supported yet
  709. 392
  710. 393
  711. 394 PROCEDURE Init();
  712. 395 BEGIN
  713. 396 IF Initialized THEN
  714. 397 RETURN;
  715. 398 ELSE
  716. 399 Initialized := TRUE;
  717. 400 END;
  718. 401 (*EntryDiag:
  719. 402 Diagnostics.Init();
  720. 403 :EntryDiag*)
  721. 404
  722. 405 GenLists.Init();
  723. ***** ^ not supported yet
  724. ***** ^ not supported yet
  725. ***** ^ not supported yet
  726. 406 ListUtils.Init();
  727. ***** ^ not supported yet
  728. ***** ^ not supported yet
  729. ***** ^ not supported yet
  730. 407 M2Strings.Init();
  731. ***** ^ not supported yet
  732. ***** ^ not supported yet
  733. ***** ^ not supported yet
  734. 408 PosUtils.Init();
  735. ***** ^ not supported yet
  736. ***** ^ not supported yet
  737. ***** ^ not supported yet
  738. 409 StrEdit.Init();
  739. ***** ^ not supported yet
  740. ***** ^ not supported yet
  741. ***** ^ not supported yet
  742. 410
  743. 411 (*EntryDiag:
  744. 412 Diagnostics.diagS('Entering Parser', '');
  745. 413 :EntryDiag*)
  746. 414
  747. 415 StrEdit.AssignStr(' ;:(){}[]-=",.^+*/|#', delimiters);
  748. ***** ^ not supported yet
  749. ***** ^ not supported yet
  750. ***** ^ not supported yet
  751. ***** ^ undeclared identifier
  752. 416 StrEdit.Append(delimiters, "'");
  753. ***** ^ not supported yet
  754. ***** ^ not supported yet
  755. ***** ^ undeclared identifier
  756. ***** ^ not supported yet
  757. 417 StrEdit.Append(delimiters, EOL);
  758. ***** ^ not supported yet
  759. ***** ^ not supported yet
  760. ***** ^ undeclared identifier
  761. ***** ^ undeclared identifier
  762. 418 StrEdit.Append(delimiters, EOF);
  763. ***** ^ not supported yet
  764. ***** ^ not supported yet
  765. ***** ^ undeclared identifier
  766. ***** ^ undeclared identifier
  767. 419 StrEdit.Append(delimiters, TAB);
  768. ***** ^ not supported yet
  769. ***** ^ not supported yet
  770. ***** ^ undeclared identifier
  771. ***** ^ undeclared identifier
  772. 420 StrEdit.SetLength(TheLine, 0);
  773. ***** ^ not supported yet
  774. ***** ^ not supported yet
  775. ***** ^ undeclared identifier
  776. ***** ^ not supported yet
  777. 421 StartComment := '(*';
  778. ***** ^ undeclared identifier
  779. ***** ^ not supported yet
  780. 422 EndComment := '*)';
  781. ***** ^ undeclared identifier
  782. ***** ^ not supported yet
  783. 423 whitespace[0] := space;
  784. ***** ^ undeclared identifier
  785. ***** ^ not supported yet
  786. 424 whitespace[1] := TAB;
  787. ***** ^ undeclared identifier
  788. ***** ^ not supported yet
  789. ***** ^ undeclared identifier
  790. 425 whitespace[2] := EOL;
  791. ***** ^ undeclared identifier
  792. ***** ^ not supported yet
  793. ***** ^ undeclared identifier
  794. 426 whitespace[3] := 12C; (* linefeed *)
  795. ***** ^ undeclared identifier
  796. ***** ^ not supported yet
  797. 427 whitespace[4] := 0C;
  798. ***** ^ undeclared identifier
  799. ***** ^ not supported yet
  800. 428
  801. 429 (*EntryDiag:
  802. 430 Diagnostics.diagS('Exiting Parser', '');
  803. 431 :EntryDiag*)
  804. 432 END Init;
  805. ***** ^ not supported yet
  806. 433
  807. 434 BEGIN
  808. 435 Initialized := FALSE;
  809. 436 Init();
  810. ***** ^ not supported yet
  811. ***** ^ not supported yet
  812. 437 END Parser.
  813. ***** ^ not supported yet
  814. 375 errors