- n = mdoc->last;
- if (MDOC_ELEM != n->type)
- n = n->parent;
- assert(MDOC_ELEM == n->type);
- assert(tok == n->data.elem.tok);
+ if (MDOC_ROOT == p->type)
+ return(REWIND_HALT);
+ if (MDOC_TEXT == p->type)
+ return(REWIND_NOHALT);
+ if (MDOC_ELEM == p->type)
+ return(REWIND_NOHALT);
+
+ switch (tok) {
+ /* One-liner implicit-scope. */
+ case (MDOC_Aq):
+ /* FALLTHROUGH */
+ case (MDOC_Bq):
+ /* FALLTHROUGH */
+ case (MDOC_D1):
+ /* FALLTHROUGH */
+ case (MDOC_Dl):
+ /* FALLTHROUGH */
+ case (MDOC_Dq):
+ /* FALLTHROUGH */
+ case (MDOC_Op):
+ /* FALLTHROUGH */
+ case (MDOC_Pq):
+ /* FALLTHROUGH */
+ case (MDOC_Ql):
+ /* FALLTHROUGH */
+ case (MDOC_Qq):
+ /* FALLTHROUGH */
+ case (MDOC_Sq):
+ assert(MDOC_BODY != type);
+ assert(MDOC_TAIL != type);
+ if (type == p->type && tok == p->tok)
+ return(REWIND_REWIND);
+ break;
+
+ /* Multi-line implicit-scope. */
+ case (MDOC_It):
+ assert(MDOC_TAIL != type);
+ if (type == p->type && tok == p->tok)
+ return(REWIND_REWIND);
+ if (MDOC_BODY == p->type && MDOC_Bl == p->tok)
+ return(REWIND_HALT);
+ break;
+ case (MDOC_Sh):
+ if (type == p->type && tok == p->tok)
+ return(REWIND_REWIND);
+ break;
+ case (MDOC_Ss):
+ assert(MDOC_TAIL != type);
+ if (type == p->type && tok == p->tok)
+ return(REWIND_REWIND);
+ if (MDOC_BODY == p->type && MDOC_Sh == p->tok)
+ return(REWIND_HALT);
+ break;
+
+ /* Multi-line explicit scope start. */
+ case (MDOC_Ao):
+ /* FALLTHROUGH */
+ case (MDOC_Bd):
+ /* FALLTHROUGH */
+ case (MDOC_Bf):
+ /* FALLTHROUGH */
+ case (MDOC_Bk):
+ /* FALLTHROUGH */
+ case (MDOC_Bl):
+ /* FALLTHROUGH */
+ case (MDOC_Bo):
+ /* FALLTHROUGH */
+ case (MDOC_Do):
+ /* FALLTHROUGH */
+ case (MDOC_Eo):
+ /* FALLTHROUGH */
+ case (MDOC_Fo):
+ /* FALLTHROUGH */
+ case (MDOC_Oo):
+ /* FALLTHROUGH */
+ case (MDOC_Po):
+ /* FALLTHROUGH */
+ case (MDOC_Qo):
+ /* FALLTHROUGH */
+ case (MDOC_Rs):
+ /* FALLTHROUGH */
+ case (MDOC_So):
+ /* FALLTHROUGH */
+ case (MDOC_Xo):
+ if (type == p->type && tok == p->tok)
+ return(REWIND_REWIND);
+ break;