scanner.pas 55 KB

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