scandir.inc 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  1. {
  2. $Id$
  3. Copyright (c) 1998 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=16;
  20. type
  21. directivestr=string[directivelen];
  22. tdirectivetoken=(
  23. _DIR_NONE,
  24. _DIR_D,_DIR_DEFINE,
  25. _DIR_ELSE,_DIR_ENDIF,_DIR_ERROR,
  26. _DIR_FATAL,
  27. _DIR_I,_DIR_I386_ATT,_DIR_I386_DIRECT,_DIR_I386_INTEL,_DIR_IF,_DIR_IFDEF,_DIR_IFNDEF,_DIR_IFOPT,
  28. _DIR_INFO,
  29. _DIR_L,_DIR_LINKLIB,
  30. _DIR_MESSAGE,_DIR_MMX,
  31. _DIR_NOTE,
  32. _DIR_OUTPUT_FORMAT,
  33. _DIR_PACKRECORDS,
  34. _DIR_SATURATION,_DIR_STOP,
  35. _DIR_UNDEF,
  36. _DIR_WAIT,_DIR_WARNING
  37. );
  38. const
  39. firstdirective=_DIR_NONE;
  40. lastdirective=_DIR_WARNING;
  41. directive:array[tdirectivetoken] of directivestr=(
  42. '',
  43. 'D','DEFINE',
  44. 'ELSE','ENDIF','ERROR',
  45. 'FATAL',
  46. 'I','I386_ATT','I386_DIRECT','I386_INTEL','IF','IFDEF','IFNDEF','IFOPT','INFO',
  47. 'L','LINKLIB',
  48. 'MESSAGE','MMX',
  49. 'NOTE',
  50. 'OUTPUT_FORMAT',
  51. 'PACKRECORDS',
  52. 'SATURATION','STOP',
  53. 'UNDEF',
  54. 'WAIT','WARNING'
  55. );
  56. function Get_Directive(const hs:string):tdirectivetoken;
  57. var
  58. i : tdirectivetoken;
  59. begin
  60. for i:=firstdirective to lastdirective do
  61. if directive[i]=hs then
  62. begin
  63. Get_Directive:=i;
  64. exit;
  65. end;
  66. Get_Directive:=_DIR_NONE;
  67. end;
  68. {-------------------------------------------
  69. IF Conditional Handling
  70. -------------------------------------------}
  71. var
  72. preprocpat : string;
  73. preproc_token : ttoken;
  74. function read_preproc : ttoken;
  75. begin
  76. skipspace;
  77. case c of
  78. 'A'..'Z',
  79. 'a'..'z',
  80. '_','0'..'9' : begin
  81. preprocpat:=readid;
  82. read_preproc:=ID;
  83. end;
  84. '(' : begin
  85. readchar;
  86. read_preproc:=LKLAMMER;
  87. end;
  88. ')' : begin
  89. readchar;
  90. read_preproc:=RKLAMMER;
  91. end;
  92. '+' : begin
  93. readchar;
  94. read_preproc:=PLUS;
  95. end;
  96. '-' : begin
  97. readchar;
  98. read_preproc:=MINUS;
  99. end;
  100. '*' : begin
  101. readchar;
  102. read_preproc:=STAR;
  103. end;
  104. '/' : begin
  105. readchar;
  106. read_preproc:=SLASH;
  107. end;
  108. '=' : begin
  109. readchar;
  110. read_preproc:=EQUAL;
  111. end;
  112. '>' : begin
  113. readchar;
  114. if c='=' then
  115. begin
  116. readchar;
  117. read_preproc:=GTE;
  118. end
  119. else
  120. read_preproc:=GT;
  121. end;
  122. '<' : begin
  123. readchar;
  124. case c of
  125. '>' : begin
  126. readchar;
  127. read_preproc:=UNEQUAL;
  128. end;
  129. '=' : begin
  130. readchar;
  131. read_preproc:=LTE;
  132. end;
  133. else read_preproc:=LT;
  134. end;
  135. end;
  136. #26 : Message(scan_f_end_of_file);
  137. else
  138. begin
  139. read_preproc:=_EOF;
  140. end;
  141. end;
  142. end;
  143. procedure preproc_consume(t : ttoken);
  144. begin
  145. if t<>preproc_token then
  146. Message(scan_e_preproc_syntax_error);
  147. preproc_token:=read_preproc;
  148. end;
  149. function read_expr : string;forward;
  150. function read_factor : string;
  151. var
  152. hs : string;
  153. mac : pmacrosym;
  154. len : byte;
  155. begin
  156. if preproc_token=ID then
  157. begin
  158. if preprocpat='NOT' then
  159. begin
  160. preproc_consume(ID);
  161. hs:=read_expr;
  162. if hs='0' then
  163. read_factor:='1'
  164. else
  165. read_factor:='0';
  166. end
  167. else
  168. begin
  169. mac:=pmacrosym(macros^.search(hs));
  170. hs:=preprocpat;
  171. preproc_consume(ID);
  172. if assigned(mac) then
  173. begin
  174. if mac^.defined and assigned(mac^.buftext) then
  175. begin
  176. if mac^.buflen>255 then
  177. begin
  178. len:=255;
  179. Message(scan_w_marco_cut_after_255_chars);
  180. end
  181. else
  182. len:=mac^.buflen;
  183. hs[0]:=char(len);
  184. move(mac^.buftext^,hs[1],len);
  185. end
  186. else
  187. read_factor:='';
  188. end
  189. else
  190. read_factor:=hs;
  191. end
  192. end
  193. else if preproc_token=LKLAMMER then
  194. begin
  195. preproc_consume(LKLAMMER);
  196. read_factor:=read_expr;
  197. preproc_consume(RKLAMMER);
  198. end
  199. else
  200. Message(scan_e_error_in_preproc_expr);
  201. end;
  202. function read_term : string;
  203. var
  204. hs1,hs2 : string;
  205. begin
  206. hs1:=read_factor;
  207. while true do
  208. begin
  209. if (preproc_token=ID) then
  210. begin
  211. if preprocpat='AND' then
  212. begin
  213. preproc_consume(ID);
  214. hs2:=read_factor;
  215. if (hs1<>'0') and (hs2<>'0') then
  216. hs1:='1';
  217. end
  218. else
  219. break;
  220. end
  221. else
  222. break;
  223. end;
  224. read_term:=hs1;
  225. end;
  226. function read_simple_expr : string;
  227. var
  228. hs1,hs2 : string;
  229. begin
  230. hs1:=read_term;
  231. while true do
  232. begin
  233. if (preproc_token=ID) then
  234. begin
  235. if preprocpat='OR' then
  236. begin
  237. preproc_consume(ID);
  238. hs2:=read_term;
  239. if (hs1<>'0') or (hs2<>'0') then
  240. hs1:='1';
  241. end
  242. else
  243. break;
  244. end
  245. else
  246. break;
  247. end;
  248. read_simple_expr:=hs1;
  249. end;
  250. function read_expr : string;
  251. var
  252. hs1,hs2 : string;
  253. b : boolean;
  254. t : ttoken;
  255. w : word;
  256. l1,l2 : longint;
  257. begin
  258. hs1:=read_simple_expr;
  259. t:=preproc_token;
  260. if not(t in [EQUAL,UNEQUAL,LT,GT,LTE,GTE]) then
  261. begin
  262. read_expr:=hs1;
  263. exit;
  264. end;
  265. preproc_consume(t);
  266. hs2:=read_simple_expr;
  267. if is_number(hs1) and is_number(hs2) then
  268. begin
  269. valint(hs1,l1,w);
  270. valint(hs2,l2,w);
  271. case t of
  272. EQUAL:
  273. b:=l1=l2;
  274. UNEQUAL:
  275. b:=l1<>l2;
  276. LT:
  277. b:=l1<l2;
  278. GT:
  279. b:=l1>l2;
  280. GTE:
  281. b:=l1>=l2;
  282. LTE:
  283. b:=l1<=l2;
  284. end;
  285. end
  286. else
  287. begin
  288. case t of
  289. EQUAL:
  290. b:=hs1=hs2;
  291. UNEQUAL:
  292. b:=hs1<>hs2;
  293. LT:
  294. b:=hs1<hs2;
  295. GT:
  296. b:=hs1>hs2;
  297. GTE:
  298. b:=hs1>=hs2;
  299. LTE:
  300. b:=hs1<=hs2;
  301. end;
  302. end;
  303. if b then
  304. read_expr:='1'
  305. else
  306. read_expr:='0';
  307. end;
  308. {-------------------------------------------
  309. Directives
  310. -------------------------------------------}
  311. function is_conditional(t:tdirectivetoken):boolean;
  312. begin
  313. is_conditional:=(t in [_DIR_ENDIF,_DIR_IFDEF,_DIR_IFNDEF,_DIR_IFOPT,_DIR_IF,_DIR_ELSE]);
  314. end;
  315. procedure dir_conditional(t:tdirectivetoken);
  316. procedure newpreproc(isifdef,a:boolean;const s:string;w:tmsgconst);
  317. begin
  318. preprocstack:=new(ppreprocstack,init(isifdef,
  319. ((preprocstack=nil) or preprocstack^.accept) and a,preprocstack));
  320. preprocstack^.name:=s;
  321. preprocstack^.line_nb:=current_module^.current_inputfile^.line_no;
  322. if preprocstack^.accept then
  323. Message2(w,preprocstack^.name,'accepted')
  324. else
  325. Message2(w,preprocstack^.name,'rejected');
  326. end;
  327. var
  328. hs : string;
  329. mac : pmacrosym;
  330. found : boolean;
  331. begin
  332. while true do
  333. begin
  334. case t of
  335. _DIR_ENDIF : begin
  336. { we can always accept an ELSE }
  337. if assigned(preprocstack) then
  338. begin
  339. Message1(scan_c_endif_found,preprocstack^.name);
  340. if not preprocstack^.isifdef then
  341. popstack;
  342. end
  343. else
  344. Message(scan_e_endif_without_if);
  345. { now pop the condition }
  346. if assigned(preprocstack) then
  347. begin
  348. { we only use $ifdef in the stack }
  349. if preprocstack^.isifdef then
  350. popstack
  351. else
  352. Message(scan_e_too_much_endifs);
  353. end
  354. else
  355. Message(scan_e_endif_without_if);
  356. end;
  357. _DIR_ELSE : begin
  358. if assigned(preprocstack) then
  359. begin
  360. preprocstack:=new(ppreprocstack,init(false,
  361. not(preprocstack^.accept) and
  362. ((preprocstack^.next=nil) or (preprocstack^.next^.accept)),preprocstack));
  363. preprocstack^.line_nb:=current_module^.current_inputfile^.line_no;
  364. preprocstack^.name:=preprocstack^.next^.name;
  365. if preprocstack^.accept then
  366. Message2(scan_c_else_found,preprocstack^.name,'accepted')
  367. else
  368. Message2(scan_c_else_found,preprocstack^.name,'rejected');
  369. end
  370. else
  371. Message(scan_e_endif_without_if);
  372. end;
  373. _DIR_IFDEF : begin
  374. skipspace;
  375. hs:=readid;
  376. mac:=pmacrosym(macros^.search(hs));
  377. newpreproc(true,assigned(mac) and mac^.defined,hs,scan_c_ifdef_found);
  378. end;
  379. _DIR_IFOPT : begin
  380. skipspace;
  381. hs:=readid;
  382. if (length(hs)=1) and (c in ['-','+']) then
  383. begin
  384. found:=CheckSwitch(hs[1],c);
  385. readchar; {read + or -}
  386. end
  387. else
  388. Message(scan_w_illegal_switch);
  389. newpreproc(true,found,hs,scan_c_ifopt_found);
  390. end;
  391. _DIR_IF : begin
  392. skipspace;
  393. { start preproc expression scanner }
  394. preproc_token:=read_preproc;
  395. hs:=read_expr;
  396. newpreproc(true,hs<>'0',hs,scan_c_if_found);
  397. end;
  398. _DIR_IFNDEF : begin
  399. skipspace;
  400. hs:=readid;
  401. mac:=pmacrosym(macros^.search(hs));
  402. newpreproc(true,not(assigned(mac) and mac^.defined),hs,scan_c_ifndef_found);
  403. end;
  404. end;
  405. { accept the text ? }
  406. if (preprocstack=nil) or preprocstack^.accept then
  407. break
  408. else
  409. begin
  410. Message(scan_c_skipping_until);
  411. repeat
  412. skipuntildirective;
  413. t:=Get_Directive(readid);
  414. until is_conditional(t);
  415. end;
  416. end;
  417. end;
  418. procedure dir_define(t:tdirectivetoken);
  419. var
  420. ht : ttoken;
  421. hs2,
  422. hs : string;
  423. mac : pmacrosym;
  424. begin
  425. skipspace;
  426. hs:=readid;
  427. mac:=pmacrosym(macros^.search(hs));
  428. if not assigned(mac) then
  429. begin
  430. mac:=new(pmacrosym,init(hs));
  431. mac^.defined:=true;
  432. Message1(parser_m_macro_defined,mac^.name);
  433. macros^.insert(mac);
  434. end
  435. else
  436. begin
  437. Message1(parser_m_macro_defined,mac^.name);
  438. mac^.defined:=true;
  439. { delete old definition }
  440. if assigned(mac^.buftext) then
  441. begin
  442. freemem(mac^.buftext,mac^.buflen);
  443. mac^.buftext:=nil;
  444. end;
  445. end;
  446. if support_macros then
  447. begin
  448. { key words are never substituted }
  449. hs2:=pattern;
  450. pattern:=hs;
  451. if is_keyword(ht) then
  452. Message(scan_e_keyword_cant_be_a_macro);
  453. pattern:=hs2;
  454. { !!!!!! handle macro params, need we this? }
  455. skipspace;
  456. { may be a macro? }
  457. if c=':' then
  458. begin
  459. readchar;
  460. if c='=' then
  461. begin
  462. { first char }
  463. readchar;
  464. macropos:=0;
  465. while (c<>'}') do
  466. begin
  467. macrobuffer^[macropos]:=c;
  468. readchar;
  469. if c=#26 then Message(scan_f_end_of_file);
  470. inc(macropos);
  471. if macropos>maxmacrolen then
  472. Message(scan_f_macro_buffer_overflow);
  473. end;
  474. { free buffer of macro ?}
  475. if assigned(mac^.buftext) then
  476. freemem(mac^.buftext,mac^.buflen);
  477. { get new mem }
  478. getmem(mac^.buftext,macropos);
  479. mac^.buflen:=macropos;
  480. { copy the text }
  481. move(macrobuffer^,mac^.buftext^,macropos);
  482. end;
  483. end;
  484. end;
  485. end;
  486. procedure dir_undef(t:tdirectivetoken);
  487. var
  488. hs : string;
  489. mac : pmacrosym;
  490. begin
  491. skipspace;
  492. hs:=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. end;
  513. procedure dir_message(t:tdirectivetoken);
  514. var
  515. w : tmsgconst;
  516. begin
  517. case t of
  518. _DIR_STOP,
  519. _DIR_FATAL : w:=scan_f_user_defined;
  520. _DIR_ERROR : w:=scan_e_user_defined;
  521. _DIR_WARNING : w:=scan_w_user_defined;
  522. _DIR_NOTE : w:=scan_n_user_defined;
  523. _DIR_MESSAGE,
  524. _DIR_INFO : w:=scan_i_user_defined;
  525. end;
  526. skipspace;
  527. Message1(w,readcomment);
  528. end;
  529. procedure dir_switch(t:tdirectivetoken);
  530. {$ifdef SUPPORT_MMX}
  531. var
  532. sw : tcswitch;
  533. {$endif}
  534. begin
  535. {$ifdef SUPPORT_MMX}
  536. case t of
  537. _DIR_MMX : sw:=cs_mmx;
  538. _DIR_SATURATION : sw:=cs_mmx_saturation;
  539. end;
  540. {$endif}
  541. end;
  542. procedure dir_include(t:tdirectivetoken);
  543. var
  544. hs : string;
  545. path : dirstr;
  546. name : namestr;
  547. ext : extstr;
  548. hp : pinputfile;
  549. found : boolean;
  550. begin
  551. skipspace;
  552. hs:=readcomment;
  553. while (hs<>'') and (hs[length(hs)]=' ') do
  554. dec(byte(hs[0]));
  555. hs:=FixFileName(hs);
  556. fsplit(hs,path,name,ext);
  557. { first look in the path of _d then currentmodule }
  558. path:=search(hs,path+';'+current_module^.current_inputfile^.path^+';'+includesearchpath,found);
  559. hp:=new(pinputfile,init(path,name,ext));
  560. hp^.reset;
  561. if ioresult=0 then
  562. begin
  563. current_module^.current_inputfile^.bufpos:=longint(inputpointer)-longint(inputbuffer);
  564. hp^.next:=current_module^.current_inputfile;
  565. current_module^.current_inputfile:=hp;
  566. current_module^.sourcefiles.register_file(hp);
  567. inputbuffer:=current_module^.current_inputfile^.buf;
  568. Message1(scan_u_start_include_file,current_module^.current_inputfile^.name^);
  569. reload;
  570. end
  571. else
  572. Message1(scan_f_cannot_open_includefile,hs);
  573. end;
  574. procedure dir_description(t:tdirectivetoken);
  575. begin
  576. end;
  577. procedure dir_linkobject(t:tdirectivetoken);
  578. var
  579. path,hs : string;
  580. found : boolean;
  581. begin
  582. skipspace;
  583. hs:=FixFileName(readstring);
  584. if (not path_absolute(hs)) and (not assigned(current_module^.current_inputfile^.path)) then
  585. path:=search(hs,current_module^.current_inputfile^.path^+';'+objectsearchpath,found);
  586. Linker.AddObjectFile(path+hs);
  587. current_module^.linkofiles.insert(hs);
  588. end;
  589. procedure dir_linklib(t:tdirectivetoken);
  590. var
  591. hs : string;
  592. begin
  593. skipspace;
  594. hs:=FixFileName(readstring);
  595. Linker.AddLibraryFile(hs);
  596. current_module^.linklibfiles.insert(hs);
  597. end;
  598. procedure dir_outputformat(t:tdirectivetoken);
  599. var
  600. hs : string;
  601. begin
  602. if not current_module^.in_main then
  603. Message(scan_w_switch_is_global)
  604. else
  605. begin
  606. skipspace;
  607. hs:=readid;
  608. {$ifdef i386}
  609. if hs='NASM' then
  610. current_module^.output_format:=of_nasm
  611. else
  612. if hs='MASM' then
  613. current_module^.output_format:=of_masm
  614. else
  615. if hs='O' then
  616. current_module^.output_format:=of_o
  617. else
  618. if hs='OBJ' then
  619. current_module^.output_format:=of_obj
  620. else
  621. {$endif}
  622. Message(scan_w_illegal_switch);
  623. end;
  624. { for use in globals }
  625. output_format:=current_module^.output_format;
  626. end;
  627. procedure dir_packrecords(t:tdirectivetoken);
  628. var
  629. hs : string;
  630. begin
  631. skipspace;
  632. if upcase(c)='N' then
  633. begin
  634. hs:=readid;
  635. if hs='NORMAL' then
  636. aktpackrecords:=2
  637. else
  638. Message(scan_w_only_pack_records);
  639. end
  640. else
  641. begin
  642. case readval of
  643. 1 : aktpackrecords:=1;
  644. 2 : aktpackrecords:=2;
  645. 4 : aktpackrecords:=4;
  646. else
  647. Message(scan_w_only_pack_records);
  648. end;
  649. end;
  650. end;
  651. procedure dir_wait(t:tdirectivetoken);
  652. begin
  653. Message(scan_i_press_enter);
  654. readln;
  655. end;
  656. procedure dir_asmmode(t:tdirectivetoken);
  657. begin
  658. {$ifdef i386}
  659. case t of
  660. _DIR_I386_ATT : aktasmmode:=I386_ATT;
  661. _DIR_I386_DIRECT : aktasmmode:=I386_INTEL;
  662. _DIR_I386_INTEL : aktasmmode:=I386_DIRECT;
  663. end;
  664. {$endif}
  665. end;
  666. type
  667. tdirectiveproc=procedure(t:tdirectivetoken);
  668. const
  669. directiveproc:array[tdirectivetoken] of tdirectiveproc=(
  670. {_DIR_NONE} nil,
  671. {_DIR_D} dir_description,
  672. {_DIR_DEFINE} dir_define,
  673. {_DIR_ELSE} dir_conditional,
  674. {_DIR_ENDIF} dir_conditional,
  675. {_DIR_ERROR} dir_message,
  676. {_DIR_FATAL} dir_message,
  677. {_DIR_I} dir_include,
  678. {_DIR_I386_ATT} dir_asmmode,
  679. {_DIR_I386_DIRECT} dir_asmmode,
  680. {_DIR_I386_INTEL} dir_asmmode,
  681. {_DIR_IF} dir_conditional,
  682. {_DIR_IFDEF} dir_conditional,
  683. {_DIR_IFNDEF} dir_conditional,
  684. {_DIR_IFOPT} dir_conditional,
  685. {_DIR_INFO} dir_message,
  686. {_DIR_L} dir_linkobject,
  687. {_DIR_LINKLIB} dir_linklib,
  688. {_DIR_MESSAGE} dir_message,
  689. {_DIR_MMX} dir_switch,
  690. {_DIR_NOTE} dir_message,
  691. {_DIR_OUTPUT_FORMAT} dir_outputformat,
  692. {_DIR_PACKRECORDS} dir_packrecords,
  693. {_DIR_SATURATION} dir_switch,
  694. {_DIR_STOP} dir_message,
  695. {_DIR_UNDEF} dir_undef,
  696. {_DIR_WAIT} dir_wait,
  697. {_DIR_WARNING} dir_message
  698. );
  699. {-------------------------------------------
  700. Main switches handling
  701. -------------------------------------------}
  702. procedure handledirectives;
  703. var
  704. t : tdirectivetoken;
  705. p : tdirectiveproc;
  706. hs : string;
  707. begin
  708. readchar; {Remove the $}
  709. hs:=readid;
  710. Message1(scan_d_handling_switch,'$'+hs);
  711. if hs='' then
  712. Message1(scan_w_illegal_switch,'$'+hs);
  713. { Check for compiler switches }
  714. while (length(hs)=1) and (c in ['-','+']) do
  715. begin
  716. HandleSwitch(hs[1],c);
  717. readchar; {Remove + or -}
  718. if c=',' then
  719. begin
  720. readchar; {Remove , }
  721. hs:=readid; {Check for multiple switches on one line}
  722. Message1(scan_d_handling_switch,'$'+hs);
  723. end
  724. else
  725. hs:='';
  726. end;
  727. { directives may follow switches after a , }
  728. if hs<>'' then
  729. begin
  730. t:=Get_Directive(hs);
  731. if t<>_DIR_NONE then
  732. begin
  733. p:=directiveproc[t];
  734. if assigned(p) then
  735. p(t);
  736. end
  737. else
  738. Message1(scan_w_illegal_directive,'$'+hs);
  739. { conditionals already read the comment }
  740. if (comment_level>0) then
  741. readcomment;
  742. end;
  743. end;
  744. {
  745. $Log$
  746. Revision 1.1 1998-04-27 23:13:53 peter
  747. + the new files for the scanner
  748. }