scanner.pas 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839
  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. '(' : begin
  721. readchar;
  722. if c='*' then
  723. skipoldtpcomment;
  724. end;
  725. else
  726. found:=0;
  727. end;
  728. c:=inputpointer^;
  729. if c=#0 then
  730. reload
  731. else
  732. inc(longint(inputpointer));
  733. case c of
  734. #26 : reload;
  735. #10,
  736. #13 : linebreak;
  737. end;
  738. until (found=2);
  739. end;
  740. {$i scandir.inc}
  741. procedure tscannerfile.skipcomment;
  742. begin
  743. readchar;
  744. inc_comment_level;
  745. { handle compiler switches }
  746. if (c='$') then
  747. handledirectives;
  748. { handle_switches can dec comment_level, }
  749. while (comment_level>0) do
  750. begin
  751. case c of
  752. '{' : inc_comment_level;
  753. '}' : dec_comment_level;
  754. #26 : Message(scan_f_end_of_file);
  755. end;
  756. c:=inputpointer^;
  757. if c=#0 then
  758. reload
  759. else
  760. inc(longint(inputpointer));
  761. case c of
  762. #26 : reload;
  763. #10,
  764. #13 : linebreak;
  765. end;
  766. end;
  767. end;
  768. procedure tscannerfile.skipdelphicomment;
  769. begin
  770. inc_comment_level;
  771. readchar;
  772. { this is currently not supported }
  773. if c='$' then
  774. Message(scan_e_wrong_styled_switch);
  775. { skip comment }
  776. while c<>newline do
  777. begin
  778. if c=#26 then
  779. Message(scan_f_end_of_file);
  780. readchar;
  781. end;
  782. dec_comment_level;
  783. end;
  784. procedure tscannerfile.skipoldtpcomment;
  785. var
  786. found : longint;
  787. begin
  788. inc_comment_level;
  789. readchar;
  790. { this is currently not supported }
  791. if c='$' then
  792. Message(scan_e_wrong_styled_switch);
  793. { skip comment }
  794. while (comment_level>0) do
  795. begin
  796. found:=0;
  797. repeat
  798. case c of
  799. #26 : Message(scan_f_end_of_file);
  800. '*' : begin
  801. if found=3 then
  802. begin
  803. inc_comment_level;
  804. found:=0;
  805. end
  806. else
  807. found:=1;
  808. end;
  809. ')' : begin
  810. if found=1 then
  811. begin
  812. dec_comment_level;
  813. if comment_level=0 then
  814. found:=2
  815. else
  816. found:=0;
  817. end;
  818. end;
  819. '(' : found:=3;
  820. else
  821. found:=0;
  822. end;
  823. c:=inputpointer^;
  824. if c=#0 then
  825. reload
  826. else
  827. inc(longint(inputpointer));
  828. case c of
  829. #26 : reload;
  830. #10,
  831. #13 : linebreak;
  832. end;
  833. until (found=2);
  834. end;
  835. end;
  836. procedure tscannerfile.skipccomment;
  837. var
  838. found : longint;
  839. begin
  840. inc_comment_level;
  841. readchar;
  842. { this is currently not supported }
  843. if c='$' then
  844. Message(scan_e_wrong_styled_switch);
  845. { skip comment }
  846. while (comment_level>0) do
  847. begin
  848. found:=0;
  849. repeat
  850. case c of
  851. #26 : Message(scan_f_end_of_file);
  852. '*' : begin
  853. if found=3 then
  854. begin
  855. inc_comment_level;
  856. found:=0;
  857. end
  858. else
  859. found:=1;
  860. end;
  861. '/' : begin
  862. if found=1 then
  863. begin
  864. dec_comment_level;
  865. if comment_level=0 then
  866. found:=2
  867. else
  868. found:=0;
  869. end
  870. else found:=3;
  871. end;
  872. else
  873. found:=0;
  874. end;
  875. c:=inputpointer^;
  876. if c=#0 then
  877. reload
  878. else
  879. inc(longint(inputpointer));
  880. case c of
  881. #26 : reload;
  882. #10,
  883. #13 : linebreak;
  884. end;
  885. until (found=2);
  886. end;
  887. end;
  888. procedure tscannerfile.readtoken;
  889. var
  890. code : integer;
  891. low,high,mid,
  892. l : {$ifdef TP} word; {$else} longint; {$endif}
  893. m : longint;
  894. mac : pmacrosym;
  895. asciinr : string[3];
  896. label
  897. exit_label;
  898. begin
  899. { was the last character a point ? }
  900. { this code is needed because the scanner if there is a 1. found if }
  901. { this is a floating point number or range like 1..3 }
  902. if do_special>0 then
  903. begin
  904. gettokenpos;
  905. l:=do_special;
  906. do_special:=0;
  907. case l of
  908. 1 : begin { first char was a point }
  909. case c of
  910. '.' : begin
  911. readchar;
  912. token:=POINTPOINT;
  913. goto exit_label;
  914. end;
  915. ')' : begin
  916. readchar;
  917. token:=RECKKLAMMER;
  918. goto exit_label;
  919. end;
  920. end;
  921. token:=POINT;
  922. goto exit_label;
  923. end;
  924. 2 : begin { first char was a Caret }
  925. token:=CARET;
  926. readchar;
  927. goto exit_label;
  928. end;
  929. end;
  930. end;
  931. { Skip all spaces and comments }
  932. repeat
  933. case c of
  934. '{' : skipcomment;
  935. ' ',#9..#13 : skipspace;
  936. else
  937. break;
  938. end;
  939. until false;
  940. { Save current token position, for EOF its already loaded }
  941. if c<>#26 then
  942. gettokenpos;
  943. { Check first for a identifier/keyword, this is 20+% faster (PFV) }
  944. if c in ['A'..'Z','a'..'z','_'] then
  945. begin
  946. readstring;
  947. token:=ID;
  948. idtoken:=ID;
  949. { keyword or any other known token ? }
  950. if length(pattern) in [2..tokenidlen] then
  951. begin
  952. low:=ord(tokenidx[length(pattern)].first);
  953. high:=ord(tokenidx[length(pattern)].last);
  954. while low<high do
  955. begin
  956. mid:=(high+low+1) shr 1;
  957. if pattern<tokeninfo[ttoken(mid)].str then
  958. high:=mid-1
  959. else
  960. low:=mid;
  961. end;
  962. if pattern=tokeninfo[ttoken(high)].str then
  963. begin
  964. if tokeninfo[ttoken(high)].keyword in aktmodeswitches then
  965. token:=ttoken(high);
  966. idtoken:=ttoken(high);
  967. end;
  968. end;
  969. { Only process identifiers and not keywords }
  970. if token=ID then
  971. begin
  972. { this takes some time ... }
  973. if (cs_support_macro in aktmoduleswitches) then
  974. begin
  975. mac:=pmacrosym(macros^.search(pattern));
  976. if assigned(mac) and (assigned(mac^.buftext)) then
  977. begin
  978. insertmacro(mac^.buftext,mac^.buflen);
  979. { handle empty macros }
  980. if c=#0 then
  981. reload;
  982. { play it again ... }
  983. inc(yylexcount);
  984. if yylexcount>16 then
  985. Message(scan_w_macro_deep_ten);
  986. readtoken;
  987. { that's all folks }
  988. dec(yylexcount);
  989. exit;
  990. end;
  991. end;
  992. end;
  993. { a following caret, then set special handling }
  994. if (c='^') then
  995. do_special:=2;
  996. { return token }
  997. goto exit_label;
  998. end
  999. else
  1000. begin
  1001. idtoken:=NOID;
  1002. case c of
  1003. '$' : begin
  1004. readnumber;
  1005. token:=INTCONST;
  1006. goto exit_label;
  1007. end;
  1008. '%' : begin
  1009. readnumber;
  1010. token:=INTCONST;
  1011. goto exit_label;
  1012. end;
  1013. '0'..'9' : begin
  1014. readnumber;
  1015. if (c in ['.','e','E']) then
  1016. begin
  1017. { first check for a . }
  1018. if c='.' then
  1019. begin
  1020. readchar;
  1021. if not(c in ['0'..'9']) then
  1022. begin
  1023. do_special:=1;
  1024. token:=INTCONST;
  1025. goto exit_label;
  1026. end;
  1027. pattern:=pattern+'.';
  1028. while c in ['0'..'9'] do
  1029. begin
  1030. pattern:=pattern+c;
  1031. readchar;
  1032. end;
  1033. end;
  1034. { E can also follow after a point is scanned }
  1035. if c in ['e','E'] then
  1036. begin
  1037. pattern:=pattern+'E';
  1038. readchar;
  1039. if c in ['-','+'] then
  1040. begin
  1041. pattern:=pattern+c;
  1042. readchar;
  1043. end;
  1044. if not(c in ['0'..'9']) then
  1045. Message(scan_f_illegal_char);
  1046. while c in ['0'..'9'] do
  1047. begin
  1048. pattern:=pattern+c;
  1049. readchar;
  1050. end;
  1051. end;
  1052. token:=REALNUMBER;
  1053. goto exit_label;
  1054. end;
  1055. token:=INTCONST;
  1056. goto exit_label;
  1057. end;
  1058. ';' : begin
  1059. readchar;
  1060. token:=SEMICOLON;
  1061. goto exit_label;
  1062. end;
  1063. '[' : begin
  1064. readchar;
  1065. token:=LECKKLAMMER;
  1066. goto exit_label;
  1067. end;
  1068. ']' : begin
  1069. readchar;
  1070. token:=RECKKLAMMER;
  1071. goto exit_label;
  1072. end;
  1073. '(' : begin
  1074. readchar;
  1075. case c of
  1076. '*' : begin
  1077. skipoldtpcomment;
  1078. readtoken;
  1079. exit;
  1080. end;
  1081. '.' : begin
  1082. readchar;
  1083. token:=LECKKLAMMER;
  1084. goto exit_label;
  1085. end;
  1086. end;
  1087. token:=LKLAMMER;
  1088. goto exit_label;
  1089. end;
  1090. ')' : begin
  1091. readchar;
  1092. token:=RKLAMMER;
  1093. goto exit_label;
  1094. end;
  1095. '+' : begin
  1096. readchar;
  1097. if (c='=') and (cs_support_c_operators in aktmoduleswitches) then
  1098. begin
  1099. readchar;
  1100. token:=_PLUSASN;
  1101. goto exit_label;
  1102. end;
  1103. token:=PLUS;
  1104. goto exit_label;
  1105. end;
  1106. '-' : begin
  1107. readchar;
  1108. if (c='=') and (cs_support_c_operators in aktmoduleswitches) then
  1109. begin
  1110. readchar;
  1111. token:=_MINUSASN;
  1112. goto exit_label;
  1113. end;
  1114. token:=MINUS;
  1115. goto exit_label;
  1116. end;
  1117. ':' : begin
  1118. readchar;
  1119. if c='=' then
  1120. begin
  1121. readchar;
  1122. token:=ASSIGNMENT;
  1123. goto exit_label;
  1124. end;
  1125. token:=COLON;
  1126. goto exit_label;
  1127. end;
  1128. '*' : begin
  1129. readchar;
  1130. if (c='=') and (cs_support_c_operators in aktmoduleswitches) then
  1131. begin
  1132. readchar;
  1133. token:=_STARASN;
  1134. end
  1135. else
  1136. if c='*' then
  1137. begin
  1138. readchar;
  1139. token:=STARSTAR;
  1140. end
  1141. else
  1142. token:=STAR;
  1143. goto exit_label;
  1144. end;
  1145. '/' : begin
  1146. readchar;
  1147. case c of
  1148. '=' : begin
  1149. if (cs_support_c_operators in aktmoduleswitches) then
  1150. begin
  1151. readchar;
  1152. token:=_SLASHASN;
  1153. goto exit_label;
  1154. end;
  1155. end;
  1156. '/' : begin
  1157. skipdelphicomment;
  1158. readtoken;
  1159. exit;
  1160. end;
  1161. '*' : begin
  1162. skipccomment;
  1163. readtoken;
  1164. exit;
  1165. end;
  1166. end;
  1167. token:=SLASH;
  1168. goto exit_label;
  1169. end;
  1170. '=' : begin
  1171. readchar;
  1172. token:=EQUAL;
  1173. goto exit_label;
  1174. end;
  1175. '.' : begin
  1176. readchar;
  1177. case c of
  1178. '.' : begin
  1179. readchar;
  1180. token:=POINTPOINT;
  1181. goto exit_label;
  1182. end;
  1183. ')' : begin
  1184. readchar;
  1185. token:=RECKKLAMMER;
  1186. goto exit_label;
  1187. end;
  1188. end;
  1189. token:=POINT;
  1190. goto exit_label;
  1191. end;
  1192. '@' : begin
  1193. readchar;
  1194. if c='@' then
  1195. begin
  1196. readchar;
  1197. token:=DOUBLEADDR;
  1198. end
  1199. else
  1200. token:=KLAMMERAFFE;
  1201. goto exit_label;
  1202. end;
  1203. ',' : begin
  1204. readchar;
  1205. token:=COMMA;
  1206. goto exit_label;
  1207. end;
  1208. '''','#','^' : begin
  1209. if c='^' then
  1210. begin
  1211. readchar;
  1212. c:=upcase(c);
  1213. if not(block_type=bt_type) and (c in ['A'..'Z']) then
  1214. begin
  1215. pattern:=chr(ord(c)-64);
  1216. readchar;
  1217. end
  1218. else
  1219. begin
  1220. token:=CARET;
  1221. goto exit_label;
  1222. end;
  1223. end
  1224. else
  1225. pattern:='';
  1226. repeat
  1227. case c of
  1228. '#' : begin
  1229. readchar; { read # }
  1230. if c='$' then
  1231. begin
  1232. readchar; { read leading $ }
  1233. asciinr:='$';
  1234. while (upcase(c) in ['A'..'F','0'..'9']) and (length(asciinr)<3) do
  1235. begin
  1236. asciinr:=asciinr+c;
  1237. readchar;
  1238. end;
  1239. end
  1240. else
  1241. begin
  1242. asciinr:='';
  1243. while (c in ['0'..'9']) and (length(asciinr)<3) do
  1244. begin
  1245. asciinr:=asciinr+c;
  1246. readchar;
  1247. end;
  1248. end;
  1249. valint(asciinr,m,code);
  1250. if (asciinr='') or (code<>0) or
  1251. (m<0) or (m>255) then
  1252. Message(scan_e_illegal_char_const);
  1253. pattern:=pattern+chr(m);
  1254. end;
  1255. '''' : begin
  1256. repeat
  1257. readchar;
  1258. case c of
  1259. #26 : Message(scan_f_end_of_file);
  1260. newline : Message(scan_f_string_exceeds_line);
  1261. '''' : begin
  1262. readchar;
  1263. if c<>'''' then
  1264. break;
  1265. end;
  1266. end;
  1267. pattern:=pattern+c;
  1268. until false;
  1269. end;
  1270. '^' : begin
  1271. readchar;
  1272. if c<#64 then
  1273. c:=chr(ord(c)+64)
  1274. else
  1275. c:=chr(ord(c)-64);
  1276. pattern:=pattern+c;
  1277. readchar;
  1278. end;
  1279. else
  1280. break;
  1281. end;
  1282. until false;
  1283. { strings with length 1 become const chars }
  1284. if length(pattern)=1 then
  1285. token:=CCHAR
  1286. else
  1287. token:=CSTRING;
  1288. goto exit_label;
  1289. end;
  1290. '>' : begin
  1291. readchar;
  1292. case c of
  1293. '=' : begin
  1294. readchar;
  1295. token:=GTE;
  1296. goto exit_label;
  1297. end;
  1298. '>' : begin
  1299. readchar;
  1300. token:=_SHR;
  1301. goto exit_label;
  1302. end;
  1303. '<' : begin { >< is for a symetric diff for sets }
  1304. readchar;
  1305. token:=SYMDIF;
  1306. goto exit_label;
  1307. end;
  1308. end;
  1309. token:=GT;
  1310. goto exit_label;
  1311. end;
  1312. '<' : begin
  1313. readchar;
  1314. case c of
  1315. '>' : begin
  1316. readchar;
  1317. token:=UNEQUAL;
  1318. goto exit_label;
  1319. end;
  1320. '=' : begin
  1321. readchar;
  1322. token:=LTE;
  1323. goto exit_label;
  1324. end;
  1325. '<' : begin
  1326. readchar;
  1327. token:=_SHL;
  1328. goto exit_label;
  1329. end;
  1330. end;
  1331. token:=LT;
  1332. goto exit_label;
  1333. end;
  1334. #26 : begin
  1335. token:=_EOF;
  1336. goto exit_label;
  1337. end;
  1338. else
  1339. begin
  1340. Message(scan_f_illegal_char);
  1341. end;
  1342. end;
  1343. end;
  1344. exit_label:
  1345. end;
  1346. function tscannerfile.readpreproc:ttoken;
  1347. begin
  1348. skipspace;
  1349. case c of
  1350. 'A'..'Z',
  1351. 'a'..'z',
  1352. '_','0'..'9' : begin
  1353. preprocpat:=readid;
  1354. readpreproc:=ID;
  1355. end;
  1356. '(' : begin
  1357. readchar;
  1358. readpreproc:=LKLAMMER;
  1359. end;
  1360. ')' : begin
  1361. readchar;
  1362. readpreproc:=RKLAMMER;
  1363. end;
  1364. '+' : begin
  1365. readchar;
  1366. readpreproc:=PLUS;
  1367. end;
  1368. '-' : begin
  1369. readchar;
  1370. readpreproc:=MINUS;
  1371. end;
  1372. '*' : begin
  1373. readchar;
  1374. readpreproc:=STAR;
  1375. end;
  1376. '/' : begin
  1377. readchar;
  1378. readpreproc:=SLASH;
  1379. end;
  1380. '=' : begin
  1381. readchar;
  1382. readpreproc:=EQUAL;
  1383. end;
  1384. '>' : begin
  1385. readchar;
  1386. if c='=' then
  1387. begin
  1388. readchar;
  1389. readpreproc:=GTE;
  1390. end
  1391. else
  1392. readpreproc:=GT;
  1393. end;
  1394. '<' : begin
  1395. readchar;
  1396. case c of
  1397. '>' : begin
  1398. readchar;
  1399. readpreproc:=UNEQUAL;
  1400. end;
  1401. '=' : begin
  1402. readchar;
  1403. readpreproc:=LTE;
  1404. end;
  1405. else readpreproc:=LT;
  1406. end;
  1407. end;
  1408. #26 : Message(scan_f_end_of_file);
  1409. else
  1410. begin
  1411. readpreproc:=_EOF;
  1412. end;
  1413. end;
  1414. end;
  1415. function tscannerfile.asmgetchar : char;
  1416. begin
  1417. if lastasmgetchar<>#0 then
  1418. begin
  1419. c:=lastasmgetchar;
  1420. lastasmgetchar:=#0;
  1421. end
  1422. else
  1423. readchar;
  1424. case c of
  1425. '{' : begin
  1426. skipcomment;
  1427. asmgetchar:=c;
  1428. exit;
  1429. end;
  1430. '/' : begin
  1431. readchar;
  1432. if c='/' then
  1433. begin
  1434. skipdelphicomment;
  1435. asmgetchar:=c;
  1436. end
  1437. else
  1438. begin
  1439. asmgetchar:='/';
  1440. lastasmgetchar:=c;
  1441. end;
  1442. exit;
  1443. end;
  1444. '(' : begin
  1445. readchar;
  1446. if c='*' then
  1447. begin
  1448. skipoldtpcomment;
  1449. asmgetchar:=c;
  1450. end
  1451. else
  1452. begin
  1453. asmgetchar:='(';
  1454. lastasmgetchar:=c;
  1455. end;
  1456. exit;
  1457. end;
  1458. else
  1459. begin
  1460. asmgetchar:=c;
  1461. end;
  1462. end;
  1463. end;
  1464. begin
  1465. create_tokenidx;
  1466. end.
  1467. {
  1468. $Log$
  1469. Revision 1.75 1999-03-16 21:00:27 peter
  1470. * fixed old tp comment behaviour within directives
  1471. Revision 1.74 1999/03/11 10:46:29 daniel
  1472. * Reverted C styled comments
  1473. Revision 1.73 1999/03/02 22:49:35 peter
  1474. * fixed nested comments for old style tp and c
  1475. Revision 1.72 1999/02/02 00:15:10 florian
  1476. + c styled comments
  1477. Revision 1.71 1999/01/27 13:05:45 pierre
  1478. * give include file name on error
  1479. Revision 1.70 1999/01/19 12:14:38 peter
  1480. * fixed eof bug with includefiles
  1481. Revision 1.69 1998/12/11 00:03:46 peter
  1482. + globtype,tokens,version unit splitted from globals
  1483. Revision 1.68 1998/11/16 15:41:44 peter
  1484. * tp7 didn't like my ifopt H+ :(
  1485. Revision 1.67 1998/11/16 12:18:06 peter
  1486. * H+ fixes
  1487. Revision 1.66 1998/11/05 23:48:29 peter
  1488. * recordtype.field support in constant expressions
  1489. * fixed imul for oa_imm8 which was not allowed
  1490. * fixed reading of local typed constants
  1491. * fixed comment reading which is not any longer a separator
  1492. Revision 1.65 1998/11/03 11:35:02 peter
  1493. * don't check for endif if error
  1494. Revision 1.64 1998/10/21 20:16:05 peter
  1495. * beter line info for conditionals
  1496. Revision 1.63 1998/10/16 14:20:57 daniel
  1497. * Faster keyword scanning.
  1498. * Import library and smartlink library in one file.
  1499. Revision 1.62 1998/10/15 12:22:23 pierre
  1500. * close include files immediately after end reading
  1501. instead of waiting until unit compilation ended !
  1502. Revision 1.61 1998/10/09 11:08:15 peter
  1503. * fixed inputfile^.name^ bug
  1504. Revision 1.60 1998/10/09 08:56:31 pierre
  1505. * several memory leaks fixed
  1506. Revision 1.59 1998/10/08 23:29:05 peter
  1507. * -vu shows unit info, -vt shows tried/used files
  1508. Revision 1.58 1998/10/08 17:17:30 pierre
  1509. * current_module old scanner tagged as invalid if unit is recompiled
  1510. + added ppheap for better info on tracegetmem of heaptrc
  1511. (adds line column and file index)
  1512. * several memory leaks removed ith help of heaptrc !!
  1513. Revision 1.57 1998/10/08 13:45:25 peter
  1514. * EOF position is now correctly saved in aktfilepos
  1515. Revision 1.56 1998/09/30 16:43:38 peter
  1516. * fixed unit interdependency with circular uses
  1517. Revision 1.55 1998/09/28 16:57:26 pierre
  1518. * changed all length(p^.value_str^) into str_length(p)
  1519. to get it work with and without ansistrings
  1520. * changed sourcefiles field of tmodule to a pointer
  1521. Revision 1.54 1998/09/26 17:45:41 peter
  1522. + idtoken and only one token table
  1523. Revision 1.53 1998/09/24 23:49:20 peter
  1524. + aktmodeswitches
  1525. Revision 1.52 1998/09/18 16:03:45 florian
  1526. * some changes to compile with Delphi
  1527. Revision 1.51 1998/09/16 16:41:49 peter
  1528. * merged fixes
  1529. Revision 1.50.2.1 1998/09/16 16:09:49 peter
  1530. * on/off support also for the local/module switches
  1531. Revision 1.50 1998/09/04 08:36:06 peter
  1532. + (. and .) which are equal to [ and ]
  1533. Revision 1.49 1998/09/03 11:24:03 peter
  1534. * moved more inputfile things from tscannerfile to tinputfile
  1535. * changed ifdef Sourceline to cs_asm_source
  1536. Revision 1.48 1998/09/01 12:51:02 peter
  1537. * close also resets lastlinepos
  1538. Revision 1.47 1998/09/01 09:01:52 peter
  1539. * initialize all object variables in .init
  1540. Revision 1.46 1998/08/29 13:49:00 peter
  1541. * fixed freemem calls which had the wrong size sometimes
  1542. Revision 1.45 1998/08/26 15:35:35 peter
  1543. * fixed scannerfiles for macros
  1544. + $I %<environment>%
  1545. Revision 1.44 1998/08/20 16:09:55 pierre
  1546. * tokenpos has to be restored also after
  1547. printstatus
  1548. Revision 1.43 1998/08/20 09:26:45 pierre
  1549. + funcret setting in underproc testing
  1550. compile with _dTEST_FUNCRET
  1551. Revision 1.42 1998/08/19 14:57:51 peter
  1552. * small fix for aktfilepos
  1553. Revision 1.41 1998/08/18 14:17:10 pierre
  1554. * bug about assigning the return value of a function to
  1555. a procvar fixed : warning
  1556. assigning a proc to a procvar need @ in FPC mode !!
  1557. * missing file/line info restored
  1558. Revision 1.40 1998/08/11 14:04:33 peter
  1559. * auto close an open file and better error msg
  1560. Revision 1.39 1998/08/10 14:50:26 peter
  1561. + localswitches, moduleswitches, globalswitches splitting
  1562. Revision 1.38 1998/08/10 10:18:34 peter
  1563. + Compiler,Comphook unit which are the new interface units to the
  1564. compiler
  1565. Revision 1.37 1998/07/23 12:40:41 michael
  1566. No nested comments in Delphi mode.
  1567. Revision 1.36 1998/07/20 22:17:17 florian
  1568. * hex constants in numeric char (#$54#$43 ...) are now allowed
  1569. * there was a bug in record_var_dec which prevents the used
  1570. of nested variant records (for example drivers.tevent of tv)
  1571. Revision 1.35 1998/07/14 21:38:13 peter
  1572. + support for with p^do constructs
  1573. Revision 1.34 1998/07/14 14:47:04 peter
  1574. * released NEWINPUT
  1575. Revision 1.33 1998/07/10 10:48:40 peter
  1576. * fixed realnumber scanning
  1577. * [] after asmblock was not uppercased anymore
  1578. Revision 1.31 1998/07/07 17:39:38 peter
  1579. * fixed $I with following eof
  1580. Revision 1.30 1998/07/07 12:32:55 peter
  1581. * status.currentsource is now calculated in verbose (more accurated)
  1582. Revision 1.29 1998/07/07 11:20:11 peter
  1583. + NEWINPUT for a better inputfile and scanner object
  1584. Revision 1.28 1998/07/01 15:26:57 peter
  1585. * better bufferfile.reset error handling
  1586. Revision 1.27 1998/06/25 08:48:19 florian
  1587. * first version of rtti support
  1588. Revision 1.26 1998/06/16 08:56:30 peter
  1589. + targetcpu
  1590. * cleaner pmodules for newppu
  1591. Revision 1.25 1998/06/13 00:10:15 peter
  1592. * working browser and newppu
  1593. * some small fixes against crashes which occured in bp7 (but not in
  1594. fpc?!)
  1595. Revision 1.24 1998/06/12 10:32:36 pierre
  1596. * column problem hopefully solved
  1597. + C vars declaration changed
  1598. Revision 1.23 1998/06/03 22:49:02 peter
  1599. + wordbool,longbool
  1600. * rename bis,von -> high,low
  1601. * moved some systemunit loading/creating to psystem.pas
  1602. Revision 1.21 1998/05/27 00:20:32 peter
  1603. * some scanner optimizes
  1604. * automaticly aout2exe for go32v1
  1605. * fixed dynamiclinker option which was added at the wrong place
  1606. Revision 1.20 1998/05/23 01:21:30 peter
  1607. + aktasmmode, aktoptprocessor, aktoutputformat
  1608. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  1609. + $LIBNAME to set the library name where the unit will be put in
  1610. * splitted cgi386 a bit (codeseg to large for bp7)
  1611. * nasm, tasm works again. nasm moved to ag386nsm.pas
  1612. Revision 1.19 1998/05/20 09:42:37 pierre
  1613. + UseTokenInfo now default
  1614. * unit in interface uses and implementation uses gives error now
  1615. * only one error for unknown symbol (uses lastsymknown boolean)
  1616. the problem came from the label code !
  1617. + first inlined procedures and function work
  1618. (warning there might be allowed cases were the result is still wrong !!)
  1619. * UseBrower updated gives a global list of all position of all used symbols
  1620. with switch -gb
  1621. Revision 1.18 1998/05/12 10:47:00 peter
  1622. * moved printstatus to verb_def
  1623. + V_Normal which is between V_Error and V_Warning and doesn't have a
  1624. prefix like error: warning: and is included in V_Default
  1625. * fixed some messages
  1626. * first time parameter scan is only for -v and -T
  1627. - removed old style messages
  1628. Revision 1.17 1998/05/06 08:38:47 pierre
  1629. * better position info with UseTokenInfo
  1630. UseTokenInfo greatly simplified
  1631. + added check for changed tree after first time firstpass
  1632. (if we could remove all the cases were it happen
  1633. we could skip all firstpass if firstpasscount > 1)
  1634. Only with ExtDebug
  1635. Revision 1.16 1998/05/04 17:54:28 peter
  1636. + smartlinking works (only case jumptable left todo)
  1637. * redesign of systems.pas to support assemblers and linkers
  1638. + Unitname is now also in the PPU-file, increased version to 14
  1639. Revision 1.15 1998/05/01 16:38:46 florian
  1640. * handling of private and protected fixed
  1641. + change_keywords_to_tp implemented to remove
  1642. keywords which aren't supported by tp
  1643. * break and continue are now symbols of the system unit
  1644. + widestring, longstring and ansistring type released
  1645. Revision 1.14 1998/04/30 15:59:42 pierre
  1646. * GDB works again better :
  1647. correct type info in one pass
  1648. + UseTokenInfo for better source position
  1649. * fixed one remaining bug in scanner for line counts
  1650. * several little fixes
  1651. Revision 1.13 1998/04/29 13:42:27 peter
  1652. + $IOCHECKS and $ALIGN to test already, other will follow soon
  1653. * fixed the wrong linecounting with comments
  1654. Revision 1.12 1998/04/29 10:34:04 pierre
  1655. + added some code for ansistring (not complete nor working yet)
  1656. * corrected operator overloading
  1657. * corrected nasm output
  1658. + started inline procedures
  1659. + added starstarn : use ** for exponentiation (^ gave problems)
  1660. + started UseTokenInfo cond to get accurate positions
  1661. Revision 1.11 1998/04/27 23:10:29 peter
  1662. + new scanner
  1663. * $makelib -> if smartlink
  1664. * small filename fixes pmodule.setfilename
  1665. * moved import from files.pas -> import.pas
  1666. }