tree_types.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /* Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016
  2. Free Software Foundation, Inc.
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. #include <stdlib.h>
  14. #include "command_ids.h"
  15. #include "element_types.h"
  16. typedef struct TEXT {
  17. char *text;
  18. size_t space; /* Allocated bytes in 'text', including terminating null. */
  19. size_t end;
  20. } TEXT;
  21. enum extra_type {
  22. extra_element,
  23. extra_element_contents,
  24. extra_element_contents_array,
  25. extra_element_text,
  26. extra_index_entry,
  27. extra_misc_args,
  28. extra_node_spec,
  29. extra_node_spec_array,
  30. extra_string,
  31. extra_def_args,
  32. extra_float_type,
  33. extra_deleted
  34. };
  35. typedef struct KEY_PAIR {
  36. char *key;
  37. enum extra_type type;
  38. struct ELEMENT *value;
  39. } KEY_PAIR;
  40. typedef struct {
  41. enum command_id cmd;
  42. char *begin;
  43. char *end;
  44. } INFO_ENCLOSE;
  45. typedef struct ELEMENT_LIST {
  46. struct ELEMENT **list;
  47. size_t number;
  48. size_t space;
  49. } ELEMENT_LIST;
  50. typedef struct LINE_NR {
  51. int line_nr;
  52. char *file_name;
  53. char *macro;
  54. } LINE_NR;
  55. /* Type of a link in the route from the root of the tree to an element. */
  56. enum route_element_type { route_uninitialized, route_contents, route_args,
  57. route_not_in_tree };
  58. typedef struct {
  59. /* Element that contains a reference to this one. */
  60. struct ELEMENT *element;
  61. /* Index into the referring element's extra keys that is the reference. */
  62. int extra_index;
  63. } PENDING_REFERENCE;
  64. typedef struct ELEMENT {
  65. enum command_id cmd;
  66. TEXT text;
  67. enum element_type type;
  68. ELEMENT_LIST args;
  69. ELEMENT_LIST contents;
  70. struct ELEMENT *parent;
  71. LINE_NR line_nr;
  72. KEY_PAIR *extra;
  73. size_t extra_number;
  74. size_t extra_space;
  75. /* Set to route_not_in_tree if element not in main tree. Also
  76. used for routing information along with 'index_in_parent' when
  77. dumping to a text stream. */
  78. enum route_element_type parent_type;
  79. /********* Used when dumping to a text stream only. ************/
  80. int index_in_parent;
  81. PENDING_REFERENCE *pending_references;
  82. size_t pending_number;
  83. size_t pending_space;
  84. /********* Used when building Perl tree only ********************/
  85. /* should be HV *hv; */
  86. void *hv;
  87. } ELEMENT;
  88. typedef struct GLOBAL_INFO {
  89. char *input_file_name;
  90. char *input_encoding_name;
  91. /* Elements that should be unique. */
  92. // 288 and Common.pm:164
  93. ELEMENT *settitle; /* Title of document. */
  94. ELEMENT *copying;
  95. ELEMENT *title;
  96. ELEMENT *titlepage;
  97. ELEMENT *top;
  98. ELEMENT *setfilename;
  99. ELEMENT *documentdescription;
  100. ELEMENT *setcontentsaftertitlepage;
  101. ELEMENT *setshortcontentsaftertitlepage;
  102. ELEMENT *novalidate;
  103. ELEMENT *validatemenus;
  104. ELEMENT *pagesizes;
  105. ELEMENT *fonttextsize;
  106. ELEMENT *footnotestyle;
  107. ELEMENT *setchapternewpage;
  108. ELEMENT *everyheading;
  109. ELEMENT *everyfooting;
  110. ELEMENT *evenheading;
  111. ELEMENT *evenfooting;
  112. ELEMENT *oddheading;
  113. ELEMENT *oddfooting;
  114. ELEMENT *everyheadingmarks;
  115. ELEMENT *everyfootingmarks;
  116. ELEMENT *evenheadingmarks;
  117. ELEMENT *oddheadingmarks;
  118. ELEMENT *evenfootingmarks;
  119. ELEMENT *oddfootingmarks;
  120. ELEMENT *shorttitlepage;
  121. /* Arrays of elements */
  122. ELEMENT footnotes;
  123. ELEMENT hyphenation;
  124. ELEMENT insertcopying;
  125. ELEMENT printindex;
  126. ELEMENT subtitle;
  127. ELEMENT titlefont;
  128. ELEMENT listoffloats;
  129. ELEMENT detailmenu;
  130. ELEMENT part;
  131. ELEMENT allowcodebreaks;
  132. ELEMENT clickstyle;
  133. ELEMENT codequotebacktick;
  134. ELEMENT codequoteundirected;
  135. ELEMENT contents;
  136. ELEMENT deftypefnnewline;
  137. ELEMENT documentencoding;
  138. ELEMENT documentlanguage;
  139. ELEMENT exampleindent;
  140. ELEMENT firstparagraphindent;
  141. ELEMENT frenchspacing;
  142. ELEMENT headings;
  143. ELEMENT kbdinputstyle;
  144. ELEMENT paragraphindent;
  145. ELEMENT shortcontents;
  146. ELEMENT urefbreakstyle;
  147. ELEMENT xrefautomaticsectiontitle;
  148. } GLOBAL_INFO;
  149. typedef struct CONF {
  150. int show_menu;
  151. } CONF;
  152. typedef struct {
  153. char *index_name;
  154. char *index_prefix;
  155. enum command_id index_at_command;
  156. enum command_id index_type_command;
  157. /* content->contents is the index entry text */
  158. ELEMENT *content;
  159. /* content_normalized */
  160. ELEMENT *command;
  161. ELEMENT *node;
  162. int number; /* Index of entry in containing index, 1-based. */
  163. ELEMENT *region;
  164. } INDEX_ENTRY;
  165. typedef struct INDEX {
  166. char *name;
  167. char *prefix;
  168. int in_code;
  169. struct INDEX *merged_in; /* Index this index is merged into, if any. */
  170. INDEX_ENTRY *index_entries;
  171. size_t index_number;
  172. size_t index_space;
  173. /********* Used when building Perl hash value ********************/
  174. void *hv;
  175. void *contained_hv;
  176. } INDEX;
  177. /* Used when dumping to a text stream only. A reference to an
  178. index entry, in the "index_entry" extra key of an element.
  179. index->index_entries[entry] is the referred-to index entry. */
  180. typedef struct {
  181. INDEX *index;
  182. int entry;
  183. } INDEX_ENTRY_REF;
  184. /* See parse_node_manual function. */
  185. typedef struct {
  186. ELEMENT *manual_content;
  187. ELEMENT *node_content;
  188. } NODE_SPEC_EXTRA;
  189. typedef struct {
  190. char **labels;
  191. ELEMENT **elements;
  192. int nelements;
  193. int space;
  194. } DEF_ARGS_EXTRA;
  195. typedef struct {
  196. ELEMENT *content;
  197. char *normalized;
  198. } EXTRA_FLOAT_TYPE;
  199. enum error_type { error, warning };
  200. typedef struct {
  201. char *macro_name;
  202. ELEMENT *element;
  203. enum command_id cmd;
  204. char *macrobody;
  205. } MACRO;