fork download
  1. %{
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. %}
  5. %token DIGIT LETTER UND NL
  6. %%
  7. stmt: variable NL {printf("Valid Identifier\n");exit(0);}
  8. variable: LETTER alphanumeric;
  9. alphanumeric: LETTER alphanumeric
  10. | DIGIT alphanumeric
  11. | UND alphanumeric
  12. | LETTER
  13. | DIGIT
  14. | UND;
  15. %%
  16.  
  17. int yyerror(){
  18. printf("Invalid Identifier\n");
  19. exit(0);
  20. }
  21.  
  22. void main(){
  23. printf("Enter the variable name: ");
  24. yyparse();
  25. }
Success #stdin #stdout #stderr 0.03s 6784KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/MBhe2w/prog:25:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit