scandir.inc 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286
  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_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_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. _DIR_R,_DIR_RANGECHECKS,_DIR_REFERENCEINFO,
  41. _DIR_SATURATION,_DIR_SMARTLINK,_DIR_STACKFRAMES,_DIR_STATIC,_DIR_STOP,
  42. _DIR_TYPEDADDRESS,_DIR_TYPEINFO,
  43. _DIR_UNDEF,_DIR_UNITPATH,
  44. _DIR_VARSTRINGCHECKS,
  45. _DIR_WAIT,_DIR_WARNING,_DIR_WARNINGS,
  46. _DIR_Z1,_DIR_Z2,_DIR_Z4
  47. );
  48. const
  49. firstdirective=_DIR_NONE;
  50. lastdirective=_DIR_Z4;
  51. directive:array[tdirectivetoken] of directivestr=(
  52. '',
  53. 'ALIGN','APPTYPE','ASMMODE','ASSERTIONS',
  54. 'BOOLEVAL',
  55. 'D','DEBUGINFO','DEFINE','DESCRIPTION',
  56. 'ELSE','ENDIF','ERROR','EXTENDEDSYNTAX',
  57. 'FATAL',
  58. 'GOTO',
  59. 'HINT','HINTS',
  60. 'I','I386_ATT','I386_DIRECT','I386_INTEL','IOCHECKS',
  61. 'IF','IFDEF','IFNDEF','IFOPT','INCLUDE','INCLUDEPATH',
  62. 'INFO','INLINE',
  63. 'L','LIBRARYPATH','LINK','LINKLIB','LOCALSYMBOLS',
  64. 'LONGSTRINGS',
  65. 'M','MACRO','MEMORY','MESSAGE','MINENUMSIZE','MMX','MODE',
  66. 'NOTE','NOTES',
  67. 'OBJECTPATH','OPENSTRINGS','OUTPUT_FORMAT','OVERFLOWCHECKS',
  68. 'PACKENUM','PACKRECORDS',
  69. 'R','RANGECHECKS','REFERENCEINFO',
  70. 'SATURATION','SMARTLINK','STACKFRAMES','STATIC','STOP',
  71. 'TYPEDADDRESS','TYPEINFO',
  72. 'UNDEF','UNITPATH',
  73. 'VARSTRINGCHECKS',
  74. 'WAIT','WARNING','WARNINGS',
  75. 'Z1','Z2','Z4'
  76. );
  77. function Get_Directive(const hs:string):tdirectivetoken;
  78. var
  79. i : tdirectivetoken;
  80. begin
  81. for i:=firstdirective to lastdirective do
  82. if directive[i]=hs then
  83. begin
  84. Get_Directive:=i;
  85. exit;
  86. end;
  87. Get_Directive:=_DIR_NONE;
  88. end;
  89. {-------------------------------------------
  90. IF Conditional Handling
  91. -------------------------------------------}
  92. var
  93. preprocpat : string;
  94. preproc_token : ttoken;
  95. procedure preproc_consume(t : ttoken);
  96. begin
  97. if t<>preproc_token then
  98. Message(scan_e_preproc_syntax_error);
  99. preproc_token:=current_scanner^.readpreproc;
  100. end;
  101. function read_expr : string;forward;
  102. function read_factor : string;
  103. var
  104. hs : string;
  105. mac : pmacrosym;
  106. len : byte;
  107. begin
  108. if preproc_token=ID then
  109. begin
  110. if preprocpat='NOT' then
  111. begin
  112. preproc_consume(ID);
  113. hs:=read_expr;
  114. if hs='0' then
  115. read_factor:='1'
  116. else
  117. read_factor:='0';
  118. end
  119. else
  120. begin
  121. mac:=pmacrosym(macros^.search(hs));
  122. hs:=preprocpat;
  123. preproc_consume(ID);
  124. if assigned(mac) then
  125. begin
  126. if mac^.defined and assigned(mac^.buftext) then
  127. begin
  128. if mac^.buflen>255 then
  129. begin
  130. len:=255;
  131. Message(scan_w_marco_cut_after_255_chars);
  132. end
  133. else
  134. len:=mac^.buflen;
  135. {$ifndef TP}
  136. {$ifopt H+}
  137. setlength(hs,len);
  138. {$else}
  139. hs[0]:=char(len);
  140. {$endif}
  141. {$else}
  142. hs[0]:=char(len);
  143. {$endif}
  144. move(mac^.buftext^,hs[1],len);
  145. end
  146. else
  147. read_factor:='';
  148. end
  149. else
  150. read_factor:=hs;
  151. end
  152. end
  153. else if preproc_token=LKLAMMER then
  154. begin
  155. preproc_consume(LKLAMMER);
  156. read_factor:=read_expr;
  157. preproc_consume(RKLAMMER);
  158. end
  159. else
  160. Message(scan_e_error_in_preproc_expr);
  161. end;
  162. function read_term : string;
  163. var
  164. hs1,hs2 : string;
  165. begin
  166. hs1:=read_factor;
  167. while true do
  168. begin
  169. if (preproc_token=ID) then
  170. begin
  171. if preprocpat='AND' then
  172. begin
  173. preproc_consume(ID);
  174. hs2:=read_factor;
  175. if (hs1<>'0') and (hs2<>'0') then
  176. hs1:='1';
  177. end
  178. else
  179. break;
  180. end
  181. else
  182. break;
  183. end;
  184. read_term:=hs1;
  185. end;
  186. function read_simple_expr : string;
  187. var
  188. hs1,hs2 : string;
  189. begin
  190. hs1:=read_term;
  191. while true do
  192. begin
  193. if (preproc_token=ID) then
  194. begin
  195. if preprocpat='OR' then
  196. begin
  197. preproc_consume(ID);
  198. hs2:=read_term;
  199. if (hs1<>'0') or (hs2<>'0') then
  200. hs1:='1';
  201. end
  202. else
  203. break;
  204. end
  205. else
  206. break;
  207. end;
  208. read_simple_expr:=hs1;
  209. end;
  210. function read_expr : string;
  211. var
  212. hs1,hs2 : string;
  213. b : boolean;
  214. t : ttoken;
  215. w : integer;
  216. l1,l2 : longint;
  217. begin
  218. hs1:=read_simple_expr;
  219. t:=preproc_token;
  220. if not(t in [EQUAL,UNEQUAL,LT,GT,LTE,GTE]) then
  221. begin
  222. read_expr:=hs1;
  223. exit;
  224. end;
  225. preproc_consume(t);
  226. hs2:=read_simple_expr;
  227. if is_number(hs1) and is_number(hs2) then
  228. begin
  229. valint(hs1,l1,w);
  230. valint(hs2,l2,w);
  231. case t of
  232. EQUAL : b:=l1=l2;
  233. UNEQUAL : b:=l1<>l2;
  234. LT : b:=l1<l2;
  235. GT : b:=l1>l2;
  236. GTE : b:=l1>=l2;
  237. LTE : b:=l1<=l2;
  238. end;
  239. end
  240. else
  241. begin
  242. case t of
  243. EQUAL : b:=hs1=hs2;
  244. UNEQUAL : b:=hs1<>hs2;
  245. LT : b:=hs1<hs2;
  246. GT : b:=hs1>hs2;
  247. GTE : b:=hs1>=hs2;
  248. LTE : b:=hs1<=hs2;
  249. end;
  250. end;
  251. if b then
  252. read_expr:='1'
  253. else
  254. read_expr:='0';
  255. end;
  256. {-------------------------------------------
  257. Directives
  258. -------------------------------------------}
  259. function is_conditional(t:tdirectivetoken):boolean;
  260. begin
  261. is_conditional:=(t in [_DIR_ENDIF,_DIR_IFDEF,_DIR_IFNDEF,_DIR_IFOPT,_DIR_IF,_DIR_ELSE]);
  262. end;
  263. procedure dir_conditional(t:tdirectivetoken);
  264. var
  265. hs : string;
  266. mac : pmacrosym;
  267. found : boolean;
  268. state : char;
  269. oldaktfilepos : tfileposinfo;
  270. begin
  271. oldaktfilepos:=aktfilepos;
  272. while true do
  273. begin
  274. current_scanner^.gettokenpos;
  275. case t of
  276. _DIR_ENDIF : begin
  277. current_scanner^.poppreprocstack;
  278. end;
  279. _DIR_ELSE : begin
  280. current_scanner^.elsepreprocstack;
  281. end;
  282. _DIR_IFDEF : begin
  283. current_scanner^.skipspace;
  284. hs:=current_scanner^.readid;
  285. mac:=pmacrosym(macros^.search(hs));
  286. current_scanner^.addpreprocstack(pp_ifdef,assigned(mac) and mac^.defined,hs,scan_c_ifdef_found);
  287. end;
  288. _DIR_IFOPT : begin
  289. current_scanner^.skipspace;
  290. hs:=current_scanner^.readid;
  291. if (length(hs)>1) then
  292. Message(scan_w_illegal_switch)
  293. else
  294. begin
  295. state:=current_scanner^.ReadState;
  296. if state in ['-','+'] then
  297. found:=CheckSwitch(hs[1],state);
  298. end;
  299. current_scanner^.addpreprocstack(pp_ifopt,found,hs,scan_c_ifopt_found);
  300. end;
  301. _DIR_IF : begin
  302. current_scanner^.skipspace;
  303. { start preproc expression scanner }
  304. preproc_token:=current_scanner^.readpreproc;
  305. hs:=read_expr;
  306. current_scanner^.addpreprocstack(pp_if,hs<>'0',hs,scan_c_if_found);
  307. end;
  308. _DIR_IFNDEF : begin
  309. current_scanner^.skipspace;
  310. hs:=current_scanner^.readid;
  311. mac:=pmacrosym(macros^.search(hs));
  312. current_scanner^.addpreprocstack(pp_ifndef,not(assigned(mac) and mac^.defined),hs,scan_c_ifndef_found);
  313. end;
  314. end;
  315. { accept the text ? }
  316. if (current_scanner^.preprocstack=nil) or current_scanner^.preprocstack^.accept then
  317. break
  318. else
  319. begin
  320. current_scanner^.gettokenpos;
  321. Message(scan_c_skipping_until);
  322. repeat
  323. current_scanner^.skipuntildirective;
  324. t:=Get_Directive(current_scanner^.readid);
  325. until is_conditional(t);
  326. current_scanner^.gettokenpos;
  327. Message1(scan_d_handling_switch,'$'+directive[t]);
  328. end;
  329. end;
  330. oldaktfilepos:=aktfilepos;
  331. end;
  332. procedure dir_define(t:tdirectivetoken);
  333. var
  334. hs : string;
  335. mac : pmacrosym;
  336. macropos : longint;
  337. macrobuffer : pmacrobuffer;
  338. begin
  339. current_scanner^.skipspace;
  340. hs:=current_scanner^.readid;
  341. mac:=pmacrosym(macros^.search(hs));
  342. if not assigned(mac) then
  343. begin
  344. mac:=new(pmacrosym,init(hs));
  345. mac^.defined:=true;
  346. Message1(parser_m_macro_defined,mac^.name);
  347. macros^.insert(mac);
  348. end
  349. else
  350. begin
  351. Message1(parser_m_macro_defined,mac^.name);
  352. mac^.defined:=true;
  353. { delete old definition }
  354. if assigned(mac^.buftext) then
  355. begin
  356. freemem(mac^.buftext,mac^.buflen);
  357. mac^.buftext:=nil;
  358. end;
  359. end;
  360. if (cs_support_macro in aktmoduleswitches) then
  361. begin
  362. { key words are never substituted }
  363. if is_keyword(hs) then
  364. Message(scan_e_keyword_cant_be_a_macro);
  365. { !!!!!! handle macro params, need we this? }
  366. current_scanner^.skipspace;
  367. { may be a macro? }
  368. if c=':' then
  369. begin
  370. current_scanner^.readchar;
  371. if c='=' then
  372. begin
  373. new(macrobuffer);
  374. macropos:=0;
  375. { first char }
  376. current_scanner^.readchar;
  377. while (c<>'}') do
  378. begin
  379. macrobuffer^[macropos]:=c;
  380. current_scanner^.readchar;
  381. if c=#26 then Message(scan_f_end_of_file);
  382. inc(macropos);
  383. if macropos>maxmacrolen then
  384. Message(scan_f_macro_buffer_overflow);
  385. end;
  386. { free buffer of macro ?}
  387. if assigned(mac^.buftext) then
  388. freemem(mac^.buftext,mac^.buflen);
  389. { get new mem }
  390. getmem(mac^.buftext,macropos);
  391. mac^.buflen:=macropos;
  392. { copy the text }
  393. move(macrobuffer^,mac^.buftext^,macropos);
  394. dispose(macrobuffer);
  395. end;
  396. end;
  397. end;
  398. end;
  399. procedure dir_undef(t:tdirectivetoken);
  400. var
  401. hs : string;
  402. mac : pmacrosym;
  403. begin
  404. current_scanner^.skipspace;
  405. hs:=current_scanner^.readid;
  406. mac:=pmacrosym(macros^.search(hs));
  407. if not assigned(mac) then
  408. begin
  409. mac:=new(pmacrosym,init(hs));
  410. Message1(parser_m_macro_undefined,mac^.name);
  411. mac^.defined:=false;
  412. macros^.insert(mac);
  413. end
  414. else
  415. begin
  416. Message1(parser_m_macro_undefined,mac^.name);
  417. mac^.defined:=false;
  418. { delete old definition }
  419. if assigned(mac^.buftext) then
  420. begin
  421. freemem(mac^.buftext,mac^.buflen);
  422. mac^.buftext:=nil;
  423. end;
  424. end;
  425. end;
  426. procedure dir_message(t:tdirectivetoken);
  427. var
  428. w : tmsgconst;
  429. begin
  430. case t of
  431. _DIR_STOP,
  432. _DIR_FATAL : w:=scan_f_user_defined;
  433. _DIR_ERROR : w:=scan_e_user_defined;
  434. _DIR_WARNING : w:=scan_w_user_defined;
  435. _DIR_HINT : w:=scan_h_user_defined;
  436. _DIR_NOTE : w:=scan_n_user_defined;
  437. _DIR_MESSAGE,
  438. _DIR_INFO : w:=scan_i_user_defined;
  439. end;
  440. current_scanner^.skipspace;
  441. Message1(w,current_scanner^.readcomment);
  442. end;
  443. procedure dir_moduleswitch(t:tdirectivetoken);
  444. var
  445. sw : tmoduleswitch;
  446. state : char;
  447. begin
  448. sw:=cs_modulenone;
  449. case t of
  450. _DIR_GOTO : sw:=cs_support_goto;
  451. _DIR_MACRO : sw:=cs_support_macro;
  452. _DIR_INLINE : sw:=cs_support_inline;
  453. _DIR_SMARTLINK : sw:=cs_smartlink;
  454. _DIR_STATIC : sw:=cs_static_keyword;
  455. end;
  456. state:=current_scanner^.readstate;
  457. if (sw<>cs_modulenone) and (state in ['-','+']) then
  458. begin
  459. if state='-' then
  460. aktmoduleswitches:=aktmoduleswitches-[sw]
  461. else
  462. aktmoduleswitches:=aktmoduleswitches+[sw];
  463. end;
  464. end;
  465. procedure dir_localswitch(t:tdirectivetoken);
  466. var
  467. sw : tlocalswitch;
  468. state : char;
  469. begin
  470. sw:=cs_localnone;
  471. {$ifdef SUPPORT_MMX}
  472. case t of
  473. _DIR_MMX : sw:=cs_mmx;
  474. _DIR_SATURATION : sw:=cs_mmx_saturation;
  475. end;
  476. {$endif}
  477. state:=current_scanner^.readstate;
  478. if (sw<>cs_localnone) and (state in ['-','+']) then
  479. begin
  480. if state='-' then
  481. aktlocalswitches:=aktlocalswitches-[sw]
  482. else
  483. aktlocalswitches:=aktlocalswitches+[sw];
  484. end;
  485. end;
  486. procedure dir_include(t:tdirectivetoken);
  487. var
  488. hs : string;
  489. path : dirstr;
  490. name : namestr;
  491. ext : extstr;
  492. hp : pinputfile;
  493. i : longint;
  494. found : boolean;
  495. begin
  496. current_scanner^.skipspace;
  497. hs:=current_scanner^.readcomment;
  498. i:=length(hs);
  499. while (i>0) and (hs[i]=' ') do
  500. dec(i);
  501. Delete(hs,i+1,length(hs)-i);
  502. if hs='' then
  503. exit;
  504. if (hs[1]='%') then
  505. begin
  506. { case insensitive }
  507. hs:=upper(hs);
  508. { save old }
  509. path:=hs;
  510. { remove %'s }
  511. Delete(hs,1,1);
  512. if hs[length(hs)]='%' then
  513. Delete(hs,length(hs),1);
  514. { first check for internal macros }
  515. if hs='TIME' then
  516. hs:=gettimestr
  517. else
  518. if hs='DATE' then
  519. hs:=getdatestr
  520. else
  521. if hs='FILE' then
  522. hs:=current_module^.sourcefiles^.get_file_name(aktfilepos.fileindex)
  523. else
  524. if hs='LINE' then
  525. hs:=tostr(aktfilepos.line)
  526. else
  527. if hs='FPCVERSION' then
  528. hs:=version_string
  529. else
  530. if hs='FPCTARGET' then
  531. hs:=target_cpu_string
  532. else
  533. hs:=getenv(hs);
  534. if hs='' then
  535. Comment(V_Warning,'Include environment '+path+' not found in environment')
  536. else
  537. begin
  538. { make it a stringconst }
  539. hs:=''''+hs+'''';
  540. current_scanner^.insertmacro(@hs[1],length(hs));
  541. end;
  542. end
  543. else
  544. begin
  545. hs:=FixFileName(hs);
  546. fsplit(hs,path,name,ext);
  547. { look for the include file
  548. 1. specified path,path of current inputfile,current dir
  549. 2. local includepath
  550. 3. global includepath }
  551. found:=false;
  552. path:=search(name+ext,path+';'+current_scanner^.inputfile^.path^+';.',found);
  553. if (not found) and assigned(current_module^.localincludesearchpath) then
  554. path:=search(name+ext,current_module^.localincludesearchpath^,found);
  555. if (not found) then
  556. path:=search(name+ext,includesearchpath,found);
  557. { shutdown current file }
  558. current_scanner^.tempcloseinputfile;
  559. { load new file }
  560. hp:=new(pinputfile,init(path+name+ext));
  561. current_scanner^.addfile(hp);
  562. if not current_scanner^.openinputfile then
  563. Message1(scan_f_cannot_open_includefile,hs);
  564. Message1(scan_t_start_include_file,current_scanner^.inputfile^.path^+current_scanner^.inputfile^.name^);
  565. current_scanner^.reload;
  566. { register for refs }
  567. current_module^.sourcefiles^.register_file(hp);
  568. end;
  569. end;
  570. procedure dir_description(t:tdirectivetoken);
  571. begin
  572. end;
  573. procedure dir_linkobject(t:tdirectivetoken);
  574. var
  575. s : string;
  576. begin
  577. current_scanner^.skipspace;
  578. s:=AddExtension(FixFileName(current_scanner^.readcomment),target_info.objext);
  579. current_module^.linkofiles.insert(s);
  580. end;
  581. procedure dir_resource(t:tdirectivetoken);
  582. var
  583. s : string;
  584. begin
  585. current_scanner^.skipspace;
  586. s:=AddExtension(FixFileName(current_scanner^.readcomment),target_info.resext);
  587. if target_info.res<>res_none then
  588. current_module^.resourcefiles.insert(FixFileName(s))
  589. else
  590. Message(scan_e_resourcefiles_not_supported);
  591. end;
  592. procedure dir_linklib(t:tdirectivetoken);
  593. begin
  594. current_scanner^.skipspace;
  595. current_scanner^.readstring;
  596. current_module^.linkSharedLibs.insert(orgpattern);
  597. end;
  598. procedure dir_outputformat(t:tdirectivetoken);
  599. begin
  600. if not current_module^.in_global then
  601. Message(scan_w_switch_is_global)
  602. else
  603. begin
  604. current_scanner^.skipspace;
  605. if set_string_asm(current_scanner^.readid) then
  606. aktoutputformat:=target_asm.id
  607. else
  608. Message(scan_w_illegal_switch);
  609. end;
  610. end;
  611. procedure dir_unitpath(t:tdirectivetoken);
  612. begin
  613. if not current_module^.in_global then
  614. Message(scan_w_switch_is_global)
  615. else
  616. begin
  617. current_scanner^.skipspace;
  618. if assigned(current_module^.localunitsearchpath) then
  619. stringdispose(current_module^.localunitsearchpath);
  620. current_module^.localunitsearchpath:=stringdup(current_scanner^.readcomment);
  621. end;
  622. end;
  623. procedure dir_includepath(t:tdirectivetoken);
  624. begin
  625. if not current_module^.in_global then
  626. Message(scan_w_switch_is_global)
  627. else
  628. begin
  629. current_scanner^.skipspace;
  630. if assigned(current_module^.localincludesearchpath) then
  631. stringdispose(current_module^.localincludesearchpath);
  632. current_module^.localincludesearchpath:=stringdup(current_scanner^.readcomment);
  633. end;
  634. end;
  635. procedure dir_librarypath(t:tdirectivetoken);
  636. begin
  637. if not current_module^.in_global then
  638. Message(scan_w_switch_is_global)
  639. else
  640. begin
  641. current_scanner^.skipspace;
  642. if assigned(current_module^.locallibrarysearchpath) then
  643. stringdispose(current_module^.locallibrarysearchpath);
  644. current_module^.locallibrarysearchpath:=stringdup(current_scanner^.readcomment);
  645. end;
  646. end;
  647. procedure dir_objectpath(t:tdirectivetoken);
  648. begin
  649. if not current_module^.in_global then
  650. Message(scan_w_switch_is_global)
  651. else
  652. begin
  653. current_scanner^.skipspace;
  654. if assigned(current_module^.localobjectsearchpath) then
  655. stringdispose(current_module^.localobjectsearchpath);
  656. current_module^.localobjectsearchpath:=stringdup(current_scanner^.readcomment);
  657. end;
  658. end;
  659. procedure dir_mode(t:tdirectivetoken);
  660. begin
  661. if not current_module^.in_global then
  662. Message(scan_w_switch_is_global)
  663. else
  664. begin
  665. current_scanner^.skipspace;
  666. current_scanner^.readstring;
  667. if pattern='DEFAULT' then
  668. aktmodeswitches:=initmodeswitches
  669. else
  670. if pattern='DELPHI' then
  671. aktmodeswitches:=delphimodeswitches
  672. else
  673. if pattern='TP' then
  674. aktmodeswitches:=tpmodeswitches
  675. else
  676. if pattern='FPC' then
  677. aktmodeswitches:=fpcmodeswitches
  678. else
  679. if pattern='OBJFPC' then
  680. aktmodeswitches:=objfpcmodeswitches
  681. else
  682. if pattern='GPC' then
  683. aktmodeswitches:=gpcmodeswitches;
  684. end;
  685. end;
  686. procedure dir_packrecords(t:tdirectivetoken);
  687. var
  688. hs : string;
  689. begin
  690. current_scanner^.skipspace;
  691. if not(c in ['0'..'9']) then
  692. begin
  693. hs:=current_scanner^.readid;
  694. if (hs='NORMAL') or (hs='DEFAULT') then
  695. aktpackrecords:=2
  696. else
  697. Message(scan_w_only_pack_records);
  698. end
  699. else
  700. begin
  701. case current_scanner^.readval of
  702. 1 : aktpackrecords:=1;
  703. 2 : aktpackrecords:=2;
  704. 4 : aktpackrecords:=4;
  705. 8 : aktpackrecords:=8;
  706. 16 : aktpackrecords:=16;
  707. 32 : aktpackrecords:=32;
  708. else
  709. Message(scan_w_only_pack_records);
  710. end;
  711. end;
  712. end;
  713. procedure dir_packenum(t:tdirectivetoken);
  714. var
  715. hs : string;
  716. begin
  717. if t in [_DIR_Z1,_DIR_Z2,_DIR_Z4] then
  718. begin
  719. aktpackenum:=ord(pattern[2])-ord('0');
  720. exit;
  721. end;
  722. current_scanner^.skipspace;
  723. if not(c in ['0'..'9']) then
  724. begin
  725. hs:=current_scanner^.readid;
  726. if (hs='NORMAL') or (hs='DEFAULT') then
  727. aktpackenum:=4
  728. else
  729. Message(scan_w_only_pack_enum);
  730. end
  731. else
  732. begin
  733. case current_scanner^.readval of
  734. 1 : aktpackenum:=1;
  735. 2 : aktpackenum:=2;
  736. 4 : aktpackenum:=4;
  737. else
  738. Message(scan_w_only_pack_enum);
  739. end;
  740. end;
  741. end;
  742. procedure dir_apptype(t:tdirectivetoken);
  743. var
  744. hs : string;
  745. begin
  746. if target_info.target<>target_i386_win32 then
  747. Message(scan_w_app_type_not_support);
  748. if not current_module^.in_global then
  749. Message(scan_w_switch_is_global)
  750. else
  751. begin
  752. current_scanner^.skipspace;
  753. hs:=current_scanner^.readid;
  754. if hs='GUI' then
  755. apptype:=at_gui
  756. else if hs='CONSOLE' then
  757. apptype:=at_cui
  758. else
  759. Message1(scan_w_unsupported_app_type,hs);
  760. end;
  761. end;
  762. procedure dir_wait(t:tdirectivetoken);
  763. var had_info : boolean;
  764. begin
  765. had_info:=(status.verbosity and V_Info)<>0;
  766. { this message should allways appear !! }
  767. status.verbosity:=status.verbosity or V_Info;
  768. Message(scan_i_press_enter);
  769. readln;
  770. If not(had_info) then
  771. status.verbosity:=status.verbosity and (not V_Info);
  772. end;
  773. procedure dir_asmmode(t:tdirectivetoken);
  774. var
  775. s : string;
  776. begin
  777. If Inside_asm_statement then
  778. Message1(scan_w_no_asm_reader_switch_inside_asm,s);
  779. current_scanner^.skipspace;
  780. s:=current_scanner^.readid;
  781. if s='DEFAULT' then
  782. aktasmmode:=initasmmode
  783. else
  784. if not set_string_asmmode(s,aktasmmode) then
  785. Message1(scan_w_unsupported_asmmode_specifier,s);
  786. end;
  787. procedure dir_oldasmmode(t:tdirectivetoken);
  788. begin
  789. If Inside_asm_statement then
  790. Message1(scan_w_no_asm_reader_switch_inside_asm,directive[t]);
  791. {$ifdef i386}
  792. case t of
  793. _DIR_I386_ATT : aktasmmode:=asmmode_i386_att;
  794. _DIR_I386_DIRECT : aktasmmode:=asmmode_i386_direct;
  795. _DIR_I386_INTEL : aktasmmode:=asmmode_i386_intel;
  796. end;
  797. {$endif i386}
  798. end;
  799. procedure dir_delphiswitch(t:tdirectivetoken);
  800. var
  801. sw,state : char;
  802. begin
  803. case t of
  804. _DIR_ALIGN : sw:='A';
  805. _DIR_ASSERTIONS : sw:='C';
  806. _DIR_BOOLEVAL : sw:='B';
  807. _DIR_DEBUGINFO : sw:='D';
  808. _DIR_IOCHECKS : sw:='I';
  809. _DIR_LOCALSYMBOLS : sw:='L';
  810. _DIR_LONGSTRINGS : sw:='H';
  811. _DIR_OPENSTRINGS : sw:='P';
  812. _DIR_OVERFLOWCHECKS : sw:='Q';
  813. _DIR_RANGECHECKS : sw:='R';
  814. _DIR_REFERENCEINFO : sw:='Y';
  815. _DIR_STACKFRAMES : sw:='W';
  816. _DIR_TYPEDADDRESS : sw:='T';
  817. _DIR_TYPEINFO : sw:='M';
  818. _DIR_VARSTRINGCHECKS : sw:='V';
  819. else
  820. exit;
  821. end;
  822. { c contains the next char, a + or - would be fine }
  823. state:=current_scanner^.readstate;
  824. if state in ['-','+'] then
  825. HandleSwitch(sw,state);
  826. end;
  827. procedure dir_memory(t:tdirectivetoken);
  828. var
  829. l : longint;
  830. begin
  831. current_scanner^.skipspace;
  832. l:=current_scanner^.readval;
  833. if l>1024 then
  834. stacksize:=l;
  835. current_scanner^.skipspace;
  836. if c=',' then
  837. begin
  838. current_scanner^.readchar;
  839. current_scanner^.skipspace;
  840. l:=current_scanner^.readval;
  841. if l>1024 then
  842. heapsize:=l;
  843. end;
  844. if c=',' then
  845. begin
  846. current_scanner^.readchar;
  847. current_scanner^.skipspace;
  848. l:=current_scanner^.readval;
  849. if l>1024 then
  850. maxheapsize:=l;
  851. end;
  852. if heapsize>maxheapsize then
  853. message(scan_w_illegal_switch);
  854. end;
  855. procedure dir_setverbose(t:tdirectivetoken);
  856. var
  857. flag,
  858. state : char;
  859. begin
  860. case t of
  861. _DIR_HINTS : flag:='H';
  862. _DIR_WARNINGS : flag:='W';
  863. _DIR_NOTES : flag:='N';
  864. else
  865. exit;
  866. end;
  867. { support ON/OFF }
  868. state:=current_scanner^.ReadState;
  869. SetVerbosity(flag+state);
  870. end;
  871. type
  872. tdirectiveproc=procedure(t:tdirectivetoken);
  873. const
  874. directiveproc:array[tdirectivetoken] of tdirectiveproc=(
  875. {_DIR_NONE} nil,
  876. {_DIR_ALIGN} dir_delphiswitch,
  877. {_DIR_APPTYPE} dir_apptype,
  878. {_DIR_ASMMODE} dir_asmmode,
  879. {_DIR_ASSERTION} dir_delphiswitch,
  880. {_DIR_BOOLEVAL} dir_delphiswitch,
  881. {_DIR_D} dir_description,
  882. {_DIR_DEBUGINFO} dir_delphiswitch,
  883. {_DIR_DEFINE} dir_define,
  884. {_DIR_DESCRIPTION} dir_description,
  885. {_DIR_ELSE} dir_conditional,
  886. {_DIR_ENDIF} dir_conditional,
  887. {_DIR_ERROR} dir_message,
  888. {_DIR_EXTENDEDSYNTAX} dir_delphiswitch,
  889. {_DIR_FATAL} dir_message,
  890. {_DIR_GOTO} dir_moduleswitch,
  891. {_DIR_HINT} dir_message,
  892. {_DIR_HINTS} dir_setverbose,
  893. {_DIR_I} dir_include,
  894. {_DIR_I386_ATT} dir_oldasmmode,
  895. {_DIR_I386_DIRECT} dir_oldasmmode,
  896. {_DIR_I386_INTEL} dir_oldasmmode,
  897. {_DIR_IOCHECKS} dir_delphiswitch,
  898. {_DIR_IF} dir_conditional,
  899. {_DIR_IFDEF} dir_conditional,
  900. {_DIR_IFNDEF} dir_conditional,
  901. {_DIR_IFOPT} dir_conditional,
  902. {_DIR_INCLUDE} dir_include,
  903. {_DIR_INCLUDEPATH} dir_includepath,
  904. {_DIR_INFO} dir_message,
  905. {_DIR_INLINE} dir_moduleswitch,
  906. {_DIR_L} dir_linkobject,
  907. {_DIR_LIBRARYPATH} dir_librarypath,
  908. {_DIR_LINK} dir_linkobject,
  909. {_DIR_LINKLIB} dir_linklib,
  910. {_DIR_LOCALSYMBOLS} dir_delphiswitch,
  911. {_DIR_LONGSTRINGS} dir_delphiswitch,
  912. {_DIR_M} dir_memory,
  913. {_DIR_MACRO} dir_moduleswitch,
  914. {_DIR_MEMORY} dir_memory,
  915. {_DIR_MESSAGE} dir_message,
  916. {_DIR_MINENUMSIZE} dir_packenum,
  917. {_DIR_MMX} dir_localswitch,
  918. {_DIR_MODE} dir_mode,
  919. {_DIR_NOTE} dir_message,
  920. {_DIR_NOTES} dir_setverbose,
  921. {_DIR_OBJECTPATH} dir_objectpath,
  922. {_DIR_OPENSTRINGS} dir_delphiswitch,
  923. {_DIR_OUTPUT_FORMAT} dir_outputformat,
  924. {_DIR_OVERFLOWCHECKS} dir_delphiswitch,
  925. {_DIR_PACKENUM} dir_packenum,
  926. {_DIR_PACKRECORDS} dir_packrecords,
  927. {_DIR_R} dir_resource,
  928. {_DIR_RANGECHECKS} dir_delphiswitch,
  929. {_DIR_REFERENCEINFO} dir_delphiswitch,
  930. {_DIR_SATURATION} dir_localswitch,
  931. {_DIR_SMARTLINK} dir_moduleswitch,
  932. {_DIR_STACKFRAMES} dir_delphiswitch,
  933. {_DIR_STATIC} dir_moduleswitch,
  934. {_DIR_STOP} dir_message,
  935. {_DIR_TYPEDADDRESS} dir_delphiswitch,
  936. {_DIR_TYPEINFO} dir_delphiswitch,
  937. {_DIR_UNDEF} dir_undef,
  938. {_DIR_UNITPATH} dir_unitpath,
  939. {_DIR_VARSTRINGCHECKS} dir_delphiswitch,
  940. {_DIR_WAIT} dir_wait,
  941. {_DIR_WARNING} dir_message,
  942. {_DIR_WARNINGS} dir_setverbose,
  943. {_DIR_Z1} dir_packenum,
  944. {_DIR_Z2} dir_packenum,
  945. {_DIR_Z4} dir_packenum
  946. );
  947. {-------------------------------------------
  948. Main switches handling
  949. -------------------------------------------}
  950. procedure handledirectives;
  951. var
  952. t : tdirectivetoken;
  953. p : tdirectiveproc;
  954. hs : string;
  955. begin
  956. current_scanner^.gettokenpos;
  957. current_scanner^.readchar; {Remove the $}
  958. hs:=current_scanner^.readid;
  959. Message1(scan_d_handling_switch,'$'+hs);
  960. if hs='' then
  961. Message1(scan_w_illegal_switch,'$'+hs);
  962. { Check for compiler switches }
  963. while (length(hs)=1) and (c in ['-','+']) do
  964. begin
  965. HandleSwitch(hs[1],c);
  966. current_scanner^.readchar; {Remove + or -}
  967. if c=',' then
  968. begin
  969. current_scanner^.readchar; {Remove , }
  970. { read next switch, support $v+,$+}
  971. hs:=current_scanner^.readid;
  972. if (hs='') then
  973. begin
  974. if (c='$') and (m_fpc in aktmodeswitches) then
  975. begin
  976. current_scanner^.readchar; { skip $ }
  977. hs:=current_scanner^.readid;
  978. end;
  979. if (hs='') then
  980. Message1(scan_w_illegal_directive,'$'+c);
  981. end
  982. else
  983. Message1(scan_d_handling_switch,'$'+hs);
  984. end
  985. else
  986. hs:='';
  987. end;
  988. { directives may follow switches after a , }
  989. if hs<>'' then
  990. begin
  991. t:=Get_Directive(hs);
  992. if t<>_DIR_NONE then
  993. begin
  994. p:=directiveproc[t];
  995. {$ifdef FPC}
  996. if assigned(p) then
  997. {$else}
  998. if @p<>nil then
  999. {$endif}
  1000. p(t);
  1001. end
  1002. else
  1003. Message1(scan_w_illegal_directive,'$'+hs);
  1004. { conditionals already read the comment }
  1005. if (current_scanner^.comment_level>0) then
  1006. current_scanner^.readcomment;
  1007. end;
  1008. end;
  1009. {
  1010. $Log$
  1011. Revision 1.51 1999-04-07 14:36:45 pierre
  1012. + better preproc stack checking and report
  1013. Revision 1.50 1999/03/31 13:55:20 peter
  1014. * assembler inlining working for ag386bin
  1015. Revision 1.49 1999/03/26 00:05:44 peter
  1016. * released valintern
  1017. + deffile is now removed when compiling is finished
  1018. * ^( compiles now correct
  1019. + static directive
  1020. * shrd fixed
  1021. Revision 1.48 1999/03/25 16:55:34 peter
  1022. + unitpath,librarypath,includepath,objectpath directives
  1023. Revision 1.47 1999/02/22 13:07:05 pierre
  1024. + -b and -bl options work !
  1025. + cs_local_browser ($L+) is disabled if cs_browser ($Y+)
  1026. is not enabled when quitting global section
  1027. * local vars and procedures are not yet stored into PPU
  1028. Revision 1.46 1999/02/05 08:51:16 pierre
  1029. * $L default extension from resext to objext
  1030. Revision 1.45 1998/12/28 23:26:25 peter
  1031. + resource file handling ($R directive) for Win32
  1032. Revision 1.44 1998/12/15 10:23:29 peter
  1033. + -iSO, -iSP, -iTO, -iTP
  1034. Revision 1.43 1998/11/16 15:41:43 peter
  1035. * tp7 didn't like my ifopt H+ :(
  1036. Revision 1.42 1998/11/16 12:18:04 peter
  1037. * H+ fixes
  1038. Revision 1.41 1998/10/22 17:54:08 florian
  1039. + switch $APPTYPE for win32 added
  1040. Revision 1.40 1998/10/21 20:16:04 peter
  1041. * beter line info for conditionals
  1042. Revision 1.39 1998/10/13 16:50:21 pierre
  1043. * undid some changes of Peter that made the compiler wrong
  1044. for m68k (I had to reinsert some ifdefs)
  1045. * removed several memory leaks under m68k
  1046. * removed the meory leaks for assembler readers
  1047. * cross compiling shoud work again better
  1048. ( crosscompiling sysamiga works
  1049. but as68k still complain about some code !)
  1050. Revision 1.38 1998/10/13 13:10:28 peter
  1051. * new style for m68k/i386 infos and enums
  1052. Revision 1.37 1998/10/08 23:29:04 peter
  1053. * -vu shows unit info, -vt shows tried/used files
  1054. Revision 1.36 1998/10/08 17:17:29 pierre
  1055. * current_module old scanner tagged as invalid if unit is recompiled
  1056. + added ppheap for better info on tracegetmem of heaptrc
  1057. (adds line column and file index)
  1058. * several memory leaks removed ith help of heaptrc !!
  1059. Revision 1.35 1998/10/08 13:44:39 peter
  1060. * fixed $I %date% not in uppercase
  1061. Revision 1.34 1998/09/28 16:57:24 pierre
  1062. * changed all length(p^.value_str^) into str_length(p)
  1063. to get it work with and without ansistrings
  1064. * changed sourcefiles field of tmodule to a pointer
  1065. Revision 1.33 1998/09/26 17:45:40 peter
  1066. + idtoken and only one token table
  1067. Revision 1.32 1998/09/24 23:49:19 peter
  1068. + aktmodeswitches
  1069. Revision 1.31 1998/09/18 16:03:44 florian
  1070. * some changes to compile with Delphi
  1071. Revision 1.30 1998/09/16 16:41:47 peter
  1072. * merged fixes
  1073. Revision 1.28.2.1 1998/09/16 16:09:51 peter
  1074. * on/off support also for the local/module switches
  1075. Revision 1.29 1998/09/11 09:19:53 daniel
  1076. * Removed tabs.
  1077. Revision 1.28 1998/09/10 15:25:36 daniel
  1078. + Added maxheapsize.
  1079. * Corrected semi-bug in calling the assembler and the linker
  1080. Revision 1.27 1998/09/09 15:33:59 peter
  1081. * removed warnings
  1082. Revision 1.26 1998/09/03 11:24:02 peter
  1083. * moved more inputfile things from tscannerfile to tinputfile
  1084. * changed ifdef Sourceline to cs_asm_source
  1085. Revision 1.25 1998/09/02 15:13:31 peter
  1086. * fixed typo in directive table
  1087. Revision 1.24 1998/09/01 12:52:06 peter
  1088. + a lot of delphi switches
  1089. Revision 1.23 1998/08/26 15:35:34 peter
  1090. * fixed scannerfiles for macros
  1091. + $I %<environment>%
  1092. Revision 1.22 1998/08/19 14:57:50 peter
  1093. * small fix for aktfilepos
  1094. Revision 1.20 1998/08/18 15:11:52 peter
  1095. * recompiles again
  1096. Revision 1.19 1998/08/18 09:24:44 pierre
  1097. * small warning position bug fixed
  1098. * support_mmx switches splitting was missing
  1099. * rhide error and warning output corrected
  1100. Revision 1.18 1998/08/10 14:50:25 peter
  1101. + localswitches, moduleswitches, globalswitches splitting
  1102. Revision 1.17 1998/08/10 09:56:04 peter
  1103. * path to the include file is also written to the debug output
  1104. Revision 1.16 1998/08/04 22:03:44 michael
  1105. + fixed dir_include search() call
  1106. Revision 1.15 1998/07/14 21:46:55 peter
  1107. * updated messages file
  1108. Revision 1.14 1998/07/14 14:47:03 peter
  1109. * released NEWINPUT
  1110. Revision 1.13 1998/07/07 12:32:54 peter
  1111. * status.currentsource is now calculated in verbose (more accurated)
  1112. Revision 1.12 1998/07/07 11:20:10 peter
  1113. + NEWINPUT for a better inputfile and scanner object
  1114. Revision 1.11 1998/06/04 23:51:59 peter
  1115. * m68k compiles
  1116. + .def file creation moved to gendef.pas so it could also be used
  1117. for win32
  1118. Revision 1.10 1998/05/30 14:31:10 peter
  1119. + $ASMMODE
  1120. Revision 1.9 1998/05/23 01:21:28 peter
  1121. + aktasmmode, aktoptprocessor, aktoutputformat
  1122. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  1123. + $LIBNAME to set the library name where the unit will be put in
  1124. * splitted cgi386 a bit (codeseg to large for bp7)
  1125. * nasm, tasm works again. nasm moved to ag386nsm.pas
  1126. Revision 1.8 1998/05/11 13:07:57 peter
  1127. + $ifdef NEWPPU for the new ppuformat
  1128. + $define GDB not longer required
  1129. * removed all warnings and stripped some log comments
  1130. * no findfirst/findnext anymore to remove smartlink *.o files
  1131. Revision 1.7 1998/05/08 09:21:20 michael
  1132. * Added missing -Fl message to messages file.
  1133. * Corrected mangling of file names when doing Linklib
  1134. * -Fl now actually WORKS.
  1135. * Librarysearchpath is now a field in linker object.
  1136. Revision 1.6 1998/05/04 17:54:28 peter
  1137. + smartlinking works (only case jumptable left todo)
  1138. * redesign of systems.pas to support assemblers and linkers
  1139. + Unitname is now also in the PPU-file, increased version to 14
  1140. Revision 1.5 1998/04/30 15:59:42 pierre
  1141. * GDB works again better :
  1142. correct type info in one pass
  1143. + UseTokenInfo for better source position
  1144. * fixed one remaining bug in scanner for line counts
  1145. * several little fixes
  1146. Revision 1.4 1998/04/29 13:42:27 peter
  1147. + $IOCHECKS and $ALIGN to test already, other will follow soon
  1148. * fixed the wrong linecounting with comments
  1149. Revision 1.3 1998/04/28 11:45:53 florian
  1150. * make it compilable with TP
  1151. + small COM problems solved to compile classes.pp
  1152. Revision 1.2 1998/04/28 10:09:54 pierre
  1153. * typo error in asm style reading corrected
  1154. Revision 1.1 1998/04/27 23:13:53 peter
  1155. + the new files for the scanner
  1156. }