scanner.pas 53 KB

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