scanner.pas 56 KB

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