Annotation of mandoc/roff.h, Revision 1.33
1.28 schwarze 1: /* $OpenBSD$ */
1.1 kristaps 2: /*
1.28 schwarze 3: * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
1.31 schwarze 4: * Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
1.1 kristaps 5: *
6: * Permission to use, copy, modify, and distribute this software for any
1.12 kristaps 7: * purpose with or without fee is hereby granted, provided that the above
8: * copyright notice and this permission notice appear in all copies.
1.1 kristaps 9: *
1.28 schwarze 10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
1.12 kristaps 11: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1.28 schwarze 12: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
1.12 kristaps 13: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1.1 kristaps 17: */
18:
1.29 schwarze 19: struct mdoc_arg;
20: union mdoc_data;
21:
1.32 schwarze 22: enum roff_macroset {
23: MACROSET_NONE = 0,
24: MACROSET_MDOC,
25: MACROSET_MAN
26: };
27:
1.29 schwarze 28: enum roff_sec {
29: SEC_NONE = 0,
30: SEC_NAME,
31: SEC_LIBRARY,
32: SEC_SYNOPSIS,
33: SEC_DESCRIPTION,
34: SEC_CONTEXT,
35: SEC_IMPLEMENTATION, /* IMPLEMENTATION NOTES */
36: SEC_RETURN_VALUES,
37: SEC_ENVIRONMENT,
38: SEC_FILES,
39: SEC_EXIT_STATUS,
40: SEC_EXAMPLES,
41: SEC_DIAGNOSTICS,
42: SEC_COMPATIBILITY,
43: SEC_ERRORS,
44: SEC_SEE_ALSO,
45: SEC_STANDARDS,
46: SEC_HISTORY,
47: SEC_AUTHORS,
48: SEC_CAVEATS,
49: SEC_BUGS,
50: SEC_SECURITY,
51: SEC_CUSTOM,
52: SEC__MAX
53: };
54:
1.28 schwarze 55: enum roff_type {
56: ROFFT_ROOT,
57: ROFFT_BLOCK,
58: ROFFT_HEAD,
59: ROFFT_BODY,
60: ROFFT_TAIL,
61: ROFFT_ELEM,
62: ROFFT_TEXT,
63: ROFFT_TBL,
64: ROFFT_EQN
1.29 schwarze 65: };
66:
1.31 schwarze 67: enum roff_next {
68: ROFF_NEXT_SIBLING = 0,
69: ROFF_NEXT_CHILD
70: };
71:
1.29 schwarze 72: /*
73: * Indicates that a BODY's formatting has ended, but
74: * the scope is still open. Used for badly nested blocks.
75: */
76: enum mdoc_endbody {
77: ENDBODY_NOT = 0,
78: ENDBODY_SPACE, /* Is broken: append a space. */
79: ENDBODY_NOSPACE /* Is broken: don't append a space. */
80: };
81:
82: struct roff_node {
83: struct roff_node *parent; /* Parent AST node. */
84: struct roff_node *child; /* First child AST node. */
85: struct roff_node *last; /* Last child AST node. */
86: struct roff_node *next; /* Sibling AST node. */
87: struct roff_node *prev; /* Prior sibling AST node. */
88: struct roff_node *head; /* BLOCK */
89: struct roff_node *body; /* BLOCK/ENDBODY */
90: struct roff_node *tail; /* BLOCK */
91: struct mdoc_arg *args; /* BLOCK/ELEM */
92: union mdoc_data *norm; /* Normalized arguments. */
93: char *string; /* TEXT */
94: const struct tbl_span *span; /* TBL */
95: const struct eqn *eqn; /* EQN */
96: int nchild; /* Number of child nodes. */
97: int line; /* Input file line number. */
98: int pos; /* Input file column number. */
99: int tok; /* Request or macro ID. */
1.33 ! schwarze 100: #define TOKEN_NONE (-1) /* No request or macro. */
1.29 schwarze 101: int flags;
102: #define MDOC_VALID (1 << 0) /* Has been validated. */
103: #define MDOC_ENDED (1 << 1) /* Gone past body end mark. */
104: #define MDOC_EOS (1 << 2) /* At sentence boundary. */
105: #define MDOC_LINE (1 << 3) /* First macro/text on line. */
106: #define MDOC_SYNPRETTY (1 << 4) /* SYNOPSIS-style formatting. */
107: #define MDOC_BROKEN (1 << 5) /* Must validate parent when ending. */
108: #define MDOC_DELIMO (1 << 6)
109: #define MDOC_DELIMC (1 << 7)
110: #define MAN_VALID MDOC_VALID
111: #define MAN_EOS MDOC_EOS
112: #define MAN_LINE MDOC_LINE
113: int prev_font; /* Before entering this node. */
114: int aux; /* Decoded node data, type-dependent. */
115: enum roff_type type; /* AST node type. */
116: enum roff_sec sec; /* Current named section. */
117: enum mdoc_endbody end; /* BODY */
1.28 schwarze 118: };
1.30 schwarze 119:
120: struct roff_meta {
121: char *msec; /* Manual section, usually a digit. */
122: char *vol; /* Manual volume title. */
123: char *os; /* Operating system. */
124: char *arch; /* Machine architecture. */
125: char *title; /* Manual title, usually CAPS. */
126: char *name; /* Leading manual name. */
127: char *date; /* Normalized date. */
128: int hasbody; /* Document is not empty. */
1.31 schwarze 129: };
130:
131: struct roff_man {
132: struct roff_meta meta; /* Document meta-data. */
133: struct mparse *parse; /* Parse pointer. */
134: struct roff *roff; /* Roff parser state data. */
135: const char *defos; /* Default operating system. */
136: struct roff_node *first; /* The first node parsed. */
137: struct roff_node *last; /* The last node parsed. */
138: struct roff_node *last_es; /* The most recent Es node. */
139: int quick; /* Abort parse early. */
140: int flags; /* Parse flags. */
141: #define MDOC_LITERAL (1 << 1) /* In a literal scope. */
142: #define MDOC_PBODY (1 << 2) /* In the document body. */
143: #define MDOC_NEWLINE (1 << 3) /* First macro/text in a line. */
144: #define MDOC_PHRASELIT (1 << 4) /* Literal within a partial phrase. */
145: #define MDOC_PPHRASE (1 << 5) /* Within a partial phrase. */
146: #define MDOC_FREECOL (1 << 6) /* `It' invocation should close. */
147: #define MDOC_SYNOPSIS (1 << 7) /* SYNOPSIS-style formatting. */
148: #define MDOC_KEEP (1 << 8) /* In a word keep. */
149: #define MDOC_SMOFF (1 << 9) /* Spacing is off. */
150: #define MDOC_NODELIMC (1 << 10) /* Disable closing delimiter handling. */
151: #define MAN_ELINE (1 << 11) /* Next-line element scope. */
152: #define MAN_BLINE (1 << 12) /* Next-line block scope. */
153: #define MAN_LITERAL MDOC_LITERAL
154: #define MAN_NEWLINE MDOC_NEWLINE
1.32 schwarze 155: enum roff_macroset macroset; /* Kind of high-level macros used. */
1.31 schwarze 156: enum roff_sec lastsec; /* Last section seen. */
157: enum roff_sec lastnamed; /* Last standard section seen. */
158: enum roff_next next; /* Where to put the next node. */
1.30 schwarze 159: };
CVSweb