Lines Matching defs:mdoc
29 #include "mdoc.h"
44 static void dword(struct mdoc *, int, int, const char *,
46 static void append_delims(struct mdoc *, int, int *, char *);
47 static enum mdoct lookup(struct mdoc *, enum mdoct,
50 static int parse_rest(struct mdoc *, enum mdoct,
53 static void rew_elem(struct mdoc *, enum mdoct);
54 static void rew_last(struct mdoc *, const struct mdoc_node *);
55 static void rew_pending(struct mdoc *, const struct mdoc_node *);
210 mdoc_macroend(struct mdoc *mdoc)
216 n = mdoc->last->flags & MDOC_VALID ?
217 mdoc->last->parent : mdoc->last;
222 mandoc_msg(MANDOCERR_BLK_NOEND, mdoc->parse,
227 rew_last(mdoc, mdoc->first);
235 lookup(struct mdoc *mdoc, enum mdoct from, int line, int ppos, const char *p)
246 mdoc->parse, line, ppos, p);
256 rew_last(struct mdoc *mdoc, const struct mdoc_node *to)
261 mdoc->next = MDOC_NEXT_SIBLING;
262 while (mdoc->last != to) {
265 * mdoc->last node in the post-validation phase and reset
266 * it to mdoc->last->parent, causing a step in the closing
269 np = mdoc->last->parent;
270 mdoc_valid_post(mdoc);
271 n = mdoc->last;
272 mdoc->last = np;
273 assert(mdoc->last);
274 mdoc->last->last = n;
276 mdoc_valid_post(mdoc);
283 rew_pending(struct mdoc *mdoc, const struct mdoc_node *n)
287 rew_last(mdoc, n);
291 mdoc_body_alloc(mdoc, n->line, n->pos, n->tok);
364 rew_elem(struct mdoc *mdoc, enum mdoct tok)
368 n = mdoc->last;
373 rew_last(mdoc, n);
381 dword(struct mdoc *mdoc, int line, int col, const char *p,
389 ! (mdoc->flags & (MDOC_SYNOPSIS | MDOC_KEEP | MDOC_SMOFF)) &&
390 d == DELIM_NONE && mdoc->last->type == MDOC_TEXT &&
391 mdoc_isdelim(mdoc->last->string) == DELIM_NONE) {
392 mdoc_word_append(mdoc, p);
396 mdoc_word_alloc(mdoc, line, col, p);
406 mdoc->last->flags |= MDOC_DELIMO;
408 ! (mdoc->flags & MDOC_NODELIMC) &&
409 mdoc->last->parent->tok != MDOC_Fd)
410 mdoc->last->flags |= MDOC_DELIMC;
411 mdoc->flags &= ~MDOC_NODELIMC;
415 append_delims(struct mdoc *mdoc, int line, int *pos, char *buf)
425 if (mdoc_args(mdoc, line, pos, buf, MDOC_MAX, &p) == ARGS_EOLN)
427 dword(mdoc, line, la, p, DELIM_MAX, 1);
442 mdoc->last->flags |= MDOC_EOS;
461 else if (parsed && ! (mdoc->flags & MDOC_PHRASELIT))
462 ntok = lookup(mdoc, tok, line, ppos, p);
465 dword(mdoc, line, ppos, p, DELIM_MAX, tok == MDOC_MAX ||
470 rew_elem(mdoc, tok);
471 mdoc_macro(mdoc, ntok, line, ppos, pos, buf);
473 append_delims(mdoc, line, pos, buf);
495 nl = MDOC_NEWLINE & mdoc->flags;
502 mdoc->flags &= ~MDOC_KEEP;
516 for (n = mdoc->last; n; n = n->parent) {
560 mandoc_vmsg(MANDOCERR_BLK_NEST, mdoc->parse,
565 endbody = mdoc_endbody_alloc(mdoc, line, ppos,
578 mdoc->next = MDOC_NEXT_CHILD;
585 rew_last(mdoc, n);
597 mandoc_msg(MANDOCERR_BLK_NOTOPEN, mdoc->parse,
604 mdoc_elem_alloc(mdoc, line, ppos, MDOC_br, NULL);
605 rew_elem(mdoc, MDOC_br);
608 rew_last(mdoc, body);
610 mdoc_tail_alloc(mdoc, line, ppos, atok);
616 mdoc->parse, line, ppos,
620 rew_pending(mdoc, n);
630 rew_pending(mdoc, n);
634 ac = mdoc_args(mdoc, line, pos, buf, tok, &p);
639 lookup(mdoc, tok, line, lastarg, p);
642 dword(mdoc, line, lastarg, p, DELIM_MAX,
648 rew_pending(mdoc, n);
651 mdoc->flags &= ~MDOC_NEWLINE;
652 mdoc_macro(mdoc, ntok, line, lastarg, pos, buf);
657 rew_pending(mdoc, n);
659 append_delims(mdoc, line, pos, buf);
672 nl = MDOC_NEWLINE & mdoc->flags;
698 mdoc_argv(mdoc, line, tok, &arg, pos, buf);
705 ac = mdoc_args(mdoc, line, pos, buf, tok, &p);
714 mdoc->last->flags &= ~MDOC_DELIMO;
728 mdoc->flags |= MDOC_NODELIMC;
733 MDOC_MAX : lookup(mdoc, tok, line, la, p);
744 rew_elem(mdoc, tok);
746 mdoc_elem_alloc(mdoc, line, ppos, tok, arg);
747 rew_last(mdoc, mdoc->last);
751 mdoc->parse, line, ppos,
754 mdoc_macro(mdoc, ntok, line, la, pos, buf);
756 append_delims(mdoc, line, pos, buf);
778 mdoc_elem_alloc(mdoc, line, ppos, tok, arg);
789 rew_elem(mdoc, tok);
794 mdoc_elem_alloc(mdoc, line, ppos, tok, arg);
799 dword(mdoc, line, la, p, d,
808 mdoc->last->flags &= ~MDOC_DELIMC;
817 rew_elem(mdoc, tok);
823 rew_elem(mdoc, tok);
833 mdoc_elem_alloc(mdoc, line, ppos, tok, arg);
834 rew_last(mdoc, mdoc->last);
837 mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse,
842 append_delims(mdoc, line, pos, buf);
857 nl = MDOC_NEWLINE & mdoc->flags;
860 mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse,
870 for (n = mdoc->last; n != NULL; n = n->parent) {
882 mdoc->parse, line, ppos,
885 rew_pending(mdoc, blk);
896 mdoc->parse, line, ppos,
900 rew_pending(mdoc, n);
901 n = mdoc->last;
924 mdoc->parse, line, ppos,
927 rew_pending(mdoc, blk);
933 rew_last(mdoc, n);
939 mandoc_vmsg(MANDOCERR_IT_STRAY, mdoc->parse,
941 mdoc_elem_alloc(mdoc, line, ppos, MDOC_br, NULL);
942 rew_elem(mdoc, MDOC_br);
956 mdoc_argv(mdoc, line, tok, &arg, pos, buf);
957 blk = mdoc_block_alloc(mdoc, line, ppos, tok, arg);
966 mdoc->last->parent->tok != MDOC_Bl ||
967 mdoc->last->parent->norm->Bl.type != LIST_diag;
975 head = mdoc_head_alloc(mdoc, line, ppos, tok);
976 rew_last(mdoc, head);
977 body = mdoc_body_alloc(mdoc, line, ppos, tok);
981 mdoc->flags |= MDOC_KEEP;
987 ac = mdoc_args(mdoc, line, pos, buf, tok, &p);
999 rew_last(mdoc, body);
1000 body = mdoc_body_alloc(mdoc, line, ppos, tok);
1005 mdoc->parse, line, la, "%s ... %s",
1010 mandoc_vmsg(MANDOCERR_ARG_SKIP, mdoc->parse,
1028 dword(mdoc, line, la, p, DELIM_OPEN, 0);
1035 head = mdoc_head_alloc(mdoc, line, ppos, tok);
1046 rew_last(mdoc, body == NULL ? head : body);
1047 body = mdoc_body_alloc(mdoc, line, ppos, tok);
1056 mdoc->flags |= MDOC_PPHRASE;
1058 mdoc->flags |= MDOC_PPHRASE;
1059 parse_rest(mdoc, MDOC_MAX, line, &la, buf);
1060 mdoc->flags &= ~MDOC_PPHRASE;
1064 if (macro_or_word(mdoc, tok, line, la, pos, buf, parsed))
1071 head = mdoc_head_alloc(mdoc, line, ppos, tok);
1073 append_delims(mdoc, line, pos, buf);
1083 for (n = mdoc->last; n && n != head; n = n->parent) {
1100 rew_last(mdoc, head);
1101 body = mdoc_body_alloc(mdoc, line, ppos, tok);
1103 if (mdoc->flags & MDOC_FREECOL) {
1104 rew_last(mdoc, body);
1105 rew_last(mdoc, blk);
1106 mdoc->flags &= ~MDOC_FREECOL;
1120 nl = MDOC_NEWLINE & mdoc->flags;
1131 blk = mdoc_block_alloc(mdoc, line, ppos, tok, NULL);
1132 rew_last(mdoc, mdoc_head_alloc(mdoc, line, ppos, tok));
1142 ac = mdoc_args(mdoc, line, pos, buf, tok, &p);
1148 dword(mdoc, line, la, p, DELIM_OPEN, 0);
1153 body = mdoc_body_alloc(mdoc, line, ppos, tok);
1155 if (macro_or_word(mdoc, tok, line, la, pos, buf, 1))
1159 body = mdoc_body_alloc(mdoc, line, ppos, tok);
1167 for (n = mdoc->last; n && n != body && n != blk->parent;
1179 mdoc->parse, line, ppos,
1182 mdoc_endbody_alloc(mdoc, line, ppos,
1191 rew_last(mdoc, body);
1193 append_delims(mdoc, line, pos, buf);
1194 rew_pending(mdoc, blk);
1201 mdoc_node_relink(mdoc, n);
1212 nl = MDOC_NEWLINE & mdoc->flags;
1220 mdoc_block_alloc(mdoc, line, ppos, tok, NULL);
1224 ac = mdoc_args(mdoc, line, pos, buf, tok, &p);
1232 dword(mdoc, line, la, p, DELIM_OPEN, 0);
1237 head = mdoc_head_alloc(mdoc, line, ppos, tok);
1239 dword(mdoc, line, la, p, DELIM_MAX, 0);
1240 rew_last(mdoc, head);
1241 mdoc_body_alloc(mdoc, line, ppos, tok);
1246 if (macro_or_word(mdoc, tok, line, la, pos, buf, 1))
1253 rew_last(mdoc, mdoc_head_alloc(mdoc, line, ppos, tok));
1254 mdoc_body_alloc(mdoc, line, ppos, tok);
1257 append_delims(mdoc, line, pos, buf);
1270 nl = mdoc->flags & MDOC_NEWLINE;
1300 mdoc_argv(mdoc, line, tok, &arg, pos, buf);
1306 ac = mdoc_args(mdoc, line, pos, buf, tok, &p);
1311 dword(mdoc, line, la, p, DELIM_OPEN, 0);
1317 mdoc_elem_alloc(mdoc, line, ppos, tok, arg);
1324 mdoc->parse, line, ppos, "Pf %s",
1330 rew_elem(mdoc, tok);
1335 MDOC_MAX : lookup(mdoc, tok, line, la, p);
1339 rew_elem(mdoc, tok);
1342 mdoc_macro(mdoc, ntok, line, la, pos, buf);
1350 mdoc_elem_alloc(mdoc, line, ppos, tok, arg);
1355 rew_elem(mdoc, tok);
1359 dword(mdoc, line, la, p, DELIM_MAX,
1364 mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse,
1370 append_delims(mdoc, line, pos, buf);
1372 rew_elem(mdoc, tok);
1374 append_delims(mdoc, line, pos, buf);
1384 ! (mdoc->flags & MDOC_SYNOPSIS)) {
1385 n = mdoc->last;
1386 if (mdoc->next == MDOC_NEXT_SIBLING)
1389 rew_last(mdoc, mdoc->last->parent);
1394 mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse,
1399 mdoc_argv(mdoc, line, tok, &arg, pos, buf);
1400 mdoc_elem_alloc(mdoc, line, ppos, tok, arg);
1401 if (parse_rest(mdoc, tok, line, pos, buf))
1403 rew_elem(mdoc, tok);
1412 parse_rest(struct mdoc *mdoc, enum mdoct tok, int line, int *pos, char *buf)
1418 if (mdoc_args(mdoc, line, pos, buf, tok, NULL) == ARGS_EOLN)
1420 if (macro_or_word(mdoc, tok, line, la, pos, buf, 1))
1429 if (~mdoc->flags & (MDOC_SYNOPSIS | MDOC_NEWLINE))
1430 in_line(mdoc, tok, line, ppos, pos, buf);
1432 blk_full(mdoc, tok, line, ppos, pos, buf);
1435 blk_part_imp(mdoc, tok, line, ppos, pos, buf);
1452 for (n = mdoc->last; n != NULL; n = n->parent) {
1462 mandoc_msg(MANDOCERR_TA_STRAY, mdoc->parse,
1469 rew_last(mdoc, body);
1470 mdoc_body_alloc(mdoc, line, ppos, MDOC_It);
1471 parse_rest(mdoc, MDOC_MAX, line, pos, buf);