fork download
  1. %{
  2. #include <stdio.h>
  3. %}
  4.  
  5. %token NOUN PRONOUN VERB ADVERB ADJECTIVE PREPOSITION CONJUNCTION
  6.  
  7. %%
  8.  
  9. sentence: simple_sentence { printf("Parsed a simple sentence.\n"); }
  10. | compound_sentence { printf("Parsed a compound sentence.\n"); }
  11. ;
  12.  
  13. simple_sentence: subject verb object
  14. | subject verb object prep_phrase
  15. ;
  16.  
  17. compound_sentence: simple_sentence CONJUNCTION simple_sentence
  18. | compound_sentence CONJUNCTION simple_sentence
  19. ;
  20.  
  21. subject: NOUN
  22. | PRONOUN
  23. | ADJECTIVE subject
  24. ;
  25.  
  26. verb: VERB
  27. | ADVERB VERB
  28. | verb VERB
  29. ;
  30.  
  31. object: NOUN
  32. | ADJECTIVE object
  33. ;
  34.  
  35. prep_phrase: PREPOSITION NOUN
  36. ;
  37.  
  38. %%
  39.  
  40. extern FILE *yyin;
  41.  
  42. main()
  43. {
  44. do
  45. {
  46. yyparse();
  47. }
  48. while(!feof(yyin));
  49. }
  50.  
  51. yyerror(s)
  52. char *s;
  53. {
  54. fprintf(stderr, "%s\n", s);
  55. }
Success #stdin #stdout #stderr 0.02s 6272KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/QTyepJ/prog:55:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit