0
1 %{
2        #include<stdio.h>
3        #include<ctype.h>
4 %}
5 %option noyywrap
6 %%
7 [a-z]   {  putchar(yytext[0]);  }
8
9 "/*"
10        {
11                char ch;
12                while((ch = input()) != '*')
13                        putchar(toupper(ch));
14                while((ch = input()) == '*');
15                if((ch = input()) == '/')
16                        return 0;
17        }



%%

int main()
{
yylex();
return 0;
}
~  

when i'm trying to compile this "lex comment.lex" i'm getting unrecognized rule error in lines 12 ,14 ,15...... Can anyone tell me the answer.........

nwellnhof
  • 32,319
  • 7
  • 89
  • 113
DSC
  • 103
  • 2

1 Answers1

1

See flex info page:

The rule form is:

pattern action

Flex thinks that an actionless new rule is started in lines 9, 10, 11 and so on. Pull the opening curly brace from line 10 on line up so it looks like:

...
"/*"   {
   char ch;
...
Linus Kleen
  • 33,871
  • 11
  • 91
  • 99