]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc_macro.c
1 /* $Id: mdoc_macro.c,v 1.91 2010/07/02 10:53:28 kristaps Exp $ */
3 * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
30 #include "libmandoc.h"
32 enum rew
{ /* see rew_dohalt() */
40 static int blk_full(MACRO_PROT_ARGS
);
41 static int blk_exp_close(MACRO_PROT_ARGS
);
42 static int blk_part_exp(MACRO_PROT_ARGS
);
43 static int blk_part_imp(MACRO_PROT_ARGS
);
44 static int ctx_synopsis(MACRO_PROT_ARGS
);
45 static int in_line_eoln(MACRO_PROT_ARGS
);
46 static int in_line_argn(MACRO_PROT_ARGS
);
47 static int in_line(MACRO_PROT_ARGS
);
48 static int obsolete(MACRO_PROT_ARGS
);
49 static int phrase_ta(MACRO_PROT_ARGS
);
51 static int append_delims(struct mdoc
*,
53 static enum mdoct
lookup(enum mdoct
, const char *);
54 static enum mdoct
lookup_raw(const char *);
55 static int make_pending(struct mdoc_node
*, enum mdoct
,
56 struct mdoc
*, int, int);
57 static int phrase(struct mdoc
*, int, int, char *);
58 static enum mdoct
rew_alt(enum mdoct
);
59 static enum rew
rew_dohalt(enum mdoct
, enum mdoc_type
,
60 const struct mdoc_node
*);
61 static int rew_elem(struct mdoc
*, enum mdoct
);
62 static int rew_last(struct mdoc
*,
63 const struct mdoc_node
*);
64 static int rew_sub(enum mdoc_type
, struct mdoc
*,
65 enum mdoct
, int, int);
67 const struct mdoc_macro __mdoc_macros
[MDOC_MAX
] = {
68 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ap */
69 { in_line_eoln
, MDOC_PROLOGUE
}, /* Dd */
70 { in_line_eoln
, MDOC_PROLOGUE
}, /* Dt */
71 { in_line_eoln
, MDOC_PROLOGUE
}, /* Os */
72 { blk_full
, 0 }, /* Sh */
73 { blk_full
, 0 }, /* Ss */
74 { in_line_eoln
, 0 }, /* Pp */
75 { blk_part_imp
, MDOC_PARSED
}, /* D1 */
76 { blk_part_imp
, MDOC_PARSED
}, /* Dl */
77 { blk_full
, MDOC_EXPLICIT
}, /* Bd */
78 { blk_exp_close
, MDOC_EXPLICIT
}, /* Ed */
79 { blk_full
, MDOC_EXPLICIT
}, /* Bl */
80 { blk_exp_close
, MDOC_EXPLICIT
}, /* El */
81 { blk_full
, MDOC_PARSED
}, /* It */
82 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ad */
83 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* An */
84 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ar */
85 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Cd */
86 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Cm */
87 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Dv */
88 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Er */
89 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ev */
90 { in_line_eoln
, 0 }, /* Ex */
91 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fa */
92 { in_line_eoln
, 0 }, /* Fd */
93 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fl */
94 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fn */
95 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ft */
96 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ic */
97 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* In */
98 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Li */
99 { blk_full
, 0 }, /* Nd */
100 { ctx_synopsis
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Nm */
101 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Op */
102 { obsolete
, 0 }, /* Ot */
103 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Pa */
104 { in_line_eoln
, 0 }, /* Rv */
105 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* St */
106 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Va */
107 { ctx_synopsis
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Vt */
108 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Xr */
109 { in_line_eoln
, 0 }, /* %A */
110 { in_line_eoln
, 0 }, /* %B */
111 { in_line_eoln
, 0 }, /* %D */
112 { in_line_eoln
, 0 }, /* %I */
113 { in_line_eoln
, 0 }, /* %J */
114 { in_line_eoln
, 0 }, /* %N */
115 { in_line_eoln
, 0 }, /* %O */
116 { in_line_eoln
, 0 }, /* %P */
117 { in_line_eoln
, 0 }, /* %R */
118 { in_line_eoln
, 0 }, /* %T */
119 { in_line_eoln
, 0 }, /* %V */
120 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Ac */
121 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Ao */
122 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Aq */
123 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* At */
124 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Bc */
125 { blk_full
, MDOC_EXPLICIT
}, /* Bf */
126 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Bo */
127 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* 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_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Dc */
132 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Do */
133 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Dq */
134 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Ec */
135 { blk_exp_close
, MDOC_EXPLICIT
}, /* Ef */
136 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Em */
137 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Eo */
138 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fx */
139 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ms */
140 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* No */
141 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ns */
142 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Nx */
143 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ox */
144 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Pc */
145 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_IGNDELIM
}, /* Pf */
146 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Po */
147 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Pq */
148 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Qc */
149 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ql */
150 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Qo */
151 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Qq */
152 { blk_exp_close
, MDOC_EXPLICIT
}, /* Re */
153 { blk_full
, MDOC_EXPLICIT
}, /* Rs */
154 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Sc */
155 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* So */
156 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Sq */
157 { in_line_eoln
, 0 }, /* Sm */
158 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Sx */
159 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Sy */
160 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Tn */
161 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ux */
162 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Xc */
163 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Xo */
164 { blk_full
, MDOC_EXPLICIT
| MDOC_CALLABLE
}, /* Fo */
165 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Fc */
166 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Oo */
167 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Oc */
168 { blk_full
, MDOC_EXPLICIT
}, /* Bk */
169 { blk_exp_close
, MDOC_EXPLICIT
}, /* Ek */
170 { in_line_eoln
, 0 }, /* Bt */
171 { in_line_eoln
, 0 }, /* Hf */
172 { obsolete
, 0 }, /* Fr */
173 { in_line_eoln
, 0 }, /* Ud */
174 { in_line
, 0 }, /* Lb */
175 { in_line_eoln
, 0 }, /* Lp */
176 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Lk */
177 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Mt */
178 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Brq */
179 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Bro */
180 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Brc */
181 { in_line_eoln
, 0 }, /* %C */
182 { obsolete
, 0 }, /* Es */
183 { obsolete
, 0 }, /* En */
184 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Dx */
185 { in_line_eoln
, 0 }, /* %Q */
186 { in_line_eoln
, 0 }, /* br */
187 { in_line_eoln
, 0 }, /* sp */
188 { in_line_eoln
, 0 }, /* %U */
189 { phrase_ta
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ta */
192 const struct mdoc_macro
* const mdoc_macros
= __mdoc_macros
;
196 * This is called at the end of parsing. It must traverse up the tree,
197 * closing out open [implicit] scopes. Obviously, open explicit scopes
201 mdoc_macroend(struct mdoc
*m
)
205 /* Scan for open explicit scopes. */
207 n
= MDOC_VALID
& m
->last
->flags
? m
->last
->parent
: m
->last
;
209 for ( ; n
; n
= n
->parent
) {
210 if (MDOC_BLOCK
!= n
->type
)
212 if ( ! (MDOC_EXPLICIT
& mdoc_macros
[n
->tok
].flags
))
214 mdoc_nmsg(m
, n
, MANDOCERR_SYNTSCOPE
);
218 /* Rewind to the first. */
220 return(rew_last(m
, m
->first
));
225 * Look up a macro from within a subsequent context.
228 lookup(enum mdoct from
, const char *p
)
230 /* FIXME: make -diag lists be un-PARSED. */
232 if ( ! (MDOC_PARSED
& mdoc_macros
[from
].flags
))
234 return(lookup_raw(p
));
239 * Lookup a macro following the initial line macro.
242 lookup_raw(const char *p
)
246 if (MDOC_MAX
== (res
= mdoc_hash_find(p
)))
248 if (MDOC_CALLABLE
& mdoc_macros
[res
].flags
)
255 rew_last(struct mdoc
*mdoc
, const struct mdoc_node
*to
)
259 mdoc
->next
= MDOC_NEXT_SIBLING
;
262 while (mdoc
->last
!= to
) {
263 if ( ! mdoc_valid_post(mdoc
))
265 if ( ! mdoc_action_post(mdoc
))
267 mdoc
->last
= mdoc
->last
->parent
;
271 if ( ! mdoc_valid_post(mdoc
))
273 return(mdoc_action_post(mdoc
));
278 * For a block closing macro, return the corresponding opening one.
279 * Otherwise, return the macro itself.
282 rew_alt(enum mdoct tok
)
325 * Rewinding to tok, how do we have to handle *p?
326 * REWIND_NONE: *p would delimit tok, but no tok scope is open
327 * inside *p, so there is no need to rewind anything at all.
328 * REWIND_THIS: *p matches tok, so rewind *p and nothing else.
329 * REWIND_MORE: *p is implicit, rewind it and keep searching for tok.
330 * REWIND_LATER: *p is explicit and still open, postpone rewinding.
331 * REWIND_ERROR: No tok block is open at all.
334 rew_dohalt(enum mdoct tok
, enum mdoc_type type
,
335 const struct mdoc_node
*p
)
339 * No matching token, no delimiting block, no broken block.
340 * This can happen when full implicit macros are called for
341 * the first time but try to rewind their previous
344 if (MDOC_ROOT
== p
->type
)
345 return(MDOC_BLOCK
== type
&&
346 MDOC_EXPLICIT
& mdoc_macros
[tok
].flags
?
347 REWIND_ERROR
: REWIND_NONE
);
350 * When starting to rewind, skip plain text
351 * and nodes that have already been rewound.
353 if (MDOC_TEXT
== p
->type
|| MDOC_VALID
& p
->flags
)
357 * The easiest case: Found a matching token.
358 * This applies to both blocks and elements.
362 return(p
->end
? REWIND_NONE
:
363 type
== p
->type
? REWIND_THIS
: REWIND_MORE
);
366 * While elements do require rewinding for themselves,
367 * they never affect rewinding of other nodes.
369 if (MDOC_ELEM
== p
->type
)
373 * Blocks delimited by our target token get REWIND_MORE.
374 * Blocks delimiting our target token get REWIND_NONE.
378 if (MDOC_It
== p
->tok
)
382 if (MDOC_BODY
== p
->type
&& MDOC_Bl
== p
->tok
)
386 * XXX Badly nested block handling still fails badly
387 * when one block is breaking two blocks of the same type.
388 * This is an incomplete and extremely ugly workaround,
389 * required to let the OpenBSD tree build.
392 if (MDOC_Op
== p
->tok
)
400 if (MDOC_BODY
== p
->type
&& MDOC_Sh
== p
->tok
)
404 if (MDOC_Nd
== p
->tok
|| MDOC_Ss
== p
->tok
||
413 * Default block rewinding rules.
414 * In particular, always skip block end markers,
415 * and let all blocks rewind Nm children.
417 if (ENDBODY_NOT
!= p
->end
|| MDOC_Nm
== p
->tok
||
418 (MDOC_BLOCK
== p
->type
&&
419 ! (MDOC_EXPLICIT
& mdoc_macros
[tok
].flags
)))
423 * Partial blocks allow delayed rewinding by default.
425 if (&blk_full
!= mdoc_macros
[tok
].fp
)
426 return (REWIND_LATER
);
429 * Full blocks can only be rewound when matching
430 * or when there is an explicit rule.
432 return(REWIND_ERROR
);
437 rew_elem(struct mdoc
*mdoc
, enum mdoct tok
)
442 if (MDOC_ELEM
!= n
->type
)
444 assert(MDOC_ELEM
== n
->type
);
445 assert(tok
== n
->tok
);
447 return(rew_last(mdoc
, n
));
452 * We are trying to close a block identified by tok,
453 * but the child block *broken is still open.
454 * Thus, postpone closing the tok block
455 * until the rew_sub call closing *broken.
458 make_pending(struct mdoc_node
*broken
, enum mdoct tok
,
459 struct mdoc
*m
, int line
, int ppos
)
461 struct mdoc_node
*breaker
;
464 * Iterate backwards, searching for the block matching tok,
465 * that is, the block breaking the *broken block.
467 for (breaker
= broken
->parent
; breaker
; breaker
= breaker
->parent
) {
470 * If the *broken block had already been broken before
471 * and we encounter its breaker, make the tok block
472 * pending on the inner breaker.
473 * Graphically, "[A breaker=[B broken=[C->B B] tok=A] C]"
474 * becomes "[A broken=[B [C->B B] tok=A] C]"
475 * and finally "[A [B->A [C->B B] A] C]".
477 if (breaker
== broken
->pending
) {
482 if (REWIND_THIS
!= rew_dohalt(tok
, MDOC_BLOCK
, breaker
))
484 if (MDOC_BODY
== broken
->type
)
485 broken
= broken
->parent
;
489 * If another, outer breaker is already pending on
490 * the *broken block, we must not clobber the link
491 * to the outer breaker, but make it pending on the
492 * new, now inner breaker.
493 * Graphically, "[A breaker=[B broken=[C->A A] tok=B] C]"
494 * becomes "[A breaker=[B->A broken=[C A] tok=B] C]"
495 * and finally "[A [B->A [C->B A] B] C]".
497 if (broken
->pending
) {
498 struct mdoc_node
*taker
;
501 * If the breaker had also been broken before,
502 * it cannot take on the outer breaker itself,
503 * but must hand it on to its own breakers.
504 * Graphically, this is the following situation:
505 * "[A [B breaker=[C->B B] broken=[D->A A] tok=C] D]"
506 * "[A taker=[B->A breaker=[C->B B] [D->C A] C] D]"
509 while (taker
->pending
)
510 taker
= taker
->pending
;
511 taker
->pending
= broken
->pending
;
513 broken
->pending
= breaker
;
514 mdoc_vmsg(m
, MANDOCERR_SCOPENEST
, line
, ppos
,
515 "%s breaks %s", mdoc_macronames
[tok
],
516 mdoc_macronames
[broken
->tok
]);
521 * Found no matching block for tok.
522 * Are you trying to close a block that is not open?
523 * XXX Make this non-fatal.
525 mdoc_pmsg(m
, line
, ppos
, MANDOCERR_SYNTNOSCOPE
);
531 rew_sub(enum mdoc_type t
, struct mdoc
*m
,
532 enum mdoct tok
, int line
, int ppos
)
538 switch (rew_dohalt(tok
, t
, n
)) {
547 return(make_pending(n
, tok
, m
, line
, ppos
));
549 /* XXX Make this non-fatal. */
550 mdoc_vmsg(m
, MANDOCERR_SCOPEFATAL
, line
, ppos
,
551 "%s cannot break %s", mdoc_macronames
[tok
],
552 mdoc_macronames
[n
->tok
]);
559 if ( ! rew_last(m
, n
))
563 * The current block extends an enclosing block.
564 * Now that the current block ends, close the enclosing block, too.
566 while (NULL
!= (n
= n
->pending
)) {
567 if ( ! rew_last(m
, n
))
569 if (MDOC_HEAD
== n
->type
&&
570 ! mdoc_body_alloc(m
, n
->line
, n
->pos
, n
->tok
))
579 append_delims(struct mdoc
*m
, int line
, int *pos
, char *buf
)
585 if ('\0' == buf
[*pos
])
590 ac
= mdoc_zargs(m
, line
, pos
, buf
, ARGS_NOWARN
, &p
);
592 if (ARGS_ERROR
== ac
)
594 else if (ARGS_EOLN
== ac
)
597 assert(DELIM_NONE
!= mdoc_isdelim(p
));
598 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
602 * If we encounter end-of-sentence symbols, then trigger
605 * XXX: it's easy to allow this to propogate outward to
606 * the last symbol, such that `. )' will cause the
607 * correct double-spacing. However, (1) groff isn't
608 * smart enough to do this and (2) it would require
609 * knowing which symbols break this behaviour, for
610 * example, `. ;' shouldn't propogate the double-space.
612 if (mandoc_eos(p
, strlen(p
)))
613 m
->last
->flags
|= MDOC_EOS
;
621 * Close out block partial/full explicit.
624 blk_exp_close(MACRO_PROT_ARGS
)
626 struct mdoc_node
*body
; /* Our own body. */
627 struct mdoc_node
*later
; /* A sub-block starting later. */
628 struct mdoc_node
*n
; /* For searching backwards. */
630 int j
, lastarg
, maxargs
, flushed
, nl
;
632 enum mdoct atok
, ntok
;
635 nl
= MDOC_NEWLINE
& m
->flags
;
647 * Search backwards for beginnings of blocks,
648 * both of our own and of pending sub-blocks.
652 for (n
= m
->last
; n
; n
= n
->parent
) {
653 if (MDOC_VALID
& n
->flags
)
656 /* Remember the start of our own body. */
657 if (MDOC_BODY
== n
->type
&& atok
== n
->tok
) {
658 if (ENDBODY_NOT
== n
->end
)
663 if (MDOC_BLOCK
!= n
->type
|| MDOC_Nm
== n
->tok
)
665 if (atok
== n
->tok
) {
669 * Found the start of our own block.
670 * When there is no pending sub block,
671 * just proceed to closing out.
677 * When there is a pending sub block,
678 * postpone closing out the current block
679 * until the rew_sub() closing out the sub-block.
681 if ( ! make_pending(later
, tok
, m
, line
, ppos
))
685 * Mark the place where the formatting - but not
686 * the scope - of the current block ends.
688 if ( ! mdoc_endbody_alloc(m
, line
, ppos
,
689 atok
, body
, ENDBODY_SPACE
))
695 * When finding an open sub block, remember the last
696 * open explicit block, or, in case there are only
697 * implicit ones, the first open implicit block.
700 MDOC_EXPLICIT
& mdoc_macros
[later
->tok
].flags
)
702 if (MDOC_CALLABLE
& mdoc_macros
[n
->tok
].flags
) {
703 assert( ! (MDOC_ACTED
& n
->flags
));
708 if ( ! (MDOC_CALLABLE
& mdoc_macros
[tok
].flags
)) {
709 /* FIXME: do this in validate */
711 if ( ! mdoc_pmsg(m
, line
, ppos
, MANDOCERR_ARGSLOST
))
714 if ( ! rew_sub(MDOC_BODY
, m
, tok
, line
, ppos
))
716 return(rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
));
719 if ( ! rew_sub(MDOC_BODY
, m
, tok
, line
, ppos
))
722 if (NULL
== later
&& maxargs
> 0)
723 if ( ! mdoc_tail_alloc(m
, line
, ppos
, rew_alt(tok
)))
726 for (flushed
= j
= 0; ; j
++) {
729 if (j
== maxargs
&& ! flushed
) {
730 if ( ! rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
))
735 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
737 if (ARGS_ERROR
== ac
)
739 if (ARGS_PUNCT
== ac
)
744 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
746 if (MDOC_MAX
== ntok
) {
747 if ( ! mdoc_word_alloc(m
, line
, lastarg
, p
))
753 if ( ! rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
))
757 if ( ! mdoc_macro(m
, ntok
, line
, lastarg
, pos
, buf
))
762 if ( ! flushed
&& ! rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
))
767 return(append_delims(m
, line
, pos
, buf
));
772 in_line(MACRO_PROT_ARGS
)
774 int la
, scope
, cnt
, nc
, nl
;
779 struct mdoc_arg
*arg
;
782 nl
= MDOC_NEWLINE
& m
->flags
;
785 * Whether we allow ignored elements (those without content,
786 * usually because of reserved words) to squeak by.
808 for (arg
= NULL
;; ) {
810 av
= mdoc_argv(m
, line
, tok
, &arg
, pos
, buf
);
812 if (ARGV_WORD
== av
) {
825 for (cnt
= scope
= 0;; ) {
827 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
829 if (ARGS_ERROR
== ac
)
833 if (ARGS_PUNCT
== ac
)
836 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
839 * In this case, we've located a submacro and must
840 * execute it. Close out scope, if open. If no
841 * elements have been generated, either create one (nc)
842 * or raise a warning.
845 if (MDOC_MAX
!= ntok
) {
846 if (scope
&& ! rew_elem(m
, tok
))
848 if (nc
&& 0 == cnt
) {
849 if ( ! mdoc_elem_alloc(m
, line
, ppos
, tok
, arg
))
851 if ( ! rew_last(m
, m
->last
))
853 } else if ( ! nc
&& 0 == cnt
) {
855 if ( ! mdoc_pmsg(m
, line
, ppos
, MANDOCERR_MACROEMPTY
))
858 if ( ! mdoc_macro(m
, ntok
, line
, la
, pos
, buf
))
862 return(append_delims(m
, line
, pos
, buf
));
866 * Non-quote-enclosed punctuation. Set up our scope, if
867 * a word; rewind the scope, if a delimiter; then append
871 d
= ARGS_QWORD
== ac
? DELIM_NONE
: mdoc_isdelim(p
);
873 if (DELIM_NONE
!= d
) {
875 * If we encounter closing punctuation, no word
876 * has been omitted, no scope is open, and we're
877 * allowed to have an empty element, then start
878 * a new scope. `Ar', `Fl', and `Li', only do
879 * this once per invocation. There may be more
880 * of these (all of them?).
882 if (0 == cnt
&& (nc
|| MDOC_Li
== tok
) &&
883 DELIM_CLOSE
== d
&& ! scope
) {
884 if ( ! mdoc_elem_alloc(m
, line
, ppos
, tok
, arg
))
886 if (MDOC_Ar
== tok
|| MDOC_Li
== tok
||
892 * Close out our scope, if one is open, before
895 if (scope
&& ! rew_elem(m
, tok
))
898 } else if ( ! scope
) {
899 if ( ! mdoc_elem_alloc(m
, line
, ppos
, tok
, arg
))
906 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
910 * `Fl' macros have their scope re-opened with each new
911 * word so that the `-' can be added to each one without
912 * having to parse out spaces.
914 if (scope
&& MDOC_Fl
== tok
) {
915 if ( ! rew_elem(m
, tok
))
921 if (scope
&& ! rew_elem(m
, tok
))
925 * If no elements have been collected and we're allowed to have
926 * empties (nc), open a scope and close it out. Otherwise,
930 if (nc
&& 0 == cnt
) {
931 if ( ! mdoc_elem_alloc(m
, line
, ppos
, tok
, arg
))
933 if ( ! rew_last(m
, m
->last
))
935 } else if ( ! nc
&& 0 == cnt
) {
937 if ( ! mdoc_pmsg(m
, line
, ppos
, MANDOCERR_MACROEMPTY
))
943 return(append_delims(m
, line
, pos
, buf
));
948 blk_full(MACRO_PROT_ARGS
)
951 struct mdoc_arg
*arg
;
952 struct mdoc_node
*head
; /* save of head macro */
953 struct mdoc_node
*body
; /* save of body macro */
957 enum margserr ac
, lac
;
961 nl
= MDOC_NEWLINE
& m
->flags
;
963 /* Close out prior implicit scope. */
965 if ( ! (MDOC_EXPLICIT
& mdoc_macros
[tok
].flags
)) {
966 if ( ! rew_sub(MDOC_BODY
, m
, tok
, line
, ppos
))
968 if ( ! rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
))
973 * This routine accomodates implicitly- and explicitly-scoped
974 * macro openings. Implicit ones first close out prior scope
975 * (seen above). Delay opening the head until necessary to
976 * allow leading punctuation to print. Special consideration
977 * for `It -column', which has phrase-part syntax instead of
978 * regular child nodes.
981 for (arg
= NULL
;; ) {
983 av
= mdoc_argv(m
, line
, tok
, &arg
, pos
, buf
);
985 if (ARGV_WORD
== av
) {
999 if ( ! mdoc_block_alloc(m
, line
, ppos
, tok
, arg
))
1005 * The `Nd' macro has all arguments in its body: it's a hybrid
1006 * of block partial-explicit and full-implicit. Stupid.
1009 if (MDOC_Nd
== tok
) {
1010 if ( ! mdoc_head_alloc(m
, line
, ppos
, tok
))
1013 if ( ! rew_sub(MDOC_HEAD
, m
, tok
, line
, ppos
))
1015 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1024 /* Initialise last-phrase-type with ARGS_PEND. */
1025 lac
= ARGS_ERROR
== ac
? ARGS_PEND
: ac
;
1026 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
1028 if (ARGS_PUNCT
== ac
)
1031 if (ARGS_ERROR
== ac
)
1034 if (ARGS_EOLN
== ac
) {
1035 if (ARGS_PPHRASE
!= lac
&& ARGS_PHRASE
!= lac
)
1038 * This is necessary: if the last token on a
1039 * line is a `Ta' or tab, then we'll get
1040 * ARGS_EOLN, so we must be smart enough to
1041 * reopen our scope if the last parse was a
1042 * phrase or partial phrase.
1044 if ( ! rew_sub(MDOC_BODY
, m
, tok
, line
, ppos
))
1046 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1053 * Emit leading punctuation (i.e., punctuation before
1054 * the MDOC_HEAD) for non-phrase types.
1059 ARGS_PHRASE
!= ac
&&
1060 ARGS_PPHRASE
!= ac
&&
1062 DELIM_OPEN
== mdoc_isdelim(p
)) {
1063 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1068 /* Open a head if one hasn't been opened. */
1071 if ( ! mdoc_head_alloc(m
, line
, ppos
, tok
))
1076 if (ARGS_PHRASE
== ac
||
1078 ARGS_PPHRASE
== ac
) {
1080 * If we haven't opened a body yet, rewind the
1081 * head; if we have, rewind that instead.
1084 mtt
= body
? MDOC_BODY
: MDOC_HEAD
;
1085 if ( ! rew_sub(mtt
, m
, tok
, line
, ppos
))
1088 /* Then allocate our body context. */
1090 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1095 * Process phrases: set whether we're in a
1096 * partial-phrase (this effects line handling)
1097 * then call down into the phrase parser.
1100 if (ARGS_PPHRASE
== ac
)
1101 m
->flags
|= MDOC_PPHRASE
;
1102 if (ARGS_PEND
== ac
&& ARGS_PPHRASE
== lac
)
1103 m
->flags
|= MDOC_PPHRASE
;
1105 if ( ! phrase(m
, line
, la
, buf
))
1108 m
->flags
&= ~MDOC_PPHRASE
;
1112 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
1114 if (MDOC_MAX
== ntok
) {
1115 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1120 if ( ! mdoc_macro(m
, ntok
, line
, la
, pos
, buf
))
1126 if ( ! mdoc_head_alloc(m
, line
, ppos
, tok
))
1131 if (nl
&& ! append_delims(m
, line
, pos
, buf
))
1134 /* If we've already opened our body, exit now. */
1140 * If there is an open (i.e., unvalidated) sub-block requiring
1141 * explicit close-out, postpone switching the current block from
1142 * head to body until the rew_sub() call closing out that
1145 for (n
= m
->last
; n
&& n
!= head
; n
= n
->parent
) {
1146 if (MDOC_BLOCK
== n
->type
&&
1147 MDOC_EXPLICIT
& mdoc_macros
[n
->tok
].flags
&&
1148 ! (MDOC_VALID
& n
->flags
)) {
1149 assert( ! (MDOC_ACTED
& n
->flags
));
1155 /* Close out scopes to remain in a consistent state. */
1157 if ( ! rew_sub(MDOC_HEAD
, m
, tok
, line
, ppos
))
1159 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1163 if ( ! (MDOC_FREECOL
& m
->flags
))
1166 if ( ! rew_sub(MDOC_BODY
, m
, tok
, line
, ppos
))
1168 if ( ! rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
))
1171 m
->flags
&= ~MDOC_FREECOL
;
1177 blk_part_imp(MACRO_PROT_ARGS
)
1183 struct mdoc_node
*blk
; /* saved block context */
1184 struct mdoc_node
*body
; /* saved body context */
1185 struct mdoc_node
*n
;
1187 nl
= MDOC_NEWLINE
& m
->flags
;
1190 * A macro that spans to the end of the line. This is generally
1191 * (but not necessarily) called as the first macro. The block
1192 * has a head as the immediate child, which is always empty,
1193 * followed by zero or more opening punctuation nodes, then the
1194 * body (which may be empty, depending on the macro), then zero
1195 * or more closing punctuation nodes.
1198 if ( ! mdoc_block_alloc(m
, line
, ppos
, tok
, NULL
))
1203 if ( ! mdoc_head_alloc(m
, line
, ppos
, tok
))
1205 if ( ! rew_sub(MDOC_HEAD
, m
, tok
, line
, ppos
))
1209 * Open the body scope "on-demand", that is, after we've
1210 * processed all our the leading delimiters (open parenthesis,
1214 for (body
= NULL
; ; ) {
1216 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
1218 if (ARGS_ERROR
== ac
)
1220 if (ARGS_EOLN
== ac
)
1222 if (ARGS_PUNCT
== ac
)
1225 if (NULL
== body
&& ARGS_QWORD
!= ac
&&
1226 DELIM_OPEN
== mdoc_isdelim(p
)) {
1227 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1233 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1238 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
1240 if (MDOC_MAX
== ntok
) {
1241 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1246 if ( ! mdoc_macro(m
, ntok
, line
, la
, pos
, buf
))
1251 /* Clean-ups to leave in a consistent state. */
1254 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1259 for (n
= body
->child
; n
&& n
->next
; n
= n
->next
)
1263 * End of sentence spacing: if the last node is a text node and
1264 * has a trailing period, then mark it as being end-of-sentence.
1267 if (n
&& MDOC_TEXT
== n
->type
&& n
->string
)
1268 if (mandoc_eos(n
->string
, strlen(n
->string
)))
1269 n
->flags
|= MDOC_EOS
;
1271 /* Up-propogate the end-of-space flag. */
1273 if (n
&& (MDOC_EOS
& n
->flags
)) {
1274 body
->flags
|= MDOC_EOS
;
1275 body
->parent
->flags
|= MDOC_EOS
;
1279 * If there is an open sub-block requiring explicit close-out,
1280 * postpone closing out the current block
1281 * until the rew_sub() call closing out the sub-block.
1283 for (n
= m
->last
; n
&& n
!= body
&& n
!= blk
->parent
; n
= n
->parent
) {
1284 if (MDOC_BLOCK
== n
->type
&&
1285 MDOC_EXPLICIT
& mdoc_macros
[n
->tok
].flags
&&
1286 ! (MDOC_VALID
& n
->flags
)) {
1287 assert( ! (MDOC_ACTED
& n
->flags
));
1288 if ( ! make_pending(n
, tok
, m
, line
, ppos
))
1290 if ( ! mdoc_endbody_alloc(m
, line
, ppos
,
1291 tok
, body
, ENDBODY_NOSPACE
))
1298 * If we can't rewind to our body, then our scope has already
1299 * been closed by another macro (like `Oc' closing `Op'). This
1300 * is ugly behaviour nodding its head to OpenBSD's overwhelming
1301 * crufty use of `Op' breakage.
1303 if (n
!= body
&& ! mdoc_vmsg(m
, MANDOCERR_SCOPENEST
,
1304 line
, ppos
, "%s broken", mdoc_macronames
[tok
]))
1307 if (n
&& ! rew_sub(MDOC_BODY
, m
, tok
, line
, ppos
))
1310 /* Standard appending of delimiters. */
1312 if (nl
&& ! append_delims(m
, line
, pos
, buf
))
1315 /* Rewind scope, if applicable. */
1317 if (n
&& ! rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
))
1325 blk_part_exp(MACRO_PROT_ARGS
)
1329 struct mdoc_node
*head
; /* keep track of head */
1330 struct mdoc_node
*body
; /* keep track of body */
1334 nl
= MDOC_NEWLINE
& m
->flags
;
1337 * The opening of an explicit macro having zero or more leading
1338 * punctuation nodes; a head with optional single element (the
1339 * case of `Eo'); and a body that may be empty.
1342 if ( ! mdoc_block_alloc(m
, line
, ppos
, tok
, NULL
))
1345 for (head
= body
= NULL
; ; ) {
1347 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
1349 if (ARGS_ERROR
== ac
)
1351 if (ARGS_PUNCT
== ac
)
1353 if (ARGS_EOLN
== ac
)
1356 /* Flush out leading punctuation. */
1358 if (NULL
== head
&& ARGS_QWORD
!= ac
&&
1359 DELIM_OPEN
== mdoc_isdelim(p
)) {
1360 assert(NULL
== body
);
1361 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1367 assert(NULL
== body
);
1368 if ( ! mdoc_head_alloc(m
, line
, ppos
, tok
))
1374 * `Eo' gobbles any data into the head, but most other
1375 * macros just immediately close out and begin the body.
1380 /* No check whether it's a macro! */
1382 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1385 if ( ! rew_sub(MDOC_HEAD
, m
, tok
, line
, ppos
))
1387 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1395 assert(NULL
!= head
&& NULL
!= body
);
1397 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
1399 if (MDOC_MAX
== ntok
) {
1400 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1405 if ( ! mdoc_macro(m
, ntok
, line
, la
, pos
, buf
))
1410 /* Clean-up to leave in a consistent state. */
1413 if ( ! mdoc_head_alloc(m
, line
, ppos
, tok
))
1419 if ( ! rew_sub(MDOC_HEAD
, m
, tok
, line
, ppos
))
1421 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1426 /* Standard appending of delimiters. */
1430 return(append_delims(m
, line
, pos
, buf
));
1436 in_line_argn(MACRO_PROT_ARGS
)
1438 int la
, flushed
, j
, maxargs
, nl
;
1441 struct mdoc_arg
*arg
;
1445 nl
= MDOC_NEWLINE
& m
->flags
;
1448 * A line macro that has a fixed number of arguments (maxargs).
1449 * Only open the scope once the first non-leading-punctuation is
1450 * found (unless MDOC_IGNDELIM is noted, like in `Pf'), then
1451 * keep it open until the maximum number of arguments are
1473 for (arg
= NULL
; ; ) {
1475 av
= mdoc_argv(m
, line
, tok
, &arg
, pos
, buf
);
1477 if (ARGV_WORD
== av
) {
1482 if (ARGV_EOLN
== av
)
1487 mdoc_argv_free(arg
);
1491 for (flushed
= j
= 0; ; ) {
1493 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
1495 if (ARGS_ERROR
== ac
)
1497 if (ARGS_PUNCT
== ac
)
1499 if (ARGS_EOLN
== ac
)
1502 if ( ! (MDOC_IGNDELIM
& mdoc_macros
[tok
].flags
) &&
1504 0 == j
&& DELIM_OPEN
== mdoc_isdelim(p
)) {
1505 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1509 if ( ! mdoc_elem_alloc(m
, line
, la
, tok
, arg
))
1512 if (j
== maxargs
&& ! flushed
) {
1513 if ( ! rew_elem(m
, tok
))
1518 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
1520 if (MDOC_MAX
!= ntok
) {
1521 if ( ! flushed
&& ! rew_elem(m
, tok
))
1524 if ( ! mdoc_macro(m
, ntok
, line
, la
, pos
, buf
))
1530 if ( ! (MDOC_IGNDELIM
& mdoc_macros
[tok
].flags
) &&
1533 DELIM_NONE
!= mdoc_isdelim(p
)) {
1534 if ( ! rew_elem(m
, tok
))
1540 * XXX: this is a hack to work around groff's ugliness
1541 * as regards `Xr' and extraneous arguments. It should
1542 * ideally be deprecated behaviour, but because this is
1543 * code is no here, it's unlikely to be removed.
1547 if (MDOC_Xr
== tok
&& j
== maxargs
) {
1548 if ( ! mdoc_elem_alloc(m
, line
, la
, MDOC_Ns
, NULL
))
1550 if ( ! rew_elem(m
, MDOC_Ns
))
1555 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1560 if (0 == j
&& ! mdoc_elem_alloc(m
, line
, la
, tok
, arg
))
1563 /* Close out in a consistent state. */
1565 if ( ! flushed
&& ! rew_elem(m
, tok
))
1569 return(append_delims(m
, line
, pos
, buf
));
1574 in_line_eoln(MACRO_PROT_ARGS
)
1579 struct mdoc_arg
*arg
;
1583 assert( ! (MDOC_PARSED
& mdoc_macros
[tok
].flags
));
1586 rew_sub(MDOC_BLOCK
, m
, MDOC_Nm
, line
, ppos
);
1588 /* Parse macro arguments. */
1590 for (arg
= NULL
; ; ) {
1592 av
= mdoc_argv(m
, line
, tok
, &arg
, pos
, buf
);
1594 if (ARGV_WORD
== av
) {
1598 if (ARGV_EOLN
== av
)
1603 mdoc_argv_free(arg
);
1607 /* Open element scope. */
1609 if ( ! mdoc_elem_alloc(m
, line
, ppos
, tok
, arg
))
1612 /* Parse argument terms. */
1616 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
1618 if (ARGS_ERROR
== ac
)
1620 if (ARGS_EOLN
== ac
)
1623 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
1625 if (MDOC_MAX
== ntok
) {
1626 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1631 if ( ! rew_elem(m
, tok
))
1633 return(mdoc_macro(m
, ntok
, line
, la
, pos
, buf
));
1636 /* Close out (no delimiters). */
1638 return(rew_elem(m
, tok
));
1644 ctx_synopsis(MACRO_PROT_ARGS
)
1648 nl
= MDOC_NEWLINE
& m
->flags
;
1650 /* If we're not in the SYNOPSIS, go straight to in-line. */
1651 if ( ! (MDOC_SYNOPSIS
& m
->flags
))
1652 return(in_line(m
, tok
, line
, ppos
, pos
, buf
));
1654 /* If we're a nested call, same place. */
1656 return(in_line(m
, tok
, line
, ppos
, pos
, buf
));
1659 * XXX: this will open a block scope; however, if later we end
1660 * up formatting the block scope, then child nodes will inherit
1661 * the formatting. Be careful.
1664 return(blk_full(m
, tok
, line
, ppos
, pos
, buf
));
1665 assert(MDOC_Vt
== tok
);
1666 return(blk_part_imp(m
, tok
, line
, ppos
, pos
, buf
));
1672 obsolete(MACRO_PROT_ARGS
)
1675 return(mdoc_pmsg(m
, line
, ppos
, MANDOCERR_MACROOBS
));
1680 * Phrases occur within `Bl -column' entries, separated by `Ta' or tabs.
1681 * They're unusual because they're basically free-form text until a
1682 * macro is encountered.
1685 phrase(struct mdoc
*m
, int line
, int ppos
, char *buf
)
1692 for (pos
= ppos
; ; ) {
1695 ac
= mdoc_zargs(m
, line
, &pos
, buf
, 0, &p
);
1697 if (ARGS_ERROR
== ac
)
1699 if (ARGS_EOLN
== ac
)
1702 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup_raw(p
);
1704 if (MDOC_MAX
== ntok
) {
1705 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1710 if ( ! mdoc_macro(m
, ntok
, line
, la
, &pos
, buf
))
1712 return(append_delims(m
, line
, &pos
, buf
));
1721 phrase_ta(MACRO_PROT_ARGS
)
1729 * FIXME: this is overly restrictive: if the `Ta' is unexpected,
1730 * it should simply error out with ARGSLOST.
1733 if ( ! rew_sub(MDOC_BODY
, m
, MDOC_It
, line
, ppos
))
1735 if ( ! mdoc_body_alloc(m
, line
, ppos
, MDOC_It
))
1740 ac
= mdoc_zargs(m
, line
, pos
, buf
, 0, &p
);
1742 if (ARGS_ERROR
== ac
)
1744 if (ARGS_EOLN
== ac
)
1747 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup_raw(p
);
1749 if (MDOC_MAX
== ntok
) {
1750 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1755 if ( ! mdoc_macro(m
, ntok
, line
, la
, pos
, buf
))
1757 return(append_delims(m
, line
, pos
, buf
));