scanner.pas 54 KB

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