UNIX Free Pascal


.. lex - 4


ENTER=4;

%}

 

%%

'[^']*' begin yyretval:=STROKA; yydone:=true; end;

\"[^"]*\" begin yyretval:=STROKA; yydone:=true; end;

"end." begin yyretval:=STROKA; yydone:=true; end;

\n begin yyretval:=ENTER; yydone:=true; end;

. begin yyretval:=ANY; yydone:=true; end;

"{"[^"}"]*"}" begin yyretval:=COMMENT;yydone:=true; end;

"/*""/"*([^*/]|[^*]"/"|"*"[^/])*"*"*"*/" begin

yyretval:=COMMENT;yydone:=true;

end;

"(*""("*([^*)]|[^*]")"|"*"[^)])*"*"*"*)" begin

yyretval:=COMMENT;yydone:=true;

end;

"//"[^\n]*\n begin yyretval:=COMMENT;yydone:=true; end;

%%

 

(*

function yywrap:boolean;

begin

writeln('end?');

yywrap:=true;

end;

*)

 

var

token:integer;

fresult,fcomment:text;

 

 

begin

if paramcount<>3 then

begin

writeln(': ', paramstr(0), ' _ _ _');

exit;

end;

 

assign(yyinput,paramstr(1));

{$I-}

reset(yyinput);

if ioresult<>0 then

begin

writeln(' ', paramstr(1));

exit;

end;

assign(fresult,paramstr(2));

rewrite(fresult);

if ioresult<>0 then

begin

writeln(' ', paramstr(2));

exit;

end;

assign(fcomment,paramstr(3));

rewrite(fcomment);

if ioresult<>0 then

begin

writeln(' ', paramstr(3));

exit;

end;

token:=yylex;

while not eof(yyinput) do

begin

if token=COMMENT then

writeln(fcomment,yytext)

else

write(fresult,yytext);

token:=yylex;

end;

write(fresult,yytext);

close(yyinput);

close(fcomment);

close(fresult);

end.

 




- -  - -  - -