scanner.pas 55 KB

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