scanner.pas 53 KB

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