scanner.pas 53 KB

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