org_parser.y 786 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* Org Mode file parser -*-c-*- */
  2. %{
  3. #include <stdio.h>
  4. %}
  5. %defines
  6. %token HEADING TEXT NUMBERED_LIST LIST NEW_LINE NEW_ELEMENT
  7. %%
  8. org_document: /* empty */
  9. | org_document heading
  10. | org_document text
  11. | org_document numbered_list
  12. | org_document list
  13. | org_document NEW_ELEMENT
  14. ;
  15. heading: HEADING TEXT NEW_LINE {printf ("HEADING ");}
  16. | HEADING NEW_LINE {printf ("heading blank\n");}
  17. ;
  18. numbered_list: NUMBERED_LIST TEXT NEW_LINE {printf ("NUMBERED_LIST ");}
  19. | NUMBERED_LIST NEW_LINE
  20. | numbered_list TEXT {printf ("nl_text ");}
  21. | numbered_list NUMBERED_LIST {printf (" element ");}
  22. | numbered_list NEW_LINE {printf ("nl_newline\n");}
  23. ;
  24. list: LIST {printf ("new list\n");}
  25. | list TEXT {printf ("list text\n");}
  26. | list NEW_LINE
  27. text: TEXT {printf ("new text\n");}
  28. | text NEW_LINE
  29. %%