Blame


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