scanner.pas 55 KB

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