#99 Article 1016 Posted at 1995/12/11 13:51:55 by sura (MAP022) [SAHOU.2]

Subject: Re: プログラミング作法・お題2 /995

%{

#include <stdio.h>
#define	output(a)	/*null*/

int main(){
int retc, wordcount = 0;

   if ( (yyin = fopen("LOG","r")) == NULL){
      perror("cannot read open LOG");
      return 1;
   }

  for (;(retc = yylex()) != 0; ){
     if ( retc == 'M' ){
       ++wordcount;
     }
  }

   printf("match:%d\n", wordcount);
   return 0;
}


%}

letter	[a-zA-Z]
maple    MAPLE
notmaple	{letter}+{maple}|{maple}{letter}+
other		.

%%
{notmaple}		{return 'N';}
{maple}			{return 'M';}
{other}			{return 1;}
%%