3 <style|<tuple|article|fangle>>
7 <assign|par-first|0fn><assign|par-par-sep|0.5fn>
10 <doc-data|<doc-title|Literate Example>|<doc-author-data|<author-name|Sam
11 Liddicott>|<\author-address>
17 This is a simple example of how to use literate programming templates,
20 Hello-world is a famous <em|first program> with a visible side effect.
22 This example produces hello-world in multiple languages.
26 <\table-of-contents|toc>
27 <vspace*|1fn><with|font-series|bold|math-font-series|bold|1<space|2spc>Hello
28 World> <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
29 <no-break><pageref|auto-1><vspace|0.5fn>
31 <with|par-left|1.5fn|1.1<space|2spc>In French
32 <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
33 <no-break><pageref|auto-2>>
35 <with|par-left|1.5fn|1.2<space|2spc>In German
36 <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
37 <no-break><pageref|auto-3>>
42 The typical hello world program looks like this:
44 <\nf-chunk|hello-world>
45 <item>/* The traditional hello-world program in <nf-arg|language>\
47 <item> * generated using fangle literate programming macros
53 <item>#include stdio.c
59 <item> \ printf("<nf-arg|message>\\n");
62 </nf-chunk||<tuple|message|language>>
64 <subsection|In French>
68 We will derive the french hello-world program like this:
70 <\nf-chunk|./hello-world.fr.c>
71 <item><nf-ref|hello-world|<tuple|Bonjour tout le monde|french>>
74 <subsection|In German>
76 We will derive the german hello-world program like this:
78 <\nf-chunk|./hello-world.de.c>
79 <item><nf-ref|hello-world|<tuple|Hallo welt|german>>
85 <associate||<tuple|?c|?>>
86 <associate|./hello-world|<tuple|?a|?>>
87 <associate|./hello-world.de.c|<tuple|?b|?>>
88 <associate|./hello-world.fr.c|<tuple|?a|?>>
89 <associate|.hello-world|<tuple|?a|?>>
90 <associate|.hello-world.de.c|<tuple|?b|?>>
91 <associate|.hello-world.fr.c|<tuple|?a|?>>
92 <associate|auto-1|<tuple|1|1>>
93 <associate|auto-2|<tuple|1.1|1>>
94 <associate|auto-3|<tuple|1.2|1>>
95 <associate|code-end--1|<tuple|?c|?>>
96 <associate|code-end-./hello-world-1|<tuple|?a|?>>
97 <associate|code-end-./hello-world.de.c-1|<tuple|?b|?>>
98 <associate|code-end-./hello-world.fr.c-1|<tuple|?a|?>>
99 <associate|code-end-.hello-world-1|<tuple|?a|?>>
100 <associate|code-end-.hello-world.de.c-1|<tuple|?b|?>>
101 <associate|code-end-.hello-world.fr.c-1|<tuple|?a|?>>
102 <associate|code-end-h-1|<tuple|?c|?>>
103 <associate|code-end-he-1|<tuple|?c|?>>
104 <associate|code-end-hel-1|<tuple|?c|?>>
105 <associate|code-end-hell-1|<tuple|?c|?>>
106 <associate|code-end-hello--1|<tuple|?c|?>>
107 <associate|code-end-hello-1|<tuple|?c|?>>
108 <associate|code-end-hello-w-1|<tuple|?c|?>>
109 <associate|code-end-hello-wo-1|<tuple|?c|?>>
110 <associate|code-end-hello-wor-1|<tuple|?c|?>>
111 <associate|code-end-hello-worl-1|<tuple|?c|?>>
112 <associate|code-end-hello-world--1|<tuple|?c|?>>
113 <associate|code-end-hello-world-1|<tuple|1a|1>>
114 <associate|code-end-hello-world-2|<tuple|?c|?>>
115 <associate|code-end-hello-world-d-1|<tuple|?c|?>>
116 <associate|code-end-hello-world-de-1|<tuple|?c|?>>
117 <associate|code-end-hello-world-de.-1|<tuple|?c|?>>
118 <associate|code-end-hello-world-de.c-1|<tuple|?c|?>>
119 <associate|code-end-hello-world.-1|<tuple|?b|?>>
120 <associate|code-end-hello-world.de.c-1|<tuple|1a|1>>
121 <associate|code-end-hello-world.f-1|<tuple|?b|?>>
122 <associate|code-end-hello-world.fr-1|<tuple|?b|?>>
123 <associate|code-end-hello-world.fr.-1|<tuple|?b|?>>
124 <associate|code-end-hello-world.fr.c-1|<tuple|1b|1>>
125 <associate|code-end-hello-worldde.c-1|<tuple|?c|?>>
126 <associate|code-label--1|<tuple|[ 1]|?>>
127 <associate|code-label-./hello-world-1|<tuple|[./hello-world 1]|?>>
128 <associate|code-label-./hello-world.de.c-1|<tuple|[./hello-world.de.c
130 <associate|code-label-./hello-world.fr.c-1|<tuple|[./hello-world.fr.c
132 <associate|code-label-.hello-world-1|<tuple|[.hello-world 1]|?>>
133 <associate|code-label-.hello-world.de.c-1|<tuple|[.hello-world.de.c
135 <associate|code-label-.hello-world.fr.c-1|<tuple|[.hello-world.fr.c
137 <associate|code-label-h-1|<tuple|[h 1]|?>>
138 <associate|code-label-he-1|<tuple|[he 1]|?>>
139 <associate|code-label-hel-1|<tuple|[hel 1]|?>>
140 <associate|code-label-hell-1|<tuple|[hell 1]|?>>
141 <associate|code-label-hello--1|<tuple|[hello- 1]|?>>
142 <associate|code-label-hello-1|<tuple|[hello 1]|?>>
143 <associate|code-label-hello-w-1|<tuple|[hello-w 1]|?>>
144 <associate|code-label-hello-wo-1|<tuple|[hello-wo 1]|?>>
145 <associate|code-label-hello-wor-1|<tuple|[hello-wor 1]|?>>
146 <associate|code-label-hello-worl-1|<tuple|[hello-worl 1]|?>>
147 <associate|code-label-hello-world--1|<tuple|[hello-world- 1]|?>>
148 <associate|code-label-hello-world-1|<tuple|[hello-world 1]|1>>
149 <associate|code-label-hello-world-2|<tuple|[hello-world 2]|?>>
150 <associate|code-label-hello-world-d-1|<tuple|[hello-world-d 1]|?>>
151 <associate|code-label-hello-world-de-1|<tuple|[hello-world-de 1]|?>>
152 <associate|code-label-hello-world-de.-1|<tuple|[hello-world-de. 1]|?>>
153 <associate|code-label-hello-world-de.c-1|<tuple|[hello-world-de.c 1]|?>>
154 <associate|code-label-hello-world.-1|<tuple|[hello-world. 1]|?>>
155 <associate|code-label-hello-world.de.c-1|<tuple|[hello-world.de.c 1]|1>>
156 <associate|code-label-hello-world.f-1|<tuple|[hello-world.f 1]|?>>
157 <associate|code-label-hello-world.fr-1|<tuple|[hello-world.fr 1]|?>>
158 <associate|code-label-hello-world.fr.-1|<tuple|[hello-world.fr. 1]|?>>
159 <associate|code-label-hello-world.fr.c-1|<tuple|[hello-world.fr.c 1]|1>>
160 <associate|code-label-hello-worldde.c-1|<tuple|[hello-worldde.c 1]|?>>
161 <associate|code-ref--1|<tuple|?c|?>>
162 <associate|code-ref-./hello-world-1|<tuple|?a|?>>
163 <associate|code-ref-./hello-world.de.c-1|<tuple|?b|?>>
164 <associate|code-ref-./hello-world.fr.c-1|<tuple|?a|?>>
165 <associate|code-ref-.hello-world-1|<tuple|?a|?>>
166 <associate|code-ref-.hello-world.de.c-1|<tuple|?b|?>>
167 <associate|code-ref-.hello-world.fr.c-1|<tuple|?a|?>>
168 <associate|code-ref-h-1|<tuple|?c|?>>
169 <associate|code-ref-he-1|<tuple|?c|?>>
170 <associate|code-ref-hel-1|<tuple|?c|?>>
171 <associate|code-ref-hell-1|<tuple|?c|?>>
172 <associate|code-ref-hello--1|<tuple|?c|?>>
173 <associate|code-ref-hello-1|<tuple|?c|?>>
174 <associate|code-ref-hello-w-1|<tuple|?c|?>>
175 <associate|code-ref-hello-wo-1|<tuple|?c|?>>
176 <associate|code-ref-hello-wor-1|<tuple|?c|?>>
177 <associate|code-ref-hello-worl-1|<tuple|?c|?>>
178 <associate|code-ref-hello-world--1|<tuple|?c|?>>
179 <associate|code-ref-hello-world-1|<tuple|1a|1>>
180 <associate|code-ref-hello-world-2|<tuple|?c|?>>
181 <associate|code-ref-hello-world-d-1|<tuple|?c|?>>
182 <associate|code-ref-hello-world-de-1|<tuple|?c|?>>
183 <associate|code-ref-hello-world-de.-1|<tuple|?c|?>>
184 <associate|code-ref-hello-world-de.c-1|<tuple|?c|?>>
185 <associate|code-ref-hello-world.-1|<tuple|?b|?>>
186 <associate|code-ref-hello-world.de.c-1|<tuple|1a|1>>
187 <associate|code-ref-hello-world.f-1|<tuple|?b|?>>
188 <associate|code-ref-hello-world.fr-1|<tuple|?b|?>>
189 <associate|code-ref-hello-world.fr.-1|<tuple|?b|?>>
190 <associate|code-ref-hello-world.fr.c-1|<tuple|1b|1>>
191 <associate|code-ref-hello-worldde.c-1|<tuple|?c|?>>
192 <associate|h|<tuple|?c|?>>
193 <associate|he|<tuple|?c|?>>
194 <associate|hel|<tuple|?c|?>>
195 <associate|hell|<tuple|?c|?>>
196 <associate|hello|<tuple|?c|?>>
197 <associate|hello-|<tuple|?c|?>>
198 <associate|hello-w|<tuple|?c|?>>
199 <associate|hello-wo|<tuple|?c|?>>
200 <associate|hello-wor|<tuple|?c|?>>
201 <associate|hello-worl|<tuple|?c|?>>
202 <associate|hello-world|<tuple|1a|1>>
203 <associate|hello-world-|<tuple|?c|?>>
204 <associate|hello-world-d|<tuple|?c|?>>
205 <associate|hello-world-de|<tuple|?c|?>>
206 <associate|hello-world-de.|<tuple|?c|?>>
207 <associate|hello-world-de.c|<tuple|?c|?>>
208 <associate|hello-world.|<tuple|?b|?>>
209 <associate|hello-world.de.c|<tuple|1a|1>>
210 <associate|hello-world.f|<tuple|?b|?>>
211 <associate|hello-world.fr|<tuple|?b|?>>
212 <associate|hello-world.fr.|<tuple|?b|?>>
213 <associate|hello-world.fr.c|<tuple|1b|1>>
214 <associate|hello-worldde.c|<tuple|?c|?>>
221 <vspace*|1fn><with|font-series|<quote|bold>|math-font-series|<quote|bold>|1<space|2spc>Hello
222 World> <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
223 <no-break><pageref|auto-1><vspace|0.5fn>
225 <with|par-left|<quote|1.5fn>|1.1<space|2spc>In French
226 <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
227 <no-break><pageref|auto-2>>
229 <with|par-left|<quote|1.5fn>|1.2<space|2spc>In German
230 <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
231 <no-break><pageref|auto-3>>