scanner.pas 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784
  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. if tokeninfo^[ttoken(high)].op=NOTOKEN then
  1004. token:=ttoken(high)
  1005. else
  1006. token:=tokeninfo^[ttoken(high)].op;
  1007. idtoken:=ttoken(high);
  1008. end;
  1009. end;
  1010. { Only process identifiers and not keywords }
  1011. if token=_ID then
  1012. begin
  1013. { this takes some time ... }
  1014. if (cs_support_macro in aktmoduleswitches) then
  1015. begin
  1016. mac:=pmacrosym(macros^.search(pattern));
  1017. if assigned(mac) and (assigned(mac^.buftext)) then
  1018. begin
  1019. insertmacro(pattern,mac^.buftext,mac^.buflen);
  1020. { handle empty macros }
  1021. if c=#0 then
  1022. begin
  1023. reload;
  1024. case c of
  1025. #26 : reload;
  1026. #10,
  1027. #13 : linebreak;
  1028. end;
  1029. end;
  1030. { play it again ... }
  1031. inc(yylexcount);
  1032. if yylexcount>16 then
  1033. Message(scan_w_macro_deep_ten);
  1034. readtoken;
  1035. { that's all folks }
  1036. dec(yylexcount);
  1037. exit;
  1038. end;
  1039. end;
  1040. end;
  1041. { return token }
  1042. goto exit_label;
  1043. end
  1044. else
  1045. begin
  1046. idtoken:=_NOID;
  1047. case c of
  1048. '$' :
  1049. begin
  1050. readnumber;
  1051. token:=_INTCONST;
  1052. goto exit_label;
  1053. end;
  1054. '%' :
  1055. begin
  1056. readnumber;
  1057. token:=_INTCONST;
  1058. goto exit_label;
  1059. end;
  1060. '0'..'9' :
  1061. begin
  1062. readnumber;
  1063. if (c in ['.','e','E']) then
  1064. begin
  1065. { first check for a . }
  1066. if c='.' then
  1067. begin
  1068. readchar;
  1069. { is it a .. from a range? }
  1070. case c of
  1071. '.' :
  1072. begin
  1073. readchar;
  1074. token:=_INTCONST;
  1075. nexttoken:=_POINTPOINT;
  1076. goto exit_label;
  1077. end;
  1078. ')' :
  1079. begin
  1080. readchar;
  1081. token:=_INTCONST;
  1082. nexttoken:=_RECKKLAMMER;
  1083. goto exit_label;
  1084. end;
  1085. end;
  1086. { insert the number after the . }
  1087. pattern:=pattern+'.';
  1088. while c in ['0'..'9'] do
  1089. begin
  1090. pattern:=pattern+c;
  1091. readchar;
  1092. end;
  1093. end;
  1094. { E can also follow after a point is scanned }
  1095. if c in ['e','E'] then
  1096. begin
  1097. pattern:=pattern+'E';
  1098. readchar;
  1099. if c in ['-','+'] then
  1100. begin
  1101. pattern:=pattern+c;
  1102. readchar;
  1103. end;
  1104. if not(c in ['0'..'9']) then
  1105. Message(scan_f_illegal_char);
  1106. while c in ['0'..'9'] do
  1107. begin
  1108. pattern:=pattern+c;
  1109. readchar;
  1110. end;
  1111. end;
  1112. token:=_REALNUMBER;
  1113. goto exit_label;
  1114. end;
  1115. token:=_INTCONST;
  1116. goto exit_label;
  1117. end;
  1118. ';' :
  1119. begin
  1120. readchar;
  1121. token:=_SEMICOLON;
  1122. goto exit_label;
  1123. end;
  1124. '[' :
  1125. begin
  1126. readchar;
  1127. token:=_LECKKLAMMER;
  1128. goto exit_label;
  1129. end;
  1130. ']' :
  1131. begin
  1132. readchar;
  1133. token:=_RECKKLAMMER;
  1134. goto exit_label;
  1135. end;
  1136. '(' :
  1137. begin
  1138. readchar;
  1139. case c of
  1140. '*' :
  1141. begin
  1142. skipoldtpcomment;
  1143. readtoken;
  1144. exit;
  1145. end;
  1146. '.' :
  1147. begin
  1148. readchar;
  1149. token:=_LECKKLAMMER;
  1150. goto exit_label;
  1151. end;
  1152. end;
  1153. token:=_LKLAMMER;
  1154. goto exit_label;
  1155. end;
  1156. ')' :
  1157. begin
  1158. readchar;
  1159. token:=_RKLAMMER;
  1160. goto exit_label;
  1161. end;
  1162. '+' :
  1163. begin
  1164. readchar;
  1165. if (c='=') and (cs_support_c_operators in aktmoduleswitches) then
  1166. begin
  1167. readchar;
  1168. token:=_PLUSASN;
  1169. goto exit_label;
  1170. end;
  1171. token:=_PLUS;
  1172. goto exit_label;
  1173. end;
  1174. '-' :
  1175. begin
  1176. readchar;
  1177. if (c='=') and (cs_support_c_operators in aktmoduleswitches) then
  1178. begin
  1179. readchar;
  1180. token:=_MINUSASN;
  1181. goto exit_label;
  1182. end;
  1183. token:=_MINUS;
  1184. goto exit_label;
  1185. end;
  1186. ':' :
  1187. begin
  1188. readchar;
  1189. if c='=' then
  1190. begin
  1191. readchar;
  1192. token:=_ASSIGNMENT;
  1193. goto exit_label;
  1194. end;
  1195. token:=_COLON;
  1196. goto exit_label;
  1197. end;
  1198. '*' :
  1199. begin
  1200. readchar;
  1201. if (c='=') and (cs_support_c_operators in aktmoduleswitches) then
  1202. begin
  1203. readchar;
  1204. token:=_STARASN;
  1205. end
  1206. else
  1207. if c='*' then
  1208. begin
  1209. readchar;
  1210. token:=_STARSTAR;
  1211. end
  1212. else
  1213. token:=_STAR;
  1214. goto exit_label;
  1215. end;
  1216. '/' :
  1217. begin
  1218. readchar;
  1219. case c of
  1220. '=' :
  1221. begin
  1222. if (cs_support_c_operators in aktmoduleswitches) then
  1223. begin
  1224. readchar;
  1225. token:=_SLASHASN;
  1226. goto exit_label;
  1227. end;
  1228. end;
  1229. '/' :
  1230. begin
  1231. skipdelphicomment;
  1232. readtoken;
  1233. exit;
  1234. end;
  1235. end;
  1236. token:=_SLASH;
  1237. goto exit_label;
  1238. end;
  1239. '=' :
  1240. begin
  1241. readchar;
  1242. token:=_EQUAL;
  1243. goto exit_label;
  1244. end;
  1245. '.' :
  1246. begin
  1247. readchar;
  1248. case c of
  1249. '.' :
  1250. begin
  1251. readchar;
  1252. token:=_POINTPOINT;
  1253. goto exit_label;
  1254. end;
  1255. ')' :
  1256. begin
  1257. readchar;
  1258. token:=_RECKKLAMMER;
  1259. goto exit_label;
  1260. end;
  1261. end;
  1262. token:=_POINT;
  1263. goto exit_label;
  1264. end;
  1265. '@' :
  1266. begin
  1267. readchar;
  1268. if c='@' then
  1269. begin
  1270. readchar;
  1271. token:=_DOUBLEADDR;
  1272. end
  1273. else
  1274. token:=_KLAMMERAFFE;
  1275. goto exit_label;
  1276. end;
  1277. ',' :
  1278. begin
  1279. readchar;
  1280. token:=_COMMA;
  1281. goto exit_label;
  1282. end;
  1283. '''','#','^' :
  1284. begin
  1285. if c='^' then
  1286. begin
  1287. readchar;
  1288. c:=upcase(c);
  1289. if (block_type=bt_type) or
  1290. (lasttoken=_ID) or
  1291. (lasttoken=_RKLAMMER) or (lasttoken=_RECKKLAMMER) or (lasttoken=_CARET) then
  1292. begin
  1293. token:=_CARET;
  1294. goto exit_label;
  1295. end
  1296. else
  1297. begin
  1298. if c<#64 then
  1299. pattern:=chr(ord(c)+64)
  1300. else
  1301. pattern:=chr(ord(c)-64);
  1302. readchar;
  1303. end;
  1304. end
  1305. else
  1306. pattern:='';
  1307. repeat
  1308. case c of
  1309. '#' :
  1310. begin
  1311. readchar; { read # }
  1312. if c='$' then
  1313. begin
  1314. readchar; { read leading $ }
  1315. asciinr:='$';
  1316. while (upcase(c) in ['A'..'F','0'..'9']) and (length(asciinr)<6) do
  1317. begin
  1318. asciinr:=asciinr+c;
  1319. readchar;
  1320. end;
  1321. end
  1322. else
  1323. begin
  1324. asciinr:='';
  1325. while (c in ['0'..'9']) and (length(asciinr)<6) do
  1326. begin
  1327. asciinr:=asciinr+c;
  1328. readchar;
  1329. end;
  1330. end;
  1331. valint(asciinr,m,code);
  1332. if (asciinr='') or (code<>0) or
  1333. (m<0) or (m>255) then
  1334. Message(scan_e_illegal_char_const);
  1335. pattern:=pattern+chr(m);
  1336. end;
  1337. '''' :
  1338. begin
  1339. repeat
  1340. readchar;
  1341. case c of
  1342. #26 :
  1343. end_of_file;
  1344. newline :
  1345. Message(scan_f_string_exceeds_line);
  1346. '''' :
  1347. begin
  1348. readchar;
  1349. if c<>'''' then
  1350. break;
  1351. end;
  1352. end;
  1353. pattern:=pattern+c;
  1354. until false;
  1355. end;
  1356. '^' :
  1357. begin
  1358. readchar;
  1359. if c<#64 then
  1360. c:=chr(ord(c)+64)
  1361. else
  1362. c:=chr(ord(c)-64);
  1363. pattern:=pattern+c;
  1364. readchar;
  1365. end;
  1366. else
  1367. break;
  1368. end;
  1369. until false;
  1370. { strings with length 1 become const chars }
  1371. if length(pattern)=1 then
  1372. token:=_CCHAR
  1373. else
  1374. token:=_CSTRING;
  1375. goto exit_label;
  1376. end;
  1377. '>' :
  1378. begin
  1379. readchar;
  1380. case c of
  1381. '=' :
  1382. begin
  1383. readchar;
  1384. token:=_GTE;
  1385. goto exit_label;
  1386. end;
  1387. '>' :
  1388. begin
  1389. readchar;
  1390. token:=_OP_SHR;
  1391. goto exit_label;
  1392. end;
  1393. '<' :
  1394. begin { >< is for a symetric diff for sets }
  1395. readchar;
  1396. token:=_SYMDIF;
  1397. goto exit_label;
  1398. end;
  1399. end;
  1400. token:=_GT;
  1401. goto exit_label;
  1402. end;
  1403. '<' :
  1404. begin
  1405. readchar;
  1406. case c of
  1407. '>' :
  1408. begin
  1409. readchar;
  1410. token:=_UNEQUAL;
  1411. goto exit_label;
  1412. end;
  1413. '=' :
  1414. begin
  1415. readchar;
  1416. token:=_LTE;
  1417. goto exit_label;
  1418. end;
  1419. '<' :
  1420. begin
  1421. readchar;
  1422. token:=_OP_SHL;
  1423. goto exit_label;
  1424. end;
  1425. end;
  1426. token:=_LT;
  1427. goto exit_label;
  1428. end;
  1429. #26 :
  1430. begin
  1431. token:=_EOF;
  1432. checkpreprocstack;
  1433. goto exit_label;
  1434. end;
  1435. else
  1436. begin
  1437. Message(scan_f_illegal_char);
  1438. end;
  1439. end;
  1440. end;
  1441. exit_label:
  1442. lasttoken:=token;
  1443. end;
  1444. function tscannerfile.readpreproc:ttoken;
  1445. begin
  1446. skipspace;
  1447. case c of
  1448. 'A'..'Z',
  1449. 'a'..'z',
  1450. '_','0'..'9' : begin
  1451. preprocpat:=readid;
  1452. readpreproc:=_ID;
  1453. end;
  1454. '(' : begin
  1455. readchar;
  1456. readpreproc:=_LKLAMMER;
  1457. end;
  1458. ')' : begin
  1459. readchar;
  1460. readpreproc:=_RKLAMMER;
  1461. end;
  1462. '+' : begin
  1463. readchar;
  1464. readpreproc:=_PLUS;
  1465. end;
  1466. '-' : begin
  1467. readchar;
  1468. readpreproc:=_MINUS;
  1469. end;
  1470. '*' : begin
  1471. readchar;
  1472. readpreproc:=_STAR;
  1473. end;
  1474. '/' : begin
  1475. readchar;
  1476. readpreproc:=_SLASH;
  1477. end;
  1478. '=' : begin
  1479. readchar;
  1480. readpreproc:=_EQUAL;
  1481. end;
  1482. '>' : begin
  1483. readchar;
  1484. if c='=' then
  1485. begin
  1486. readchar;
  1487. readpreproc:=_GTE;
  1488. end
  1489. else
  1490. readpreproc:=_GT;
  1491. end;
  1492. '<' : begin
  1493. readchar;
  1494. case c of
  1495. '>' : begin
  1496. readchar;
  1497. readpreproc:=_UNEQUAL;
  1498. end;
  1499. '=' : begin
  1500. readchar;
  1501. readpreproc:=_LTE;
  1502. end;
  1503. else readpreproc:=_LT;
  1504. end;
  1505. end;
  1506. #26 :
  1507. end_of_file;
  1508. else
  1509. begin
  1510. readpreproc:=_EOF;
  1511. checkpreprocstack;
  1512. end;
  1513. end;
  1514. end;
  1515. function tscannerfile.asmgetchar : char;
  1516. begin
  1517. if lastasmgetchar<>#0 then
  1518. begin
  1519. c:=lastasmgetchar;
  1520. lastasmgetchar:=#0;
  1521. end
  1522. else
  1523. readchar;
  1524. case c of
  1525. '{' : begin
  1526. skipcomment;
  1527. asmgetchar:=c;
  1528. exit;
  1529. end;
  1530. '/' : begin
  1531. readchar;
  1532. if c='/' then
  1533. begin
  1534. skipdelphicomment;
  1535. asmgetchar:=c;
  1536. end
  1537. else
  1538. begin
  1539. asmgetchar:='/';
  1540. lastasmgetchar:=c;
  1541. end;
  1542. exit;
  1543. end;
  1544. '(' : begin
  1545. readchar;
  1546. if c='*' then
  1547. begin
  1548. skipoldtpcomment;
  1549. asmgetchar:=c;
  1550. end
  1551. else
  1552. begin
  1553. asmgetchar:='(';
  1554. lastasmgetchar:=c;
  1555. end;
  1556. exit;
  1557. end;
  1558. else
  1559. begin
  1560. asmgetchar:=c;
  1561. end;
  1562. end;
  1563. end;
  1564. end.
  1565. {
  1566. $Log$
  1567. Revision 1.101 1999-11-15 17:52:59 pierre
  1568. + one field added for ttoken record for operator
  1569. linking the id to the corresponding operator token that
  1570. can now now all be overloaded
  1571. * overloaded operators are resetted to nil in InitSymtable
  1572. (bug when trying to compile a uint that overloads operators twice)
  1573. Revision 1.100 1999/11/06 14:34:26 peter
  1574. * truncated log to 20 revs
  1575. Revision 1.99 1999/11/03 23:44:28 peter
  1576. * fixed comment level counting after directive
  1577. Revision 1.98 1999/11/02 15:05:08 peter
  1578. * fixed oldtp comment parsing
  1579. Revision 1.97 1999/10/30 12:32:30 peter
  1580. * fixed line counter when the first line had #10 only. This was buggy
  1581. for both the main file as for include files
  1582. Revision 1.96 1999/09/27 23:40:10 peter
  1583. * fixed macro within macro endless-loop
  1584. Revision 1.95 1999/09/03 10:02:48 peter
  1585. * $IFNDEF is 7 chars and not 6 chars
  1586. Revision 1.94 1999/09/02 18:47:47 daniel
  1587. * Could not compile with TP, some arrays moved to heap
  1588. * NOAG386BIN default for TP
  1589. * AG386* files were not compatible with TP, fixed.
  1590. Revision 1.93 1999/08/30 10:17:58 peter
  1591. * fixed crash in psub
  1592. * ansistringcompare fixed
  1593. * support for #$0b8
  1594. Revision 1.92 1999/08/06 13:11:44 michael
  1595. * Removed C style comments.
  1596. Revision 1.91 1999/08/05 16:53:11 peter
  1597. * V_Fatal=1, all other V_ are also increased
  1598. * Check for local procedure when assigning procvar
  1599. * fixed comment parsing because directives
  1600. * oldtp mode directives better supported
  1601. * added some messages to errore.msg
  1602. Revision 1.90 1999/08/04 13:03:05 jonas
  1603. * all tokens now start with an underscore
  1604. * PowerPC compiles!!
  1605. Revision 1.89 1999/07/29 11:43:22 peter
  1606. * always output preprocstack when unexpected eof is found
  1607. * fixed tp7/delphi skipuntildirective parsing
  1608. Revision 1.88 1999/07/24 11:20:59 peter
  1609. * directives are allowed in (* *)
  1610. * fixed parsing of (* between conditional code
  1611. Revision 1.87 1999/07/18 10:20:02 florian
  1612. * made it compilable with Dlephi 4 again
  1613. + fixed problem with large stack allocations on win32
  1614. Revision 1.86 1999/06/02 22:44:19 pierre
  1615. * previous wrong log corrected
  1616. Revision 1.85 1999/06/02 22:25:49 pierre
  1617. * changed $ifdef FPC @ into $ifndef TP
  1618. Revision 1.84 1999/05/31 23:28:42 pierre
  1619. * problem with main file end without newline
  1620. Revision 1.83 1999/05/20 14:57:29 peter
  1621. * fixed line counting with macro's
  1622. Revision 1.82 1999/05/04 21:45:04 florian
  1623. * changes to compile it with Delphi 4.0
  1624. Revision 1.81 1999/04/07 14:36:44 pierre
  1625. + better preproc stack checking and report
  1626. Revision 1.80 1999/04/06 11:20:59 peter
  1627. * more hashing for keyword table
  1628. }