scandir.inc 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Peter Vreman
  4. This unit implements directive parsing for the scanner
  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. const
  19. directivelen=15;
  20. type
  21. directivestr=string[directivelen];
  22. tdirectivetoken=(
  23. _DIR_NONE,
  24. _DIR_ALIGN,_DIR_APPTYPE,_DIR_ASMMODE,_DIR_ASSERTIONS,
  25. _DIR_BOOLEVAL,
  26. _DIR_D,_DIR_DEBUGINFO,_DIR_DEFINE,_DIR_DESCRIPTION,
  27. _DIR_ELSE,_DIR_ENDIF,_DIR_ERROR,_DIR_EXTENDEDSYNTAX,
  28. _DIR_FATAL,
  29. _DIR_GOTO,
  30. _DIR_HINT,_DIR_HINTS,
  31. _DIR_I,_DIR_I386_ATT,_DIR_I386_DIRECT,_DIR_I386_INTEL,_DIR_IOCHECKS,
  32. _DIR_IF,_DIR_IFDEF,_DIR_IFNDEF,_DIR_IFOPT,_DIR_INCLUDE,_DIR_INCLUDEPATH,
  33. _DIR_INFO,_DIR_INLINE,
  34. _DIR_L,_DIR_LIBRARYPATH,_DIR_LINK,_DIR_LINKLIB,_DIR_LOCALSYMBOLS,
  35. _DIR_LONGSTRINGS,
  36. _DIR_M,_DIR_MACRO,_DIR_MAXFPUREGISTERS,_DIR_MEMORY,_DIR_MESSAGE,_DIR_MINENUMSIZE,_DIR_MMX,_DIR_MODE,
  37. _DIR_NOTE,_DIR_NOTES,
  38. _DIR_OBJECTPATH,_DIR_OPENSTRINGS,_DIR_OUTPUT_FORMAT,_DIR_OVERFLOWCHECKS,
  39. _DIR_PACKENUM,_DIR_PACKRECORDS,
  40. {$IFDEF Testvarsets}
  41. _DIR_PACKSET,
  42. {$ENDIF}
  43. _DIR_R,_DIR_RANGECHECKS,_DIR_REFERENCEINFO,
  44. _DIR_SATURATION,_DIR_SMARTLINK,_DIR_STACKFRAMES,_DIR_STATIC,_DIR_STOP,
  45. _DIR_TYPEDADDRESS,_DIR_TYPEINFO,
  46. _DIR_UNDEF,_DIR_UNITPATH,
  47. _DIR_VARSTRINGCHECKS,_DIR_VERSION,
  48. _DIR_WAIT,_DIR_WARNING,_DIR_WARNINGS,
  49. _DIR_Z1,_DIR_Z2,_DIR_Z4
  50. );
  51. const
  52. firstdirective=_DIR_NONE;
  53. lastdirective=_DIR_Z4;
  54. directive:array[tdirectivetoken] of directivestr=(
  55. {12345678901234567890 (To determine longest string.)}
  56. '',
  57. 'ALIGN',
  58. 'APPTYPE',
  59. 'ASMMODE',
  60. 'ASSERTIONS',
  61. 'BOOLEVAL',
  62. 'D',
  63. 'DEBUGINFO',
  64. 'DEFINE',
  65. 'DESCRIPTION',
  66. 'ELSE',
  67. 'ENDIF',
  68. 'ERROR',
  69. 'EXTENDEDSYNTAX',
  70. 'FATAL',
  71. 'GOTO',
  72. 'HINT',
  73. 'HINTS',
  74. 'I',
  75. {12345678901234567890 (To determine longest string.)}
  76. 'I386_ATT',
  77. 'I386_DIRECT',
  78. 'I386_INTEL',
  79. 'IOCHECKS',
  80. 'IF',
  81. 'IFDEF',
  82. 'IFNDEF',
  83. 'IFOPT',
  84. 'INCLUDE',
  85. 'INCLUDEPATH',
  86. 'INFO',
  87. 'INLINE',
  88. 'L',
  89. 'LIBRARYPATH',
  90. 'LINK',
  91. 'LINKLIB',
  92. 'LOCALSYMBOLS',
  93. 'LONGSTRINGS',
  94. 'M',
  95. {12345678901234567890 (To determine longest string.)}
  96. 'MACRO',
  97. 'MAXFPUREGISTERS',
  98. 'MEMORY',
  99. 'MESSAGE',
  100. 'MINENUMSIZE',
  101. 'MMX',
  102. 'MODE',
  103. 'NOTE',
  104. 'NOTES',
  105. 'OBJECTPATH',
  106. 'OPENSTRINGS',
  107. 'OUTPUT_FORMAT',
  108. 'OVERFLOWCHECKS',
  109. 'PACKENUM',
  110. 'PACKRECORDS',
  111. {$IFDEF testvarsets}
  112. 'PACKSET',
  113. {$ENDIF}
  114. 'R',
  115. 'RANGECHECKS',
  116. 'REFERENCEINFO',
  117. 'SATURATION',
  118. 'SMARTLINK',
  119. {12345678901234567890 (To determine longest string.)}
  120. 'STACKFRAMES',
  121. 'STATIC',
  122. 'STOP',
  123. 'TYPEDADDRESS',
  124. 'TYPEINFO',
  125. 'UNDEF',
  126. 'UNITPATH',
  127. 'VARSTRINGCHECKS',
  128. 'VERSION',
  129. 'WAIT',
  130. 'WARNING',
  131. 'WARNINGS',
  132. 'Z1',
  133. 'Z2',
  134. 'Z4'
  135. );
  136. function Get_Directive(const hs:string):tdirectivetoken;
  137. var
  138. i : tdirectivetoken;
  139. begin
  140. for i:=firstdirective to lastdirective do
  141. if directive[i]=hs then
  142. begin
  143. Get_Directive:=i;
  144. exit;
  145. end;
  146. Get_Directive:=_DIR_NONE;
  147. end;
  148. {-------------------------------------------
  149. IF Conditional Handling
  150. -------------------------------------------}
  151. var
  152. preprocpat : string;
  153. preproc_token : ttoken;
  154. procedure preproc_consume(t : ttoken);
  155. begin
  156. if t<>preproc_token then
  157. Message(scan_e_preproc_syntax_error);
  158. preproc_token:=current_scanner^.readpreproc;
  159. end;
  160. function read_expr : string;forward;
  161. function read_factor : string;
  162. var
  163. hs : string;
  164. mac : pmacrosym;
  165. len : byte;
  166. begin
  167. if preproc_token=_ID then
  168. begin
  169. if preprocpat='NOT' then
  170. begin
  171. preproc_consume(_ID);
  172. hs:=read_expr;
  173. if hs='0' then
  174. read_factor:='1'
  175. else
  176. read_factor:='0';
  177. end
  178. else
  179. begin
  180. mac:=pmacrosym(macros^.search(hs));
  181. hs:=preprocpat;
  182. preproc_consume(_ID);
  183. if assigned(mac) then
  184. begin
  185. if mac^.defined and assigned(mac^.buftext) then
  186. begin
  187. if mac^.buflen>255 then
  188. begin
  189. len:=255;
  190. Message(scan_w_macro_cut_after_255_chars);
  191. end
  192. else
  193. len:=mac^.buflen;
  194. {$ifndef TP}
  195. {$ifopt H+}
  196. setlength(hs,len);
  197. {$else}
  198. hs[0]:=char(len);
  199. {$endif}
  200. {$else}
  201. hs[0]:=char(len);
  202. {$endif}
  203. move(mac^.buftext^,hs[1],len);
  204. end
  205. else
  206. read_factor:='';
  207. end
  208. else
  209. read_factor:=hs;
  210. end
  211. end
  212. else if preproc_token=_LKLAMMER then
  213. begin
  214. preproc_consume(_LKLAMMER);
  215. read_factor:=read_expr;
  216. preproc_consume(_RKLAMMER);
  217. end
  218. else
  219. Message(scan_e_error_in_preproc_expr);
  220. end;
  221. function read_term : string;
  222. var
  223. hs1,hs2 : string;
  224. begin
  225. hs1:=read_factor;
  226. while true do
  227. begin
  228. if (preproc_token=_ID) then
  229. begin
  230. if preprocpat='AND' then
  231. begin
  232. preproc_consume(_ID);
  233. hs2:=read_factor;
  234. if (hs1<>'0') and (hs2<>'0') then
  235. hs1:='1';
  236. end
  237. else
  238. break;
  239. end
  240. else
  241. break;
  242. end;
  243. read_term:=hs1;
  244. end;
  245. function read_simple_expr : string;
  246. var
  247. hs1,hs2 : string;
  248. begin
  249. hs1:=read_term;
  250. while true do
  251. begin
  252. if (preproc_token=_ID) then
  253. begin
  254. if preprocpat='OR' then
  255. begin
  256. preproc_consume(_ID);
  257. hs2:=read_term;
  258. if (hs1<>'0') or (hs2<>'0') then
  259. hs1:='1';
  260. end
  261. else
  262. break;
  263. end
  264. else
  265. break;
  266. end;
  267. read_simple_expr:=hs1;
  268. end;
  269. function read_expr : string;
  270. var
  271. hs1,hs2 : string;
  272. b : boolean;
  273. t : ttoken;
  274. w : integer;
  275. l1,l2 : longint;
  276. begin
  277. hs1:=read_simple_expr;
  278. t:=preproc_token;
  279. if not(t in [_EQUAL,_UNEQUAL,_LT,_GT,_LTE,_GTE]) then
  280. begin
  281. read_expr:=hs1;
  282. exit;
  283. end;
  284. preproc_consume(t);
  285. hs2:=read_simple_expr;
  286. if is_number(hs1) and is_number(hs2) then
  287. begin
  288. valint(hs1,l1,w);
  289. valint(hs2,l2,w);
  290. case t of
  291. _EQUAL : b:=l1=l2;
  292. _UNEQUAL : b:=l1<>l2;
  293. _LT : b:=l1<l2;
  294. _GT : b:=l1>l2;
  295. _GTE : b:=l1>=l2;
  296. _LTE : b:=l1<=l2;
  297. end;
  298. end
  299. else
  300. begin
  301. case t of
  302. _EQUAL : b:=hs1=hs2;
  303. _UNEQUAL : b:=hs1<>hs2;
  304. _LT : b:=hs1<hs2;
  305. _GT : b:=hs1>hs2;
  306. _GTE : b:=hs1>=hs2;
  307. _LTE : b:=hs1<=hs2;
  308. end;
  309. end;
  310. if b then
  311. read_expr:='1'
  312. else
  313. read_expr:='0';
  314. end;
  315. {-------------------------------------------
  316. Directives
  317. -------------------------------------------}
  318. function is_conditional(t:tdirectivetoken):boolean;
  319. begin
  320. is_conditional:=(t in [_DIR_ENDIF,_DIR_IFDEF,_DIR_IFNDEF,_DIR_IFOPT,_DIR_IF,_DIR_ELSE]);
  321. end;
  322. procedure dir_conditional(t:tdirectivetoken);
  323. var
  324. hs : string;
  325. mac : pmacrosym;
  326. found : boolean;
  327. state : char;
  328. oldaktfilepos : tfileposinfo;
  329. begin
  330. oldaktfilepos:=aktfilepos;
  331. while true do
  332. begin
  333. current_scanner^.gettokenpos;
  334. case t of
  335. _DIR_ENDIF : begin
  336. current_scanner^.poppreprocstack;
  337. end;
  338. _DIR_ELSE : begin
  339. current_scanner^.elsepreprocstack;
  340. end;
  341. _DIR_IFDEF : begin
  342. current_scanner^.skipspace;
  343. hs:=current_scanner^.readid;
  344. mac:=pmacrosym(macros^.search(hs));
  345. if assigned(mac) then
  346. mac^.is_used:=true;
  347. current_scanner^.addpreprocstack(pp_ifdef,assigned(mac) and mac^.defined,hs,scan_c_ifdef_found);
  348. end;
  349. _DIR_IFOPT : begin
  350. current_scanner^.skipspace;
  351. hs:=current_scanner^.readid;
  352. if (length(hs)>1) then
  353. Message(scan_w_illegal_switch)
  354. else
  355. begin
  356. state:=current_scanner^.ReadState;
  357. if state in ['-','+'] then
  358. found:=CheckSwitch(hs[1],state);
  359. end;
  360. current_scanner^.addpreprocstack(pp_ifopt,found,hs,scan_c_ifopt_found);
  361. end;
  362. _DIR_IF : begin
  363. current_scanner^.skipspace;
  364. { start preproc expression scanner }
  365. preproc_token:=current_scanner^.readpreproc;
  366. hs:=read_expr;
  367. current_scanner^.addpreprocstack(pp_if,hs<>'0',hs,scan_c_if_found);
  368. end;
  369. _DIR_IFNDEF : begin
  370. current_scanner^.skipspace;
  371. hs:=current_scanner^.readid;
  372. mac:=pmacrosym(macros^.search(hs));
  373. if assigned(mac) then
  374. mac^.is_used:=true;
  375. current_scanner^.addpreprocstack(pp_ifndef,not(assigned(mac) and mac^.defined),hs,scan_c_ifndef_found);
  376. end;
  377. end;
  378. { accept the text ? }
  379. if (current_scanner^.preprocstack=nil) or current_scanner^.preprocstack^.accept then
  380. break
  381. else
  382. begin
  383. current_scanner^.gettokenpos;
  384. Message(scan_c_skipping_until);
  385. repeat
  386. current_scanner^.skipuntildirective;
  387. t:=Get_Directive(current_scanner^.readid);
  388. until is_conditional(t);
  389. current_scanner^.gettokenpos;
  390. Message1(scan_d_handling_switch,'$'+directive[t]);
  391. end;
  392. end;
  393. aktfilepos:=oldaktfilepos;
  394. end;
  395. procedure dir_define(t:tdirectivetoken);
  396. var
  397. hs : string;
  398. bracketcount : longint;
  399. mac : pmacrosym;
  400. macropos : longint;
  401. macrobuffer : pmacrobuffer;
  402. begin
  403. current_scanner^.skipspace;
  404. hs:=current_scanner^.readid;
  405. mac:=pmacrosym(macros^.search(hs));
  406. if not assigned(mac) then
  407. begin
  408. mac:=new(pmacrosym,init(hs));
  409. mac^.defined:=true;
  410. Message1(parser_m_macro_defined,mac^.name);
  411. macros^.insert(mac);
  412. end
  413. else
  414. begin
  415. Message1(parser_m_macro_defined,mac^.name);
  416. mac^.defined:=true;
  417. { delete old definition }
  418. if assigned(mac^.buftext) then
  419. begin
  420. freemem(mac^.buftext,mac^.buflen);
  421. mac^.buftext:=nil;
  422. end;
  423. end;
  424. mac^.is_used:=true;
  425. if (cs_support_macro in aktmoduleswitches) then
  426. begin
  427. { key words are never substituted }
  428. if is_keyword(hs) then
  429. Message(scan_e_keyword_cant_be_a_macro);
  430. { !!!!!! handle macro params, need we this? }
  431. current_scanner^.skipspace;
  432. { may be a macro? }
  433. if c=':' then
  434. begin
  435. current_scanner^.readchar;
  436. if c='=' then
  437. begin
  438. new(macrobuffer);
  439. macropos:=0;
  440. { parse macro, brackets are counted so it's possible
  441. to have a $ifdef etc. in the macro }
  442. bracketcount:=0;
  443. repeat
  444. current_scanner^.readchar;
  445. case c of
  446. '}' :
  447. if (bracketcount=0) then
  448. break
  449. else
  450. dec(bracketcount);
  451. '{' :
  452. inc(bracketcount);
  453. #26 :
  454. current_scanner^.end_of_file;
  455. end;
  456. macrobuffer^[macropos]:=c;
  457. inc(macropos);
  458. if macropos>maxmacrolen then
  459. Message(scan_f_macro_buffer_overflow);
  460. until false;
  461. { free buffer of macro ?}
  462. if assigned(mac^.buftext) then
  463. freemem(mac^.buftext,mac^.buflen);
  464. { get new mem }
  465. getmem(mac^.buftext,macropos);
  466. mac^.buflen:=macropos;
  467. { copy the text }
  468. move(macrobuffer^,mac^.buftext^,macropos);
  469. dispose(macrobuffer);
  470. end;
  471. end;
  472. end
  473. else
  474. begin
  475. { check if there is an assignment, then we need to give a
  476. warning }
  477. current_scanner^.skipspace;
  478. if c=':' then
  479. begin
  480. current_scanner^.readchar;
  481. if c='=' then
  482. Comment(V_Warning,'Marco support has been turned off');
  483. end;
  484. end;
  485. end;
  486. procedure dir_undef(t:tdirectivetoken);
  487. var
  488. hs : string;
  489. mac : pmacrosym;
  490. begin
  491. current_scanner^.skipspace;
  492. hs:=current_scanner^.readid;
  493. mac:=pmacrosym(macros^.search(hs));
  494. if not assigned(mac) then
  495. begin
  496. mac:=new(pmacrosym,init(hs));
  497. Message1(parser_m_macro_undefined,mac^.name);
  498. mac^.defined:=false;
  499. macros^.insert(mac);
  500. end
  501. else
  502. begin
  503. Message1(parser_m_macro_undefined,mac^.name);
  504. mac^.defined:=false;
  505. { delete old definition }
  506. if assigned(mac^.buftext) then
  507. begin
  508. freemem(mac^.buftext,mac^.buflen);
  509. mac^.buftext:=nil;
  510. end;
  511. end;
  512. mac^.is_used:=true;
  513. end;
  514. procedure dir_message(t:tdirectivetoken);
  515. var
  516. w : longint;
  517. begin
  518. case t of
  519. _DIR_STOP,
  520. _DIR_FATAL : w:=scan_f_user_defined;
  521. _DIR_ERROR : w:=scan_e_user_defined;
  522. _DIR_WARNING : w:=scan_w_user_defined;
  523. _DIR_HINT : w:=scan_h_user_defined;
  524. _DIR_NOTE : w:=scan_n_user_defined;
  525. _DIR_MESSAGE,
  526. _DIR_INFO : w:=scan_i_user_defined;
  527. end;
  528. current_scanner^.skipspace;
  529. Message1(w,current_scanner^.readcomment);
  530. end;
  531. procedure dir_moduleswitch(t:tdirectivetoken);
  532. var
  533. sw : tmoduleswitch;
  534. state : char;
  535. begin
  536. sw:=cs_modulenone;
  537. case t of
  538. _DIR_GOTO : sw:=cs_support_goto;
  539. _DIR_MACRO : sw:=cs_support_macro;
  540. _DIR_INLINE : sw:=cs_support_inline;
  541. _DIR_SMARTLINK : sw:=cs_create_smart;
  542. _DIR_STATIC : sw:=cs_static_keyword;
  543. end;
  544. state:=current_scanner^.readstate;
  545. if (sw<>cs_modulenone) and (state in ['-','+']) then
  546. begin
  547. if state='-' then
  548. aktmoduleswitches:=aktmoduleswitches-[sw]
  549. else
  550. aktmoduleswitches:=aktmoduleswitches+[sw];
  551. end;
  552. end;
  553. procedure dir_localswitch(t:tdirectivetoken);
  554. var
  555. sw : tlocalswitch;
  556. state : char;
  557. begin
  558. sw:=cs_localnone;
  559. {$ifdef SUPPORT_MMX}
  560. case t of
  561. _DIR_MMX : sw:=cs_mmx;
  562. _DIR_SATURATION : sw:=cs_mmx_saturation;
  563. end;
  564. {$endif}
  565. state:=current_scanner^.readstate;
  566. if (sw<>cs_localnone) and (state in ['-','+']) then
  567. begin
  568. if not localswitcheschanged then
  569. nextaktlocalswitches:=aktlocalswitches;
  570. if state='-' then
  571. nextaktlocalswitches:=nextaktlocalswitches-[sw]
  572. else
  573. nextaktlocalswitches:=nextaktlocalswitches+[sw];
  574. localswitcheschanged:=true;
  575. end;
  576. end;
  577. procedure dir_include(t:tdirectivetoken);
  578. var
  579. hs : string;
  580. path : dirstr;
  581. name : namestr;
  582. ext : extstr;
  583. hp : pinputfile;
  584. i : longint;
  585. found : boolean;
  586. begin
  587. current_scanner^.skipspace;
  588. hs:=current_scanner^.readcomment;
  589. i:=length(hs);
  590. while (i>0) and (hs[i]=' ') do
  591. dec(i);
  592. Delete(hs,i+1,length(hs)-i);
  593. if hs='' then
  594. exit;
  595. if (hs[1]='%') then
  596. begin
  597. { case insensitive }
  598. hs:=upper(hs);
  599. { remove %'s }
  600. Delete(hs,1,1);
  601. if hs[length(hs)]='%' then
  602. Delete(hs,length(hs),1);
  603. { save old }
  604. path:=hs;
  605. { first check for internal macros }
  606. if hs='TIME' then
  607. hs:=gettimestr
  608. else
  609. if hs='DATE' then
  610. hs:=getdatestr
  611. else
  612. if hs='FILE' then
  613. hs:=current_module^.sourcefiles^.get_file_name(aktfilepos.fileindex)
  614. else
  615. if hs='LINE' then
  616. hs:=tostr(aktfilepos.line)
  617. else
  618. if hs='FPCVERSION' then
  619. hs:=version_string
  620. else
  621. if hs='FPCTARGET' then
  622. hs:=target_cpu_string
  623. else
  624. hs:=getenv(hs);
  625. if hs='' then
  626. Message1(scan_w_include_env_not_found,path);
  627. { make it a stringconst }
  628. hs:=''''+hs+'''';
  629. current_scanner^.insertmacro(path,@hs[1],length(hs));
  630. end
  631. else
  632. begin
  633. hs:=FixFileName(hs);
  634. fsplit(hs,path,name,ext);
  635. { look for the include file
  636. 1. specified path,path of current inputfile,current dir
  637. 2. local includepath
  638. 3. global includepath }
  639. found:=false;
  640. if path<>'' then
  641. path:=path+';';
  642. path:=FindFile(name+ext,path+current_scanner^.inputfile^.path^+';.'+DirSep,found);
  643. if (not found) then
  644. path:=current_module^.localincludesearchpath.FindFile(name+ext,found);
  645. if (not found) then
  646. path:=includesearchpath.FindFile(name+ext,found);
  647. { shutdown current file }
  648. current_scanner^.tempcloseinputfile;
  649. { load new file }
  650. hp:=do_openinputfile(path+name+ext);
  651. current_scanner^.addfile(hp);
  652. if not current_scanner^.openinputfile then
  653. Message1(scan_f_cannot_open_includefile,hs);
  654. Message1(scan_t_start_include_file,current_scanner^.inputfile^.path^+current_scanner^.inputfile^.name^);
  655. current_scanner^.reload;
  656. { process first read char }
  657. case c of
  658. #26 : current_scanner^.reload;
  659. #10,
  660. #13 : current_scanner^.linebreak;
  661. end;
  662. { register for refs }
  663. current_module^.sourcefiles^.register_file(hp);
  664. end;
  665. end;
  666. procedure dir_description(t:tdirectivetoken);
  667. begin
  668. if not (target_info.target in [target_i386_os2,target_i386_win32,target_i386_netware]) then
  669. Message(scan_w_decription_not_support);
  670. { change description global var in all cases }
  671. { it not used but in win32, os2 and netware }
  672. current_scanner^.skipspace;
  673. description:=current_scanner^.readcomment;
  674. end;
  675. procedure dir_version(t:tdirectivetoken);
  676. var
  677. major, minor, revision : longint;
  678. error : integer;
  679. begin
  680. if not (target_info.target in [target_i386_os2,target_i386_win32,target_i386_netware]) then // AD
  681. begin
  682. Message(scan_n_version_not_support);
  683. exit;
  684. end;
  685. if (compile_level<>1) then
  686. Message(scan_n_only_exe_version)
  687. else
  688. begin
  689. { change description global var in all cases }
  690. { it not used but in win32, os2 and netware }
  691. current_scanner^.skipspace;
  692. { we should only accept Major.Minor format for win32 and os2 }
  693. current_scanner^.readnumber;
  694. major:=0;
  695. minor:=0;
  696. revision:=0;
  697. valint(pattern,major,error);
  698. if error<>0 then
  699. begin
  700. Message1(scan_w_wrong_version_ignored,pattern);
  701. exit;
  702. end;
  703. if c='.' then
  704. begin
  705. current_scanner^.readchar;
  706. current_scanner^.readnumber;
  707. valint(pattern,minor,error);
  708. if error<>0 then
  709. begin
  710. Message1(scan_w_wrong_version_ignored,tostr(major)+'.'+pattern);
  711. exit;
  712. end;
  713. if (c='.') and
  714. (target_info.target = target_i386_netware) then // AD
  715. begin
  716. current_scanner^.readchar;
  717. current_scanner^.readnumber;
  718. valint(pattern,revision,error);
  719. if error<>0 then
  720. begin
  721. Message1(scan_w_wrong_version_ignored,tostr(revision)+'.'+pattern);
  722. exit;
  723. end;
  724. dllmajor:=major;
  725. dllminor:=minor;
  726. dllrevision:=revision;
  727. dllversion:=tostr(major)+','+tostr(minor)+','+tostr(revision);
  728. end
  729. else
  730. begin
  731. dllmajor:=major;
  732. dllminor:=minor;
  733. dllversion:=tostr(major)+'.'+tostr(minor);
  734. end;
  735. end
  736. else
  737. dllversion:=tostr(major);
  738. end;
  739. end;
  740. procedure dir_linkobject(t:tdirectivetoken);
  741. var
  742. s : string;
  743. begin
  744. current_scanner^.skipspace;
  745. s:=AddExtension(FixFileName(current_scanner^.readcomment),target_info.objext);
  746. {$IFDEF NEWST}
  747. current_module^.linkotherofiles.
  748. insert(new(Plinkitem,init(s,link_allways)));
  749. {$ELSE}
  750. current_module^.linkotherofiles.
  751. insert(s,link_allways);
  752. {$ENDIF NEWST}
  753. end;
  754. procedure dir_resource(t:tdirectivetoken);
  755. var
  756. s : string;
  757. begin
  758. current_scanner^.skipspace;
  759. s:=current_scanner^.readcomment;
  760. { replace * with current module name.
  761. This should always be defined. }
  762. if s[1]='*' then
  763. if Assigned(Current_Module) then
  764. begin
  765. delete(S,1,1);
  766. insert(lower(current_module^.modulename^),S,1);
  767. end;
  768. s:=AddExtension(FixFileName(s),target_info.resext);
  769. if target_info.res<>res_none then
  770. if (target_info.res = res_i386_emx) and
  771. not (Current_Module^.ResourceFiles.Empty) then
  772. Message(scan_w_only_one_resourcefile_supported)
  773. else
  774. current_module^.resourcefiles.insert(FixFileName(s))
  775. else
  776. Message(scan_e_resourcefiles_not_supported);
  777. end;
  778. {$ifndef PAVEL_LINKLIB}
  779. procedure dir_linklib(t:tdirectivetoken);
  780. var
  781. s : string;
  782. quote : char;
  783. begin
  784. current_scanner^.skipspace;
  785. { This way spaces are also allowed in library names
  786. if quoted PM }
  787. if (c='''') or (c='"') then
  788. begin
  789. quote:=c;
  790. current_scanner^.readchar;
  791. s:=current_scanner^.readcomment;
  792. if pos(quote,s)>0 then
  793. s:=copy(s,1,pos(quote,s)-1);
  794. end
  795. else
  796. begin
  797. current_scanner^.readstring;
  798. s:=orgpattern;
  799. if c='.' then
  800. begin
  801. s:=s+'.';
  802. current_scanner^.readchar;
  803. current_scanner^.readstring;
  804. s:=s+orgpattern;
  805. end;
  806. end;
  807. {$IFDEF NEWST}
  808. current_module^.linkOtherSharedLibs.
  809. insert(new(Plinkitem,init(s,link_allways)));
  810. {$ELSE}
  811. current_module^.linkOtherSharedLibs.
  812. insert(s,link_allways);
  813. {$ENDIF}
  814. end;
  815. {$else PAVEL_LINKLIB}
  816. procedure dir_linklib(t:tdirectivetoken);
  817. var
  818. s:string;
  819. libname,linkmodeStr:string;
  820. p:longint;
  821. type
  822. tLinkMode=(lm_dynamic,lm_static);
  823. var
  824. linkMode:tLinkMode;
  825. function ExtractLinkMode:tLinkMode;
  826. var
  827. p:longint;
  828. begin
  829. p:=pos(',',linkmodeStr);
  830. if p>0 then
  831. linkmodeStr:=copy(linkmodeStr,1,pred(p));
  832. for p:=1 to length(linkmodeStr)do
  833. linkmodeStr[p]:=upcase(linkmodeStr[p]);
  834. if linkmodeStr='STATIC' then
  835. ExtractLinkMode:=lm_static
  836. else
  837. ExtractLinkMode:=lm_dynamic
  838. end;
  839. procedure MangleLibName(mode:tLinkMode);
  840. begin
  841. if (libname[1]='''')and(libname[length(libname)]='''')then
  842. begin
  843. delete(libname,1,1);
  844. delete(libname,length(libname),1);
  845. end
  846. else
  847. begin
  848. libname:=target_os.libprefix+libname;
  849. case mode of
  850. lm_static:
  851. libname:=AddExtension(FixFileName(libname),target_os.staticlibext);
  852. lm_dynamic:
  853. libname:=AddExtension(FixFileName(libname),target_os.sharedlibext);
  854. end;
  855. end;
  856. end;
  857. begin
  858. current_scanner^.skipspace;
  859. s:=current_scanner^.readcomment;
  860. p:=pos(',',s);
  861. if p=0 then
  862. begin
  863. libname:=s;
  864. linkmodeStr:=''
  865. end
  866. else
  867. begin
  868. libname:=copy(s,1,pred(p));
  869. linkmodeStr:=copy(s,succ(p),255);
  870. end;
  871. if(libname='')or(libname='''''')then
  872. exit;
  873. linkMode:=ExtractLinkMode;
  874. MangleLibName(linkMode);
  875. if linkMode=lm_static then
  876. {$IFDEF NEWST}
  877. current_module^.linkOtherStaticLibs.
  878. insert(new(Plinkitem,init(FixFileName(libname),link_allways)))
  879. {$ELSE}
  880. current_module^.linkOtherStaticLibs.
  881. insert(FixFileName(libname),link_allways)
  882. {$ENDIF}
  883. else
  884. {$IFDEF NEWST}
  885. current_module^.linkOtherSharedLibs.
  886. insert(new(Plinkitem,init(FixFileName(libname),link_allways)));
  887. {$ELSE}
  888. current_module^.linkOtherSharedLibs.
  889. insert(FixFileName(libname),link_allways);
  890. {$ENDIF}
  891. end;
  892. {$endif PAVEL_LINKLIB}
  893. procedure dir_outputformat(t:tdirectivetoken);
  894. begin
  895. if not current_module^.in_global then
  896. Message(scan_w_switch_is_global)
  897. else
  898. begin
  899. current_scanner^.skipspace;
  900. if set_string_asm(current_scanner^.readid) then
  901. aktoutputformat:=target_asm.id
  902. else
  903. Message(scan_w_illegal_switch);
  904. end;
  905. end;
  906. procedure dir_unitpath(t:tdirectivetoken);
  907. begin
  908. if not current_module^.in_global then
  909. Message(scan_w_switch_is_global)
  910. else
  911. begin
  912. current_scanner^.skipspace;
  913. current_module^.localunitsearchpath.AddPath(current_scanner^.readcomment,false);
  914. end;
  915. end;
  916. procedure dir_includepath(t:tdirectivetoken);
  917. begin
  918. if not current_module^.in_global then
  919. Message(scan_w_switch_is_global)
  920. else
  921. begin
  922. current_scanner^.skipspace;
  923. current_module^.localincludesearchpath.AddPath(current_scanner^.readcomment,false);
  924. end;
  925. end;
  926. procedure dir_librarypath(t:tdirectivetoken);
  927. begin
  928. if not current_module^.in_global then
  929. Message(scan_w_switch_is_global)
  930. else
  931. begin
  932. current_scanner^.skipspace;
  933. current_module^.locallibrarysearchpath.AddPath(current_scanner^.readcomment,false);
  934. end;
  935. end;
  936. procedure dir_objectpath(t:tdirectivetoken);
  937. begin
  938. if not current_module^.in_global then
  939. Message(scan_w_switch_is_global)
  940. else
  941. begin
  942. current_scanner^.skipspace;
  943. current_module^.localobjectsearchpath.AddPath(current_scanner^.readcomment,false);
  944. end;
  945. end;
  946. procedure dir_mode(t:tdirectivetoken);
  947. begin
  948. if not current_module^.in_global then
  949. Message(scan_w_switch_is_global)
  950. else
  951. begin
  952. current_scanner^.skipspace;
  953. current_scanner^.readstring;
  954. if pattern='DEFAULT' then
  955. aktmodeswitches:=initmodeswitches
  956. else
  957. if pattern='DELPHI' then
  958. aktmodeswitches:=delphimodeswitches
  959. else
  960. if pattern='TP' then
  961. aktmodeswitches:=tpmodeswitches
  962. else
  963. if pattern='FPC' then
  964. aktmodeswitches:=fpcmodeswitches
  965. else
  966. if pattern='OBJFPC' then
  967. aktmodeswitches:=objfpcmodeswitches
  968. else
  969. if pattern='GPC' then
  970. aktmodeswitches:=gpcmodeswitches
  971. else
  972. Message(scan_w_illegal_switch);
  973. end;
  974. end;
  975. procedure dir_packrecords(t:tdirectivetoken);
  976. var
  977. hs : string;
  978. begin
  979. current_scanner^.skipspace;
  980. if not(c in ['0'..'9']) then
  981. begin
  982. hs:=current_scanner^.readid;
  983. if (hs='C') then
  984. aktpackrecords:=packrecord_C
  985. else
  986. if (hs='NORMAL') or (hs='DEFAULT') then
  987. aktpackrecords:=packrecord_2
  988. else
  989. Message(scan_w_only_pack_records);
  990. end
  991. else
  992. begin
  993. case current_scanner^.readval of
  994. 1 : aktpackrecords:=packrecord_1;
  995. 2 : aktpackrecords:=packrecord_2;
  996. 4 : aktpackrecords:=packrecord_4;
  997. 8 : aktpackrecords:=packrecord_8;
  998. 16 : aktpackrecords:=packrecord_16;
  999. 32 : aktpackrecords:=packrecord_32;
  1000. else
  1001. Message(scan_w_only_pack_records);
  1002. end;
  1003. end;
  1004. end;
  1005. procedure dir_maxfpuregisters(t:tdirectivetoken);
  1006. var
  1007. l : longint;
  1008. hs : string;
  1009. begin
  1010. current_scanner^.skipspace;
  1011. if not(c in ['0'..'9']) then
  1012. begin
  1013. hs:=current_scanner^.readid;
  1014. if (hs='NORMAL') or (hs='DEFAULT') then
  1015. aktmaxfpuregisters:=-1
  1016. else
  1017. Message(scan_e_invalid_maxfpureg_value);
  1018. end
  1019. else
  1020. begin
  1021. l:=current_scanner^.readval;
  1022. case l of
  1023. 0..8:
  1024. aktmaxfpuregisters:=l;
  1025. else
  1026. Message(scan_e_invalid_maxfpureg_value);
  1027. end;
  1028. end;
  1029. end;
  1030. procedure dir_packenum(t:tdirectivetoken);
  1031. var
  1032. hs : string;
  1033. begin
  1034. if t in [_DIR_Z1,_DIR_Z2,_DIR_Z4] then
  1035. begin
  1036. aktpackenum:=ord(pattern[2])-ord('0');
  1037. exit;
  1038. end;
  1039. current_scanner^.skipspace;
  1040. if not(c in ['0'..'9']) then
  1041. begin
  1042. hs:=current_scanner^.readid;
  1043. if (hs='NORMAL') or (hs='DEFAULT') then
  1044. aktpackenum:=4
  1045. else
  1046. Message(scan_w_only_pack_enum);
  1047. end
  1048. else
  1049. begin
  1050. case current_scanner^.readval of
  1051. 1 : aktpackenum:=1;
  1052. 2 : aktpackenum:=2;
  1053. 4 : aktpackenum:=4;
  1054. else
  1055. Message(scan_w_only_pack_enum);
  1056. end;
  1057. end;
  1058. end;
  1059. {$ifdef testvarsets}
  1060. procedure dir_setalloc(t:tdirectivetoken);
  1061. var
  1062. hs : string;
  1063. begin
  1064. current_scanner^.skipspace;
  1065. if not(c in ['1','2','4']) then
  1066. begin
  1067. hs:=current_scanner^.readid;
  1068. if (hs='FIXED') or ((hs='DEFAULT') OR (hs='NORMAL')) then
  1069. aktsetalloc:=0 {Fixed mode, sets are 4 or 32 bytes}
  1070. else
  1071. Message(scan_w_only_packset);
  1072. end
  1073. else
  1074. begin
  1075. case current_scanner^.readval of
  1076. 1 : aktpackenum:=1;
  1077. 2 : aktpackenum:=2;
  1078. 4 : aktpackenum:=4;
  1079. else
  1080. Message(scan_w_only_packset);
  1081. end;
  1082. end;
  1083. end;
  1084. {$ENDIF}
  1085. procedure dir_apptype(t:tdirectivetoken);
  1086. var
  1087. hs : string;
  1088. begin
  1089. if target_info.target<>target_i386_win32 then
  1090. Message(scan_w_app_type_not_support);
  1091. if not current_module^.in_global then
  1092. Message(scan_w_switch_is_global)
  1093. else
  1094. begin
  1095. current_scanner^.skipspace;
  1096. hs:=current_scanner^.readid;
  1097. if hs='GUI' then
  1098. apptype:=at_gui
  1099. else if hs='CONSOLE' then
  1100. apptype:=at_cui
  1101. else
  1102. Message1(scan_w_unsupported_app_type,hs);
  1103. end;
  1104. end;
  1105. procedure dir_wait(t:tdirectivetoken);
  1106. var had_info : boolean;
  1107. begin
  1108. had_info:=(status.verbosity and V_Info)<>0;
  1109. { this message should allways appear !! }
  1110. status.verbosity:=status.verbosity or V_Info;
  1111. Message(scan_i_press_enter);
  1112. readln;
  1113. If not(had_info) then
  1114. status.verbosity:=status.verbosity and (not V_Info);
  1115. end;
  1116. procedure dir_asmmode(t:tdirectivetoken);
  1117. var
  1118. s : string;
  1119. begin
  1120. current_scanner^.skipspace;
  1121. s:=current_scanner^.readid;
  1122. If Inside_asm_statement then
  1123. Message1(scan_w_no_asm_reader_switch_inside_asm,s);
  1124. if s='DEFAULT' then
  1125. aktasmmode:=initasmmode
  1126. else
  1127. if not set_string_asmmode(s,aktasmmode) then
  1128. Message1(scan_w_unsupported_asmmode_specifier,s);
  1129. end;
  1130. procedure dir_oldasmmode(t:tdirectivetoken);
  1131. begin
  1132. If Inside_asm_statement then
  1133. Message1(scan_w_no_asm_reader_switch_inside_asm,directive[t]);
  1134. {$ifdef i386}
  1135. case t of
  1136. _DIR_I386_ATT : aktasmmode:=asmmode_i386_att;
  1137. _DIR_I386_DIRECT : aktasmmode:=asmmode_i386_direct;
  1138. _DIR_I386_INTEL : aktasmmode:=asmmode_i386_intel;
  1139. end;
  1140. {$endif i386}
  1141. end;
  1142. procedure dir_delphiswitch(t:tdirectivetoken);
  1143. var
  1144. sw,state : char;
  1145. begin
  1146. case t of
  1147. _DIR_ALIGN : sw:='A';
  1148. _DIR_ASSERTIONS : sw:='C';
  1149. _DIR_BOOLEVAL : sw:='B';
  1150. _DIR_DEBUGINFO : sw:='D';
  1151. _DIR_IOCHECKS : sw:='I';
  1152. _DIR_LOCALSYMBOLS : sw:='L';
  1153. _DIR_LONGSTRINGS : sw:='H';
  1154. _DIR_OPENSTRINGS : sw:='P';
  1155. _DIR_OVERFLOWCHECKS : sw:='Q';
  1156. _DIR_RANGECHECKS : sw:='R';
  1157. _DIR_REFERENCEINFO : sw:='Y';
  1158. _DIR_STACKFRAMES : sw:='W';
  1159. _DIR_TYPEDADDRESS : sw:='T';
  1160. _DIR_TYPEINFO : sw:='M';
  1161. _DIR_VARSTRINGCHECKS : sw:='V';
  1162. else
  1163. exit;
  1164. end;
  1165. { c contains the next char, a + or - would be fine }
  1166. state:=current_scanner^.readstate;
  1167. if state in ['-','+'] then
  1168. HandleSwitch(sw,state);
  1169. end;
  1170. procedure dir_memory(t:tdirectivetoken);
  1171. var
  1172. l : longint;
  1173. begin
  1174. current_scanner^.skipspace;
  1175. l:=current_scanner^.readval;
  1176. if l>1024 then
  1177. stacksize:=l;
  1178. current_scanner^.skipspace;
  1179. if c=',' then
  1180. begin
  1181. current_scanner^.readchar;
  1182. current_scanner^.skipspace;
  1183. l:=current_scanner^.readval;
  1184. if l>1024 then
  1185. heapsize:=l;
  1186. end;
  1187. if c=',' then
  1188. begin
  1189. current_scanner^.readchar;
  1190. current_scanner^.skipspace;
  1191. l:=current_scanner^.readval;
  1192. { Ignore this value, because the limit is set by the OS
  1193. info and shouldn't be changed by the user (PFV) }
  1194. end;
  1195. end;
  1196. procedure dir_setverbose(t:tdirectivetoken);
  1197. var
  1198. flag,
  1199. state : char;
  1200. begin
  1201. case t of
  1202. _DIR_HINTS : flag:='H';
  1203. _DIR_WARNINGS : flag:='W';
  1204. _DIR_NOTES : flag:='N';
  1205. else
  1206. exit;
  1207. end;
  1208. { support ON/OFF }
  1209. state:=current_scanner^.ReadState;
  1210. SetVerbosity(flag+state);
  1211. end;
  1212. type
  1213. tdirectiveproc=procedure(t:tdirectivetoken);
  1214. const
  1215. directiveproc:array[tdirectivetoken] of tdirectiveproc=(
  1216. {_DIR_NONE} nil,
  1217. {_DIR_ALIGN} dir_delphiswitch,
  1218. {_DIR_APPTYPE} dir_apptype,
  1219. {_DIR_ASMMODE} dir_asmmode,
  1220. {_DIR_ASSERTION} dir_delphiswitch,
  1221. {_DIR_BOOLEVAL} dir_delphiswitch,
  1222. {_DIR_D} dir_description,
  1223. {_DIR_DEBUGINFO} dir_delphiswitch,
  1224. {_DIR_DEFINE} dir_define,
  1225. {_DIR_DESCRIPTION} dir_description,
  1226. {_DIR_ELSE} dir_conditional,
  1227. {_DIR_ENDIF} dir_conditional,
  1228. {_DIR_ERROR} dir_message,
  1229. {_DIR_EXTENDEDSYNTAX} dir_delphiswitch,
  1230. {_DIR_FATAL} dir_message,
  1231. {_DIR_GOTO} dir_moduleswitch,
  1232. {_DIR_HINT} dir_message,
  1233. {_DIR_HINTS} dir_setverbose,
  1234. {_DIR_I} dir_include,
  1235. {_DIR_I386_ATT} dir_oldasmmode,
  1236. {_DIR_I386_DIRECT} dir_oldasmmode,
  1237. {_DIR_I386_INTEL} dir_oldasmmode,
  1238. {_DIR_IOCHECKS} dir_delphiswitch,
  1239. {_DIR_IF} dir_conditional,
  1240. {_DIR_IFDEF} dir_conditional,
  1241. {_DIR_IFNDEF} dir_conditional,
  1242. {_DIR_IFOPT} dir_conditional,
  1243. {_DIR_INCLUDE} dir_include,
  1244. {_DIR_INCLUDEPATH} dir_includepath,
  1245. {_DIR_INFO} dir_message,
  1246. {_DIR_INLINE} dir_moduleswitch,
  1247. {_DIR_L} dir_linkobject,
  1248. {_DIR_LIBRARYPATH} dir_librarypath,
  1249. {_DIR_LINK} dir_linkobject,
  1250. {_DIR_LINKLIB} dir_linklib,
  1251. {_DIR_LOCALSYMBOLS} dir_delphiswitch,
  1252. {_DIR_LONGSTRINGS} dir_delphiswitch,
  1253. {_DIR_M} dir_memory,
  1254. {_DIR_MACRO} dir_moduleswitch,
  1255. {_DIR_MAXFPUREGISTERS} dir_maxfpuregisters,
  1256. {_DIR_MEMORY} dir_memory,
  1257. {_DIR_MESSAGE} dir_message,
  1258. {_DIR_MINENUMSIZE} dir_packenum,
  1259. {_DIR_MMX} dir_localswitch,
  1260. {_DIR_MODE} dir_mode,
  1261. {_DIR_NOTE} dir_message,
  1262. {_DIR_NOTES} dir_setverbose,
  1263. {_DIR_OBJECTPATH} dir_objectpath,
  1264. {_DIR_OPENSTRINGS} dir_delphiswitch,
  1265. {_DIR_OUTPUT_FORMAT} dir_outputformat,
  1266. {_DIR_OVERFLOWCHECKS} dir_delphiswitch,
  1267. {_DIR_PACKENUM} dir_packenum,
  1268. {_DIR_PACKRECORDS} dir_packrecords,
  1269. {$IFDEF TestVarsets}
  1270. {_DIR_PACKSET} dir_packset,
  1271. {$ENDIF}
  1272. {_DIR_R} dir_resource,
  1273. {_DIR_RANGECHECKS} dir_delphiswitch,
  1274. {_DIR_REFERENCEINFO} dir_delphiswitch,
  1275. {_DIR_SATURATION} dir_localswitch,
  1276. {_DIR_SMARTLINK} dir_moduleswitch,
  1277. {_DIR_STACKFRAMES} dir_delphiswitch,
  1278. {_DIR_STATIC} dir_moduleswitch,
  1279. {_DIR_STOP} dir_message,
  1280. {_DIR_TYPEDADDRESS} dir_delphiswitch,
  1281. {_DIR_TYPEINFO} dir_delphiswitch,
  1282. {_DIR_UNDEF} dir_undef,
  1283. {_DIR_UNITPATH} dir_unitpath,
  1284. {_DIR_VARSTRINGCHECKS} dir_delphiswitch,
  1285. {_DIR_VERSION} dir_version,
  1286. {_DIR_WAIT} dir_wait,
  1287. {_DIR_WARNING} dir_message,
  1288. {_DIR_WARNINGS} dir_setverbose,
  1289. {_DIR_Z1} dir_packenum,
  1290. {_DIR_Z2} dir_packenum,
  1291. {_DIR_Z4} dir_packenum
  1292. );
  1293. {-------------------------------------------
  1294. Main switches handling
  1295. -------------------------------------------}
  1296. procedure handledirectives;
  1297. var
  1298. t : tdirectivetoken;
  1299. p : tdirectiveproc;
  1300. hs : string;
  1301. begin
  1302. current_scanner^.gettokenpos;
  1303. current_scanner^.readchar; {Remove the $}
  1304. hs:=current_scanner^.readid;
  1305. if parapreprocess then
  1306. begin
  1307. t:=Get_Directive(hs);
  1308. if not(is_conditional(t) or (t=_DIR_DEFINE) or (t=_DIR_UNDEF)) then
  1309. begin
  1310. preprocfile^.AddSpace;
  1311. preprocfile^.Add('{$'+hs+current_scanner^.readcomment+'}');
  1312. exit;
  1313. end;
  1314. end;
  1315. { skip this directive? }
  1316. if current_scanner^.ignoredirectives.find(hs) then
  1317. begin
  1318. if (current_scanner^.comment_level>0) then
  1319. current_scanner^.readcomment;
  1320. { we've read the whole comment }
  1321. aktcommentstyle:=comment_none;
  1322. exit;
  1323. end;
  1324. if hs='' then
  1325. begin
  1326. Message1(scan_w_illegal_switch,'$'+hs);
  1327. end;
  1328. { Check for compiler switches }
  1329. while (length(hs)=1) and (c in ['-','+']) do
  1330. begin
  1331. HandleSwitch(hs[1],c);
  1332. current_scanner^.readchar; {Remove + or -}
  1333. if c=',' then
  1334. begin
  1335. current_scanner^.readchar; {Remove , }
  1336. { read next switch, support $v+,$+}
  1337. hs:=current_scanner^.readid;
  1338. if (hs='') then
  1339. begin
  1340. if (c='$') and (m_fpc in aktmodeswitches) then
  1341. begin
  1342. current_scanner^.readchar; { skip $ }
  1343. hs:=current_scanner^.readid;
  1344. end;
  1345. if (hs='') then
  1346. Message1(scan_w_illegal_directive,'$'+c);
  1347. end
  1348. else
  1349. Message1(scan_d_handling_switch,'$'+hs);
  1350. end
  1351. else
  1352. hs:='';
  1353. end;
  1354. { directives may follow switches after a , }
  1355. if hs<>'' then
  1356. begin
  1357. t:=Get_Directive(hs);
  1358. if t<>_DIR_NONE then
  1359. begin
  1360. p:=directiveproc[t];
  1361. {$ifndef TP}
  1362. if assigned(p) then
  1363. {$else}
  1364. if @p<>nil then
  1365. {$endif}
  1366. p(t);
  1367. end
  1368. else
  1369. begin
  1370. current_scanner^.ignoredirectives.insert(hs);
  1371. Message1(scan_w_illegal_directive,'$'+hs);
  1372. end;
  1373. { conditionals already read the comment }
  1374. if (current_scanner^.comment_level>0) then
  1375. current_scanner^.readcomment;
  1376. { we've read the whole comment }
  1377. aktcommentstyle:=comment_none;
  1378. end;
  1379. end;
  1380. {
  1381. $Log$
  1382. Revision 1.6 2000-09-11 17:00:23 florian
  1383. + first implementation of Netware Module support, thanks to
  1384. Armin Diehl ([email protected]) for providing the patches
  1385. Revision 1.5 2000/09/10 21:18:15 peter
  1386. * macro warning (merged)
  1387. Revision 1.4 2000/08/12 15:30:44 peter
  1388. * IDE patch for stream reading (merged)
  1389. Revision 1.3 2000/08/08 19:28:57 peter
  1390. * memdebug/memory patches (merged)
  1391. * only once illegal directive (merged)
  1392. Revision 1.2 2000/07/13 11:32:49 michael
  1393. + removed logs
  1394. }