Blame


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