scanner.pas 53 KB

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