fork download
  1. %{
  2. /* A Lex program to print the name when ENTER key is pressed */
  3. /* The lexer is generated using flex */
  4. #include <stdio.h>
  5. char Name[10]; // Global variable to store name
  6. %}
  7.  
  8. %%
  9. \n {
  10. /* First rule is matched when a new line is found */
  11. /* Print the message along with the given input name */
  12. printf("Hi......%s......Good Morning\n", Name);
  13. }
  14. %%
  15.  
  16. int main()
  17. {
  18. char opt;
  19. do
  20. {
  21. printf("\nWhat is your name: ");
  22. scanf("%s", Name); // Scanning your name
  23. yylex(); // Calling the rule section function
  24. printf("\nPress any key to continue (Y/y): ");
  25. scanf(" %c", &opt);
  26. } while (opt == 'Y' || opt == 'y');
  27.  
  28. return 0;
  29. }
Success #stdin #stdout #stderr 0.02s 6904KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/fux3vq/prog:29:0: Syntax error: end_of_file_in_quasi_quotation
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit