scandir.pas 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 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. unit scandir;
  19. {$i fpcdefs.inc}
  20. interface
  21. procedure InitScannerDirectives;
  22. implementation
  23. uses
  24. cutils,
  25. globtype,globals,systems,widestr,
  26. verbose,comphook,
  27. scanner,switches,
  28. fmodule;
  29. {*****************************************************************************
  30. Helpers
  31. *****************************************************************************}
  32. procedure do_delphiswitch(sw:char);
  33. var
  34. state : char;
  35. begin
  36. { c contains the next char, a + or - would be fine }
  37. state:=current_scanner.readstate;
  38. if state in ['-','+'] then
  39. HandleSwitch(sw,state);
  40. end;
  41. procedure do_setverbose(flag:char);
  42. var
  43. state : char;
  44. begin
  45. { support ON/OFF }
  46. state:=current_scanner.ReadState;
  47. SetVerbosity(flag+state);
  48. end;
  49. procedure do_moduleswitch(sw:tmoduleswitch);
  50. var
  51. state : char;
  52. begin
  53. state:=current_scanner.readstate;
  54. if (sw<>cs_modulenone) and (state in ['-','+']) then
  55. begin
  56. if state='-' then
  57. exclude(aktmoduleswitches,sw)
  58. else
  59. include(aktmoduleswitches,sw);
  60. end;
  61. end;
  62. procedure do_localswitch(sw:tlocalswitch);
  63. var
  64. state : char;
  65. begin
  66. state:=current_scanner.readstate;
  67. if (sw<>cs_localnone) and (state in ['-','+']) then
  68. begin
  69. if not localswitcheschanged then
  70. nextaktlocalswitches:=aktlocalswitches;
  71. if state='-' then
  72. exclude(nextaktlocalswitches,sw)
  73. else
  74. include(nextaktlocalswitches,sw);
  75. localswitcheschanged:=true;
  76. end;
  77. end;
  78. procedure do_message(w:integer);
  79. begin
  80. current_scanner.skipspace;
  81. Message1(w,current_scanner.readcomment);
  82. end;
  83. {*****************************************************************************
  84. Directive Callbacks
  85. *****************************************************************************}
  86. procedure dir_align;
  87. var
  88. hs : string;
  89. begin
  90. current_scanner.skipspace;
  91. if not(c in ['0'..'9']) then
  92. begin
  93. { Support also the ON and OFF as switch }
  94. hs:=current_scanner.readid;
  95. if (hs='ON') then
  96. aktalignment.recordalignmax:=4
  97. else
  98. if (hs='OFF') then
  99. aktalignment.recordalignmax:=1
  100. else
  101. Message(scan_w_only_pack_records);
  102. end
  103. else
  104. begin
  105. case current_scanner.readval of
  106. 1 : aktalignment.recordalignmax:=1;
  107. 2 : aktalignment.recordalignmax:=2;
  108. 4 : aktalignment.recordalignmax:=4;
  109. 8 : aktalignment.recordalignmax:=8;
  110. 16 : aktalignment.recordalignmax:=16;
  111. 32 : aktalignment.recordalignmax:=32;
  112. else
  113. Message(scan_w_only_pack_records);
  114. end;
  115. end;
  116. end;
  117. procedure dir_asmmode;
  118. var
  119. s : string;
  120. begin
  121. current_scanner.skipspace;
  122. s:=current_scanner.readid;
  123. If Inside_asm_statement then
  124. Message1(scan_w_no_asm_reader_switch_inside_asm,s);
  125. if s='DEFAULT' then
  126. aktasmmode:=initasmmode
  127. else
  128. if not set_asmmode_by_string(s,aktasmmode) then
  129. Message1(scan_w_unsupported_asmmode_specifier,s);
  130. end;
  131. {$ifdef m68k}
  132. procedure dir_appid;
  133. begin
  134. if target_info.system<>system_m68k_palmos then
  135. Message(scan_w_appid_not_support);
  136. { change description global var in all cases }
  137. { it not used but in win32 and os2 }
  138. current_scanner.skipspace;
  139. palmos_applicationid:=current_scanner.readcomment;
  140. end;
  141. procedure dir_appname;
  142. begin
  143. if target_info.system<>system_m68k_palmos then
  144. Message(scan_w_appname_not_support);
  145. { change description global var in all cases }
  146. { it not used but in win32 and os2 }
  147. current_scanner.skipspace;
  148. palmos_applicationname:=current_scanner.readcomment;
  149. end;
  150. {$endif m68k}
  151. procedure dir_apptype;
  152. var
  153. hs : string;
  154. begin
  155. if not (target_info.system in [system_i386_win32,system_i386_os2,
  156. system_i386_emx]) then
  157. Message(scan_w_app_type_not_support);
  158. if not current_module.in_global then
  159. Message(scan_w_switch_is_global)
  160. else
  161. begin
  162. current_scanner.skipspace;
  163. hs:=current_scanner.readid;
  164. if hs='GUI' then
  165. apptype:=app_gui
  166. else if hs='CONSOLE' then
  167. apptype:=app_cui
  168. else if (hs='FS') and (target_info.system in [system_i386_os2,
  169. system_i386_emx]) then
  170. apptype:=app_fs
  171. else
  172. Message1(scan_w_unsupported_app_type,hs);
  173. end;
  174. end;
  175. procedure dir_calling;
  176. var
  177. hs : string;
  178. begin
  179. current_scanner.skipspace;
  180. hs:=current_scanner.readid;
  181. if not SetAktProcCall(hs,false) then
  182. Message1(parser_w_unknown_proc_directive_ignored,hs);
  183. end;
  184. procedure dir_objectchecks;
  185. begin
  186. do_localswitch(cs_check_object);
  187. end;
  188. procedure dir_assertions;
  189. begin
  190. do_delphiswitch('C');
  191. end;
  192. procedure dir_booleval;
  193. begin
  194. do_delphiswitch('B');
  195. end;
  196. procedure dir_debuginfo;
  197. begin
  198. do_delphiswitch('D');
  199. end;
  200. procedure dir_description;
  201. begin
  202. if not (target_info.system in [system_i386_os2,system_i386_emx,
  203. system_i386_win32,system_i386_netware,system_i386_wdosx]) then
  204. Message(scan_w_description_not_support);
  205. { change description global var in all cases }
  206. { it not used but in win32, os2 and netware }
  207. current_scanner.skipspace;
  208. description:=current_scanner.readcomment;
  209. end;
  210. procedure dir_screenname; {ad}
  211. begin
  212. if target_info.system <> system_i386_netware then
  213. {Message(scan_w_decription_not_support);}
  214. comment (V_Warning,'Screenname only supported for target netware');
  215. current_scanner.skipspace;
  216. nwscreenname:=current_scanner.readcomment;
  217. end;
  218. procedure dir_threadname; {ad}
  219. begin
  220. if target_info.system <> system_i386_netware then
  221. {Message(scan_w_decription_not_support);}
  222. comment (V_Warning,'Threadname only supported for target netware');
  223. current_scanner.skipspace;
  224. nwthreadname:=current_scanner.readcomment;
  225. end;
  226. procedure dir_copyright; {ad}
  227. begin
  228. if target_info.system <> system_i386_netware then
  229. {Message(scan_w_decription_not_support);}
  230. comment (V_Warning,'Copyright only supported for target netware');
  231. current_scanner.skipspace;
  232. nwcopyright:=current_scanner.readcomment;
  233. end;
  234. procedure dir_error;
  235. begin
  236. do_message(scan_e_user_defined);
  237. end;
  238. procedure dir_extendedsyntax;
  239. begin
  240. do_delphiswitch('X');
  241. end;
  242. procedure dir_fatal;
  243. begin
  244. do_message(scan_f_user_defined);
  245. end;
  246. procedure dir_goto;
  247. begin
  248. do_moduleswitch(cs_support_goto);
  249. end;
  250. procedure dir_hint;
  251. begin
  252. do_message(scan_h_user_defined);
  253. end;
  254. procedure dir_hints;
  255. begin
  256. do_setverbose('H');
  257. end;
  258. procedure dir_implicitexceptions;
  259. begin
  260. do_moduleswitch(cs_implicit_exceptions);
  261. end;
  262. procedure dir_includepath;
  263. begin
  264. if not current_module.in_global then
  265. Message(scan_w_switch_is_global)
  266. else
  267. begin
  268. current_scanner.skipspace;
  269. current_module.localincludesearchpath.AddPath(current_scanner.readcomment,false);
  270. end;
  271. end;
  272. procedure dir_info;
  273. begin
  274. do_message(scan_i_user_defined);
  275. end;
  276. procedure dir_inline;
  277. begin
  278. do_moduleswitch(cs_support_inline);
  279. end;
  280. procedure dir_interfaces;
  281. var
  282. hs : string;
  283. begin
  284. {corba/com/default}
  285. current_scanner.skipspace;
  286. hs:=current_scanner.readid;
  287. if (hs='CORBA') then
  288. aktinterfacetype:=it_interfacecorba
  289. else if (hs='COM') then
  290. aktinterfacetype:=it_interfacecom
  291. else if (hs='DEFAULT') then
  292. aktinterfacetype:=initinterfacetype
  293. else
  294. Message(scan_e_invalid_interface_type);
  295. end;
  296. procedure dir_iochecks;
  297. begin
  298. do_delphiswitch('I');
  299. end;
  300. procedure dir_librarypath;
  301. begin
  302. if not current_module.in_global then
  303. Message(scan_w_switch_is_global)
  304. else
  305. begin
  306. current_scanner.skipspace;
  307. current_module.locallibrarysearchpath.AddPath(current_scanner.readcomment,false);
  308. end;
  309. end;
  310. procedure dir_link;
  311. var
  312. s : string;
  313. begin
  314. current_scanner.skipspace;
  315. s:=AddExtension(FixFileName(current_scanner.readcomment),target_info.objext);
  316. current_module.linkotherofiles.add(s,link_allways);
  317. end;
  318. procedure dir_linklib;
  319. type
  320. tLinkMode=(lm_shared,lm_static);
  321. var
  322. s : string;
  323. quote : char;
  324. libname,
  325. linkmodestr : string;
  326. p : longint;
  327. linkMode : tLinkMode;
  328. begin
  329. current_scanner.skipspace;
  330. s:=current_scanner.readcomment;
  331. p:=pos(',',s);
  332. if p=0 then
  333. begin
  334. libname:=TrimSpace(s);
  335. linkmodeStr:='';
  336. end
  337. else
  338. begin
  339. libname:=TrimSpace(copy(s,1,p-1));
  340. linkmodeStr:=Upper(TrimSpace(copy(s,p+1,255)));
  341. end;
  342. if (libname='') or (libname='''''') or (libname='""') then
  343. exit;
  344. { get linkmode, default is shared linking }
  345. if linkModeStr='STATIC' then
  346. linkmode:=lm_static
  347. else if (LinkModeStr='SHARED') or (LinkModeStr='') then
  348. linkmode:=lm_shared
  349. else
  350. begin
  351. Comment(V_Error,'Wrong link mode specified: "'+Linkmodestr+'"');
  352. exit;
  353. end;
  354. { create library name }
  355. if libname[1] in ['''','"'] then
  356. begin
  357. quote:=libname[1];
  358. Delete(libname,1,1);
  359. p:=pos(quote,libname);
  360. if p>0 then
  361. Delete(libname,p,1);
  362. end;
  363. { add to the list of libraries to link }
  364. if linkMode=lm_static then
  365. current_module.linkOtherStaticLibs.add(FixFileName(libname),link_allways)
  366. else
  367. current_module.linkOtherSharedLibs.add(FixFileName(libname),link_allways);
  368. end;
  369. procedure dir_localsymbols;
  370. begin
  371. do_delphiswitch('L');
  372. end;
  373. procedure dir_longstrings;
  374. begin
  375. do_delphiswitch('H');
  376. end;
  377. procedure dir_macro;
  378. begin
  379. do_moduleswitch(cs_support_macro);
  380. end;
  381. procedure dir_maxfpuregisters;
  382. var
  383. l : integer;
  384. hs : string;
  385. begin
  386. current_scanner.skipspace;
  387. if not(c in ['0'..'9']) then
  388. begin
  389. hs:=current_scanner.readid;
  390. if (hs='NORMAL') or (hs='DEFAULT') then
  391. aktmaxfpuregisters:=-1
  392. else
  393. Message(scan_e_invalid_maxfpureg_value);
  394. end
  395. else
  396. begin
  397. l:=current_scanner.readval;
  398. case l of
  399. 0..8:
  400. aktmaxfpuregisters:=l;
  401. else
  402. Message(scan_e_invalid_maxfpureg_value);
  403. end;
  404. end;
  405. end;
  406. procedure dir_memory;
  407. var
  408. l : longint;
  409. begin
  410. current_scanner.skipspace;
  411. l:=current_scanner.readval;
  412. if l>1024 then
  413. stacksize:=l;
  414. current_scanner.skipspace;
  415. if c=',' then
  416. begin
  417. current_scanner.readchar;
  418. current_scanner.skipspace;
  419. l:=current_scanner.readval;
  420. if l>1024 then
  421. heapsize:=l;
  422. end;
  423. if c=',' then
  424. begin
  425. current_scanner.readchar;
  426. current_scanner.skipspace;
  427. l:=current_scanner.readval;
  428. { Ignore this value, because the limit is set by the OS
  429. info and shouldn't be changed by the user (PFV) }
  430. end;
  431. end;
  432. procedure dir_message;
  433. begin
  434. do_message(scan_i_user_defined);
  435. end;
  436. procedure dir_mode;
  437. begin
  438. if not current_module.in_global then
  439. Message(scan_w_switch_is_global)
  440. else
  441. begin
  442. current_scanner.skipspace;
  443. current_scanner.readstring;
  444. if not SetCompileMode(pattern,false) then
  445. Message1(scan_w_illegal_switch,pattern);
  446. end;
  447. end;
  448. procedure dir_mmx;
  449. begin
  450. do_localswitch(cs_mmx);
  451. end;
  452. procedure dir_note;
  453. begin
  454. do_message(scan_n_user_defined);
  455. end;
  456. procedure dir_notes;
  457. begin
  458. do_setverbose('N');
  459. end;
  460. procedure dir_objectpath;
  461. begin
  462. if not current_module.in_global then
  463. Message(scan_w_switch_is_global)
  464. else
  465. begin
  466. current_scanner.skipspace;
  467. current_module.localobjectsearchpath.AddPath(current_scanner.readcomment,false);
  468. end;
  469. end;
  470. procedure dir_openstrings;
  471. begin
  472. do_delphiswitch('P');
  473. end;
  474. procedure dir_output_format;
  475. begin
  476. if not current_module.in_global then
  477. Message(scan_w_switch_is_global)
  478. else
  479. begin
  480. current_scanner.skipspace;
  481. if set_target_asm_by_string(current_scanner.readid) then
  482. aktoutputformat:=target_asm.id
  483. else
  484. Message1(scan_w_illegal_switch,pattern);
  485. end;
  486. end;
  487. procedure dir_overflowchecks;
  488. begin
  489. do_delphiswitch('Q');
  490. end;
  491. procedure dir_packenum;
  492. var
  493. hs : string;
  494. begin
  495. current_scanner.skipspace;
  496. if not(c in ['0'..'9']) then
  497. begin
  498. hs:=current_scanner.readid;
  499. if (hs='NORMAL') or (hs='DEFAULT') then
  500. aktpackenum:=4
  501. else
  502. Message(scan_w_only_pack_enum);
  503. end
  504. else
  505. begin
  506. case current_scanner.readval of
  507. 1 : aktpackenum:=1;
  508. 2 : aktpackenum:=2;
  509. 4 : aktpackenum:=4;
  510. else
  511. Message(scan_w_only_pack_enum);
  512. end;
  513. end;
  514. end;
  515. procedure dir_packrecords;
  516. var
  517. hs : string;
  518. begin
  519. current_scanner.skipspace;
  520. if not(c in ['0'..'9']) then
  521. begin
  522. hs:=current_scanner.readid;
  523. { C has the special recordalignmax of -1 }
  524. if (hs='C') then
  525. aktalignment.recordalignmax:=-1
  526. else
  527. if (hs='NORMAL') or (hs='DEFAULT') then
  528. aktalignment.recordalignmax:=2
  529. else
  530. Message(scan_w_only_pack_records);
  531. end
  532. else
  533. begin
  534. case current_scanner.readval of
  535. 1 : aktalignment.recordalignmax:=1;
  536. 2 : aktalignment.recordalignmax:=2;
  537. 4 : aktalignment.recordalignmax:=4;
  538. 8 : aktalignment.recordalignmax:=8;
  539. 16 : aktalignment.recordalignmax:=16;
  540. 32 : aktalignment.recordalignmax:=32;
  541. else
  542. Message(scan_w_only_pack_records);
  543. end;
  544. end;
  545. end;
  546. {$ifdef testvarsets}
  547. procedure dir_packset;
  548. var
  549. hs : string;
  550. begin
  551. current_scanner.skipspace;
  552. if not(c in ['1','2','4']) then
  553. begin
  554. hs:=current_scanner.readid;
  555. if (hs='FIXED') or ((hs='DEFAULT') OR (hs='NORMAL')) then
  556. aktsetalloc:=0 {Fixed mode, sets are 4 or 32 bytes}
  557. else
  558. Message(scan_w_only_packset);
  559. end
  560. else
  561. begin
  562. case current_scanner.readval of
  563. 1 : aktsetalloc:=1;
  564. 2 : aktsetalloc:=2;
  565. 4 : aktsetalloc:=4;
  566. else
  567. Message(scan_w_only_packset);
  568. end;
  569. end;
  570. end;
  571. {$ENDIF}
  572. procedure dir_profile;
  573. var
  574. mac : tmacro;
  575. begin
  576. do_moduleswitch(cs_profile);
  577. { defined/undefine FPC_PROFILE }
  578. mac:=tmacro(current_scanner.macros.search('FPC_PROFILE'));
  579. if not assigned(mac) then
  580. begin
  581. mac:=tmacro.create('FPC_PROFILE');
  582. current_scanner.macros.insert(mac);
  583. end;
  584. mac.defined:=(cs_profile in aktmoduleswitches);
  585. end;
  586. procedure dir_rangechecks;
  587. begin
  588. do_delphiswitch('R');
  589. end;
  590. procedure dir_referenceinfo;
  591. begin
  592. do_delphiswitch('Y');
  593. end;
  594. procedure dir_resource;
  595. var
  596. s : string;
  597. begin
  598. current_scanner.skipspace;
  599. s:=current_scanner.readcomment;
  600. { replace * with current module name.
  601. This should always be defined. }
  602. if s[1]='*' then
  603. if Assigned(Current_Module) then
  604. begin
  605. delete(S,1,1);
  606. insert(lower(current_module.modulename^),S,1);
  607. end;
  608. s:=AddExtension(FixFileName(s),target_info.resext);
  609. if target_info.res<>res_none then
  610. if (target_info.res = res_emxbind) and
  611. not (Current_module.ResourceFiles.Empty) then
  612. Message(scan_w_only_one_resourcefile_supported)
  613. else
  614. current_module.resourcefiles.insert(FixFileName(s))
  615. else
  616. Message(scan_e_resourcefiles_not_supported);
  617. end;
  618. procedure dir_saturation;
  619. begin
  620. do_localswitch(cs_mmx_saturation);
  621. end;
  622. procedure dir_smartlink;
  623. begin
  624. do_moduleswitch(cs_create_smart);
  625. end;
  626. procedure dir_stackframes;
  627. begin
  628. do_delphiswitch('W');
  629. end;
  630. procedure dir_static;
  631. begin
  632. do_moduleswitch(cs_static_keyword);
  633. end;
  634. procedure dir_stop;
  635. begin
  636. do_message(scan_f_user_defined);
  637. end;
  638. procedure dir_threading;
  639. var
  640. mac : tmacro;
  641. begin
  642. do_moduleswitch(cs_threading);
  643. { defined/undefine FPC_THREADING }
  644. mac:=tmacro(current_scanner.macros.search('FPC_THREADING'));
  645. if not assigned(mac) then
  646. begin
  647. mac:=tmacro.create('FPC_THREADING');
  648. current_scanner.macros.insert(mac);
  649. end;
  650. mac.defined:=(cs_threading in aktmoduleswitches);
  651. end;
  652. procedure dir_typedaddress;
  653. begin
  654. do_delphiswitch('T');
  655. end;
  656. procedure dir_typeinfo;
  657. begin
  658. do_delphiswitch('M');
  659. end;
  660. procedure dir_unitpath;
  661. begin
  662. if not current_module.in_global then
  663. Message(scan_w_switch_is_global)
  664. else
  665. with current_scanner,current_module,localunitsearchpath do
  666. begin
  667. skipspace;
  668. AddPath(path^,readcomment,false);
  669. end;
  670. end;
  671. procedure dir_varstringchecks;
  672. begin
  673. do_delphiswitch('V');
  674. end;
  675. procedure dir_version;
  676. var
  677. major, minor, revision : longint;
  678. error : integer;
  679. begin
  680. if not (target_info.system in [system_i386_os2,system_i386_emx,
  681. system_i386_win32,system_i386_netware,system_i386_wdosx]) then
  682. begin
  683. Message(scan_n_version_not_support);
  684. exit;
  685. end;
  686. if (compile_level<>1) then
  687. Message(scan_n_only_exe_version)
  688. else
  689. begin
  690. { change description global var in all cases }
  691. { it not used but in win32, os2 and netware }
  692. current_scanner.skipspace;
  693. { we should only accept Major.Minor format for win32 and os2 }
  694. current_scanner.readnumber;
  695. major:=0;
  696. minor:=0;
  697. revision:=0;
  698. valint(pattern,major,error);
  699. if (error<>0) or (major > high(word)) or (major < 0) then
  700. begin
  701. Message1(scan_w_wrong_version_ignored,pattern);
  702. exit;
  703. end;
  704. if c='.' then
  705. begin
  706. current_scanner.readchar;
  707. current_scanner.readnumber;
  708. valint(pattern,minor,error);
  709. if (error<>0) or (minor > high(word)) or (minor < 0) then
  710. begin
  711. Message1(scan_w_wrong_version_ignored,tostr(major)+'.'+pattern);
  712. exit;
  713. end;
  714. if (c='.') and
  715. (target_info.system = system_i386_netware) then
  716. begin
  717. current_scanner.readchar;
  718. current_scanner.readnumber;
  719. valint(pattern,revision,error);
  720. if (error<>0) or (revision > high(word)) or (revision < 0) then
  721. begin
  722. Message1(scan_w_wrong_version_ignored,tostr(revision)+'.'+pattern);
  723. exit;
  724. end;
  725. dllmajor:=word(major);
  726. dllminor:=word(minor);
  727. dllrevision:=word(revision);
  728. dllversion:=tostr(major)+','+tostr(minor)+','+tostr(revision);
  729. end
  730. else
  731. begin
  732. dllmajor:=word(major);
  733. dllminor:=word(minor);
  734. dllversion:=tostr(major)+'.'+tostr(minor);
  735. end;
  736. end
  737. else
  738. dllversion:=tostr(major);
  739. end;
  740. end;
  741. procedure dir_wait;
  742. var
  743. had_info : boolean;
  744. begin
  745. had_info:=(status.verbosity and V_Info)<>0;
  746. { this message should allways appear !! }
  747. status.verbosity:=status.verbosity or V_Info;
  748. Message(scan_i_press_enter);
  749. readln;
  750. If not(had_info) then
  751. status.verbosity:=status.verbosity and (not V_Info);
  752. end;
  753. procedure dir_warning;
  754. begin
  755. do_message(scan_w_user_defined);
  756. end;
  757. procedure dir_warnings;
  758. begin
  759. do_setverbose('W');
  760. end;
  761. procedure dir_writeableconst;
  762. begin
  763. do_delphiswitch('J');
  764. end;
  765. procedure dir_z1;
  766. begin
  767. aktpackenum:=1;
  768. end;
  769. procedure dir_z2;
  770. begin
  771. aktpackenum:=2;
  772. end;
  773. procedure dir_z4;
  774. begin
  775. aktpackenum:=4;
  776. end;
  777. procedure dir_externalsym;
  778. begin
  779. end;
  780. procedure dir_codepage;
  781. var
  782. s : string;
  783. begin
  784. if not current_module.in_global then
  785. Message(scan_w_switch_is_global)
  786. else
  787. begin
  788. current_scanner.skipspace;
  789. s:=current_scanner.readcomment;
  790. if not(cpavailable(s)) then
  791. Message1(option_code_page_not_available,s)
  792. else
  793. aktsourcecodepage:=s;
  794. end;
  795. end;
  796. {****************************************************************************
  797. Initialize Directives
  798. ****************************************************************************}
  799. procedure InitScannerDirectives;
  800. begin
  801. AddDirective('ALIGN',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_align);
  802. {$ifdef m68k}
  803. AddDirective('APPID',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_appid);
  804. AddDirective('APPNAME',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_appname);
  805. {$endif m68k}
  806. AddDirective('APPTYPE',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_apptype);
  807. AddDirective('ASMMODE',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_asmmode);
  808. AddDirective('ASSERTIONS',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_assertions);
  809. AddDirective('BOOLEVAL',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_booleval);
  810. AddDirective('CALLING',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_calling);
  811. AddDirective('CODEPAGE',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_codepage);
  812. AddDirective('COPYRIGHT',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_copyright);
  813. AddDirective('D',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_description);
  814. AddDirective('DEBUGINFO',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_debuginfo);
  815. AddDirective('DESCRIPTION',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_description);
  816. AddDirective('ERROR',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_error);
  817. AddDirective('EXTENDEDSYNTAX',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_extendedsyntax);
  818. AddDirective('EXTERNALSYM',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_externalsym);
  819. AddDirective('FATAL',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_fatal);
  820. AddDirective('GOTO',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_goto);
  821. AddDirective('HINT',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_hint);
  822. AddDirective('HINTS',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_hints);
  823. AddDirective('IOCHECKS',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_iochecks);
  824. AddDirective('IMPLICITEXCEPTIONS',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_implicitexceptions);
  825. AddDirective('INCLUDEPATH',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_includepath);
  826. AddDirective('INFO',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_info);
  827. AddDirective('INLINE',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_inline);
  828. AddDirective('INTERFACES',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_interfaces);
  829. AddDirective('L',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_link);
  830. AddDirective('LIBRARYPATH',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_librarypath);
  831. AddDirective('LINK',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_link);
  832. AddDirective('LINKLIB',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_linklib);
  833. AddDirective('LOCALSYMBOLS',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_localsymbols);
  834. AddDirective('LONGSTRINGS',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_longstrings);
  835. AddDirective('M',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_memory);
  836. AddDirective('MACRO',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_macro);
  837. AddDirective('MAXFPUREGISTERS',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_maxfpuregisters);
  838. AddDirective('MEMORY',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_memory);
  839. AddDirective('MESSAGE',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_message);
  840. AddDirective('MINENUMSIZE',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_packenum);
  841. AddDirective('MMX',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_mmx);
  842. AddDirective('MODE',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_mode);
  843. AddDirective('NOTE',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_note);
  844. AddDirective('NOTES',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_notes);
  845. AddDirective('OBJECTCHECKS',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_objectchecks);
  846. AddDirective('OBJECTPATH',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_objectpath);
  847. AddDirective('OPENSTRINGS',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_openstrings);
  848. AddDirective('OUTPUT_FORMAT',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_output_format);
  849. AddDirective('OVERFLOWCHECKS',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_overflowchecks);
  850. AddDirective('PACKENUM',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_packenum);
  851. AddDirective('PACKRECORDS',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_packrecords);
  852. {$IFDEF TestVarsets}
  853. AddDirective('PACKSET',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_packset);
  854. {$ENDIF}
  855. AddDirective('PROFILE',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_profile);
  856. AddDirective('R',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_resource);
  857. AddDirective('RANGECHECKS',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_rangechecks);
  858. AddDirective('REFERENCEINFO',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_referenceinfo);
  859. AddDirective('SATURATION',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_saturation);
  860. AddDirective('SCREENNAME',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_screenname);
  861. AddDirective('SMARTLINK',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_smartlink);
  862. AddDirective('STACKFRAMES',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_stackframes);
  863. AddDirective('STATIC',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_static);
  864. AddDirective('STOP',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_stop);
  865. AddDirective('THREADING',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_threading);
  866. AddDirective('THREADNAME',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_threadname);
  867. AddDirective('TYPEDADDRESS',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_typedaddress);
  868. AddDirective('TYPEINFO',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_typeinfo);
  869. AddDirective('UNITPATH',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_unitpath);
  870. AddDirective('VARSTRINGCHECKS',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_varstringchecks);
  871. AddDirective('VERSION',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_version);
  872. AddDirective('WAIT',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_wait);
  873. AddDirective('WARNING',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_warning);
  874. AddDirective('WARNINGS',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_warnings);
  875. AddDirective('WRITEABLECONST',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_writeableconst);
  876. AddDirective('Z1',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_z1);
  877. AddDirective('Z2',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_z2);
  878. AddDirective('Z4',directive_all, {$ifdef FPCPROCVAR}@{$endif}dir_z4);
  879. end;
  880. end.
  881. {
  882. $Log$
  883. Revision 1.26 2003-09-17 22:30:19 olle
  884. + support for a different set of compiler directives under $MODE MAC
  885. + added mac directives $SETC $IFC $ELSEC $ENDC
  886. Revision 1.25 2003/03/23 23:20:38 hajny
  887. + emx target added
  888. Revision 1.24 2003/01/03 21:25:01 peter
  889. * OBJECTCHECKS added, equivalent of -CR
  890. * WRITEABLECONST added, equivalent of $J
  891. Revision 1.23 2002/12/07 14:06:20 carl
  892. * stricter version / revision checking (also remove some warnings)
  893. Revision 1.22 2002/11/20 11:12:46 mazen
  894. + module path is now passed to AddPath to fix relative unit path
  895. Revision 1.21 2002/10/16 19:01:43 peter
  896. + $IMPLICITEXCEPTIONS switch to turn on/off generation of the
  897. implicit exception frames for procedures with initialized variables
  898. and for constructors. The default is on for compatibility
  899. Revision 1.20 2002/10/14 19:43:41 peter
  900. * threading switch, defines the symbol FPC_THREADING
  901. Revision 1.19 2002/08/13 18:01:52 carl
  902. * rename swatoperands to swapoperands
  903. + m68k first compilable version (still needs a lot of testing):
  904. assembler generator, system information , inline
  905. assembler reader.
  906. Revision 1.18 2002/07/26 21:15:42 florian
  907. * rewrote the system handling
  908. Revision 1.17 2002/07/20 17:16:03 florian
  909. + source code page support
  910. Revision 1.16 2002/07/16 15:37:58 florian
  911. + Directive $EXTERNALSYM added, it is ignored for now
  912. Revision 1.15 2002/05/18 13:34:17 peter
  913. * readded missing revisions
  914. Revision 1.14 2002/05/16 19:46:44 carl
  915. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  916. + try to fix temp allocation (still in ifdef)
  917. + generic constructor calls
  918. + start of tassembler / tmodulebase class cleanup
  919. Revision 1.12 2002/04/07 13:34:20 carl
  920. + wdosx target
  921. Revision 1.11 2002/04/04 19:06:05 peter
  922. * removed unused units
  923. * use tlocation.size in cg.a_*loc*() routines
  924. }