scanner.pas 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814
  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. globtype,version,tokens,
  25. cobjects,globals,verbose,comphook,files;
  26. const
  27. {$ifdef TP}
  28. maxmacrolen=1024;
  29. {$else}
  30. maxmacrolen=16*1024;
  31. {$endif}
  32. Newline = #10;
  33. type
  34. pmacrobuffer = ^tmacrobuffer;
  35. tmacrobuffer = array[0..maxmacrolen-1] of char;
  36. ppreprocstack = ^tpreprocstack;
  37. tpreprocstack = object
  38. accept : boolean;
  39. next : ppreprocstack;
  40. name : stringid;
  41. line_nb : longint;
  42. constructor init(a:boolean;n:ppreprocstack);
  43. destructor done;
  44. end;
  45. pscannerfile = ^tscannerfile;
  46. tscannerfile = object
  47. inputfile : pinputfile; { current inputfile list }
  48. inputbuffer, { input buffer }
  49. inputpointer : pchar;
  50. inputstart : longint;
  51. line_no, { line }
  52. lastlinepos : longint;
  53. lasttokenpos : longint; { token }
  54. lasttoken : ttoken;
  55. do_special, { 1=point after nr, 2=caret after id }
  56. comment_level,
  57. yylexcount : longint;
  58. lastasmgetchar : char;
  59. preprocstack : ppreprocstack;
  60. invalid : boolean; { flag if sourcefiles have been destroyed ! }
  61. constructor init(const fn:string);
  62. destructor done;
  63. { File buffer things }
  64. function openinputfile:boolean;
  65. procedure closeinputfile;
  66. function tempopeninputfile:boolean;
  67. procedure tempcloseinputfile;
  68. procedure saveinputfile;
  69. procedure restoreinputfile;
  70. procedure nextfile;
  71. procedure addfile(hp:pinputfile);
  72. procedure reload;
  73. procedure insertmacro(p:pchar;len:longint);
  74. { Scanner things }
  75. procedure gettokenpos;
  76. procedure inc_comment_level;
  77. procedure dec_comment_level;
  78. procedure checkpreprocstack;
  79. procedure poppreprocstack;
  80. procedure addpreprocstack(a:boolean;const s:string;w:tmsgconst);
  81. procedure elsepreprocstack;
  82. procedure linebreak;
  83. procedure readchar;
  84. procedure readstring;
  85. procedure readnumber;
  86. function readid:string;
  87. function readval:longint;
  88. function readcomment:string;
  89. function readstate:char;
  90. procedure skipspace;
  91. procedure skipuntildirective;
  92. procedure skipcomment;
  93. procedure skipdelphicomment;
  94. procedure skipoldtpcomment;
  95. procedure skipccomment;
  96. procedure readtoken;
  97. function readpreproc:ttoken;
  98. function asmgetchar:char;
  99. end;
  100. var
  101. c : char;
  102. orgpattern,
  103. pattern : string;
  104. current_scanner : pscannerfile;
  105. implementation
  106. uses
  107. dos,systems,symtable,switches;
  108. {*****************************************************************************
  109. Helper routines
  110. *****************************************************************************}
  111. type
  112. tokenidxrec=record
  113. first,last : ttoken;
  114. end;
  115. var
  116. tokenidx:array[2..tokenidlen] of tokenidxrec;
  117. const
  118. { use any special name that is an invalid file name to avoid problems }
  119. macro_special_name = '____Macro____';
  120. procedure create_tokenidx;
  121. { create an index with the first and last token for every possible token
  122. length, so a search only will be done in that small part }
  123. var
  124. t : ttoken;
  125. begin
  126. for t:=low(ttoken) to high(ttoken) do
  127. begin
  128. if not tokeninfo[t].special then
  129. begin
  130. if ord(tokenidx[length(tokeninfo[t].str)].first)=0 then
  131. tokenidx[length(tokeninfo[t].str)].first:=t;
  132. tokenidx[length(tokeninfo[t].str)].last:=t;
  133. end;
  134. end;
  135. end;
  136. function is_keyword(const s:string):boolean;
  137. var
  138. low,high,mid : longint;
  139. begin
  140. if not (length(s) in [2..tokenidlen]) then
  141. begin
  142. is_keyword:=false;
  143. exit;
  144. end;
  145. low:=ord(tokenidx[length(s)].first);
  146. high:=ord(tokenidx[length(s)].last);
  147. while low<high do
  148. begin
  149. mid:=(high+low+1) shr 1;
  150. if pattern<tokeninfo[ttoken(mid)].str then
  151. high:=mid-1
  152. else
  153. low:=mid;
  154. end;
  155. is_keyword:=(pattern=tokeninfo[ttoken(high)].str) and
  156. (tokeninfo[ttoken(high)].keyword in aktmodeswitches);
  157. end;
  158. {*****************************************************************************
  159. TPreProcStack
  160. *****************************************************************************}
  161. constructor tpreprocstack.init(a:boolean;n:ppreprocstack);
  162. begin
  163. accept:=a;
  164. next:=n;
  165. end;
  166. destructor tpreprocstack.done;
  167. begin
  168. end;
  169. {****************************************************************************
  170. TSCANNERFILE
  171. ****************************************************************************}
  172. constructor tscannerfile.init(const fn:string);
  173. begin
  174. inputfile:=new(pinputfile,init(fn));
  175. current_module^.sourcefiles^.register_file(inputfile);
  176. { reset localinput }
  177. inputbuffer:=nil;
  178. inputpointer:=nil;
  179. inputstart:=0;
  180. { reset scanner }
  181. preprocstack:=nil;
  182. comment_level:=0;
  183. do_special:=0;
  184. yylexcount:=0;
  185. block_type:=bt_general;
  186. line_no:=0;
  187. lastlinepos:=0;
  188. lasttokenpos:=0;
  189. lasttoken:=_END;
  190. lastasmgetchar:=#0;
  191. invalid:=false;
  192. { load block }
  193. if not openinputfile then
  194. Message1(scan_f_cannot_open_input,fn);
  195. reload;
  196. end;
  197. destructor tscannerfile.done;
  198. begin
  199. if not invalid then
  200. begin
  201. if status.errorcount=0 then
  202. checkpreprocstack;
  203. { close file, but only if we are the first compile }
  204. { probably not necessary anymore with invalid flag PM }
  205. if not current_module^.in_second_compile then
  206. begin
  207. if not inputfile^.closed then
  208. closeinputfile;
  209. end;
  210. end;
  211. end;
  212. function tscannerfile.openinputfile:boolean;
  213. begin
  214. openinputfile:=inputfile^.open;
  215. { load buffer }
  216. inputbuffer:=inputfile^.buf;
  217. inputpointer:=inputfile^.buf;
  218. inputstart:=inputfile^.bufstart;
  219. { line }
  220. line_no:=0;
  221. lastlinepos:=0;
  222. lasttokenpos:=0;
  223. end;
  224. procedure tscannerfile.closeinputfile;
  225. begin
  226. inputfile^.close;
  227. { reset buffer }
  228. inputbuffer:=nil;
  229. inputpointer:=nil;
  230. inputstart:=0;
  231. { reset line }
  232. line_no:=0;
  233. lastlinepos:=0;
  234. lasttokenpos:=0;
  235. end;
  236. function tscannerfile.tempopeninputfile:boolean;
  237. begin
  238. tempopeninputfile:=inputfile^.tempopen;
  239. { reload buffer }
  240. inputbuffer:=inputfile^.buf;
  241. inputpointer:=inputfile^.buf;
  242. inputstart:=inputfile^.bufstart;
  243. end;
  244. procedure tscannerfile.tempcloseinputfile;
  245. begin
  246. inputfile^.setpos(inputstart+(inputpointer-inputbuffer));
  247. inputfile^.tempclose;
  248. { reset buffer }
  249. inputbuffer:=nil;
  250. inputpointer:=nil;
  251. inputstart:=0;
  252. end;
  253. procedure tscannerfile.saveinputfile;
  254. begin
  255. inputfile^.saveinputpointer:=inputpointer;
  256. inputfile^.savelastlinepos:=lastlinepos;
  257. inputfile^.saveline_no:=line_no;
  258. end;
  259. procedure tscannerfile.restoreinputfile;
  260. begin
  261. inputpointer:=inputfile^.saveinputpointer;
  262. lastlinepos:=inputfile^.savelastlinepos;
  263. line_no:=inputfile^.saveline_no;
  264. if not inputfile^.is_macro then
  265. parser_current_file:=inputfile^.name^;
  266. end;
  267. procedure tscannerfile.nextfile;
  268. var
  269. to_dispose : pinputfile;
  270. begin
  271. if assigned(inputfile^.next) then
  272. begin
  273. if inputfile^.is_macro then
  274. to_dispose:=inputfile
  275. else
  276. to_dispose:=nil;
  277. { we can allways close the file, no ? }
  278. inputfile^.close;
  279. inputfile:=inputfile^.next;
  280. if assigned(to_dispose) then
  281. dispose(to_dispose,done);
  282. restoreinputfile;
  283. end;
  284. end;
  285. procedure tscannerfile.addfile(hp:pinputfile);
  286. begin
  287. saveinputfile;
  288. { add to list }
  289. hp^.next:=inputfile;
  290. inputfile:=hp;
  291. { load new inputfile }
  292. restoreinputfile;
  293. end;
  294. procedure tscannerfile.reload;
  295. begin
  296. with inputfile^ do
  297. begin
  298. repeat
  299. { still more to read?, then change the #0 to a space so its seen
  300. as a seperator }
  301. if (c=#0) and (bufsize>0) and (inputpointer-inputbuffer<bufsize) then
  302. begin
  303. c:=' ';
  304. inc(longint(inputpointer));
  305. exit;
  306. end;
  307. { can we read more from this file ? }
  308. if (c<>#26) and (not endoffile) then
  309. begin
  310. readbuf;
  311. inputpointer:=buf;
  312. inputbuffer:=buf;
  313. inputstart:=bufstart;
  314. { first line? }
  315. if line_no=0 then
  316. begin
  317. line_no:=1;
  318. if cs_asm_source in aktglobalswitches then
  319. inputfile^.setline(line_no,bufstart);
  320. end;
  321. end
  322. else
  323. begin
  324. { load eof position in tokenpos/aktfilepos }
  325. gettokenpos;
  326. { close file }
  327. closeinputfile;
  328. { no next module, than EOF }
  329. if not assigned(inputfile^.next) then
  330. begin
  331. c:=#26;
  332. exit;
  333. end;
  334. { load next file and reopen it }
  335. nextfile;
  336. tempopeninputfile;
  337. { status }
  338. Message1(scan_t_back_in,inputfile^.name^);
  339. end;
  340. { load next char }
  341. c:=inputpointer^;
  342. inc(longint(inputpointer));
  343. until c<>#0; { if also end, then reload again }
  344. end;
  345. end;
  346. procedure tscannerfile.insertmacro(p:pchar;len:longint);
  347. var
  348. hp : pinputfile;
  349. begin
  350. { save old postion }
  351. dec(longint(inputpointer));
  352. tempcloseinputfile;
  353. { create macro 'file' }
  354. { use special name to dispose after !! }
  355. hp:=new(pinputfile,init(macro_special_name));
  356. addfile(hp);
  357. with inputfile^ do
  358. begin
  359. setmacro(p,len);
  360. { local buffer }
  361. inputbuffer:=buf;
  362. inputpointer:=buf;
  363. inputstart:=bufstart;
  364. end;
  365. { reset line }
  366. line_no:=0;
  367. lastlinepos:=0;
  368. lasttokenpos:=0;
  369. { load new c }
  370. c:=inputpointer^;
  371. inc(longint(inputpointer));
  372. end;
  373. procedure tscannerfile.gettokenpos;
  374. { load the values of tokenpos and lasttokenpos }
  375. begin
  376. lasttokenpos:=inputstart+(inputpointer-inputbuffer);
  377. tokenpos.line:=line_no;
  378. tokenpos.column:=lasttokenpos-lastlinepos;
  379. tokenpos.fileindex:=inputfile^.ref_index;
  380. aktfilepos:=tokenpos;
  381. end;
  382. procedure tscannerfile.inc_comment_level;
  383. var
  384. oldaktfilepos : tfileposinfo;
  385. begin
  386. inc(comment_level);
  387. if (comment_level>1) then
  388. begin
  389. oldaktfilepos:=aktfilepos;
  390. gettokenpos; { update for warning }
  391. Message1(scan_w_comment_level,tostr(comment_level));
  392. aktfilepos:=oldaktfilepos;
  393. end;
  394. end;
  395. procedure tscannerfile.dec_comment_level;
  396. begin
  397. if (m_nested_comment in aktmodeswitches) then
  398. dec(comment_level)
  399. else
  400. comment_level:=0;
  401. end;
  402. procedure tscannerfile.linebreak;
  403. var
  404. cur : char;
  405. oldtokenpos,
  406. oldaktfilepos : tfileposinfo;
  407. begin
  408. with inputfile^ do
  409. begin
  410. if (byte(inputpointer^)=0) and not(endoffile) then
  411. begin
  412. cur:=c;
  413. reload;
  414. if byte(cur)+byte(c)<>23 then
  415. dec(longint(inputpointer));
  416. end
  417. else
  418. begin
  419. { Fix linebreak to be only newline (=#10) for all types of linebreaks }
  420. if (byte(inputpointer^)+byte(c)=23) then
  421. inc(longint(inputpointer));
  422. end;
  423. c:=newline;
  424. { increase line counters }
  425. lastlinepos:=bufstart+(inputpointer-inputbuffer);
  426. inc(line_no);
  427. { update linebuffer }
  428. if cs_asm_source in aktglobalswitches then
  429. inputfile^.setline(line_no,lastlinepos);
  430. { update for status and call the show status routine,
  431. but don't touch aktfilepos ! }
  432. oldaktfilepos:=aktfilepos;
  433. oldtokenpos:=tokenpos;
  434. gettokenpos; { update for v_status }
  435. inc(status.compiledlines);
  436. ShowStatus;
  437. aktfilepos:=oldaktfilepos;
  438. tokenpos:=oldtokenpos;
  439. end;
  440. end;
  441. procedure tscannerfile.checkpreprocstack;
  442. begin
  443. { check for missing ifdefs }
  444. while assigned(preprocstack) do
  445. begin
  446. Message3(scan_e_endif_expected,'$IF(N)(DEF)',preprocstack^.name,tostr(preprocstack^.line_nb));
  447. poppreprocstack;
  448. end;
  449. end;
  450. procedure tscannerfile.poppreprocstack;
  451. var
  452. hp : ppreprocstack;
  453. begin
  454. if assigned(preprocstack) then
  455. begin
  456. Message1(scan_c_endif_found,preprocstack^.name);
  457. hp:=preprocstack^.next;
  458. dispose(preprocstack,done);
  459. preprocstack:=hp;
  460. end
  461. else
  462. Message(scan_e_endif_without_if);
  463. end;
  464. procedure tscannerfile.addpreprocstack(a:boolean;const s:string;w:tmsgconst);
  465. begin
  466. preprocstack:=new(ppreprocstack,init(((preprocstack=nil) or preprocstack^.accept) and a,preprocstack));
  467. preprocstack^.name:=s;
  468. preprocstack^.line_nb:=line_no;
  469. if preprocstack^.accept then
  470. Message2(w,preprocstack^.name,'accepted')
  471. else
  472. Message2(w,preprocstack^.name,'rejected');
  473. end;
  474. procedure tscannerfile.elsepreprocstack;
  475. begin
  476. if assigned(preprocstack) then
  477. begin
  478. if not(assigned(preprocstack^.next)) or (preprocstack^.next^.accept) then
  479. preprocstack^.accept:=not preprocstack^.accept;
  480. if preprocstack^.accept then
  481. Message2(scan_c_else_found,preprocstack^.name,'accepted')
  482. else
  483. Message2(scan_c_else_found,preprocstack^.name,'rejected');
  484. end
  485. else
  486. Message(scan_e_endif_without_if);
  487. end;
  488. procedure tscannerfile.readchar;
  489. begin
  490. c:=inputpointer^;
  491. if c=#0 then
  492. reload
  493. else
  494. inc(longint(inputpointer));
  495. case c of
  496. #26 : reload;
  497. #10,
  498. #13 : linebreak;
  499. end;
  500. end;
  501. procedure tscannerfile.readstring;
  502. var
  503. i : longint;
  504. begin
  505. i:=0;
  506. repeat
  507. case c of
  508. '_',
  509. '0'..'9',
  510. 'A'..'Z' : begin
  511. if i<255 then
  512. begin
  513. inc(i);
  514. orgpattern[i]:=c;
  515. pattern[i]:=c;
  516. end;
  517. c:=inputpointer^;
  518. inc(longint(inputpointer));
  519. end;
  520. 'a'..'z' : begin
  521. if i<255 then
  522. begin
  523. inc(i);
  524. orgpattern[i]:=c;
  525. pattern[i]:=chr(ord(c)-32)
  526. end;
  527. c:=inputpointer^;
  528. inc(longint(inputpointer));
  529. end;
  530. #0,#26 : reload;
  531. #13,#10 : begin
  532. linebreak;
  533. break;
  534. end;
  535. else
  536. break;
  537. end;
  538. until false;
  539. {$ifndef TP}
  540. {$ifopt H+}
  541. setlength(orgpattern,i);
  542. setlength(pattern,i);
  543. {$else}
  544. orgpattern[0]:=chr(i);
  545. pattern[0]:=chr(i);
  546. {$endif}
  547. {$else}
  548. orgpattern[0]:=chr(i);
  549. pattern[0]:=chr(i);
  550. {$endif}
  551. end;
  552. procedure tscannerfile.readnumber;
  553. var
  554. base,
  555. i : longint;
  556. begin
  557. case c of
  558. '%' : begin
  559. readchar;
  560. base:=2;
  561. pattern[1]:='%';
  562. i:=1;
  563. end;
  564. '$' : begin
  565. readchar;
  566. base:=16;
  567. pattern[1]:='$';
  568. i:=1;
  569. end;
  570. else
  571. begin
  572. base:=10;
  573. i:=0;
  574. end;
  575. end;
  576. while ((base>=10) and (c in ['0'..'9'])) or
  577. ((base=16) and (c in ['A'..'F','a'..'f'])) or
  578. ((base=2) and (c in ['0'..'1'])) do
  579. begin
  580. if i<255 then
  581. begin
  582. inc(i);
  583. pattern[i]:=c;
  584. end;
  585. { get next char }
  586. c:=inputpointer^;
  587. if c=#0 then
  588. reload
  589. else
  590. inc(longint(inputpointer));
  591. end;
  592. { was the next char a linebreak ? }
  593. case c of
  594. #26 : reload;
  595. #10,
  596. #13 : linebreak;
  597. end;
  598. {$ifndef TP}
  599. {$ifopt H+}
  600. setlength(pattern,i);
  601. {$else}
  602. pattern[0]:=chr(i);
  603. {$endif}
  604. {$else}
  605. pattern[0]:=chr(i);
  606. {$endif}
  607. end;
  608. function tscannerfile.readid:string;
  609. begin
  610. readstring;
  611. readid:=pattern;
  612. end;
  613. function tscannerfile.readval:longint;
  614. var
  615. l : longint;
  616. w : integer;
  617. begin
  618. readnumber;
  619. valint(pattern,l,w);
  620. readval:=l;
  621. end;
  622. function tscannerfile.readcomment:string;
  623. var
  624. i : longint;
  625. begin
  626. i:=0;
  627. repeat
  628. case c of
  629. '}' : begin
  630. readchar;
  631. dec_comment_level;
  632. break;
  633. end;
  634. #26 : Message(scan_f_end_of_file);
  635. else
  636. begin
  637. if (i<255) then
  638. begin
  639. inc(i);
  640. readcomment[i]:=c;
  641. end;
  642. end;
  643. end;
  644. c:=inputpointer^;
  645. if c=#0 then
  646. reload
  647. else
  648. inc(longint(inputpointer));
  649. if c in [#10,#13] then
  650. linebreak;
  651. until false;
  652. {$ifndef TP}
  653. {$ifopt H+}
  654. setlength(readcomment,i);
  655. {$else}
  656. readcomment[0]:=chr(i);
  657. {$endif}
  658. {$else}
  659. readcomment[0]:=chr(i);
  660. {$endif}
  661. end;
  662. function tscannerfile.readstate:char;
  663. var
  664. state : char;
  665. begin
  666. state:=' ';
  667. if c=' ' then
  668. begin
  669. current_scanner^.skipspace;
  670. current_scanner^.readid;
  671. if pattern='ON' then
  672. state:='+'
  673. else
  674. if pattern='OFF' then
  675. state:='-';
  676. end
  677. else
  678. state:=c;
  679. if not (state in ['+','-']) then
  680. Message(scan_e_wrong_switch_toggle);
  681. readstate:=state;
  682. end;
  683. procedure tscannerfile.skipspace;
  684. begin
  685. while c in [' ',#9..#13] do
  686. begin
  687. c:=inputpointer^;
  688. if c=#0 then
  689. reload
  690. else
  691. inc(longint(inputpointer));
  692. case c of
  693. #26 : reload;
  694. #10,
  695. #13 : linebreak;
  696. end;
  697. end;
  698. end;
  699. procedure tscannerfile.skipuntildirective;
  700. var
  701. found : longint;
  702. begin
  703. found:=0;
  704. repeat
  705. case c of
  706. #26 : Message(scan_f_end_of_file);
  707. '{' : begin
  708. if comment_level=0 then
  709. found:=1;
  710. inc_comment_level;
  711. end;
  712. '}' : begin
  713. dec_comment_level;
  714. found:=0;
  715. end;
  716. '$' : begin
  717. if found=1 then
  718. found:=2;
  719. end;
  720. else
  721. found:=0;
  722. end;
  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. until (found=2);
  734. end;
  735. {$i scandir.inc}
  736. procedure tscannerfile.skipcomment;
  737. begin
  738. readchar;
  739. inc_comment_level;
  740. { handle compiler switches }
  741. if (c='$') then
  742. handledirectives;
  743. { handle_switches can dec comment_level, }
  744. while (comment_level>0) do
  745. begin
  746. case c of
  747. '{' : inc_comment_level;
  748. '}' : dec_comment_level;
  749. #26 : Message(scan_f_end_of_file);
  750. end;
  751. c:=inputpointer^;
  752. if c=#0 then
  753. reload
  754. else
  755. inc(longint(inputpointer));
  756. case c of
  757. #26 : reload;
  758. #10,
  759. #13 : linebreak;
  760. end;
  761. end;
  762. end;
  763. procedure tscannerfile.skipdelphicomment;
  764. begin
  765. inc_comment_level;
  766. readchar;
  767. { this is currently not supported }
  768. if c='$' then
  769. Message(scan_e_wrong_styled_switch);
  770. { skip comment }
  771. while c<>newline do
  772. begin
  773. if c=#26 then
  774. Message(scan_f_end_of_file);
  775. readchar;
  776. end;
  777. dec_comment_level;
  778. end;
  779. procedure tscannerfile.skipoldtpcomment;
  780. var
  781. found : longint;
  782. begin
  783. inc_comment_level;
  784. readchar;
  785. { this is currently not supported }
  786. if c='$' then
  787. Message(scan_e_wrong_styled_switch);
  788. { skip comment }
  789. while (comment_level>0) do
  790. begin
  791. found:=0;
  792. repeat
  793. case c of
  794. #26 : Message(scan_f_end_of_file);
  795. '*' : begin
  796. if found=3 then
  797. inc_comment_level
  798. else
  799. found:=1;
  800. end;
  801. ')' : begin
  802. if found=1 then
  803. begin
  804. dec_comment_level;
  805. if comment_level=0 then
  806. found:=2;
  807. end;
  808. end;
  809. '(' : found:=3;
  810. else
  811. found:=0;
  812. end;
  813. c:=inputpointer^;
  814. if c=#0 then
  815. reload
  816. else
  817. inc(longint(inputpointer));
  818. case c of
  819. #26 : reload;
  820. #10,
  821. #13 : linebreak;
  822. end;
  823. until (found=2);
  824. end;
  825. end;
  826. procedure tscannerfile.skipccomment;
  827. var
  828. found : longint;
  829. begin
  830. inc_comment_level;
  831. readchar;
  832. { this is currently not supported }
  833. if c='$' then
  834. Message(scan_e_wrong_styled_switch);
  835. { skip comment }
  836. while (comment_level>0) do
  837. begin
  838. found:=0;
  839. repeat
  840. case c of
  841. #26 : Message(scan_f_end_of_file);
  842. '*' : begin
  843. if found=3 then
  844. inc_comment_level
  845. else
  846. found:=1;
  847. end;
  848. '/' : begin
  849. if found=1 then
  850. begin
  851. dec_comment_level;
  852. if comment_level=0 then
  853. found:=2;
  854. end
  855. else found:=3;
  856. end;
  857. else
  858. found:=0;
  859. end;
  860. c:=inputpointer^;
  861. if c=#0 then
  862. reload
  863. else
  864. inc(longint(inputpointer));
  865. case c of
  866. #26 : reload;
  867. #10,
  868. #13 : linebreak;
  869. end;
  870. until (found=2);
  871. end;
  872. end;
  873. procedure tscannerfile.readtoken;
  874. var
  875. code : integer;
  876. low,high,mid,
  877. l : {$ifdef TP} word; {$else} longint; {$endif}
  878. m : longint;
  879. mac : pmacrosym;
  880. asciinr : string[3];
  881. label
  882. exit_label;
  883. begin
  884. { was the last character a point ? }
  885. { this code is needed because the scanner if there is a 1. found if }
  886. { this is a floating point number or range like 1..3 }
  887. if do_special>0 then
  888. begin
  889. gettokenpos;
  890. l:=do_special;
  891. do_special:=0;
  892. case l of
  893. 1 : begin { first char was a point }
  894. case c of
  895. '.' : begin
  896. readchar;
  897. token:=POINTPOINT;
  898. goto exit_label;
  899. end;
  900. ')' : begin
  901. readchar;
  902. token:=RECKKLAMMER;
  903. goto exit_label;
  904. end;
  905. end;
  906. token:=POINT;
  907. goto exit_label;
  908. end;
  909. 2 : begin { first char was a Caret }
  910. token:=CARET;
  911. readchar;
  912. goto exit_label;
  913. end;
  914. end;
  915. end;
  916. { Skip all spaces and comments }
  917. repeat
  918. case c of
  919. '{' : skipcomment;
  920. ' ',#9..#13 : skipspace;
  921. else
  922. break;
  923. end;
  924. until false;
  925. { Save current token position, for EOF its already loaded }
  926. if c<>#26 then
  927. gettokenpos;
  928. { Check first for a identifier/keyword, this is 20+% faster (PFV) }
  929. if c in ['A'..'Z','a'..'z','_'] then
  930. begin
  931. readstring;
  932. token:=ID;
  933. idtoken:=ID;
  934. { keyword or any other known token ? }
  935. if length(pattern) in [2..tokenidlen] then
  936. begin
  937. low:=ord(tokenidx[length(pattern)].first);
  938. high:=ord(tokenidx[length(pattern)].last);
  939. while low<high do
  940. begin
  941. mid:=(high+low+1) shr 1;
  942. if pattern<tokeninfo[ttoken(mid)].str then
  943. high:=mid-1
  944. else
  945. low:=mid;
  946. end;
  947. if pattern=tokeninfo[ttoken(high)].str then
  948. begin
  949. if tokeninfo[ttoken(high)].keyword in aktmodeswitches then
  950. token:=ttoken(high);
  951. idtoken:=ttoken(high);
  952. end;
  953. end;
  954. { Only process identifiers and not keywords }
  955. if token=ID then
  956. begin
  957. { this takes some time ... }
  958. if (cs_support_macro in aktmoduleswitches) then
  959. begin
  960. mac:=pmacrosym(macros^.search(pattern));
  961. if assigned(mac) and (assigned(mac^.buftext)) then
  962. begin
  963. insertmacro(mac^.buftext,mac^.buflen);
  964. { handle empty macros }
  965. if c=#0 then
  966. reload;
  967. { play it again ... }
  968. inc(yylexcount);
  969. if yylexcount>16 then
  970. Message(scan_w_macro_deep_ten);
  971. readtoken;
  972. { that's all folks }
  973. dec(yylexcount);
  974. exit;
  975. end;
  976. end;
  977. end;
  978. { a following caret, then set special handling }
  979. if (c='^') then
  980. do_special:=2;
  981. { return token }
  982. goto exit_label;
  983. end
  984. else
  985. begin
  986. idtoken:=NOID;
  987. case c of
  988. '$' : begin
  989. readnumber;
  990. token:=INTCONST;
  991. goto exit_label;
  992. end;
  993. '%' : begin
  994. readnumber;
  995. token:=INTCONST;
  996. goto exit_label;
  997. end;
  998. '0'..'9' : begin
  999. readnumber;
  1000. if (c in ['.','e','E']) then
  1001. begin
  1002. { first check for a . }
  1003. if c='.' then
  1004. begin
  1005. readchar;
  1006. if not(c in ['0'..'9']) then
  1007. begin
  1008. do_special:=1;
  1009. token:=INTCONST;
  1010. goto exit_label;
  1011. end;
  1012. pattern:=pattern+'.';
  1013. while c in ['0'..'9'] do
  1014. begin
  1015. pattern:=pattern+c;
  1016. readchar;
  1017. end;
  1018. end;
  1019. { E can also follow after a point is scanned }
  1020. if c in ['e','E'] then
  1021. begin
  1022. pattern:=pattern+'E';
  1023. readchar;
  1024. if c in ['-','+'] then
  1025. begin
  1026. pattern:=pattern+c;
  1027. readchar;
  1028. end;
  1029. if not(c in ['0'..'9']) then
  1030. Message(scan_f_illegal_char);
  1031. while c in ['0'..'9'] do
  1032. begin
  1033. pattern:=pattern+c;
  1034. readchar;
  1035. end;
  1036. end;
  1037. token:=REALNUMBER;
  1038. goto exit_label;
  1039. end;
  1040. token:=INTCONST;
  1041. goto exit_label;
  1042. end;
  1043. ';' : begin
  1044. readchar;
  1045. token:=SEMICOLON;
  1046. goto exit_label;
  1047. end;
  1048. '[' : begin
  1049. readchar;
  1050. token:=LECKKLAMMER;
  1051. goto exit_label;
  1052. end;
  1053. ']' : begin
  1054. readchar;
  1055. token:=RECKKLAMMER;
  1056. goto exit_label;
  1057. end;
  1058. '(' : begin
  1059. readchar;
  1060. case c of
  1061. '*' : begin
  1062. skipoldtpcomment;
  1063. readtoken;
  1064. exit;
  1065. end;
  1066. '.' : begin
  1067. readchar;
  1068. token:=LECKKLAMMER;
  1069. goto exit_label;
  1070. end;
  1071. end;
  1072. token:=LKLAMMER;
  1073. goto exit_label;
  1074. end;
  1075. ')' : begin
  1076. readchar;
  1077. token:=RKLAMMER;
  1078. goto exit_label;
  1079. end;
  1080. '+' : begin
  1081. readchar;
  1082. if (c='=') and (cs_support_c_operators in aktmoduleswitches) then
  1083. begin
  1084. readchar;
  1085. token:=_PLUSASN;
  1086. goto exit_label;
  1087. end;
  1088. token:=PLUS;
  1089. goto exit_label;
  1090. end;
  1091. '-' : begin
  1092. readchar;
  1093. if (c='=') and (cs_support_c_operators in aktmoduleswitches) then
  1094. begin
  1095. readchar;
  1096. token:=_MINUSASN;
  1097. goto exit_label;
  1098. end;
  1099. token:=MINUS;
  1100. goto exit_label;
  1101. end;
  1102. ':' : begin
  1103. readchar;
  1104. if c='=' then
  1105. begin
  1106. readchar;
  1107. token:=ASSIGNMENT;
  1108. goto exit_label;
  1109. end;
  1110. token:=COLON;
  1111. goto exit_label;
  1112. end;
  1113. '*' : begin
  1114. readchar;
  1115. if (c='=') and (cs_support_c_operators in aktmoduleswitches) then
  1116. begin
  1117. readchar;
  1118. token:=_STARASN;
  1119. end
  1120. else
  1121. if c='*' then
  1122. begin
  1123. readchar;
  1124. token:=STARSTAR;
  1125. end
  1126. else
  1127. token:=STAR;
  1128. goto exit_label;
  1129. end;
  1130. '/' : begin
  1131. readchar;
  1132. case c of
  1133. '=' : begin
  1134. if (cs_support_c_operators in aktmoduleswitches) then
  1135. begin
  1136. readchar;
  1137. token:=_SLASHASN;
  1138. goto exit_label;
  1139. end;
  1140. end;
  1141. '/' : begin
  1142. skipdelphicomment;
  1143. readtoken;
  1144. exit;
  1145. end;
  1146. '*' : begin
  1147. skipccomment;
  1148. readtoken;
  1149. exit;
  1150. end;
  1151. end;
  1152. token:=SLASH;
  1153. goto exit_label;
  1154. end;
  1155. '=' : begin
  1156. readchar;
  1157. token:=EQUAL;
  1158. goto exit_label;
  1159. end;
  1160. '.' : begin
  1161. readchar;
  1162. case c of
  1163. '.' : begin
  1164. readchar;
  1165. token:=POINTPOINT;
  1166. goto exit_label;
  1167. end;
  1168. ')' : begin
  1169. readchar;
  1170. token:=RECKKLAMMER;
  1171. goto exit_label;
  1172. end;
  1173. end;
  1174. token:=POINT;
  1175. goto exit_label;
  1176. end;
  1177. '@' : begin
  1178. readchar;
  1179. if c='@' then
  1180. begin
  1181. readchar;
  1182. token:=DOUBLEADDR;
  1183. end
  1184. else
  1185. token:=KLAMMERAFFE;
  1186. goto exit_label;
  1187. end;
  1188. ',' : begin
  1189. readchar;
  1190. token:=COMMA;
  1191. goto exit_label;
  1192. end;
  1193. '''','#','^' : begin
  1194. if c='^' then
  1195. begin
  1196. readchar;
  1197. c:=upcase(c);
  1198. if not(block_type=bt_type) and (c in ['A'..'Z']) then
  1199. begin
  1200. pattern:=chr(ord(c)-64);
  1201. readchar;
  1202. end
  1203. else
  1204. begin
  1205. token:=CARET;
  1206. goto exit_label;
  1207. end;
  1208. end
  1209. else
  1210. pattern:='';
  1211. repeat
  1212. case c of
  1213. '#' : begin
  1214. readchar; { read # }
  1215. if c='$' then
  1216. begin
  1217. readchar; { read leading $ }
  1218. asciinr:='$';
  1219. while (upcase(c) in ['A'..'F','0'..'9']) and (length(asciinr)<3) do
  1220. begin
  1221. asciinr:=asciinr+c;
  1222. readchar;
  1223. end;
  1224. end
  1225. else
  1226. begin
  1227. asciinr:='';
  1228. while (c in ['0'..'9']) and (length(asciinr)<3) do
  1229. begin
  1230. asciinr:=asciinr+c;
  1231. readchar;
  1232. end;
  1233. end;
  1234. valint(asciinr,m,code);
  1235. if (asciinr='') or (code<>0) or
  1236. (m<0) or (m>255) then
  1237. Message(scan_e_illegal_char_const);
  1238. pattern:=pattern+chr(m);
  1239. end;
  1240. '''' : begin
  1241. repeat
  1242. readchar;
  1243. case c of
  1244. #26 : Message(scan_f_end_of_file);
  1245. newline : Message(scan_f_string_exceeds_line);
  1246. '''' : begin
  1247. readchar;
  1248. if c<>'''' then
  1249. break;
  1250. end;
  1251. end;
  1252. pattern:=pattern+c;
  1253. until false;
  1254. end;
  1255. '^' : begin
  1256. readchar;
  1257. if c<#64 then
  1258. c:=chr(ord(c)+64)
  1259. else
  1260. c:=chr(ord(c)-64);
  1261. pattern:=pattern+c;
  1262. readchar;
  1263. end;
  1264. else
  1265. break;
  1266. end;
  1267. until false;
  1268. { strings with length 1 become const chars }
  1269. if length(pattern)=1 then
  1270. token:=CCHAR
  1271. else
  1272. token:=CSTRING;
  1273. goto exit_label;
  1274. end;
  1275. '>' : begin
  1276. readchar;
  1277. case c of
  1278. '=' : begin
  1279. readchar;
  1280. token:=GTE;
  1281. goto exit_label;
  1282. end;
  1283. '>' : begin
  1284. readchar;
  1285. token:=_SHR;
  1286. goto exit_label;
  1287. end;
  1288. '<' : begin { >< is for a symetric diff for sets }
  1289. readchar;
  1290. token:=SYMDIF;
  1291. goto exit_label;
  1292. end;
  1293. end;
  1294. token:=GT;
  1295. goto exit_label;
  1296. end;
  1297. '<' : begin
  1298. readchar;
  1299. case c of
  1300. '>' : begin
  1301. readchar;
  1302. token:=UNEQUAL;
  1303. goto exit_label;
  1304. end;
  1305. '=' : begin
  1306. readchar;
  1307. token:=LTE;
  1308. goto exit_label;
  1309. end;
  1310. '<' : begin
  1311. readchar;
  1312. token:=_SHL;
  1313. goto exit_label;
  1314. end;
  1315. end;
  1316. token:=LT;
  1317. goto exit_label;
  1318. end;
  1319. #26 : begin
  1320. token:=_EOF;
  1321. goto exit_label;
  1322. end;
  1323. else
  1324. begin
  1325. Message(scan_f_illegal_char);
  1326. end;
  1327. end;
  1328. end;
  1329. exit_label:
  1330. end;
  1331. function tscannerfile.readpreproc:ttoken;
  1332. begin
  1333. skipspace;
  1334. case c of
  1335. 'A'..'Z',
  1336. 'a'..'z',
  1337. '_','0'..'9' : begin
  1338. preprocpat:=readid;
  1339. readpreproc:=ID;
  1340. end;
  1341. '(' : begin
  1342. readchar;
  1343. readpreproc:=LKLAMMER;
  1344. end;
  1345. ')' : begin
  1346. readchar;
  1347. readpreproc:=RKLAMMER;
  1348. end;
  1349. '+' : begin
  1350. readchar;
  1351. readpreproc:=PLUS;
  1352. end;
  1353. '-' : begin
  1354. readchar;
  1355. readpreproc:=MINUS;
  1356. end;
  1357. '*' : begin
  1358. readchar;
  1359. readpreproc:=STAR;
  1360. end;
  1361. '/' : begin
  1362. readchar;
  1363. readpreproc:=SLASH;
  1364. end;
  1365. '=' : begin
  1366. readchar;
  1367. readpreproc:=EQUAL;
  1368. end;
  1369. '>' : begin
  1370. readchar;
  1371. if c='=' then
  1372. begin
  1373. readchar;
  1374. readpreproc:=GTE;
  1375. end
  1376. else
  1377. readpreproc:=GT;
  1378. end;
  1379. '<' : begin
  1380. readchar;
  1381. case c of
  1382. '>' : begin
  1383. readchar;
  1384. readpreproc:=UNEQUAL;
  1385. end;
  1386. '=' : begin
  1387. readchar;
  1388. readpreproc:=LTE;
  1389. end;
  1390. else readpreproc:=LT;
  1391. end;
  1392. end;
  1393. #26 : Message(scan_f_end_of_file);
  1394. else
  1395. begin
  1396. readpreproc:=_EOF;
  1397. end;
  1398. end;
  1399. end;
  1400. function tscannerfile.asmgetchar : char;
  1401. begin
  1402. if lastasmgetchar<>#0 then
  1403. begin
  1404. c:=lastasmgetchar;
  1405. lastasmgetchar:=#0;
  1406. end
  1407. else
  1408. readchar;
  1409. case c of
  1410. '{' : begin
  1411. skipcomment;
  1412. asmgetchar:=c;
  1413. exit;
  1414. end;
  1415. '/' : begin
  1416. readchar;
  1417. if c='/' then
  1418. begin
  1419. skipdelphicomment;
  1420. asmgetchar:=c;
  1421. end
  1422. else
  1423. begin
  1424. asmgetchar:='/';
  1425. lastasmgetchar:=c;
  1426. end;
  1427. exit;
  1428. end;
  1429. '(' : begin
  1430. readchar;
  1431. if c='*' then
  1432. begin
  1433. skipoldtpcomment;
  1434. asmgetchar:=c;
  1435. end
  1436. else
  1437. begin
  1438. asmgetchar:='(';
  1439. lastasmgetchar:=c;
  1440. end;
  1441. exit;
  1442. end;
  1443. else
  1444. begin
  1445. asmgetchar:=c;
  1446. end;
  1447. end;
  1448. end;
  1449. begin
  1450. create_tokenidx;
  1451. end.
  1452. {
  1453. $Log$
  1454. Revision 1.72 1999-02-02 00:15:10 florian
  1455. + c styled comments
  1456. Revision 1.71 1999/01/27 13:05:45 pierre
  1457. * give include file name on error
  1458. Revision 1.70 1999/01/19 12:14:38 peter
  1459. * fixed eof bug with includefiles
  1460. Revision 1.69 1998/12/11 00:03:46 peter
  1461. + globtype,tokens,version unit splitted from globals
  1462. Revision 1.68 1998/11/16 15:41:44 peter
  1463. * tp7 didn't like my ifopt H+ :(
  1464. Revision 1.67 1998/11/16 12:18:06 peter
  1465. * H+ fixes
  1466. Revision 1.66 1998/11/05 23:48:29 peter
  1467. * recordtype.field support in constant expressions
  1468. * fixed imul for oa_imm8 which was not allowed
  1469. * fixed reading of local typed constants
  1470. * fixed comment reading which is not any longer a separator
  1471. Revision 1.65 1998/11/03 11:35:02 peter
  1472. * don't check for endif if error
  1473. Revision 1.64 1998/10/21 20:16:05 peter
  1474. * beter line info for conditionals
  1475. Revision 1.63 1998/10/16 14:20:57 daniel
  1476. * Faster keyword scanning.
  1477. * Import library and smartlink library in one file.
  1478. Revision 1.62 1998/10/15 12:22:23 pierre
  1479. * close include files immediately after end reading
  1480. instead of waiting until unit compilation ended !
  1481. Revision 1.61 1998/10/09 11:08:15 peter
  1482. * fixed inputfile^.name^ bug
  1483. Revision 1.60 1998/10/09 08:56:31 pierre
  1484. * several memory leaks fixed
  1485. Revision 1.59 1998/10/08 23:29:05 peter
  1486. * -vu shows unit info, -vt shows tried/used files
  1487. Revision 1.58 1998/10/08 17:17:30 pierre
  1488. * current_module old scanner tagged as invalid if unit is recompiled
  1489. + added ppheap for better info on tracegetmem of heaptrc
  1490. (adds line column and file index)
  1491. * several memory leaks removed ith help of heaptrc !!
  1492. Revision 1.57 1998/10/08 13:45:25 peter
  1493. * EOF position is now correctly saved in aktfilepos
  1494. Revision 1.56 1998/09/30 16:43:38 peter
  1495. * fixed unit interdependency with circular uses
  1496. Revision 1.55 1998/09/28 16:57:26 pierre
  1497. * changed all length(p^.value_str^) into str_length(p)
  1498. to get it work with and without ansistrings
  1499. * changed sourcefiles field of tmodule to a pointer
  1500. Revision 1.54 1998/09/26 17:45:41 peter
  1501. + idtoken and only one token table
  1502. Revision 1.53 1998/09/24 23:49:20 peter
  1503. + aktmodeswitches
  1504. Revision 1.52 1998/09/18 16:03:45 florian
  1505. * some changes to compile with Delphi
  1506. Revision 1.51 1998/09/16 16:41:49 peter
  1507. * merged fixes
  1508. Revision 1.50.2.1 1998/09/16 16:09:49 peter
  1509. * on/off support also for the local/module switches
  1510. Revision 1.50 1998/09/04 08:36:06 peter
  1511. + (. and .) which are equal to [ and ]
  1512. Revision 1.49 1998/09/03 11:24:03 peter
  1513. * moved more inputfile things from tscannerfile to tinputfile
  1514. * changed ifdef Sourceline to cs_asm_source
  1515. Revision 1.48 1998/09/01 12:51:02 peter
  1516. * close also resets lastlinepos
  1517. Revision 1.47 1998/09/01 09:01:52 peter
  1518. * initialize all object variables in .init
  1519. Revision 1.46 1998/08/29 13:49:00 peter
  1520. * fixed freemem calls which had the wrong size sometimes
  1521. Revision 1.45 1998/08/26 15:35:35 peter
  1522. * fixed scannerfiles for macros
  1523. + $I %<environment>%
  1524. Revision 1.44 1998/08/20 16:09:55 pierre
  1525. * tokenpos has to be restored also after
  1526. printstatus
  1527. Revision 1.43 1998/08/20 09:26:45 pierre
  1528. + funcret setting in underproc testing
  1529. compile with _dTEST_FUNCRET
  1530. Revision 1.42 1998/08/19 14:57:51 peter
  1531. * small fix for aktfilepos
  1532. Revision 1.41 1998/08/18 14:17:10 pierre
  1533. * bug about assigning the return value of a function to
  1534. a procvar fixed : warning
  1535. assigning a proc to a procvar need @ in FPC mode !!
  1536. * missing file/line info restored
  1537. Revision 1.40 1998/08/11 14:04:33 peter
  1538. * auto close an open file and better error msg
  1539. Revision 1.39 1998/08/10 14:50:26 peter
  1540. + localswitches, moduleswitches, globalswitches splitting
  1541. Revision 1.38 1998/08/10 10:18:34 peter
  1542. + Compiler,Comphook unit which are the new interface units to the
  1543. compiler
  1544. Revision 1.37 1998/07/23 12:40:41 michael
  1545. No nested comments in Delphi mode.
  1546. Revision 1.36 1998/07/20 22:17:17 florian
  1547. * hex constants in numeric char (#$54#$43 ...) are now allowed
  1548. * there was a bug in record_var_dec which prevents the used
  1549. of nested variant records (for example drivers.tevent of tv)
  1550. Revision 1.35 1998/07/14 21:38:13 peter
  1551. + support for with p^do constructs
  1552. Revision 1.34 1998/07/14 14:47:04 peter
  1553. * released NEWINPUT
  1554. Revision 1.33 1998/07/10 10:48:40 peter
  1555. * fixed realnumber scanning
  1556. * [] after asmblock was not uppercased anymore
  1557. Revision 1.31 1998/07/07 17:39:38 peter
  1558. * fixed $I with following eof
  1559. Revision 1.30 1998/07/07 12:32:55 peter
  1560. * status.currentsource is now calculated in verbose (more accurated)
  1561. Revision 1.29 1998/07/07 11:20:11 peter
  1562. + NEWINPUT for a better inputfile and scanner object
  1563. Revision 1.28 1998/07/01 15:26:57 peter
  1564. * better bufferfile.reset error handling
  1565. Revision 1.27 1998/06/25 08:48:19 florian
  1566. * first version of rtti support
  1567. Revision 1.26 1998/06/16 08:56:30 peter
  1568. + targetcpu
  1569. * cleaner pmodules for newppu
  1570. Revision 1.25 1998/06/13 00:10:15 peter
  1571. * working browser and newppu
  1572. * some small fixes against crashes which occured in bp7 (but not in
  1573. fpc?!)
  1574. Revision 1.24 1998/06/12 10:32:36 pierre
  1575. * column problem hopefully solved
  1576. + C vars declaration changed
  1577. Revision 1.23 1998/06/03 22:49:02 peter
  1578. + wordbool,longbool
  1579. * rename bis,von -> high,low
  1580. * moved some systemunit loading/creating to psystem.pas
  1581. Revision 1.21 1998/05/27 00:20:32 peter
  1582. * some scanner optimizes
  1583. * automaticly aout2exe for go32v1
  1584. * fixed dynamiclinker option which was added at the wrong place
  1585. Revision 1.20 1998/05/23 01:21:30 peter
  1586. + aktasmmode, aktoptprocessor, aktoutputformat
  1587. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  1588. + $LIBNAME to set the library name where the unit will be put in
  1589. * splitted cgi386 a bit (codeseg to large for bp7)
  1590. * nasm, tasm works again. nasm moved to ag386nsm.pas
  1591. Revision 1.19 1998/05/20 09:42:37 pierre
  1592. + UseTokenInfo now default
  1593. * unit in interface uses and implementation uses gives error now
  1594. * only one error for unknown symbol (uses lastsymknown boolean)
  1595. the problem came from the label code !
  1596. + first inlined procedures and function work
  1597. (warning there might be allowed cases were the result is still wrong !!)
  1598. * UseBrower updated gives a global list of all position of all used symbols
  1599. with switch -gb
  1600. Revision 1.18 1998/05/12 10:47:00 peter
  1601. * moved printstatus to verb_def
  1602. + V_Normal which is between V_Error and V_Warning and doesn't have a
  1603. prefix like error: warning: and is included in V_Default
  1604. * fixed some messages
  1605. * first time parameter scan is only for -v and -T
  1606. - removed old style messages
  1607. Revision 1.17 1998/05/06 08:38:47 pierre
  1608. * better position info with UseTokenInfo
  1609. UseTokenInfo greatly simplified
  1610. + added check for changed tree after first time firstpass
  1611. (if we could remove all the cases were it happen
  1612. we could skip all firstpass if firstpasscount > 1)
  1613. Only with ExtDebug
  1614. Revision 1.16 1998/05/04 17:54:28 peter
  1615. + smartlinking works (only case jumptable left todo)
  1616. * redesign of systems.pas to support assemblers and linkers
  1617. + Unitname is now also in the PPU-file, increased version to 14
  1618. Revision 1.15 1998/05/01 16:38:46 florian
  1619. * handling of private and protected fixed
  1620. + change_keywords_to_tp implemented to remove
  1621. keywords which aren't supported by tp
  1622. * break and continue are now symbols of the system unit
  1623. + widestring, longstring and ansistring type released
  1624. Revision 1.14 1998/04/30 15:59:42 pierre
  1625. * GDB works again better :
  1626. correct type info in one pass
  1627. + UseTokenInfo for better source position
  1628. * fixed one remaining bug in scanner for line counts
  1629. * several little fixes
  1630. Revision 1.13 1998/04/29 13:42:27 peter
  1631. + $IOCHECKS and $ALIGN to test already, other will follow soon
  1632. * fixed the wrong linecounting with comments
  1633. Revision 1.12 1998/04/29 10:34:04 pierre
  1634. + added some code for ansistring (not complete nor working yet)
  1635. * corrected operator overloading
  1636. * corrected nasm output
  1637. + started inline procedures
  1638. + added starstarn : use ** for exponentiation (^ gave problems)
  1639. + started UseTokenInfo cond to get accurate positions
  1640. Revision 1.11 1998/04/27 23:10:29 peter
  1641. + new scanner
  1642. * $makelib -> if smartlink
  1643. * small filename fixes pmodule.setfilename
  1644. * moved import from files.pas -> import.pas
  1645. }