0

Hello i was watching a tutorial on youtube. It was the start of tutorial but when i tried to wrote the code and run this flex.l file. The output show unexpected character [a-z] {printf("Single lowercase character\n");} . What should i do with this :(

the youtube link https://www.youtube.com/watch?v=LpVufkH4gog&t=171s time stamp 2:54

   %{
    
     /* definitions*/
    
    %}
    
    /*rules*/
    
    %%
    
    [a-z] {printf("Single lowercase character\n");}
    . {printf("Not a lowercase character\n");}
    \n {return 0;}
    
    %%
    
    
    yywrap() {}
    
    int main() {
    
        printf("Enter String:  ");
        yylex();
        
        return 0;
    
    }
coder123
  • 1
  • 3
  • That's flex, not jflex, right? Please shiw the actual commands you executed and the exact error messages produced (by copying the text into your question, not by including a screenshot.) Also: please check your code copy and paste. In your code block, the text appears to be indented one space, which woukd certainly create errors. But I suspect it's just a c&p mistake. – rici Jun 21 '22 at 15:33
  • i wrote it wrong for the command like this - jflex flex.l ..... then the output flex is not recognized – coder123 Jun 21 '22 at 15:35
  • Why are you using jflex? And, seriously: don't describe what you did. Show it. Literally. You can edit your question. – rici Jun 21 '22 at 15:38
  • i thought it was the same .. but then i google flex is for C based.. – coder123 Jun 21 '22 at 15:41
  • Yes, they are two completely different tools, and they need different input files (and produce output for different languages, at least by default). – rici Jun 21 '22 at 15:47

0 Answers0