fork download
  1. %{
  2. #include <stdio.h>
  3. #define max 5
  4. int i = 0;
  5. %}
  6. Digit [0-9]
  7. Letter [a-zA-Z]
  8. Id {Letter}({Letter}|{Digit})*
  9. Comment "//".*
  10. %%
  11. [ \t\n] {}
  12. {Comment} {}
  13. {Id} {
  14. if(yyleng > max){
  15. printf("Identifier (%s) Can't Exceed Length %d\n",yytext,max);
  16. }else{
  17. printf("Identifier : %s\n",yytext);
  18. i++;
  19. }
  20. }
  21. {Digit} { printf("Number : %s\n",yytext); }
  22. "+"|"*"|"/"|"="|"("|")"|";"|"," { printf("Operator Or Punctuation : %s\n", yytext);
  23. } .
  24. { printf("Unrecognized Character : %s\n", yytext); }
  25. %%
  26. int main(){
  27. yylex();
  28. printf("Valid Identifiers : %d\n",i);
  29. return 0;
  30. }
Success #stdin #stdout #stderr 0.03s 6952KB
stdin
Raise in pune supergints
stdout
Standard output is empty
stderr
ERROR: /home/1KLoaz/prog:2:1: Syntax error: Operator expected
ERROR: /home/1KLoaz/prog:30:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit