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