-static void
-sanity(const struct mdoc_node *n)
-{
- char *p;
-
- p = "regular form violated";
-
- switch (n->type) {
- case (MDOC_TEXT):
- if (n->child)
- errx(1, p);
- if (NULL == n->parent)
- errx(1, p);
- if (NULL == n->string)
- errx(1, p);
- switch (n->parent->type) {
- case (MDOC_TEXT):
- /* FALLTHROUGH */
- case (MDOC_ROOT):
- errx(1, p);
- /* NOTREACHED */
- default:
- break;
- }
- break;
- case (MDOC_ELEM):
- if (NULL == n->parent)
- errx(1, p);
- switch (n->parent->type) {
- case (MDOC_TAIL):
- /* FALLTHROUGH */
- case (MDOC_BODY):
- /* FALLTHROUGH */
- case (MDOC_HEAD):
- break;
- default:
- errx(1, p);
- /* NOTREACHED */
- }
- if (n->child) switch (n->child->type) {
- case (MDOC_TEXT):
- break;
- default:
- errx(1, p);
- /* NOTREACHED */
- }
- break;
- case (MDOC_HEAD):
- /* FALLTHROUGH */
- case (MDOC_BODY):
- /* FALLTHROUGH */
- case (MDOC_TAIL):
- if (NULL == n->parent)
- errx(1, p);
- if (MDOC_BLOCK != n->parent->type)
- errx(1, p);
- if (n->child) switch (n->child->type) {
- case (MDOC_BLOCK):
- /* FALLTHROUGH */
- case (MDOC_ELEM):
- /* FALLTHROUGH */
- case (MDOC_TEXT):
- break;
- default:
- errx(1, p);
- /* NOTREACHED */
- }
- break;
- case (MDOC_BLOCK):
- if (NULL == n->parent)
- errx(1, p);
- if (NULL == n->child)
- errx(1, p);
- switch (n->parent->type) {
- case (MDOC_ROOT):
- /* FALLTHROUGH */
- case (MDOC_HEAD):
- /* FALLTHROUGH */
- case (MDOC_BODY):
- /* FALLTHROUGH */
- case (MDOC_TAIL):
- break;
- default:
- errx(1, p);
- /* NOTREACHED */
- }
- switch (n->child->type) {
- case (MDOC_ROOT):
- /* FALLTHROUGH */
- case (MDOC_ELEM):
- errx(1, p);
- /* NOTREACHED */
- default:
- break;
- }
- break;
- case (MDOC_ROOT):
- if (n->parent)
- errx(1, p);
- if (NULL == n->child)
- errx(1, p);
- switch (n->child->type) {
- case (MDOC_BLOCK):
- break;
- default:
- errx(1, p);
- /* NOTREACHED */
- }
- break;
- }
-}
-
-