scanner.pas 56 KB

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