scanner.pas 55 KB

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