scanner.pas 54 KB

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