summaryrefslogtreecommitdiff
path: root/static/unix-v10/man1/twig.1
blob: 23965f9228f39039e5d4fb0581557f844aae6687 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
.TH TWIG 1
.CT 1 prog_other
.SH NAME
twig \- tree-manipulation language
.SH SYNOPSIS
.B twig
[
.B -w\fIxx\fP
]
.I file\f8.mt\fP
.SH DESCRIPTION
.I Twig
converts a tree-specification scheme consisting of pattern-action
rules with associated costs into C functions that can be called
to manipulate input trees.
The C functions first find a minimum-cost covering of an input tree
using a dynamic programming algorithm and then execute
the actions associated with the patterns used in the covering.
The tree-specification scheme may allow several coverings for an input tree,
but the dynamic programming algorithm resolves any ambiguities
by selecting a cheapest covering.
.PP
The input file containing the tree-specification scheme
must have the suffix
.LR .mt .
.I Twig
produces two output files:
.FR walker.c ,
which becomes the source file for the tree matcher, and
.FR symbols.h ,
which contains the definitions for the node and label symbols used
in the source file.
.PP
To build
.FR walker.c ,
.I twig
uses an internal template file called
.FR walker.\fIxx\fR
where \fIxx\fR is the argument of the optional
.B -w
flag.
If the flag is omitted, then \fIxx\fR defaults to
.LR c1 .
.SH FILES
.TF symbols.h
.TP
.F file.mt
input file
.TP
.F walker.c
output tree matcher
.TP
.F symbols.h
definitions of node and label symbols
.SH "SEE ALSO"
.IR yacc (1)
.br
S. W. K. Tjiang,
.I "The Twig Reference Manual,"
Computing Science Technical Report No. 120,
AT&T Bell Laboratories,
Murray Hill, N.J.
.br
A. V. Aho, M. Ganapathi, and S. W. K. Tjiang,
.I "Code generation using tree matching and dynamic programming."
.SH BUGS
When tree matching fails, the debugging output is cryptic.