org_parser.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * @file org_parser.h
  3. * @brief Parses document elements into a document structure
  4. */
  5. /*
  6. * This program is free software: you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation, either vers* ion 3 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see
  18. * <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef ORG_PARSER_H
  21. #define ORG_PARSER_H
  22. #include <stdio.h>
  23. //#include "org_lexer.h"
  24. #include "org_document.h"
  25. #include "parse_ctxt.h"
  26. struct doc_elt;
  27. typedef struct doc_elt doc_elt;
  28. /**
  29. * @file org_parser.h
  30. * @brief Implement an Org mode file parser.
  31. */
  32. /**
  33. * @brief parse a FILE stream into a doc_tree.
  34. */
  35. org_document *org_parse_file_stream (FILE * file, doc_src src, parse_ctxt *ctxt);
  36. /**
  37. * Token declaration for the lexer & parser.
  38. */
  39. typedef enum TOKEN
  40. {
  41. T_QUIT = 0, /* signal to quit from the lexer */
  42. T_NOTHING, /* return nothing (no element) */
  43. T_ORG_HEADING, /* a heading */
  44. T_ORG_TEXT, /* regular text under a heading */
  45. T_ORG_PROPERTY, /* a property */
  46. T_ORG_DRAWER_BEGIN, /* beginning of a drawer */
  47. T_ORG_DRAWER_END /* end of a drawer */
  48. } TOKEN;
  49. struct extra
  50. {
  51. doc_elt *elt;
  52. doc_elt *curr_elt;
  53. TOKEN curr_type;
  54. void *data;
  55. doc_src src;
  56. parse_ctxt *ctxt;
  57. };
  58. #endif