Blame


1 2c02675e 2022-12-14 op .\" Copyright (c) 2022 Omar Polo <op@openbsd.org>
2 2c02675e 2022-12-14 op .\"
3 2c02675e 2022-12-14 op .\" Permission to use, copy, modify, and distribute this software for any
4 2c02675e 2022-12-14 op .\" purpose with or without fee is hereby granted, provided that the above
5 2c02675e 2022-12-14 op .\" copyright notice and this permission notice appear in all copies.
6 2c02675e 2022-12-14 op .\"
7 2c02675e 2022-12-14 op .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 2c02675e 2022-12-14 op .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 2c02675e 2022-12-14 op .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 2c02675e 2022-12-14 op .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 2c02675e 2022-12-14 op .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 2c02675e 2022-12-14 op .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13 2c02675e 2022-12-14 op .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 2c02675e 2022-12-14 op .\"
15 196a7c5f 2023-01-06 op .Dd January 06, 2022
16 2c02675e 2022-12-14 op .Dt TEMPLATE 1
17 2c02675e 2022-12-14 op .Os
18 2c02675e 2022-12-14 op .Sh NAME
19 2c02675e 2022-12-14 op .Nm template
20 2c02675e 2022-12-14 op .Nd templating system compiler
21 2c02675e 2022-12-14 op .Sh SYNOPSIS
22 2c02675e 2022-12-14 op .Nm
23 2c02675e 2022-12-14 op .Op Fl G
24 2c02675e 2022-12-14 op .Op Fl o Ar out
25 2c02675e 2022-12-14 op .Op Ar
26 2c02675e 2022-12-14 op .Sh DESCRIPTION
27 2c02675e 2022-12-14 op .Nm
28 2c02675e 2022-12-14 op is an utility that converts files written in the
29 2c02675e 2022-12-14 op .Xr template 7
30 2c02675e 2022-12-14 op format format to a set of routine writtens in the C programming
31 2c02675e 2022-12-14 op language.
32 2c02675e 2022-12-14 op .Nm
33 2c02675e 2022-12-14 op converts the files given as arguments or from standard input, and
34 2c02675e 2022-12-14 op writes to standard output.
35 2c02675e 2022-12-14 op .Pp
36 2c02675e 2022-12-14 op The options are as follows:
37 2c02675e 2022-12-14 op .Bl -tag -width Ds
38 2c02675e 2022-12-14 op .It Fl G
39 2c02675e 2022-12-14 op Do not emit debug info in the generated source.
40 2c02675e 2022-12-14 op It's disabled by default, unless
41 2c02675e 2022-12-14 op .Nm
42 2c02675e 2022-12-14 op is reading from standard input.
43 2c02675e 2022-12-14 op .It Fl o Ar out
44 2c02675e 2022-12-14 op Write output to file.
45 2c02675e 2022-12-14 op .Ar out
46 2c02675e 2022-12-14 op will be created or truncated if exists and will be removed if
47 2c02675e 2022-12-14 op .Nm
48 2c02675e 2022-12-14 op encounters any error.
49 2c02675e 2022-12-14 op .El
50 2c02675e 2022-12-14 op .Sh EXIT STATUS
51 89f5e055 2023-01-06 op .Ex -std
52 2c02675e 2022-12-14 op .Sh SEE ALSO
53 2c02675e 2022-12-14 op .Xr template 7
54 2c02675e 2022-12-14 op .Sh AUTHORS
55 2c02675e 2022-12-14 op .An -nosplit
56 2c02675e 2022-12-14 op The
57 2c02675e 2022-12-14 op .Nm
58 2c02675e 2022-12-14 op utility was written by
59 2c02675e 2022-12-14 op .An Omar Polo Aq Mt op@openbsd.org .
60 2c02675e 2022-12-14 op .Sh CAVEATS
61 2c02675e 2022-12-14 op The compiler is very naive, so there are quite a few shortcomings:
62 2c02675e 2022-12-14 op .Bl -bullet -compact
63 2c02675e 2022-12-14 op .It
64 2c02675e 2022-12-14 op No attempt is made to validate the C code provided inline, nor the
65 2c02675e 2022-12-14 op validity of the arguments to many constructs.
66 2c02675e 2022-12-14 op .It
67 2c02675e 2022-12-14 op The generated code assumes that a variable called
68 2c02675e 2022-12-14 op .Va tp
69 2c02675e 2022-12-14 op of type
70 2c02675e 2022-12-14 op .Vt struct template *
71 2c02675e 2022-12-14 op is in scope inside each block.
72 2c02675e 2022-12-14 op .It
73 2c02675e 2022-12-14 op Each block may have additional variables used for the template
74 2c02675e 2022-12-14 op generation implicitly defined: to avoid clashes, don't name variables
75 2c02675e 2022-12-14 op or arguments with the
76 2c02675e 2022-12-14 op .Sq tp_
77 2c02675e 2022-12-14 op prefix.
78 2c02675e 2022-12-14 op .It
79 2c02675e 2022-12-14 op Blanks are, in most cases, trimmed.
80 2c02675e 2022-12-14 op Normally this is not a problem, but a workaround is needed in case
81 2c02675e 2022-12-14 op they need to be preserved, for e.g.:
82 2c02675e 2022-12-14 op .Bd -literal -offset indent
83 2c02675e 2022-12-14 op Name: {{ " " }} {{ render name_field(tp) }}
84 2c02675e 2022-12-14 op .Ed
85 2c02675e 2022-12-14 op .El