]>
git.cameronkatri.com Git - mandoc.git/blob - tree.c
1 /* $Id: tree.c,v 1.1 2009/01/16 15:58:50 kristaps Exp $ */
3 * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the
7 * above copyright notice and this permission notice appear in all
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
25 /* TODO: remove this to a print-tree output filter. */
27 print_node(const struct mdoc_node
*n
, int indent
)
33 struct mdoc_arg
*argv
;
39 t
= mdoc_type2a(n
->type
);
43 p
= n
->data
.text
.string
;
46 p
= mdoc_macronames
[n
->tok
];
49 p
= mdoc_macronames
[n
->tok
];
52 p
= mdoc_macronames
[n
->tok
];
55 p
= mdoc_macronames
[n
->tok
];
56 argv
= n
->data
.elem
.argv
;
57 argc
= n
->data
.elem
.argc
;
60 p
= mdoc_macronames
[n
->tok
];
61 argv
= n
->data
.block
.argv
;
62 argc
= n
->data
.block
.argc
;
72 for (i
= 0; i
< indent
; i
++)
74 xprintf("%s (%s)", p
, t
);
76 for (i
= 0; i
< (int)argc
; i
++) {
77 xprintf(" -%s", mdoc_argnames
[argv
[i
].arg
]);
80 for (j
= 0; j
< (int)argv
[i
].sz
; j
++)
81 xprintf(" [%s]", argv
[i
].value
[j
]);
86 for (i
= 0; i
< (int)sz
; i
++)
87 xprintf(" [%s]", params
[i
]);
89 xprintf(" %d:%d\n", n
->line
, n
->pos
);
92 print_node(n
->child
, indent
+ 1);
94 print_node(n
->next
, indent
);
99 treeprint(const struct mdoc_node
*node
, const char *out
)