scanner.pas 54 KB

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