]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc_macro.c
1 /* $Id: mdoc_macro.c,v 1.220 2017/04/29 12:45:42 schwarze Exp $ */
3 * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
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.
20 #include <sys/types.h>
32 #include "libmandoc.h"
36 static void blk_full(MACRO_PROT_ARGS
);
37 static void blk_exp_close(MACRO_PROT_ARGS
);
38 static void blk_part_exp(MACRO_PROT_ARGS
);
39 static void blk_part_imp(MACRO_PROT_ARGS
);
40 static void ctx_synopsis(MACRO_PROT_ARGS
);
41 static void in_line_eoln(MACRO_PROT_ARGS
);
42 static void in_line_argn(MACRO_PROT_ARGS
);
43 static void in_line(MACRO_PROT_ARGS
);
44 static void phrase_ta(MACRO_PROT_ARGS
);
46 static void append_delims(struct roff_man
*, int, int *, char *);
47 static void dword(struct roff_man
*, int, int, const char *,
49 static int find_pending(struct roff_man
*, enum roff_tok
,
50 int, int, struct roff_node
*);
51 static int lookup(struct roff_man
*, int, int, int, const char *);
52 static int macro_or_word(MACRO_PROT_ARGS
, int);
53 static void break_intermediate(struct roff_node
*,
55 static int parse_rest(struct roff_man
*, enum roff_tok
,
57 static enum roff_tok
rew_alt(enum roff_tok
);
58 static void rew_elem(struct roff_man
*, enum roff_tok
);
59 static void rew_last(struct roff_man
*, const struct roff_node
*);
60 static void rew_pending(struct roff_man
*,
61 const struct roff_node
*);
63 const struct mdoc_macro __mdoc_macros
[MDOC_MAX
- MDOC_Dd
] = {
64 { in_line_eoln
, MDOC_PROLOGUE
}, /* Dd */
65 { in_line_eoln
, MDOC_PROLOGUE
}, /* Dt */
66 { in_line_eoln
, MDOC_PROLOGUE
}, /* Os */
67 { blk_full
, MDOC_PARSED
| MDOC_JOIN
}, /* Sh */
68 { blk_full
, MDOC_PARSED
| MDOC_JOIN
}, /* Ss */
69 { in_line_eoln
, 0 }, /* Pp */
70 { blk_part_imp
, MDOC_PARSED
| MDOC_JOIN
}, /* D1 */
71 { blk_part_imp
, MDOC_PARSED
| MDOC_JOIN
}, /* Dl */
72 { blk_full
, MDOC_EXPLICIT
}, /* Bd */
73 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ed */
74 { blk_full
, MDOC_EXPLICIT
}, /* Bl */
75 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* El */
76 { blk_full
, MDOC_PARSED
| MDOC_JOIN
}, /* It */
77 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ad */
78 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* An */
79 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ap */
80 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ar */
81 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Cd */
82 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Cm */
83 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Dv */
84 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Er */
85 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ev */
86 { in_line_eoln
, 0 }, /* Ex */
87 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fa */
88 { in_line_eoln
, 0 }, /* Fd */
89 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fl */
90 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fn */
91 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ft */
92 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ic */
93 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* In */
94 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Li */
95 { blk_full
, MDOC_JOIN
}, /* Nd */
96 { ctx_synopsis
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Nm */
97 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Op */
98 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ot */
99 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Pa */
100 { in_line_eoln
, 0 }, /* Rv */
101 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* St */
102 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Va */
103 { ctx_synopsis
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Vt */
104 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Xr */
105 { in_line_eoln
, MDOC_JOIN
}, /* %A */
106 { in_line_eoln
, MDOC_JOIN
}, /* %B */
107 { in_line_eoln
, MDOC_JOIN
}, /* %D */
108 { in_line_eoln
, MDOC_JOIN
}, /* %I */
109 { in_line_eoln
, MDOC_JOIN
}, /* %J */
110 { in_line_eoln
, 0 }, /* %N */
111 { in_line_eoln
, MDOC_JOIN
}, /* %O */
112 { in_line_eoln
, 0 }, /* %P */
113 { in_line_eoln
, MDOC_JOIN
}, /* %R */
114 { in_line_eoln
, MDOC_JOIN
}, /* %T */
115 { in_line_eoln
, 0 }, /* %V */
116 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
117 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ac */
118 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
119 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ao */
120 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Aq */
121 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* At */
122 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
123 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Bc */
124 { blk_full
, MDOC_EXPLICIT
}, /* Bf */
125 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
126 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Bo */
127 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Bq */
128 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Bsx */
129 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Bx */
130 { in_line_eoln
, 0 }, /* Db */
131 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
132 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Dc */
133 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
134 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Do */
135 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Dq */
136 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Ec */
137 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ef */
138 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Em */
139 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Eo */
140 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fx */
141 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ms */
142 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* No */
143 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
|
144 MDOC_IGNDELIM
| MDOC_JOIN
}, /* Ns */
145 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Nx */
146 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ox */
147 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
148 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Pc */
149 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_IGNDELIM
}, /* Pf */
150 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
151 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Po */
152 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Pq */
153 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
154 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Qc */
155 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ql */
156 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
157 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Qo */
158 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Qq */
159 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* Re */
160 { blk_full
, MDOC_EXPLICIT
}, /* Rs */
161 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
162 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Sc */
163 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
164 MDOC_EXPLICIT
| MDOC_JOIN
}, /* So */
165 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Sq */
166 { in_line_argn
, 0 }, /* Sm */
167 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Sx */
168 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Sy */
169 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Tn */
170 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ux */
171 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Xc */
172 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Xo */
173 { blk_full
, MDOC_EXPLICIT
| MDOC_CALLABLE
}, /* Fo */
174 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
175 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Fc */
176 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
177 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Oo */
178 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
179 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Oc */
180 { blk_full
, MDOC_EXPLICIT
}, /* Bk */
181 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ek */
182 { in_line_eoln
, 0 }, /* Bt */
183 { in_line_eoln
, 0 }, /* Hf */
184 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fr */
185 { in_line_eoln
, 0 }, /* Ud */
186 { in_line
, 0 }, /* Lb */
187 { in_line_eoln
, 0 }, /* Lp */
188 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Lk */
189 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Mt */
190 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Brq */
191 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
192 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Bro */
193 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
194 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Brc */
195 { in_line_eoln
, MDOC_JOIN
}, /* %C */
196 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Es */
197 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* En */
198 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Dx */
199 { in_line_eoln
, MDOC_JOIN
}, /* %Q */
200 { in_line_eoln
, 0 }, /* br */
201 { in_line_eoln
, 0 }, /* sp */
202 { in_line_eoln
, 0 }, /* %U */
203 { phrase_ta
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ta */
204 { in_line_eoln
, MDOC_PROLOGUE
}, /* ll */
206 const struct mdoc_macro
*const mdoc_macros
= __mdoc_macros
- MDOC_Dd
;
210 * This is called at the end of parsing. It must traverse up the tree,
211 * closing out open [implicit] scopes. Obviously, open explicit scopes
215 mdoc_endparse(struct roff_man
*mdoc
)
219 /* Scan for open explicit scopes. */
221 n
= mdoc
->last
->flags
& NODE_VALID
?
222 mdoc
->last
->parent
: mdoc
->last
;
224 for ( ; n
; n
= n
->parent
)
225 if (n
->type
== ROFFT_BLOCK
&&
226 mdoc_macros
[n
->tok
].flags
& MDOC_EXPLICIT
)
227 mandoc_msg(MANDOCERR_BLK_NOEND
, mdoc
->parse
,
228 n
->line
, n
->pos
, roff_name
[n
->tok
]);
230 /* Rewind to the first. */
232 rew_last(mdoc
, mdoc
->first
);
233 mdoc_state_reset(mdoc
);
237 * Look up the macro at *p called by "from",
238 * or as a line macro if from == TOKEN_NONE.
241 lookup(struct roff_man
*mdoc
, int from
, int line
, int ppos
, const char *p
)
245 if (mdoc
->flags
& MDOC_PHRASEQF
) {
246 mdoc
->flags
&= ~MDOC_PHRASEQF
;
249 if (from
== TOKEN_NONE
|| mdoc_macros
[from
].flags
& MDOC_PARSED
) {
250 res
= roffhash_find(mdoc
->mdocmac
, p
, 0);
251 if (res
!= TOKEN_NONE
) {
252 if (mdoc_macros
[res
].flags
& MDOC_CALLABLE
)
254 if (res
!= MDOC_br
&& res
!= MDOC_sp
&& res
!= MDOC_ll
)
255 mandoc_msg(MANDOCERR_MACRO_CALL
,
256 mdoc
->parse
, line
, ppos
, p
);
263 * Rewind up to and including a specific node.
266 rew_last(struct roff_man
*mdoc
, const struct roff_node
*to
)
269 if (to
->flags
& NODE_VALID
)
272 while (mdoc
->last
!= to
) {
273 mdoc_state(mdoc
, mdoc
->last
);
274 mdoc
->last
->flags
|= NODE_VALID
| NODE_ENDED
;
275 mdoc
->last
= mdoc
->last
->parent
;
277 mdoc_state(mdoc
, mdoc
->last
);
278 mdoc
->last
->flags
|= NODE_VALID
| NODE_ENDED
;
279 mdoc
->next
= ROFF_NEXT_SIBLING
;
283 * Rewind up to a specific block, including all blocks that broke it.
286 rew_pending(struct roff_man
*mdoc
, const struct roff_node
*n
)
292 if (mdoc
->last
== n
) {
295 roff_body_alloc(mdoc
, n
->line
, n
->pos
,
303 if ( ! (n
->flags
& NODE_BROKEN
))
309 if ((n
= n
->parent
) == NULL
)
312 if (n
->type
== ROFFT_BLOCK
||
313 n
->type
== ROFFT_HEAD
) {
314 if (n
->flags
& NODE_ENDED
)
324 * For a block closing macro, return the corresponding opening one.
325 * Otherwise, return the macro itself.
328 rew_alt(enum roff_tok tok
)
369 rew_elem(struct roff_man
*mdoc
, enum roff_tok tok
)
374 if (n
->type
!= ROFFT_ELEM
)
376 assert(n
->type
== ROFFT_ELEM
);
377 assert(tok
== n
->tok
);
382 break_intermediate(struct roff_node
*n
, struct roff_node
*breaker
)
385 n
->type
!= ROFFT_BLOCK
&& n
->type
!= ROFFT_HEAD
&&
386 (n
->type
!= ROFFT_BODY
|| n
->end
!= ENDBODY_NOT
))
388 while (n
!= breaker
) {
389 if ( ! (n
->flags
& NODE_VALID
))
390 n
->flags
|= NODE_BROKEN
;
396 * If there is an open sub-block of the target requiring
397 * explicit close-out, postpone closing out the target until
398 * the rew_pending() call closing out the sub-block.
401 find_pending(struct roff_man
*mdoc
, enum roff_tok tok
, int line
, int ppos
,
402 struct roff_node
*target
)
407 if (target
->flags
& NODE_VALID
)
411 for (n
= mdoc
->last
; n
!= NULL
&& n
!= target
; n
= n
->parent
) {
412 if (n
->flags
& NODE_ENDED
)
414 if (n
->type
== ROFFT_BLOCK
&&
415 mdoc_macros
[n
->tok
].flags
& MDOC_EXPLICIT
) {
417 break_intermediate(mdoc
->last
, target
);
418 if (target
->type
== ROFFT_HEAD
)
419 target
->flags
|= NODE_ENDED
;
420 else if ( ! (target
->flags
& NODE_ENDED
)) {
421 mandoc_vmsg(MANDOCERR_BLK_NEST
,
422 mdoc
->parse
, line
, ppos
,
423 "%s breaks %s", roff_name
[tok
],
425 mdoc_endbody_alloc(mdoc
, line
, ppos
,
434 * Allocate a word and check whether it's punctuation or not.
435 * Punctuation consists of those tokens found in mdoc_isdelim().
438 dword(struct roff_man
*mdoc
, int line
, int col
, const char *p
,
439 enum mdelim d
, int may_append
)
446 ! (mdoc
->flags
& (MDOC_SYNOPSIS
| MDOC_KEEP
| MDOC_SMOFF
)) &&
447 d
== DELIM_NONE
&& mdoc
->last
->type
== ROFFT_TEXT
&&
448 mdoc_isdelim(mdoc
->last
->string
) == DELIM_NONE
) {
449 roff_word_append(mdoc
, p
);
453 roff_word_alloc(mdoc
, line
, col
, p
);
456 * If the word consists of a bare delimiter,
457 * flag the new node accordingly,
458 * unless doing so was vetoed by the invoking macro.
459 * Always clear the veto, it is only valid for one word.
463 mdoc
->last
->flags
|= NODE_DELIMO
;
464 else if (d
== DELIM_CLOSE
&&
465 ! (mdoc
->flags
& MDOC_NODELIMC
) &&
466 mdoc
->last
->parent
->tok
!= MDOC_Fd
)
467 mdoc
->last
->flags
|= NODE_DELIMC
;
468 mdoc
->flags
&= ~MDOC_NODELIMC
;
472 append_delims(struct roff_man
*mdoc
, int line
, int *pos
, char *buf
)
477 if (buf
[*pos
] == '\0')
482 if (mdoc_args(mdoc
, line
, pos
, buf
, TOKEN_NONE
, &p
) ==
485 dword(mdoc
, line
, la
, p
, DELIM_MAX
, 1);
488 * If we encounter end-of-sentence symbols, then trigger
491 * XXX: it's easy to allow this to propagate outward to
492 * the last symbol, such that `. )' will cause the
493 * correct double-spacing. However, (1) groff isn't
494 * smart enough to do this and (2) it would require
495 * knowing which symbols break this behaviour, for
496 * example, `. ;' shouldn't propagate the double-space.
499 if (mandoc_eos(p
, strlen(p
)))
500 mdoc
->last
->flags
|= NODE_EOS
;
506 * If it is a macro, call it and return 1.
507 * Otherwise, allocate it and return 0.
510 macro_or_word(MACRO_PROT_ARGS
, int parsed
)
519 else if (parsed
&& ! (mdoc
->flags
& MDOC_PHRASELIT
))
520 ntok
= lookup(mdoc
, tok
, line
, ppos
, p
);
522 if (ntok
== TOKEN_NONE
) {
523 dword(mdoc
, line
, ppos
, p
, DELIM_MAX
, tok
== TOKEN_NONE
||
524 mdoc_macros
[tok
].flags
& MDOC_JOIN
);
527 if (tok
!= TOKEN_NONE
&&
528 mdoc_macros
[tok
].fp
== in_line_eoln
)
530 mdoc_macro(mdoc
, ntok
, line
, ppos
, pos
, buf
);
531 if (tok
== TOKEN_NONE
)
532 append_delims(mdoc
, line
, pos
, buf
);
538 * Close out block partial/full explicit.
541 blk_exp_close(MACRO_PROT_ARGS
)
543 struct roff_node
*body
; /* Our own body. */
544 struct roff_node
*endbody
; /* Our own end marker. */
545 struct roff_node
*itblk
; /* An It block starting later. */
546 struct roff_node
*later
; /* A sub-block starting later. */
547 struct roff_node
*n
; /* Search back to our block. */
548 struct roff_node
*target
; /* For find_pending(). */
550 int j
, lastarg
, maxargs
, nl
, pending
;
552 enum roff_tok atok
, ntok
;
555 nl
= MDOC_NEWLINE
& mdoc
->flags
;
562 mdoc
->flags
&= ~MDOC_KEEP
;
569 /* Search backwards for the beginning of our own body. */
573 for (n
= mdoc
->last
; n
; n
= n
->parent
) {
574 if (n
->flags
& NODE_ENDED
|| n
->tok
!= atok
||
575 n
->type
!= ROFFT_BODY
|| n
->end
!= ENDBODY_NOT
)
582 * Search backwards for beginnings of blocks,
583 * both of our own and of pending sub-blocks.
586 endbody
= itblk
= later
= NULL
;
587 for (n
= mdoc
->last
; n
; n
= n
->parent
) {
588 if (n
->flags
& NODE_ENDED
)
592 * Mismatching end macros can never break anything
593 * and we only care about the breaking of BLOCKs.
596 if (body
== NULL
|| n
->type
!= ROFFT_BLOCK
)
600 * SYNOPSIS name blocks can not be broken themselves,
601 * but they do get broken together with a broken child.
604 if (n
->tok
== MDOC_Nm
) {
606 n
->flags
|= NODE_BROKEN
| NODE_ENDED
;
610 if (n
->tok
== MDOC_It
) {
615 if (atok
== n
->tok
) {
618 * Found the start of our own block.
619 * When there is no pending sub block,
620 * just proceed to closing out.
624 (tok
== MDOC_El
&& itblk
== NULL
))
628 * When there is a pending sub block, postpone
629 * closing out the current block until the
630 * rew_pending() closing out the sub-block.
631 * Mark the place where the formatting - but not
632 * the scope - of the current block ends.
635 mandoc_vmsg(MANDOCERR_BLK_NEST
, mdoc
->parse
,
636 line
, ppos
, "%s breaks %s",
637 roff_name
[atok
], roff_name
[later
->tok
]);
639 endbody
= mdoc_endbody_alloc(mdoc
, line
, ppos
,
643 itblk
->flags
|= NODE_ENDED
| NODE_BROKEN
;
646 * If a block closing macro taking arguments
647 * breaks another block, put the arguments
648 * into the end marker.
652 mdoc
->next
= ROFF_NEXT_CHILD
;
657 * Explicit blocks close out description lines, but
658 * even those can get broken together with a child.
661 if (n
->tok
== MDOC_Nd
) {
663 n
->flags
|= NODE_BROKEN
| NODE_ENDED
;
669 /* Breaking an open sub block. */
671 break_intermediate(mdoc
->last
, body
);
672 n
->flags
|= NODE_BROKEN
;
678 mandoc_msg(MANDOCERR_BLK_NOTOPEN
, mdoc
->parse
,
679 line
, ppos
, roff_name
[tok
]);
680 if (maxargs
&& endbody
== NULL
) {
682 * Stray .Ec without previous .Eo:
683 * Break the output line, keep the arguments.
685 roff_elem_alloc(mdoc
, line
, ppos
, MDOC_br
);
686 rew_elem(mdoc
, MDOC_br
);
688 } else if (endbody
== NULL
) {
689 rew_last(mdoc
, body
);
691 mdoc_tail_alloc(mdoc
, line
, ppos
, atok
);
694 if ( ! (mdoc_macros
[tok
].flags
& MDOC_PARSED
)) {
695 if (buf
[*pos
] != '\0')
696 mandoc_vmsg(MANDOCERR_ARG_SKIP
,
697 mdoc
->parse
, line
, ppos
,
698 "%s %s", roff_name
[tok
],
700 if (endbody
== NULL
&& n
!= NULL
)
701 rew_pending(mdoc
, n
);
712 if (j
== maxargs
&& n
!= NULL
)
715 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
716 if (ac
== ARGS_PUNCT
|| ac
== ARGS_EOLN
)
719 ntok
= ac
== ARGS_QWORD
? TOKEN_NONE
:
720 lookup(mdoc
, tok
, line
, lastarg
, p
);
722 if (ntok
== TOKEN_NONE
) {
723 dword(mdoc
, line
, lastarg
, p
, DELIM_MAX
,
724 MDOC_JOIN
& mdoc_macros
[tok
].flags
);
730 mdoc
->flags
&= ~MDOC_NEWLINE
;
731 mdoc_macro(mdoc
, ntok
, line
, lastarg
, pos
, buf
);
737 if (ntok
!= TOKEN_NONE
&& n
->flags
& NODE_BROKEN
) {
740 target
= target
->parent
;
741 while ( ! (target
->flags
& NODE_ENDED
));
742 pending
= find_pending(mdoc
, ntok
, line
, ppos
, target
);
745 rew_pending(mdoc
, n
);
748 append_delims(mdoc
, line
, pos
, buf
);
752 in_line(MACRO_PROT_ARGS
)
754 int la
, scope
, cnt
, firstarg
, mayopen
, nc
, nl
;
758 struct mdoc_arg
*arg
;
761 nl
= MDOC_NEWLINE
& mdoc
->flags
;
764 * Whether we allow ignored elements (those without content,
765 * usually because of reserved words) to squeak by.
782 mdoc_argv(mdoc
, line
, tok
, &arg
, pos
, buf
);
787 for (cnt
= scope
= 0;; ) {
789 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
792 * At the end of a macro line,
793 * opening delimiters do not suppress spacing.
796 if (ac
== ARGS_EOLN
) {
798 mdoc
->last
->flags
&= ~NODE_DELIMO
;
803 * The rest of the macro line is only punctuation,
804 * to be handled by append_delims().
805 * If there were no other arguments,
806 * do not allow the first one to suppress spacing,
807 * even if it turns out to be a closing one.
810 if (ac
== ARGS_PUNCT
) {
811 if (cnt
== 0 && (nc
== 0 || tok
== MDOC_An
))
812 mdoc
->flags
|= MDOC_NODELIMC
;
816 ntok
= (ac
== ARGS_QWORD
|| (tok
== MDOC_Fn
&& !cnt
)) ?
817 TOKEN_NONE
: lookup(mdoc
, tok
, line
, la
, p
);
820 * In this case, we've located a submacro and must
821 * execute it. Close out scope, if open. If no
822 * elements have been generated, either create one (nc)
823 * or raise a warning.
826 if (ntok
!= TOKEN_NONE
) {
830 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
831 rew_last(mdoc
, mdoc
->last
);
832 } else if ( ! nc
&& ! cnt
) {
834 mandoc_msg(MANDOCERR_MACRO_EMPTY
,
835 mdoc
->parse
, line
, ppos
,
838 mdoc_macro(mdoc
, ntok
, line
, la
, pos
, buf
);
840 append_delims(mdoc
, line
, pos
, buf
);
845 * Non-quote-enclosed punctuation. Set up our scope, if
846 * a word; rewind the scope, if a delimiter; then append
850 d
= ac
== ARGS_QWORD
? DELIM_NONE
: mdoc_isdelim(p
);
852 if (DELIM_NONE
!= d
) {
854 * If we encounter closing punctuation, no word
855 * has been emitted, no scope is open, and we're
856 * allowed to have an empty element, then start
859 if ((d
== DELIM_CLOSE
||
860 (d
== DELIM_MIDDLE
&& tok
== MDOC_Fl
)) &&
861 !cnt
&& !scope
&& nc
&& mayopen
) {
862 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
869 * Close out our scope, if one is open, before
877 } else if (mayopen
&& !scope
) {
878 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
883 dword(mdoc
, line
, la
, p
, d
,
884 mdoc_macros
[tok
].flags
& MDOC_JOIN
);
887 * If the first argument is a closing delimiter,
888 * do not suppress spacing before it.
891 if (firstarg
&& d
== DELIM_CLOSE
&& !nc
)
892 mdoc
->last
->flags
&= ~NODE_DELIMC
;
896 * `Fl' macros have their scope re-opened with each new
897 * word so that the `-' can be added to each one without
898 * having to parse out spaces.
900 if (scope
&& tok
== MDOC_Fl
) {
906 if (scope
&& tok
!= MDOC_Lk
) {
912 * If no elements have been collected and we're allowed to have
913 * empties (nc), open a scope and close it out. Otherwise,
919 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
920 rew_last(mdoc
, mdoc
->last
);
923 mandoc_msg(MANDOCERR_MACRO_EMPTY
, mdoc
->parse
,
924 line
, ppos
, roff_name
[tok
]);
928 append_delims(mdoc
, line
, pos
, buf
);
934 blk_full(MACRO_PROT_ARGS
)
937 struct mdoc_arg
*arg
;
938 struct roff_node
*blk
; /* Our own or a broken block. */
939 struct roff_node
*head
; /* Our own head. */
940 struct roff_node
*body
; /* Our own body. */
942 enum margserr ac
, lac
;
945 nl
= MDOC_NEWLINE
& mdoc
->flags
;
947 if (buf
[*pos
] == '\0' && (tok
== MDOC_Sh
|| tok
== MDOC_Ss
)) {
948 mandoc_msg(MANDOCERR_MACRO_EMPTY
, mdoc
->parse
,
949 line
, ppos
, roff_name
[tok
]);
953 if ( ! (mdoc_macros
[tok
].flags
& MDOC_EXPLICIT
)) {
955 /* Here, tok is one of Sh Ss Nm Nd It. */
958 for (n
= mdoc
->last
; n
!= NULL
; n
= n
->parent
) {
959 if (n
->flags
& NODE_ENDED
) {
960 if ( ! (n
->flags
& NODE_VALID
))
961 n
->flags
|= NODE_BROKEN
;
964 if (n
->type
!= ROFFT_BLOCK
)
967 if (tok
== MDOC_It
&& n
->tok
== MDOC_Bl
) {
969 mandoc_vmsg(MANDOCERR_BLK_BROKEN
,
970 mdoc
->parse
, line
, ppos
,
972 roff_name
[blk
->tok
]);
973 rew_pending(mdoc
, blk
);
978 if (mdoc_macros
[n
->tok
].flags
& MDOC_EXPLICIT
) {
982 mandoc_vmsg(MANDOCERR_BLK_BROKEN
,
983 mdoc
->parse
, line
, ppos
,
984 "%s breaks %s", roff_name
[tok
],
986 rew_pending(mdoc
, n
);
990 /* Delay in case it's astray. */
999 /* Here, n is one of Sh Ss Nm Nd It. */
1001 if (tok
!= MDOC_Sh
&& (n
->tok
== MDOC_Sh
||
1002 (tok
!= MDOC_Ss
&& (n
->tok
== MDOC_Ss
||
1003 (tok
!= MDOC_It
&& n
->tok
== MDOC_It
)))))
1006 /* Item breaking an explicit block. */
1009 mandoc_vmsg(MANDOCERR_BLK_BROKEN
,
1010 mdoc
->parse
, line
, ppos
,
1011 "It breaks %s", roff_name
[blk
->tok
]);
1012 rew_pending(mdoc
, blk
);
1016 /* Close out prior implicit scopes. */
1018 rew_pending(mdoc
, n
);
1021 /* Skip items outside lists. */
1023 if (tok
== MDOC_It
&& (n
== NULL
|| n
->tok
!= MDOC_Bl
)) {
1024 mandoc_vmsg(MANDOCERR_IT_STRAY
, mdoc
->parse
,
1025 line
, ppos
, "It %s", buf
+ *pos
);
1026 roff_elem_alloc(mdoc
, line
, ppos
, MDOC_br
);
1027 rew_elem(mdoc
, MDOC_br
);
1033 * This routine accommodates implicitly- and explicitly-scoped
1034 * macro openings. Implicit ones first close out prior scope
1035 * (seen above). Delay opening the head until necessary to
1036 * allow leading punctuation to print. Special consideration
1037 * for `It -column', which has phrase-part syntax instead of
1038 * regular child nodes.
1041 mdoc_argv(mdoc
, line
, tok
, &arg
, pos
, buf
);
1042 blk
= mdoc_block_alloc(mdoc
, line
, ppos
, tok
, arg
);
1046 * Exception: Heads of `It' macros in `-diag' lists are not
1047 * parsed, even though `It' macros in general are parsed.
1050 parsed
= tok
!= MDOC_It
||
1051 mdoc
->last
->parent
->tok
!= MDOC_Bl
||
1052 mdoc
->last
->parent
->norm
->Bl
.type
!= LIST_diag
;
1055 * The `Nd' macro has all arguments in its body: it's a hybrid
1056 * of block partial-explicit and full-implicit. Stupid.
1059 if (tok
== MDOC_Nd
) {
1060 head
= roff_head_alloc(mdoc
, line
, ppos
, tok
);
1061 rew_last(mdoc
, head
);
1062 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1066 mdoc
->flags
|= MDOC_KEEP
;
1072 * If we are right after a tab character,
1073 * do not parse the first word for macros.
1076 if (mdoc
->flags
& MDOC_PHRASEQN
) {
1077 mdoc
->flags
&= ~MDOC_PHRASEQN
;
1078 mdoc
->flags
|= MDOC_PHRASEQF
;
1083 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
1084 if (ac
== ARGS_EOLN
) {
1085 if (lac
!= ARGS_PHRASE
||
1086 ! (mdoc
->flags
& MDOC_PHRASEQF
))
1090 * This line ends in a tab; start the next
1091 * column now, with a leading blank.
1095 rew_last(mdoc
, body
);
1096 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1097 roff_word_alloc(mdoc
, line
, ppos
, "\\&");
1101 if (tok
== MDOC_Bd
|| tok
== MDOC_Bk
) {
1102 mandoc_vmsg(MANDOCERR_ARG_EXCESS
,
1103 mdoc
->parse
, line
, la
, "%s ... %s",
1104 roff_name
[tok
], buf
+ la
);
1107 if (tok
== MDOC_Rs
) {
1108 mandoc_vmsg(MANDOCERR_ARG_SKIP
, mdoc
->parse
,
1109 line
, la
, "Rs %s", buf
+ la
);
1112 if (ac
== ARGS_PUNCT
)
1116 * Emit leading punctuation (i.e., punctuation before
1117 * the ROFFT_HEAD) for non-phrase types.
1121 ac
!= ARGS_PHRASE
&&
1123 mdoc_isdelim(p
) == DELIM_OPEN
) {
1124 dword(mdoc
, line
, la
, p
, DELIM_OPEN
, 0);
1128 /* Open a head if one hasn't been opened. */
1131 head
= roff_head_alloc(mdoc
, line
, ppos
, tok
);
1133 if (ac
== ARGS_PHRASE
) {
1136 * If we haven't opened a body yet, rewind the
1137 * head; if we have, rewind that instead.
1140 rew_last(mdoc
, body
== NULL
? head
: body
);
1141 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1143 /* Process to the tab or to the end of the line. */
1145 mdoc
->flags
|= MDOC_PHRASE
;
1146 parse_rest(mdoc
, TOKEN_NONE
, line
, &la
, buf
);
1147 mdoc
->flags
&= ~MDOC_PHRASE
;
1149 /* There may have been `Ta' macros. */
1151 while (body
->next
!= NULL
)
1156 if (macro_or_word(mdoc
, tok
, line
, la
, pos
, buf
, parsed
))
1160 if (blk
->flags
& NODE_VALID
)
1163 head
= roff_head_alloc(mdoc
, line
, ppos
, tok
);
1164 if (nl
&& tok
!= MDOC_Bd
&& tok
!= MDOC_Bl
&& tok
!= MDOC_Rs
)
1165 append_delims(mdoc
, line
, pos
, buf
);
1168 if (find_pending(mdoc
, tok
, line
, ppos
, head
))
1171 /* Close out scopes to remain in a consistent state. */
1173 rew_last(mdoc
, head
);
1174 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1176 if (mdoc
->flags
& MDOC_FREECOL
) {
1177 rew_last(mdoc
, body
);
1178 rew_last(mdoc
, blk
);
1179 mdoc
->flags
&= ~MDOC_FREECOL
;
1184 blk_part_imp(MACRO_PROT_ARGS
)
1189 struct roff_node
*blk
; /* saved block context */
1190 struct roff_node
*body
; /* saved body context */
1191 struct roff_node
*n
;
1193 nl
= MDOC_NEWLINE
& mdoc
->flags
;
1196 * A macro that spans to the end of the line. This is generally
1197 * (but not necessarily) called as the first macro. The block
1198 * has a head as the immediate child, which is always empty,
1199 * followed by zero or more opening punctuation nodes, then the
1200 * body (which may be empty, depending on the macro), then zero
1201 * or more closing punctuation nodes.
1204 blk
= mdoc_block_alloc(mdoc
, line
, ppos
, tok
, NULL
);
1205 rew_last(mdoc
, roff_head_alloc(mdoc
, line
, ppos
, tok
));
1208 * Open the body scope "on-demand", that is, after we've
1209 * processed all our the leading delimiters (open parenthesis,
1213 for (body
= NULL
; ; ) {
1215 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
1216 if (ac
== ARGS_EOLN
|| ac
== ARGS_PUNCT
)
1219 if (body
== NULL
&& ac
!= ARGS_QWORD
&&
1220 mdoc_isdelim(p
) == DELIM_OPEN
) {
1221 dword(mdoc
, line
, la
, p
, DELIM_OPEN
, 0);
1226 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1228 if (macro_or_word(mdoc
, tok
, line
, la
, pos
, buf
, 1))
1232 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1234 if (find_pending(mdoc
, tok
, line
, ppos
, body
))
1237 rew_last(mdoc
, body
);
1239 append_delims(mdoc
, line
, pos
, buf
);
1240 rew_pending(mdoc
, blk
);
1242 /* Move trailing .Ns out of scope. */
1244 for (n
= body
->child
; n
&& n
->next
; n
= n
->next
)
1246 if (n
&& n
->tok
== MDOC_Ns
)
1247 mdoc_node_relink(mdoc
, n
);
1251 blk_part_exp(MACRO_PROT_ARGS
)
1255 struct roff_node
*head
; /* keep track of head */
1258 nl
= MDOC_NEWLINE
& mdoc
->flags
;
1261 * The opening of an explicit macro having zero or more leading
1262 * punctuation nodes; a head with optional single element (the
1263 * case of `Eo'); and a body that may be empty.
1266 roff_block_alloc(mdoc
, line
, ppos
, tok
);
1270 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
1271 if (ac
== ARGS_PUNCT
|| ac
== ARGS_EOLN
)
1274 /* Flush out leading punctuation. */
1276 if (head
== NULL
&& ac
!= ARGS_QWORD
&&
1277 mdoc_isdelim(p
) == DELIM_OPEN
) {
1278 dword(mdoc
, line
, la
, p
, DELIM_OPEN
, 0);
1283 head
= roff_head_alloc(mdoc
, line
, ppos
, tok
);
1284 if (tok
== MDOC_Eo
) /* Not parsed. */
1285 dword(mdoc
, line
, la
, p
, DELIM_MAX
, 0);
1286 rew_last(mdoc
, head
);
1287 roff_body_alloc(mdoc
, line
, ppos
, tok
);
1292 if (macro_or_word(mdoc
, tok
, line
, la
, pos
, buf
, 1))
1296 /* Clean-up to leave in a consistent state. */
1299 rew_last(mdoc
, roff_head_alloc(mdoc
, line
, ppos
, tok
));
1300 roff_body_alloc(mdoc
, line
, ppos
, tok
);
1303 append_delims(mdoc
, line
, pos
, buf
);
1307 in_line_argn(MACRO_PROT_ARGS
)
1309 struct mdoc_arg
*arg
;
1313 int state
; /* arg#; -1: not yet open; -2: closed */
1314 int la
, maxargs
, nl
;
1316 nl
= mdoc
->flags
& MDOC_NEWLINE
;
1319 * A line macro that has a fixed number of arguments (maxargs).
1320 * Only open the scope once the first non-leading-punctuation is
1321 * found (unless MDOC_IGNDELIM is noted, like in `Pf'), then
1322 * keep it open until the maximum number of arguments are
1342 mdoc_argv(mdoc
, line
, tok
, &arg
, pos
, buf
);
1348 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
1350 if (ac
== ARGS_WORD
&& state
== -1 &&
1351 ! (mdoc_macros
[tok
].flags
& MDOC_IGNDELIM
) &&
1352 mdoc_isdelim(p
) == DELIM_OPEN
) {
1353 dword(mdoc
, line
, la
, p
, DELIM_OPEN
, 0);
1357 if (state
== -1 && tok
!= MDOC_In
&&
1358 tok
!= MDOC_St
&& tok
!= MDOC_Xr
) {
1359 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
1363 if (ac
== ARGS_PUNCT
|| ac
== ARGS_EOLN
) {
1364 if (abs(state
) < 2 && tok
== MDOC_Pf
)
1365 mandoc_vmsg(MANDOCERR_PF_SKIP
,
1366 mdoc
->parse
, line
, ppos
, "Pf %s",
1367 p
== NULL
? "at eol" : p
);
1371 if (state
== maxargs
) {
1372 rew_elem(mdoc
, tok
);
1376 ntok
= (ac
== ARGS_QWORD
|| (tok
== MDOC_Pf
&& state
== 0)) ?
1377 TOKEN_NONE
: lookup(mdoc
, tok
, line
, la
, p
);
1379 if (ntok
!= TOKEN_NONE
) {
1381 rew_elem(mdoc
, tok
);
1384 mdoc_macro(mdoc
, ntok
, line
, la
, pos
, buf
);
1388 if (ac
== ARGS_QWORD
||
1389 mdoc_macros
[tok
].flags
& MDOC_IGNDELIM
||
1390 mdoc_isdelim(p
) == DELIM_NONE
) {
1392 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
1394 } else if (state
>= 0)
1396 } else if (state
>= 0) {
1397 rew_elem(mdoc
, tok
);
1401 dword(mdoc
, line
, la
, p
, DELIM_MAX
,
1402 mdoc_macros
[tok
].flags
& MDOC_JOIN
);
1406 mandoc_msg(MANDOCERR_MACRO_EMPTY
, mdoc
->parse
,
1407 line
, ppos
, roff_name
[tok
]);
1411 if (state
== 0 && tok
== MDOC_Pf
)
1412 append_delims(mdoc
, line
, pos
, buf
);
1414 rew_elem(mdoc
, tok
);
1416 append_delims(mdoc
, line
, pos
, buf
);
1420 in_line_eoln(MACRO_PROT_ARGS
)
1422 struct roff_node
*n
;
1423 struct mdoc_arg
*arg
;
1425 if ((tok
== MDOC_Pp
|| tok
== MDOC_Lp
) &&
1426 ! (mdoc
->flags
& MDOC_SYNOPSIS
)) {
1428 if (mdoc
->next
== ROFF_NEXT_SIBLING
)
1430 if (n
->tok
== MDOC_Nm
)
1431 rew_last(mdoc
, n
->parent
);
1434 if (buf
[*pos
] == '\0' &&
1435 (tok
== MDOC_Fd
|| *roff_name
[tok
] == '%')) {
1436 mandoc_msg(MANDOCERR_MACRO_EMPTY
, mdoc
->parse
,
1437 line
, ppos
, roff_name
[tok
]);
1441 mdoc_argv(mdoc
, line
, tok
, &arg
, pos
, buf
);
1442 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
1443 if (parse_rest(mdoc
, tok
, line
, pos
, buf
))
1445 rew_elem(mdoc
, tok
);
1449 * The simplest argument parser available: Parse the remaining
1450 * words until the end of the phrase or line and return 0
1451 * or until the next macro, call that macro, and return 1.
1454 parse_rest(struct roff_man
*mdoc
, enum roff_tok tok
,
1455 int line
, int *pos
, char *buf
)
1461 if (mdoc_args(mdoc
, line
, pos
, buf
, tok
, NULL
) == ARGS_EOLN
)
1463 if (macro_or_word(mdoc
, tok
, line
, la
, pos
, buf
, 1))
1469 ctx_synopsis(MACRO_PROT_ARGS
)
1472 if (~mdoc
->flags
& (MDOC_SYNOPSIS
| MDOC_NEWLINE
))
1473 in_line(mdoc
, tok
, line
, ppos
, pos
, buf
);
1474 else if (tok
== MDOC_Nm
)
1475 blk_full(mdoc
, tok
, line
, ppos
, pos
, buf
);
1477 assert(tok
== MDOC_Vt
);
1478 blk_part_imp(mdoc
, tok
, line
, ppos
, pos
, buf
);
1483 * Phrases occur within `Bl -column' entries, separated by `Ta' or tabs.
1484 * They're unusual because they're basically free-form text until a
1485 * macro is encountered.
1488 phrase_ta(MACRO_PROT_ARGS
)
1490 struct roff_node
*body
, *n
;
1492 /* Make sure we are in a column list or ignore this macro. */
1495 for (n
= mdoc
->last
; n
!= NULL
; n
= n
->parent
) {
1496 if (n
->flags
& NODE_ENDED
)
1498 if (n
->tok
== MDOC_It
&& n
->type
== ROFFT_BODY
)
1500 if (n
->tok
== MDOC_Bl
&& n
->end
== ENDBODY_NOT
)
1504 if (n
== NULL
|| n
->norm
->Bl
.type
!= LIST_column
) {
1505 mandoc_msg(MANDOCERR_TA_STRAY
, mdoc
->parse
,
1510 /* Advance to the next column. */
1512 rew_last(mdoc
, body
);
1513 roff_body_alloc(mdoc
, line
, ppos
, MDOC_It
);
1514 parse_rest(mdoc
, TOKEN_NONE
, line
, pos
, buf
);