]>
git.cameronkatri.com Git - mandoc.git/blob - tree.c
1 /* $Id: tree.c,v 1.6 2009/02/21 21:00:06 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.
24 #define xprintf (void)printf
26 static void treeprint_r(const struct mdoc_node
*, int);
29 treeprint_r(const struct mdoc_node
*n
, int indent
)
35 struct mdoc_arg
*argv
;
70 p
= n
->data
.text
.string
;
73 p
= mdoc_macronames
[n
->tok
];
76 p
= mdoc_macronames
[n
->tok
];
79 p
= mdoc_macronames
[n
->tok
];
82 p
= mdoc_macronames
[n
->tok
];
83 argv
= n
->data
.elem
.argv
;
84 argc
= n
->data
.elem
.argc
;
87 p
= mdoc_macronames
[n
->tok
];
88 argv
= n
->data
.block
.argv
;
89 argc
= n
->data
.block
.argc
;
99 for (i
= 0; i
< indent
; i
++)
101 xprintf("%s (%s)", p
, t
);
103 for (i
= 0; i
< (int)argc
; i
++) {
104 xprintf(" -%s", mdoc_argnames
[argv
[i
].arg
]);
107 for (j
= 0; j
< (int)argv
[i
].sz
; j
++)
108 xprintf(" [%s]", argv
[i
].value
[j
]);
113 for (i
= 0; i
< (int)sz
; i
++)
114 xprintf(" [%s]", params
[i
]);
116 xprintf(" %d:%d\n", n
->line
, n
->pos
);
119 treeprint_r(n
->child
, indent
+ 1);
121 treeprint_r(n
->next
, indent
);
127 treeprint(const struct mdoc_node
*node
,
128 const struct mdoc_meta
*meta
)
131 treeprint_r(node
, 0);