scanner.pas 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774
  1. {
  2. $Id$
  3. Copyright (c) 1993,97 by Florian Klaempfl
  4. This unit implements the scanner part and handling of the switches
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. {$ifdef tp}
  19. {$F+,N+,E+,R-}
  20. {$endif}
  21. unit scanner;
  22. interface
  23. uses
  24. {$ifdef Delphi}
  25. dmisc,
  26. {$endif Delphi}
  27. globtype,version,tokens,
  28. cobjects,globals,verbose,comphook,files;
  29. const
  30. {$ifdef TP}
  31. maxmacrolen=1024;
  32. {$else}
  33. maxmacrolen=16*1024;
  34. {$endif}
  35. Newline = #10;
  36. type
  37. tcommentstyle = (comment_none,comment_tp,comment_oldtp,comment_delphi,comment_c);
  38. pmacrobuffer = ^tmacrobuffer;
  39. tmacrobuffer = array[0..maxmacrolen-1] of char;
  40. preproctyp = (pp_ifdef,pp_ifndef,pp_if,pp_ifopt,pp_else);
  41. ppreprocstack = ^tpreprocstack;
  42. tpreprocstack = object
  43. typ : preproctyp;
  44. accept : boolean;
  45. next : ppreprocstack;
  46. name : stringid;
  47. line_nb : longint;
  48. constructor init(atyp:preproctyp;a:boolean;n:ppreprocstack);
  49. destructor done;
  50. end;
  51. pscannerfile = ^tscannerfile;
  52. tscannerfile = object
  53. inputfile : pinputfile; { current inputfile list }
  54. inputbuffer, { input buffer }
  55. inputpointer : pchar;
  56. inputstart : longint;
  57. line_no, { line }
  58. lastlinepos : longint;
  59. lasttokenpos : longint; { token }
  60. lasttoken,
  61. nexttoken : ttoken;
  62. comment_level,
  63. yylexcount : longint;
  64. lastasmgetchar : char;
  65. preprocstack : ppreprocstack;
  66. invalid : boolean; { flag if sourcefiles have been destroyed ! }
  67. constructor init(const fn:string);
  68. destructor done;
  69. { File buffer things }
  70. function openinputfile:boolean;
  71. procedure closeinputfile;
  72. function tempopeninputfile:boolean;
  73. procedure tempcloseinputfile;
  74. procedure saveinputfile;
  75. procedure restoreinputfile;
  76. procedure nextfile;
  77. procedure addfile(hp:pinputfile);
  78. procedure reload;
  79. procedure insertmacro(const macname:string;p:pchar;len:longint);
  80. { Scanner things }
  81. procedure gettokenpos;
  82. procedure inc_comment_level;
  83. procedure dec_comment_level;
  84. procedure end_of_file;
  85. procedure checkpreprocstack;
  86. procedure poppreprocstack;
  87. procedure addpreprocstack(atyp : preproctyp;a:boolean;const s:string;w:tmsgconst);
  88. procedure elsepreprocstack;
  89. procedure linebreak;
  90. procedure readchar;
  91. procedure readstring;
  92. procedure readnumber;
  93. function readid:string;
  94. function readval:longint;
  95. function readcomment:string;
  96. function readstate:char;
  97. procedure skipspace;
  98. procedure skipuntildirective;
  99. procedure skipcomment;
  100. procedure skipdelphicomment;
  101. procedure skipoldtpcomment;
  102. procedure readtoken;
  103. function readpreproc:ttoken;
  104. function asmgetchar:char;
  105. end;
  106. var
  107. c : char;
  108. orgpattern,
  109. pattern : string;
  110. current_scanner : pscannerfile;
  111. aktcommentstyle : tcommentstyle; { needed to use read_comment from directives }
  112. implementation
  113. uses
  114. {$ifndef delphi}
  115. dos,
  116. {$endif delphi}
  117. systems,symtable,switches;
  118. {*****************************************************************************
  119. Helper routines
  120. *****************************************************************************}
  121. const
  122. { use any special name that is an invalid file name to avoid problems }
  123. preprocstring : array [preproctyp] of string[7]
  124. = ('$IFDEF','$IFNDEF','$IF','$IFOPT','$ELSE');
  125. function is_keyword(const s:string):boolean;
  126. var
  127. low,high,mid : longint;
  128. begin
  129. if not (length(s) in [2..tokenidlen]) then
  130. begin
  131. is_keyword:=false;
  132. exit;
  133. end;
  134. low:=ord(tokenidx^[length(s),s[1]].first);
  135. high:=ord(tokenidx^[length(s),s[1]].last);
  136. while low<high do
  137. begin
  138. mid:=(high+low+1) shr 1;
  139. if pattern<tokeninfo^[ttoken(mid)].str then
  140. high:=mid-1
  141. else
  142. low:=mid;
  143. end;
  144. is_keyword:=(pattern=tokeninfo^[ttoken(high)].str) and
  145. (tokeninfo^[ttoken(high)].keyword in aktmodeswitches);
  146. end;
  147. {*****************************************************************************
  148. TPreProcStack
  149. *****************************************************************************}
  150. constructor tpreprocstack.init(atyp : preproctyp;a:boolean;n:ppreprocstack);
  151. begin
  152. accept:=a;
  153. typ:=atyp;
  154. next:=n;
  155. end;
  156. destructor tpreprocstack.done;
  157. begin
  158. end;
  159. {****************************************************************************
  160. TSCANNERFILE
  161. ****************************************************************************}
  162. constructor tscannerfile.init(const fn:string);
  163. begin
  164. inputfile:=new(pinputfile,init(fn));
  165. current_module^.sourcefiles^.register_file(inputfile);
  166. { reset localinput }
  167. inputbuffer:=nil;
  168. inputpointer:=nil;
  169. inputstart:=0;
  170. { reset scanner }
  171. preprocstack:=nil;
  172. comment_level:=0;
  173. yylexcount:=0;
  174. block_type:=bt_general;
  175. line_no:=0;
  176. lastlinepos:=0;
  177. lasttokenpos:=0;
  178. lasttoken:=NOTOKEN;
  179. nexttoken:=NOTOKEN;
  180. lastasmgetchar:=#0;
  181. invalid:=false;
  182. { load block }
  183. if not openinputfile then
  184. Message1(scan_f_cannot_open_input,fn);
  185. reload;
  186. { process first read char }
  187. case c of
  188. #26 : reload;
  189. #10,
  190. #13 : linebreak;
  191. end;
  192. end;
  193. destructor tscannerfile.done;
  194. begin
  195. if not invalid then
  196. begin
  197. if status.errorcount=0 then
  198. checkpreprocstack;
  199. { close file, but only if we are the first compile }
  200. { probably not necessary anymore with invalid flag PM }
  201. if not current_module^.in_second_compile then
  202. begin
  203. if not inputfile^.closed then
  204. closeinputfile;
  205. end;
  206. end;
  207. end;
  208. function tscannerfile.openinputfile:boolean;
  209. begin
  210. openinputfile:=inputfile^.open;
  211. { load buffer }
  212. inputbuffer:=inputfile^.buf;
  213. inputpointer:=inputfile^.buf;
  214. inputstart:=inputfile^.bufstart;
  215. { line }
  216. line_no:=0;
  217. lastlinepos:=0;
  218. lasttokenpos:=0;
  219. end;
  220. procedure tscannerfile.closeinputfile;
  221. begin
  222. inputfile^.close;
  223. { reset buffer }
  224. inputbuffer:=nil;
  225. inputpointer:=nil;
  226. inputstart:=0;
  227. { reset line }
  228. line_no:=0;
  229. lastlinepos:=0;
  230. lasttokenpos:=0;
  231. end;
  232. function tscannerfile.tempopeninputfile:boolean;
  233. begin
  234. tempopeninputfile:=inputfile^.tempopen;
  235. { reload buffer }
  236. inputbuffer:=inputfile^.buf;
  237. inputpointer:=inputfile^.buf;
  238. inputstart:=inputfile^.bufstart;
  239. end;
  240. procedure tscannerfile.tempcloseinputfile;
  241. begin
  242. inputfile^.setpos(inputstart+(inputpointer-inputbuffer));
  243. inputfile^.tempclose;
  244. { reset buffer }
  245. inputbuffer:=nil;
  246. inputpointer:=nil;
  247. inputstart:=0;
  248. end;
  249. procedure tscannerfile.saveinputfile;
  250. begin
  251. inputfile^.saveinputpointer:=inputpointer;
  252. inputfile^.savelastlinepos:=lastlinepos;
  253. inputfile^.saveline_no:=line_no;
  254. end;
  255. procedure tscannerfile.restoreinputfile;
  256. begin
  257. inputpointer:=inputfile^.saveinputpointer;
  258. lastlinepos:=inputfile^.savelastlinepos;
  259. line_no:=inputfile^.saveline_no;
  260. if not inputfile^.is_macro then
  261. parser_current_file:=inputfile^.name^;
  262. end;
  263. procedure tscannerfile.nextfile;
  264. var
  265. to_dispose : pinputfile;
  266. begin
  267. if assigned(inputfile^.next) then
  268. begin
  269. if inputfile^.is_macro then
  270. to_dispose:=inputfile
  271. else
  272. to_dispose:=nil;
  273. { we can allways close the file, no ? }
  274. inputfile^.close;
  275. inputfile:=inputfile^.next;
  276. if assigned(to_dispose) then
  277. dispose(to_dispose,done);
  278. restoreinputfile;
  279. end;
  280. end;
  281. procedure tscannerfile.addfile(hp:pinputfile);
  282. begin
  283. saveinputfile;
  284. { add to list }
  285. hp^.next:=inputfile;
  286. inputfile:=hp;
  287. { load new inputfile }
  288. restoreinputfile;
  289. end;
  290. procedure tscannerfile.reload;
  291. begin
  292. with inputfile^ do
  293. begin
  294. repeat
  295. { still more to read?, then change the #0 to a space so its seen
  296. as a seperator, this can't be used for macro's which can change
  297. the place of the #0 in the buffer with tempopen }
  298. if (c=#0) and (bufsize>0) and
  299. not(inputfile^.is_macro) and
  300. (inputpointer-inputbuffer<bufsize) then
  301. begin
  302. c:=' ';
  303. inc(longint(inputpointer));
  304. exit;
  305. end;
  306. { can we read more from this file ? }
  307. if (c<>#26) and (not endoffile) then
  308. begin
  309. readbuf;
  310. inputpointer:=buf;
  311. inputbuffer:=buf;
  312. inputstart:=bufstart;
  313. { first line? }
  314. if line_no=0 then
  315. begin
  316. line_no:=1;
  317. if cs_asm_source in aktglobalswitches then
  318. inputfile^.setline(line_no,bufstart);
  319. end;
  320. end
  321. else
  322. begin
  323. { load eof position in tokenpos/aktfilepos }
  324. gettokenpos;
  325. { close file }
  326. closeinputfile;
  327. { no next module, than EOF }
  328. if not assigned(inputfile^.next) then
  329. begin
  330. c:=#26;
  331. exit;
  332. end;
  333. { load next file and reopen it }
  334. nextfile;
  335. tempopeninputfile;
  336. { status }
  337. Message1(scan_t_back_in,inputfile^.name^);
  338. end;
  339. { load next char }
  340. c:=inputpointer^;
  341. inc(longint(inputpointer));
  342. until c<>#0; { if also end, then reload again }
  343. end;
  344. end;
  345. procedure tscannerfile.insertmacro(const macname:string;p:pchar;len:longint);
  346. var
  347. hp : pinputfile;
  348. begin
  349. { save old postion and decrease linebreak }
  350. if c=newline then
  351. dec(line_no);
  352. dec(longint(inputpointer));
  353. tempcloseinputfile;
  354. { create macro 'file' }
  355. { use special name to dispose after !! }
  356. hp:=new(pinputfile,init('_Macro_.'+macname));
  357. addfile(hp);
  358. with inputfile^ do
  359. begin
  360. setmacro(p,len);
  361. { local buffer }
  362. inputbuffer:=buf;
  363. inputpointer:=buf;
  364. inputstart:=bufstart;
  365. end;
  366. { reset line }
  367. line_no:=0;
  368. lastlinepos:=0;
  369. lasttokenpos:=0;
  370. { load new c }
  371. c:=inputpointer^;
  372. inc(longint(inputpointer));
  373. end;
  374. procedure tscannerfile.gettokenpos;
  375. { load the values of tokenpos and lasttokenpos }
  376. begin
  377. lasttokenpos:=inputstart+(inputpointer-inputbuffer);
  378. tokenpos.line:=line_no;
  379. tokenpos.column:=lasttokenpos-lastlinepos;
  380. tokenpos.fileindex:=inputfile^.ref_index;
  381. aktfilepos:=tokenpos;
  382. end;
  383. procedure tscannerfile.inc_comment_level;
  384. var
  385. oldaktfilepos : tfileposinfo;
  386. begin
  387. if (m_nested_comment in aktmodeswitches) then
  388. inc(comment_level)
  389. else
  390. comment_level:=1;
  391. if (comment_level>1) then
  392. begin
  393. oldaktfilepos:=aktfilepos;
  394. gettokenpos; { update for warning }
  395. Message1(scan_w_comment_level,tostr(comment_level));
  396. aktfilepos:=oldaktfilepos;
  397. end;
  398. end;
  399. procedure tscannerfile.dec_comment_level;
  400. begin
  401. if (m_nested_comment in aktmodeswitches) then
  402. dec(comment_level)
  403. else
  404. comment_level:=0;
  405. end;
  406. procedure tscannerfile.linebreak;
  407. var
  408. cur : char;
  409. oldtokenpos,
  410. oldaktfilepos : tfileposinfo;
  411. begin
  412. with inputfile^ do
  413. begin
  414. if (byte(inputpointer^)=0) and not(endoffile) then
  415. begin
  416. cur:=c;
  417. reload;
  418. if byte(cur)+byte(c)<>23 then
  419. dec(longint(inputpointer));
  420. end
  421. else
  422. begin
  423. { Fix linebreak to be only newline (=#10) for all types of linebreaks }
  424. if (byte(inputpointer^)+byte(c)=23) then
  425. inc(longint(inputpointer));
  426. end;
  427. c:=newline;
  428. { increase line counters }
  429. lastlinepos:=bufstart+(inputpointer-inputbuffer);
  430. inc(line_no);
  431. { update linebuffer }
  432. if cs_asm_source in aktglobalswitches then
  433. inputfile^.setline(line_no,lastlinepos);
  434. { update for status and call the show status routine,
  435. but don't touch aktfilepos ! }
  436. oldaktfilepos:=aktfilepos;
  437. oldtokenpos:=tokenpos;
  438. gettokenpos; { update for v_status }
  439. inc(status.compiledlines);
  440. ShowStatus;
  441. aktfilepos:=oldaktfilepos;
  442. tokenpos:=oldtokenpos;
  443. end;
  444. end;
  445. procedure tscannerfile.end_of_file;
  446. begin
  447. checkpreprocstack;
  448. Message(scan_f_end_of_file);
  449. end;
  450. procedure tscannerfile.checkpreprocstack;
  451. begin
  452. { check for missing ifdefs }
  453. while assigned(preprocstack) do
  454. begin
  455. Message3(scan_e_endif_expected,preprocstring[preprocstack^.typ],preprocstack^.name,tostr(preprocstack^.line_nb));
  456. poppreprocstack;
  457. end;
  458. end;
  459. procedure tscannerfile.poppreprocstack;
  460. var
  461. hp : ppreprocstack;
  462. begin
  463. if assigned(preprocstack) then
  464. begin
  465. Message1(scan_c_endif_found,preprocstack^.name);
  466. hp:=preprocstack^.next;
  467. dispose(preprocstack,done);
  468. preprocstack:=hp;
  469. end
  470. else
  471. Message(scan_e_endif_without_if);
  472. end;
  473. procedure tscannerfile.addpreprocstack(atyp : preproctyp;a:boolean;const s:string;w:tmsgconst);
  474. begin
  475. preprocstack:=new(ppreprocstack,init(atyp,((preprocstack=nil) or preprocstack^.accept) and a,preprocstack));
  476. preprocstack^.name:=s;
  477. preprocstack^.line_nb:=line_no;
  478. if preprocstack^.accept then
  479. Message2(w,preprocstack^.name,'accepted')
  480. else
  481. Message2(w,preprocstack^.name,'rejected');
  482. end;
  483. procedure tscannerfile.elsepreprocstack;
  484. begin
  485. if assigned(preprocstack) then
  486. begin
  487. preprocstack^.typ:=pp_else;
  488. preprocstack^.line_nb:=line_no;
  489. if not(assigned(preprocstack^.next)) or (preprocstack^.next^.accept) then
  490. preprocstack^.accept:=not preprocstack^.accept;
  491. if preprocstack^.accept then
  492. Message2(scan_c_else_found,preprocstack^.name,'accepted')
  493. else
  494. Message2(scan_c_else_found,preprocstack^.name,'rejected');
  495. end
  496. else
  497. Message(scan_e_endif_without_if);
  498. end;
  499. procedure tscannerfile.readchar;
  500. begin
  501. c:=inputpointer^;
  502. if c=#0 then
  503. reload
  504. else
  505. inc(longint(inputpointer));
  506. case c of
  507. #26 : reload;
  508. #10,
  509. #13 : linebreak;
  510. end;
  511. end;
  512. procedure tscannerfile.readstring;
  513. var
  514. i : longint;
  515. begin
  516. i:=0;
  517. repeat
  518. case c of
  519. '_',
  520. '0'..'9',
  521. 'A'..'Z' : begin
  522. if i<255 then
  523. begin
  524. inc(i);
  525. orgpattern[i]:=c;
  526. pattern[i]:=c;
  527. end;
  528. c:=inputpointer^;
  529. inc(longint(inputpointer));
  530. end;
  531. 'a'..'z' : begin
  532. if i<255 then
  533. begin
  534. inc(i);
  535. orgpattern[i]:=c;
  536. pattern[i]:=chr(ord(c)-32)
  537. end;
  538. c:=inputpointer^;
  539. inc(longint(inputpointer));
  540. end;
  541. #0 : reload;
  542. #26 : begin
  543. reload;
  544. if c=#26 then
  545. break;
  546. end;
  547. #13,#10 : begin
  548. linebreak;
  549. break;
  550. end;
  551. else
  552. break;
  553. end;
  554. until false;
  555. {$ifndef TP}
  556. {$ifopt H+}
  557. setlength(orgpattern,i);
  558. setlength(pattern,i);
  559. {$else}
  560. orgpattern[0]:=chr(i);
  561. pattern[0]:=chr(i);
  562. {$endif}
  563. {$else}
  564. orgpattern[0]:=chr(i);
  565. pattern[0]:=chr(i);
  566. {$endif}
  567. end;
  568. procedure tscannerfile.readnumber;
  569. var
  570. base,
  571. i : longint;
  572. begin
  573. case c of
  574. '%' : begin
  575. readchar;
  576. base:=2;
  577. pattern[1]:='%';
  578. i:=1;
  579. end;
  580. '$' : begin
  581. readchar;
  582. base:=16;
  583. pattern[1]:='$';
  584. i:=1;
  585. end;
  586. else
  587. begin
  588. base:=10;
  589. i:=0;
  590. end;
  591. end;
  592. while ((base>=10) and (c in ['0'..'9'])) or
  593. ((base=16) and (c in ['A'..'F','a'..'f'])) or
  594. ((base=2) and (c in ['0'..'1'])) do
  595. begin
  596. if i<255 then
  597. begin
  598. inc(i);
  599. pattern[i]:=c;
  600. end;
  601. { get next char }
  602. c:=inputpointer^;
  603. if c=#0 then
  604. reload
  605. else
  606. inc(longint(inputpointer));
  607. end;
  608. { was the next char a linebreak ? }
  609. case c of
  610. #26 : reload;
  611. #10,
  612. #13 : linebreak;
  613. end;
  614. {$ifndef TP}
  615. {$ifopt H+}
  616. setlength(pattern,i);
  617. {$else}
  618. pattern[0]:=chr(i);
  619. {$endif}
  620. {$else}
  621. pattern[0]:=chr(i);
  622. {$endif}
  623. end;
  624. function tscannerfile.readid:string;
  625. begin
  626. readstring;
  627. readid:=pattern;
  628. end;
  629. function tscannerfile.readval:longint;
  630. var
  631. l : longint;
  632. w : integer;
  633. begin
  634. readnumber;
  635. valint(pattern,l,w);
  636. readval:=l;
  637. end;
  638. function tscannerfile.readcomment:string;
  639. var
  640. i : longint;
  641. begin
  642. i:=0;
  643. repeat
  644. case c of
  645. '{' :
  646. if aktcommentstyle=comment_tp then
  647. inc_comment_level;
  648. '}' :
  649. if aktcommentstyle=comment_tp then
  650. begin
  651. readchar;
  652. dec_comment_level;
  653. if comment_level=0 then
  654. break
  655. else
  656. continue;
  657. end;
  658. '*' :
  659. if aktcommentstyle=comment_oldtp then
  660. begin
  661. readchar;
  662. if c=')' then
  663. begin
  664. readchar;
  665. dec_comment_level;
  666. break;
  667. end;
  668. end;
  669. #26 :
  670. end_of_file;
  671. else
  672. begin
  673. if (i<255) then
  674. begin
  675. inc(i);
  676. readcomment[i]:=c;
  677. end;
  678. end;
  679. end;
  680. c:=inputpointer^;
  681. if c=#0 then
  682. reload
  683. else
  684. inc(longint(inputpointer));
  685. if c in [#10,#13] then
  686. linebreak;
  687. until false;
  688. {$ifndef TP}
  689. {$ifopt H+}
  690. setlength(readcomment,i);
  691. {$else}
  692. readcomment[0]:=chr(i);
  693. {$endif}
  694. {$else}
  695. readcomment[0]:=chr(i);
  696. {$endif}
  697. end;
  698. function tscannerfile.readstate:char;
  699. var
  700. state : char;
  701. begin
  702. state:=' ';
  703. if c=' ' then
  704. begin
  705. current_scanner^.skipspace;
  706. current_scanner^.readid;
  707. if pattern='ON' then
  708. state:='+'
  709. else
  710. if pattern='OFF' then
  711. state:='-';
  712. end
  713. else
  714. state:=c;
  715. if not (state in ['+','-']) then
  716. Message(scan_e_wrong_switch_toggle);
  717. readstate:=state;
  718. end;
  719. procedure tscannerfile.skipspace;
  720. begin
  721. while c in [' ',#9..#13] do
  722. begin
  723. c:=inputpointer^;
  724. if c=#0 then
  725. reload
  726. else
  727. inc(longint(inputpointer));
  728. case c of
  729. #26 : reload;
  730. #10,
  731. #13 : linebreak;
  732. end;
  733. end;
  734. end;
  735. procedure tscannerfile.skipuntildirective;
  736. var
  737. found : longint;
  738. next_char_loaded : boolean;
  739. oldcommentstyle : tcommentstyle;
  740. begin
  741. found:=0;
  742. next_char_loaded:=false;
  743. oldcommentstyle:=aktcommentstyle;
  744. repeat
  745. case c of
  746. #26 :
  747. end_of_file;
  748. '{' :
  749. begin
  750. if not(m_nested_comment in aktmodeswitches) or
  751. (comment_level=0) then
  752. begin
  753. found:=1;
  754. aktcommentstyle:=comment_tp;
  755. end;
  756. inc_comment_level;
  757. end;
  758. '}' :
  759. begin
  760. dec_comment_level;
  761. found:=0;
  762. end;
  763. '$' :
  764. begin
  765. if found=1 then
  766. found:=2;
  767. end;
  768. '''' :
  769. if (m_tp in aktmodeswitches) or
  770. (m_delphi in aktmodeswitches) then
  771. begin
  772. repeat
  773. readchar;
  774. case c of
  775. #26 :
  776. end_of_file;
  777. newline :
  778. break;
  779. '''' :
  780. begin
  781. readchar;
  782. if c<>'''' then
  783. break;
  784. end;
  785. end;
  786. until false;
  787. end;
  788. '(' :
  789. begin
  790. readchar;
  791. if c='*' then
  792. begin
  793. readchar;
  794. if c='$' then
  795. begin
  796. found:=2;
  797. inc_comment_level;
  798. aktcommentstyle:=comment_oldtp;
  799. end
  800. else
  801. begin
  802. skipoldtpcomment;
  803. aktcommentstyle:=oldcommentstyle;
  804. end;
  805. end
  806. else
  807. next_char_loaded:=true;
  808. end;
  809. else
  810. found:=0;
  811. end;
  812. if next_char_loaded then
  813. next_char_loaded:=false
  814. else
  815. begin
  816. c:=inputpointer^;
  817. if c=#0 then
  818. reload
  819. else
  820. inc(longint(inputpointer));
  821. case c of
  822. #26 : reload;
  823. #10,
  824. #13 : linebreak;
  825. end;
  826. end;
  827. until (found=2);
  828. end;
  829. {****************************************************************************
  830. Include directive scanning/parsing
  831. ****************************************************************************}
  832. {$i scandir.inc}
  833. {****************************************************************************
  834. Comment Handling
  835. ****************************************************************************}
  836. procedure tscannerfile.skipcomment;
  837. begin
  838. aktcommentstyle:=comment_tp;
  839. readchar;
  840. inc_comment_level;
  841. { handle compiler switches }
  842. if (c='$') then
  843. handledirectives;
  844. { handle_switches can dec comment_level, }
  845. while (comment_level>0) do
  846. begin
  847. case c of
  848. '{' : inc_comment_level;
  849. '}' : dec_comment_level;
  850. #26 : end_of_file;
  851. end;
  852. c:=inputpointer^;
  853. if c=#0 then
  854. reload
  855. else
  856. inc(longint(inputpointer));
  857. case c of
  858. #26 : reload;
  859. #10,
  860. #13 : linebreak;
  861. end;
  862. end;
  863. aktcommentstyle:=comment_none;
  864. end;
  865. procedure tscannerfile.skipdelphicomment;
  866. begin
  867. aktcommentstyle:=comment_delphi;
  868. inc_comment_level;
  869. readchar;
  870. { this is currently not supported }
  871. if c='$' then
  872. Message(scan_e_wrong_styled_switch);
  873. { skip comment }
  874. while c<>newline do
  875. begin
  876. if c=#26 then
  877. end_of_file;
  878. readchar;
  879. end;
  880. dec_comment_level;
  881. aktcommentstyle:=comment_none;
  882. end;
  883. procedure tscannerfile.skipoldtpcomment;
  884. var
  885. found : longint;
  886. begin
  887. aktcommentstyle:=comment_oldtp;
  888. inc_comment_level;
  889. readchar;
  890. { this is currently not supported }
  891. if (c='$') then
  892. handledirectives;
  893. { skip comment }
  894. while (comment_level>0) do
  895. begin
  896. found:=0;
  897. repeat
  898. case c of
  899. #26 :
  900. end_of_file;
  901. '*' :
  902. begin
  903. if found=3 then
  904. found:=4
  905. else
  906. found:=1;
  907. end;
  908. ')' :
  909. begin
  910. if found in [1,4] then
  911. begin
  912. dec_comment_level;
  913. if comment_level=0 then
  914. found:=2
  915. else
  916. found:=0;
  917. end;
  918. end;
  919. '(' :
  920. begin
  921. if found=4 then
  922. inc_comment_level;
  923. found:=3;
  924. end;
  925. else
  926. begin
  927. if found=4 then
  928. inc_comment_level;
  929. found:=0;
  930. end;
  931. end;
  932. c:=inputpointer^;
  933. if c=#0 then
  934. reload
  935. else
  936. inc(longint(inputpointer));
  937. case c of
  938. #26 : reload;
  939. #10,
  940. #13 : linebreak;
  941. end;
  942. until (found=2);
  943. end;
  944. aktcommentstyle:=comment_none;
  945. end;
  946. {****************************************************************************
  947. Token Scanner
  948. ****************************************************************************}
  949. procedure tscannerfile.readtoken;
  950. var
  951. code : integer;
  952. low,high,mid : longint;
  953. m : longint;
  954. mac : pmacrosym;
  955. asciinr : string[6];
  956. label
  957. exit_label;
  958. begin
  959. { was there already a token read, then return that token }
  960. if nexttoken<>NOTOKEN then
  961. begin
  962. token:=nexttoken;
  963. nexttoken:=NOTOKEN;
  964. goto exit_label;
  965. end;
  966. { Skip all spaces and comments }
  967. repeat
  968. case c of
  969. '{' :
  970. skipcomment;
  971. ' ',#9..#13 :
  972. skipspace;
  973. else
  974. break;
  975. end;
  976. until false;
  977. { Save current token position, for EOF its already loaded }
  978. if c<>#26 then
  979. gettokenpos;
  980. { Check first for a identifier/keyword, this is 20+% faster (PFV) }
  981. if c in ['A'..'Z','a'..'z','_'] then
  982. begin
  983. readstring;
  984. token:=_ID;
  985. idtoken:=_ID;
  986. { keyword or any other known token,
  987. pattern is always uppercased }
  988. if (pattern[1]<>'_') and (length(pattern) in [2..tokenidlen]) then
  989. begin
  990. low:=ord(tokenidx^[length(pattern),pattern[1]].first);
  991. high:=ord(tokenidx^[length(pattern),pattern[1]].last);
  992. while low<high do
  993. begin
  994. mid:=(high+low+1) shr 1;
  995. if pattern<tokeninfo^[ttoken(mid)].str then
  996. high:=mid-1
  997. else
  998. low:=mid;
  999. end;
  1000. if pattern=tokeninfo^[ttoken(high)].str then
  1001. begin
  1002. if tokeninfo^[ttoken(high)].keyword in aktmodeswitches then
  1003. token:=ttoken(high);
  1004. idtoken:=ttoken(high);
  1005. end;
  1006. end;
  1007. { Only process identifiers and not keywords }
  1008. if token=_ID then
  1009. begin
  1010. { this takes some time ... }
  1011. if (cs_support_macro in aktmoduleswitches) then
  1012. begin
  1013. mac:=pmacrosym(macros^.search(pattern));
  1014. if assigned(mac) and (assigned(mac^.buftext)) then
  1015. begin
  1016. insertmacro(pattern,mac^.buftext,mac^.buflen);
  1017. { handle empty macros }
  1018. if c=#0 then
  1019. begin
  1020. reload;
  1021. case c of
  1022. #26 : reload;
  1023. #10,
  1024. #13 : linebreak;
  1025. end;
  1026. end;
  1027. { play it again ... }
  1028. inc(yylexcount);
  1029. if yylexcount>16 then
  1030. Message(scan_w_macro_deep_ten);
  1031. readtoken;
  1032. { that's all folks }
  1033. dec(yylexcount);
  1034. exit;
  1035. end;
  1036. end;
  1037. end;
  1038. { return token }
  1039. goto exit_label;
  1040. end
  1041. else
  1042. begin
  1043. idtoken:=_NOID;
  1044. case c of
  1045. '$' :
  1046. begin
  1047. readnumber;
  1048. token:=_INTCONST;
  1049. goto exit_label;
  1050. end;
  1051. '%' :
  1052. begin
  1053. readnumber;
  1054. token:=_INTCONST;
  1055. goto exit_label;
  1056. end;
  1057. '0'..'9' :
  1058. begin
  1059. readnumber;
  1060. if (c in ['.','e','E']) then
  1061. begin
  1062. { first check for a . }
  1063. if c='.' then
  1064. begin
  1065. readchar;
  1066. { is it a .. from a range? }
  1067. case c of
  1068. '.' :
  1069. begin
  1070. readchar;
  1071. token:=_INTCONST;
  1072. nexttoken:=_POINTPOINT;
  1073. goto exit_label;
  1074. end;
  1075. ')' :
  1076. begin
  1077. readchar;
  1078. token:=_INTCONST;
  1079. nexttoken:=_RECKKLAMMER;
  1080. goto exit_label;
  1081. end;
  1082. end;
  1083. { insert the number after the . }
  1084. pattern:=pattern+'.';
  1085. while c in ['0'..'9'] do
  1086. begin
  1087. pattern:=pattern+c;
  1088. readchar;
  1089. end;
  1090. end;
  1091. { E can also follow after a point is scanned }
  1092. if c in ['e','E'] then
  1093. begin
  1094. pattern:=pattern+'E';
  1095. readchar;
  1096. if c in ['-','+'] then
  1097. begin
  1098. pattern:=pattern+c;
  1099. readchar;
  1100. end;
  1101. if not(c in ['0'..'9']) then
  1102. Message(scan_f_illegal_char);
  1103. while c in ['0'..'9'] do
  1104. begin
  1105. pattern:=pattern+c;
  1106. readchar;
  1107. end;
  1108. end;
  1109. token:=_REALNUMBER;
  1110. goto exit_label;
  1111. end;
  1112. token:=_INTCONST;
  1113. goto exit_label;
  1114. end;
  1115. ';' :
  1116. begin
  1117. readchar;
  1118. token:=_SEMICOLON;
  1119. goto exit_label;
  1120. end;
  1121. '[' :
  1122. begin
  1123. readchar;
  1124. token:=_LECKKLAMMER;
  1125. goto exit_label;
  1126. end;
  1127. ']' :
  1128. begin
  1129. readchar;
  1130. token:=_RECKKLAMMER;
  1131. goto exit_label;
  1132. end;
  1133. '(' :
  1134. begin
  1135. readchar;
  1136. case c of
  1137. '*' :
  1138. begin
  1139. skipoldtpcomment;
  1140. readtoken;
  1141. exit;
  1142. end;
  1143. '.' :
  1144. begin
  1145. readchar;
  1146. token:=_LECKKLAMMER;
  1147. goto exit_label;
  1148. end;
  1149. end;
  1150. token:=_LKLAMMER;
  1151. goto exit_label;
  1152. end;
  1153. ')' :
  1154. begin
  1155. readchar;
  1156. token:=_RKLAMMER;
  1157. goto exit_label;
  1158. end;
  1159. '+' :
  1160. begin
  1161. readchar;
  1162. if (c='=') and (cs_support_c_operators in aktmoduleswitches) then
  1163. begin
  1164. readchar;
  1165. token:=_PLUSASN;
  1166. goto exit_label;
  1167. end;
  1168. token:=_PLUS;
  1169. goto exit_label;
  1170. end;
  1171. '-' :
  1172. begin
  1173. readchar;
  1174. if (c='=') and (cs_support_c_operators in aktmoduleswitches) then
  1175. begin
  1176. readchar;
  1177. token:=_MINUSASN;
  1178. goto exit_label;
  1179. end;
  1180. token:=_MINUS;
  1181. goto exit_label;
  1182. end;
  1183. ':' :
  1184. begin
  1185. readchar;
  1186. if c='=' then
  1187. begin
  1188. readchar;
  1189. token:=_ASSIGNMENT;
  1190. goto exit_label;
  1191. end;
  1192. token:=_COLON;
  1193. goto exit_label;
  1194. end;
  1195. '*' :
  1196. begin
  1197. readchar;
  1198. if (c='=') and (cs_support_c_operators in aktmoduleswitches) then
  1199. begin
  1200. readchar;
  1201. token:=_STARASN;
  1202. end
  1203. else
  1204. if c='*' then
  1205. begin
  1206. readchar;
  1207. token:=_STARSTAR;
  1208. end
  1209. else
  1210. token:=_STAR;
  1211. goto exit_label;
  1212. end;
  1213. '/' :
  1214. begin
  1215. readchar;
  1216. case c of
  1217. '=' :
  1218. begin
  1219. if (cs_support_c_operators in aktmoduleswitches) then
  1220. begin
  1221. readchar;
  1222. token:=_SLASHASN;
  1223. goto exit_label;
  1224. end;
  1225. end;
  1226. '/' :
  1227. begin
  1228. skipdelphicomment;
  1229. readtoken;
  1230. exit;
  1231. end;
  1232. end;
  1233. token:=_SLASH;
  1234. goto exit_label;
  1235. end;
  1236. '=' :
  1237. begin
  1238. readchar;
  1239. token:=_EQUAL;
  1240. goto exit_label;
  1241. end;
  1242. '.' :
  1243. begin
  1244. readchar;
  1245. case c of
  1246. '.' :
  1247. begin
  1248. readchar;
  1249. token:=_POINTPOINT;
  1250. goto exit_label;
  1251. end;
  1252. ')' :
  1253. begin
  1254. readchar;
  1255. token:=_RECKKLAMMER;
  1256. goto exit_label;
  1257. end;
  1258. end;
  1259. token:=_POINT;
  1260. goto exit_label;
  1261. end;
  1262. '@' :
  1263. begin
  1264. readchar;
  1265. if c='@' then
  1266. begin
  1267. readchar;
  1268. token:=_DOUBLEADDR;
  1269. end
  1270. else
  1271. token:=_KLAMMERAFFE;
  1272. goto exit_label;
  1273. end;
  1274. ',' :
  1275. begin
  1276. readchar;
  1277. token:=_COMMA;
  1278. goto exit_label;
  1279. end;
  1280. '''','#','^' :
  1281. begin
  1282. if c='^' then
  1283. begin
  1284. readchar;
  1285. c:=upcase(c);
  1286. if (block_type=bt_type) or
  1287. (lasttoken=_ID) or
  1288. (lasttoken=_RKLAMMER) or (lasttoken=_RECKKLAMMER) or (lasttoken=_CARET) then
  1289. begin
  1290. token:=_CARET;
  1291. goto exit_label;
  1292. end
  1293. else
  1294. begin
  1295. if c<#64 then
  1296. pattern:=chr(ord(c)+64)
  1297. else
  1298. pattern:=chr(ord(c)-64);
  1299. readchar;
  1300. end;
  1301. end
  1302. else
  1303. pattern:='';
  1304. repeat
  1305. case c of
  1306. '#' :
  1307. begin
  1308. readchar; { read # }
  1309. if c='$' then
  1310. begin
  1311. readchar; { read leading $ }
  1312. asciinr:='$';
  1313. while (upcase(c) in ['A'..'F','0'..'9']) and (length(asciinr)<6) do
  1314. begin
  1315. asciinr:=asciinr+c;
  1316. readchar;
  1317. end;
  1318. end
  1319. else
  1320. begin
  1321. asciinr:='';
  1322. while (c in ['0'..'9']) and (length(asciinr)<6) do
  1323. begin
  1324. asciinr:=asciinr+c;
  1325. readchar;
  1326. end;
  1327. end;
  1328. valint(asciinr,m,code);
  1329. if (asciinr='') or (code<>0) or
  1330. (m<0) or (m>255) then
  1331. Message(scan_e_illegal_char_const);
  1332. pattern:=pattern+chr(m);
  1333. end;
  1334. '''' :
  1335. begin
  1336. repeat
  1337. readchar;
  1338. case c of
  1339. #26 :
  1340. end_of_file;
  1341. newline :
  1342. Message(scan_f_string_exceeds_line);
  1343. '''' :
  1344. begin
  1345. readchar;
  1346. if c<>'''' then
  1347. break;
  1348. end;
  1349. end;
  1350. pattern:=pattern+c;
  1351. until false;
  1352. end;
  1353. '^' :
  1354. begin
  1355. readchar;
  1356. if c<#64 then
  1357. c:=chr(ord(c)+64)
  1358. else
  1359. c:=chr(ord(c)-64);
  1360. pattern:=pattern+c;
  1361. readchar;
  1362. end;
  1363. else
  1364. break;
  1365. end;
  1366. until false;
  1367. { strings with length 1 become const chars }
  1368. if length(pattern)=1 then
  1369. token:=_CCHAR
  1370. else
  1371. token:=_CSTRING;
  1372. goto exit_label;
  1373. end;
  1374. '>' :
  1375. begin
  1376. readchar;
  1377. case c of
  1378. '=' :
  1379. begin
  1380. readchar;
  1381. token:=_GTE;
  1382. goto exit_label;
  1383. end;
  1384. '>' :
  1385. begin
  1386. readchar;
  1387. token:=_SHR;
  1388. goto exit_label;
  1389. end;
  1390. '<' :
  1391. begin { >< is for a symetric diff for sets }
  1392. readchar;
  1393. token:=_SYMDIF;
  1394. goto exit_label;
  1395. end;
  1396. end;
  1397. token:=_GT;
  1398. goto exit_label;
  1399. end;
  1400. '<' :
  1401. begin
  1402. readchar;
  1403. case c of
  1404. '>' :
  1405. begin
  1406. readchar;
  1407. token:=_UNEQUAL;
  1408. goto exit_label;
  1409. end;
  1410. '=' :
  1411. begin
  1412. readchar;
  1413. token:=_LTE;
  1414. goto exit_label;
  1415. end;
  1416. '<' :
  1417. begin
  1418. readchar;
  1419. token:=_SHL;
  1420. goto exit_label;
  1421. end;
  1422. end;
  1423. token:=_LT;
  1424. goto exit_label;
  1425. end;
  1426. #26 :
  1427. begin
  1428. token:=_EOF;
  1429. checkpreprocstack;
  1430. goto exit_label;
  1431. end;
  1432. else
  1433. begin
  1434. Message(scan_f_illegal_char);
  1435. end;
  1436. end;
  1437. end;
  1438. exit_label:
  1439. lasttoken:=token;
  1440. end;
  1441. function tscannerfile.readpreproc:ttoken;
  1442. begin
  1443. skipspace;
  1444. case c of
  1445. 'A'..'Z',
  1446. 'a'..'z',
  1447. '_','0'..'9' : begin
  1448. preprocpat:=readid;
  1449. readpreproc:=_ID;
  1450. end;
  1451. '(' : begin
  1452. readchar;
  1453. readpreproc:=_LKLAMMER;
  1454. end;
  1455. ')' : begin
  1456. readchar;
  1457. readpreproc:=_RKLAMMER;
  1458. end;
  1459. '+' : begin
  1460. readchar;
  1461. readpreproc:=_PLUS;
  1462. end;
  1463. '-' : begin
  1464. readchar;
  1465. readpreproc:=_MINUS;
  1466. end;
  1467. '*' : begin
  1468. readchar;
  1469. readpreproc:=_STAR;
  1470. end;
  1471. '/' : begin
  1472. readchar;
  1473. readpreproc:=_SLASH;
  1474. end;
  1475. '=' : begin
  1476. readchar;
  1477. readpreproc:=_EQUAL;
  1478. end;
  1479. '>' : begin
  1480. readchar;
  1481. if c='=' then
  1482. begin
  1483. readchar;
  1484. readpreproc:=_GTE;
  1485. end
  1486. else
  1487. readpreproc:=_GT;
  1488. end;
  1489. '<' : begin
  1490. readchar;
  1491. case c of
  1492. '>' : begin
  1493. readchar;
  1494. readpreproc:=_UNEQUAL;
  1495. end;
  1496. '=' : begin
  1497. readchar;
  1498. readpreproc:=_LTE;
  1499. end;
  1500. else readpreproc:=_LT;
  1501. end;
  1502. end;
  1503. #26 :
  1504. end_of_file;
  1505. else
  1506. begin
  1507. readpreproc:=_EOF;
  1508. checkpreprocstack;
  1509. end;
  1510. end;
  1511. end;
  1512. function tscannerfile.asmgetchar : char;
  1513. begin
  1514. if lastasmgetchar<>#0 then
  1515. begin
  1516. c:=lastasmgetchar;
  1517. lastasmgetchar:=#0;
  1518. end
  1519. else
  1520. readchar;
  1521. case c of
  1522. '{' : begin
  1523. skipcomment;
  1524. asmgetchar:=c;
  1525. exit;
  1526. end;
  1527. '/' : begin
  1528. readchar;
  1529. if c='/' then
  1530. begin
  1531. skipdelphicomment;
  1532. asmgetchar:=c;
  1533. end
  1534. else
  1535. begin
  1536. asmgetchar:='/';
  1537. lastasmgetchar:=c;
  1538. end;
  1539. exit;
  1540. end;
  1541. '(' : begin
  1542. readchar;
  1543. if c='*' then
  1544. begin
  1545. skipoldtpcomment;
  1546. asmgetchar:=c;
  1547. end
  1548. else
  1549. begin
  1550. asmgetchar:='(';
  1551. lastasmgetchar:=c;
  1552. end;
  1553. exit;
  1554. end;
  1555. else
  1556. begin
  1557. asmgetchar:=c;
  1558. end;
  1559. end;
  1560. end;
  1561. end.
  1562. {
  1563. $Log$
  1564. Revision 1.100 1999-11-06 14:34:26 peter
  1565. * truncated log to 20 revs
  1566. Revision 1.99 1999/11/03 23:44:28 peter
  1567. * fixed comment level counting after directive
  1568. Revision 1.98 1999/11/02 15:05:08 peter
  1569. * fixed oldtp comment parsing
  1570. Revision 1.97 1999/10/30 12:32:30 peter
  1571. * fixed line counter when the first line had #10 only. This was buggy
  1572. for both the main file as for include files
  1573. Revision 1.96 1999/09/27 23:40:10 peter
  1574. * fixed macro within macro endless-loop
  1575. Revision 1.95 1999/09/03 10:02:48 peter
  1576. * $IFNDEF is 7 chars and not 6 chars
  1577. Revision 1.94 1999/09/02 18:47:47 daniel
  1578. * Could not compile with TP, some arrays moved to heap
  1579. * NOAG386BIN default for TP
  1580. * AG386* files were not compatible with TP, fixed.
  1581. Revision 1.93 1999/08/30 10:17:58 peter
  1582. * fixed crash in psub
  1583. * ansistringcompare fixed
  1584. * support for #$0b8
  1585. Revision 1.92 1999/08/06 13:11:44 michael
  1586. * Removed C style comments.
  1587. Revision 1.91 1999/08/05 16:53:11 peter
  1588. * V_Fatal=1, all other V_ are also increased
  1589. * Check for local procedure when assigning procvar
  1590. * fixed comment parsing because directives
  1591. * oldtp mode directives better supported
  1592. * added some messages to errore.msg
  1593. Revision 1.90 1999/08/04 13:03:05 jonas
  1594. * all tokens now start with an underscore
  1595. * PowerPC compiles!!
  1596. Revision 1.89 1999/07/29 11:43:22 peter
  1597. * always output preprocstack when unexpected eof is found
  1598. * fixed tp7/delphi skipuntildirective parsing
  1599. Revision 1.88 1999/07/24 11:20:59 peter
  1600. * directives are allowed in (* *)
  1601. * fixed parsing of (* between conditional code
  1602. Revision 1.87 1999/07/18 10:20:02 florian
  1603. * made it compilable with Dlephi 4 again
  1604. + fixed problem with large stack allocations on win32
  1605. Revision 1.86 1999/06/02 22:44:19 pierre
  1606. * previous wrong log corrected
  1607. Revision 1.85 1999/06/02 22:25:49 pierre
  1608. * changed $ifdef FPC @ into $ifndef TP
  1609. Revision 1.84 1999/05/31 23:28:42 pierre
  1610. * problem with main file end without newline
  1611. Revision 1.83 1999/05/20 14:57:29 peter
  1612. * fixed line counting with macro's
  1613. Revision 1.82 1999/05/04 21:45:04 florian
  1614. * changes to compile it with Delphi 4.0
  1615. Revision 1.81 1999/04/07 14:36:44 pierre
  1616. + better preproc stack checking and report
  1617. Revision 1.80 1999/04/06 11:20:59 peter
  1618. * more hashing for keyword table
  1619. }