Debian Codegraph @

texk/web2c/mfluadir/mf-lua.ch

raw
1 @x [0] MFLua
2 % This program is copyright (C) 1984 by D. E. Knuth; all rights are reserved.
3 @y
4 % This program is MFLua, strictly based on the METAFONT 2.71828182 source code.
5 % What follow are the original comments of METAFONT 2.71828182.
6
7 % This program is copyright (C) 1984 by D. E. Knuth; all rights are reserved.
8 @z
9
10 @x [0] MFLua
11 \def\MF{{\tenlogo META}\-{\tenlogo FONT}}
12 @y
13 %\def\MF{{\tenlogo META}\-{\tenlogo FONT}}
14 \def\MF{{\tenlogo MF}{\mc LUA}}
15 @z
16
17 @x [1.2] MFLua
18 @d banner=='This is METAFONT, Version 2.71828182' {printed when \MF\ starts}
19 @y
20 @d METAFONT_banner=='This is METAFONT, Version 2.71828182' {printed when \MF\ starts}
21 @#
22 @d MFLua_version_string=='-1.0.0-alpha'
23 @#
24 @d MFLua_banner=='This is MFLua, Version 2.71828182', MFLua_version_string
25 {printed when MFLua starts}
26 @#
27 @d banner==MFLua_banner
28 @z
29
30 @x [12.186] MFLua - runscript primitive
31 At any rate, here is the list, for future reference.
32
33 @d if_test=1 {conditional text (\&{if})}
34 @d fi_or_else=2 {delimiters for conditionals (\&{elseif}, \&{else}, \&{fi})}
35 @d input=3 {input a source file (\&{input}, \&{endinput})}
36 @d iteration=4 {iterate (\&{for}, \&{forsuffixes}, \&{forever}, \&{endfor})}
37 @d repeat_loop=5 {special command substituted for \&{endfor}}
38 @d exit_test=6 {premature exit from a loop (\&{exitif})}
39 @d relax=7 {do nothing (\.{\char`\\})}
40 @d scan_tokens=8 {put a string into the input buffer}
41 @d expand_after=9 {look ahead one token}
42 @d defined_macro=10 {a macro defined by the user}
43 @d min_command=defined_macro+1
44 @d display_command=11 {online graphic output (\&{display})}
45 @d save_command=12 {save a list of tokens (\&{save})}
46 @d interim_command=13 {save an internal quantity (\&{interim})}
47 @d let_command=14 {redefine a symbolic token (\&{let})}
48 @d new_internal=15 {define a new internal quantity (\&{newinternal})}
49 @d macro_def=16 {define a macro (\&{def}, \&{vardef}, etc.)}
50 @d ship_out_command=17 {output a character (\&{shipout})}
51 @d add_to_command=18 {add to edges (\&{addto})}
52 @d cull_command=19 {cull and normalize edges (\&{cull})}
53 @d tfm_command=20 {command for font metric info (\&{ligtable}, etc.)}
54 @d protection_command=21 {set protection flag (\&{outer}, \&{inner})}
55 @d show_command=22 {diagnostic output (\&{show}, \&{showvariable}, etc.)}
56 @d mode_command=23 {set interaction level (\&{batchmode}, etc.)}
57 @d random_seed=24 {initialize random number generator (\&{randomseed})}
58 @d message_command=25 {communicate to user (\&{message}, \&{errmessage})}
59 @d every_job_command=26 {designate a starting token (\&{everyjob})}
60 @d delimiters=27 {define a pair of delimiters (\&{delimiters})}
61 @d open_window=28 {define a window on the screen (\&{openwindow})}
62 @d special_command=29 {output special info (\&{special}, \&{numspecial})}
63 @d type_name=30 {declare a type (\&{numeric}, \&{pair}, etc.)}
64 @d max_statement_command=type_name
65 @d min_primary_command=type_name
66 @d left_delimiter=31 {the left delimiter of a matching pair}
67 @d begin_group=32 {beginning of a group (\&{begingroup})}
68 @d nullary=33 {an operator without arguments (e.g., \&{normaldeviate})}
69 @d unary=34 {an operator with one argument (e.g., \&{sqrt})}
70 @d str_op=35 {convert a suffix to a string (\&{str})}
71 @d cycle=36 {close a cyclic path (\&{cycle})}
72 @d primary_binary=37 {binary operation taking `\&{of}' (e.g., \&{point})}
73 @d capsule_token=38 {a value that has been put into a token list}
74 @d string_token=39 {a string constant (e.g., |"hello"|)}
75 @d internal_quantity=40 {internal numeric parameter (e.g., \&{pausing})}
76 @d min_suffix_token=internal_quantity
77 @d tag_token=41 {a symbolic token without a primitive meaning}
78 @d numeric_token=42 {a numeric constant (e.g., \.{3.14159})}
79 @d max_suffix_token=numeric_token
80 @d plus_or_minus=43 {either `\.+' or `\.-'}
81 @d max_primary_command=plus_or_minus {should also be |numeric_token+1|}
82 @d min_tertiary_command=plus_or_minus
83 @d tertiary_secondary_macro=44 {a macro defined by \&{secondarydef}}
84 @d tertiary_binary=45 {an operator at the tertiary level (e.g., `\.{++}')}
85 @d max_tertiary_command=tertiary_binary
86 @d left_brace=46 {the operator `\.{\char`\{}'}
87 @d min_expression_command=left_brace
88 @d path_join=47 {the operator `\.{..}'}
89 @d ampersand=48 {the operator `\.\&'}
90 @d expression_tertiary_macro=49 {a macro defined by \&{tertiarydef}}
91 @d expression_binary=50 {an operator at the expression level (e.g., `\.<')}
92 @d equals=51 {the operator `\.='}
93 @d max_expression_command=equals
94 @d and_command=52 {the operator `\&{and}'}
95 @d min_secondary_command=and_command
96 @d secondary_primary_macro=53 {a macro defined by \&{primarydef}}
97 @d slash=54 {the operator `\./'}
98 @d secondary_binary=55 {an operator at the binary level (e.g., \&{shifted})}
99 @d max_secondary_command=secondary_binary
100 @d param_type=56 {type of parameter (\&{primary}, \&{expr}, \&{suffix}, etc.)}
101 @d controls=57 {specify control points explicitly (\&{controls})}
102 @d tension=58 {specify tension between knots (\&{tension})}
103 @d at_least=59 {bounded tension value (\&{atleast})}
104 @d curl_command=60 {specify curl at an end knot (\&{curl})}
105 @d macro_special=61 {special macro operators (\&{quote}, \.{\#\AT!}, etc.)}
106 @d right_delimiter=62 {the right delimiter of a matching pair}
107 @d left_bracket=63 {the operator `\.['}
108 @d right_bracket=64 {the operator `\.]'}
109 @d right_brace=65 {the operator `\.{\char`\}}'}
110 @d with_option=66 {option for filling (\&{withpen}, \&{withweight})}
111 @d cull_op=67 {the operator `\&{keeping}' or `\&{dropping}'}
112 @d thing_to_add=68
113 {variant of \&{addto} (\&{contour}, \&{doublepath}, \&{also})}
114 @d of_token=69 {the operator `\&{of}'}
115 @d from_token=70 {the operator `\&{from}'}
116 @d to_token=71 {the operator `\&{to}'}
117 @d at_token=72 {the operator `\&{at}'}
118 @d in_window=73 {the operator `\&{inwindow}'}
119 @d step_token=74 {the operator `\&{step}'}
120 @d until_token=75 {the operator `\&{until}'}
121 @d lig_kern_token=76
122 {the operators `\&{kern}' and `\.{=:}' and `\.{=:\char'174}', etc.}
123 @d assignment=77 {the operator `\.{:=}'}
124 @d skip_to=78 {the operation `\&{skipto}'}
125 @d bchar_label=79 {the operator `\.{\char'174\char'174:}'}
126 @d double_colon=80 {the operator `\.{::}'}
127 @d colon=81 {the operator `\.:'}
128 @#
129 @d comma=82 {the operator `\.,', must be |colon+1|}
130 @d end_of_statement==cur_cmd>comma
131 @d semicolon=83 {the operator `\.;', must be |comma+1|}
132 @d end_group=84 {end a group (\&{endgroup}), must be |semicolon+1|}
133 @d stop=85 {end a job (\&{end}, \&{dump}), must be |end_group+1|}
134 @d max_command_code=stop
135 @d outer_tag=max_command_code+1 {protection code added to command code}
136 @y
137 At any rate, here is the list, for future reference.
138
139 @d delta_code=1 {n. of new primitives added }
140 @d if_test=1 {conditional text (\&{if})}
141 @d fi_or_else=2 {delimiters for conditionals (\&{elseif}, \&{else}, \&{fi})}
142 @d input=3 {input a source file (\&{input}, \&{endinput})}
143 @d iteration=4 {iterate (\&{for}, \&{forsuffixes}, \&{forever}, \&{endfor})}
144 @d repeat_loop=5 {special command substituted for \&{endfor}}
145 @d exit_test=6 {premature exit from a loop (\&{exitif})}
146 @d relax=7 {do nothing (\.{\char`\\})}
147 @d scan_tokens=8 {put a string into the input buffer}
148 @d run_script=8+delta_code {execute a Lua script}
149 @d expand_after=9+delta_code {look ahead one token}
150 @d defined_macro=10+delta_code {a macro defined by the user}
151 @d min_command=defined_macro+1
152 @d display_command=11+delta_code {online graphic output (\&{display})}
153 @d save_command=12+delta_code {save a list of tokens (\&{save})}
154 @d interim_command=13+delta_code {save an internal quantity (\&{interim})}
155 @d let_command=14+delta_code {redefine a symbolic token (\&{let})}
156 @d new_internal=15+delta_code {define a new internal quantity (\&{newinternal})}
157 @d macro_def=16+delta_code {define a macro (\&{def}, \&{vardef}, etc.)}
158 @d ship_out_command=17+delta_code {output a character (\&{shipout})}
159 @d add_to_command=18+delta_code {add to edges (\&{addto})}
160 @d cull_command=19+delta_code {cull and normalize edges (\&{cull})}
161 @d tfm_command=20+delta_code {command for font metric info (\&{ligtable}, etc.)}
162 @d protection_command=21+delta_code {set protection flag (\&{outer}, \&{inner})}
163 @d show_command=22+delta_code {diagnostic output (\&{show}, \&{showvariable}, etc.)}
164 @d mode_command=23+delta_code {set interaction level (\&{batchmode}, etc.)}
165 @d random_seed=24+delta_code {initialize random number generator (\&{randomseed})}
166 @d message_command=25+delta_code {communicate to user (\&{message}, \&{errmessage})}
167 @d every_job_command=26+delta_code {designate a starting token (\&{everyjob})}
168 @d delimiters=27+delta_code {define a pair of delimiters (\&{delimiters})}
169 @d open_window=28+delta_code {define a window on the screen (\&{openwindow})}
170 @d special_command=29+delta_code {output special info (\&{special}, \&{numspecial})}
171 @d type_name=30+delta_code {declare a type (\&{numeric}, \&{pair}, etc.)}
172 @d max_statement_command=type_name
173 @d min_primary_command=type_name
174 @d left_delimiter=31+delta_code {the left delimiter of a matching pair}
175 @d begin_group=32+delta_code {beginning of a group (\&{begingroup})}
176 @d nullary=33+delta_code {an operator without arguments (e.g., \&{normaldeviate})}
177 @d unary=34+delta_code {an operator with one argument (e.g., \&{sqrt})}
178 @d str_op=35+delta_code {convert a suffix to a string (\&{str})}
179 @d cycle=36+delta_code {close a cyclic path (\&{cycle})}
180 @d primary_binary=37+delta_code {binary operation taking `\&{of}' (e.g., \&{point})}
181 @d capsule_token=38+delta_code {a value that has been put into a token list}
182 @d string_token=39+delta_code {a string constant (e.g., |"hello"|)}
183 @d internal_quantity=40+delta_code {internal numeric parameter (e.g., \&{pausing})}
184 @d min_suffix_token=internal_quantity
185 @d tag_token=41+delta_code {a symbolic token without a primitive meaning}
186 @d numeric_token=42+delta_code {a numeric constant (e.g., \.{3.14159})}
187 @d max_suffix_token=numeric_token
188 @d plus_or_minus=43+delta_code {either `\.+' or `\.-'}
189 @d max_primary_command=plus_or_minus {should also be |numeric_token+1|}
190 @d min_tertiary_command=plus_or_minus
191 @d tertiary_secondary_macro=44+delta_code {a macro defined by \&{secondarydef}}
192 @d tertiary_binary=45+delta_code {an operator at the tertiary level (e.g., `\.{++}')}
193 @d max_tertiary_command=tertiary_binary
194 @d left_brace=46+delta_code {the operator `\.{\char`\{}'}
195 @d min_expression_command=left_brace
196 @d path_join=47+delta_code {the operator `\.{..}'}
197 @d ampersand=48+delta_code {the operator `\.\&'}
198 @d expression_tertiary_macro=49+delta_code {a macro defined by \&{tertiarydef}}
199 @d expression_binary=50+delta_code {an operator at the expression level (e.g., `\.<')}
200 @d equals=51+delta_code {the operator `\.='}
201 @d max_expression_command=equals
202 @d and_command=52+delta_code {the operator `\&{and}'}
203 @d min_secondary_command=and_command
204 @d secondary_primary_macro=53+delta_code {a macro defined by \&{primarydef}}
205 @d slash=54+delta_code {the operator `\./'}
206 @d secondary_binary=55+delta_code {an operator at the binary level (e.g., \&{shifted})}
207 @d max_secondary_command=secondary_binary
208 @d param_type=56+delta_code {type of parameter (\&{primary}, \&{expr}, \&{suffix}, etc.)}
209 @d controls=57+delta_code {specify control points explicitly (\&{controls})}
210 @d tension=58+delta_code {specify tension between knots (\&{tension})}
211 @d at_least=59+delta_code {bounded tension value (\&{atleast})}
212 @d curl_command=60+delta_code {specify curl at an end knot (\&{curl})}
213 @d macro_special=61+delta_code {special macro operators (\&{quote}, \.{\#\AT!}, etc.)}
214 @d right_delimiter=62+delta_code {the right delimiter of a matching pair}
215 @d left_bracket=63+delta_code {the operator `\.['}
216 @d right_bracket=64+delta_code {the operator `\.]'}
217 @d right_brace=65+delta_code {the operator `\.{\char`\}}'}
218 @d with_option=66+delta_code {option for filling (\&{withpen}, \&{withweight})}
219 @d cull_op=67+delta_code {the operator `\&{keeping}' or `\&{dropping}'}
220 @d thing_to_add=68+delta_code
221 {variant of \&{addto} (\&{contour}, \&{doublepath}, \&{also})}
222 @d of_token=69+delta_code {the operator `\&{of}'}
223 @d from_token=70+delta_code {the operator `\&{from}'}
224 @d to_token=71+delta_code {the operator `\&{to}'}
225 @d at_token=72+delta_code {the operator `\&{at}'}
226 @d in_window=73+delta_code {the operator `\&{inwindow}'}
227 @d step_token=74+delta_code {the operator `\&{step}'}
228 @d until_token=75+delta_code {the operator `\&{until}'}
229 @d lig_kern_token=76+delta_code
230 {the operators `\&{kern}' and `\.{=:}' and `\.{=:\char'174}', etc.}
231 @d assignment=77+delta_code {the operator `\.{:=}'}
232 @d skip_to=78+delta_code {the operation `\&{skipto}'}
233 @d bchar_label=79+delta_code {the operator `\.{\char'174\char'174:}'}
234 @d double_colon=80+delta_code {the operator `\.{::}'}
235 @d colon=81+delta_code {the operator `\.:'}
236 @#
237 @d comma=82+delta_code {the operator `\.,', must be |colon+1|}
238 @d end_of_statement==cur_cmd>comma
239 @d semicolon=83+delta_code {the operator `\.;', must be |comma+1|}
240 @d end_group=84+delta_code {end a group (\&{endgroup}), must be |semicolon+1|}
241 @d stop=85+delta_code {end a job (\&{end}, \&{dump}), must be |end_group+1|}
242 @d max_command_code=stop
243 @d outer_tag=max_command_code+1 {protection code added to command code}
244 @z
245
246 @x [13.211] MFLua - runscript primitive
247 primitive("randomseed",random_seed,0);@/
248 @!@:random_seed_}{\&{randomseed} primitive@>
249 @y
250 primitive("randomseed",random_seed,0);@/
251 @!@:random_seed_}{\&{randomseed} primitive@>
252 primitive("runscript",run_script,0);@/
253 @!@:run_script_}{\&{runscript} primitive@>
254 @z
255
256 @x [13.212] MFLua - runscript primitive
257 right_bracket:print("]");
258 @y
259 right_bracket:print("]");
260 run_script:print("runscript");
261 @z
262
263 @x [17.257] MFLua
264 begin print_diagnostic("Path",s,nuline); print_ln;
265 @y
266 begin
267 mflua_printpath(h,s,nuline);
268 print_diagnostic("Path",s,nuline); print_ln;
269 @z
270
271 @x [20.332] MFLua
272 begin print_diagnostic("Edge structure",s,nuline);
273 @y
274 begin
275 {mflua\_printedges(s,nuline,x\_off,y\_off);}
276 print_diagnostic("Edge structure",s,nuline);
277 @z
278
279 @x [22.465] MFLua
280 move_to_edges(m0,n0,m1,n1);
281 @y
282 mflua_PRE_move_to_edges(p);
283 move_to_edges(m0,n0,m1,n1);
284 mflua_POST_move_to_edges(p);
285 @z
286
287 @x [24.491] MFLua
288 begin p:=c; n:=info(h); lh:=link(h); {now |lh| points to $w_0$}
289 @y
290 begin
291 {mflua\_offsetprep(c,h);}
292 p:=c; n:=info(h); lh:=link(h); {now |lh| points to $w_0$}
293 @z
294
295 @x [24.506] MFLua
296 offset_prep(p,h); {this may clobber node~|q|, if it becomes ``dead''}
297 @y
298 mfluaPRE_offset_prep(p,h);
299 offset_prep(p,h); {this may clobber node~|q|, if it becomes ``dead''}
300 mfluaPOST_offset_prep(p,h);
301 @z
302
303 @x [24.519] MFLua
304 unskew(x1,y1,octant);@/
305 @y
306 unskew(x1,y1,octant);@/
307 mflua_print_retrograde_line(x0,y0,cur_x,cur_y);
308 @z
309
310 @x [24.515] MFLua
311 begin xx:=x_coord(r)+x_coord(w); yy:=y_coord(r)+y_coord(w)+half_unit;
312 @y
313 begin xx:=x_coord(r)+x_coord(w); yy:=y_coord(r)+y_coord(w)+half_unit;
314 mflua_print_transition_line_from(xx,yy-half_unit);
315 @z
316
317 @x [24.515] MFLua
318 else begin decr(k); w:=knil(w);
319 xp:=x_coord(r)+x_coord(w); yp:=y_coord(r)+y_coord(w)+half_unit;
320 end;
321 @y
322 else begin decr(k); w:=knil(w);
323 xp:=x_coord(r)+x_coord(w); yp:=y_coord(r)+y_coord(w)+half_unit;
324 end;
325 mflua_print_transition_line_to(xp,yp-half_unit);
326 @z
327
328 @x [24.521] MFLua
329 @<Insert a line segment dually to approach the correct offset@>=
330 begin xx:=x_coord(r)+x_coord(w); yy:=y_coord(r)+y_coord(w)+half_unit;
331 @y
332 @<Insert a line segment dually to approach the correct offset@>=
333 begin xx:=x_coord(r)+x_coord(w); yy:=y_coord(r)+y_coord(w)+half_unit;
334 mflua_print_transition_line_from(xx,yy-half_unit);
335 @z
336
337 @x [24.521] MFLua
338 else begin incr(k); w:=link(w);
339 xp:=x_coord(r)+x_coord(w); yp:=y_coord(r)+y_coord(w)+half_unit;
340 end;
341 @y
342 else begin incr(k); w:=link(w);
343 xp:=x_coord(r)+x_coord(w); yp:=y_coord(r)+y_coord(w)+half_unit;
344 end;
345 mflua_print_transition_line_to(xp,yp-half_unit);
346 @z
347
348 @x [31.630] MFLua - runscript primitive
349 moved into the buffer by \&{scantokens}.
350 @y
351 moved into the buffer by \&{scantokens} or \&{runscript}.
352 @z
353
354 @x [31.637] MFLua - runscript primitive
355 else if name=2 then print_nl("<scantokens>")
356 @y
357 else if name=2 then print_nl("<scantokens> or <runscript>")
358 @z
359
360 @x [33.679] MFLua - runscript primitive
361 {text was inserted during error recovery or by \&{scantokens}}
362 @y
363 {text was inserted during error recovery or by \&{scantokens} or \&{runscript}}
364 @z
365
366 @x [35.706] MFLua - runscript primitive
367 |exit_test|, |relax|, |scan_tokens|, |expand_after|, and |defined_macro|.
368 @y
369 |exit_test|, |relax|, |scan_tokens|, |run_script|, |expand_after|, and |defined_macro|.
370 @z
371
372 @x [35.707] MFLua - runscript primitive
373 scan_tokens: @<Put a string into the input buffer@>;
374 @y
375 scan_tokens: @<Put a string into the input buffer@>;
376 run_script: @<Pass a string to the Lua interpreter and put the result string into the input buffer@>;
377 @z
378
379 @x [39.796] MFLua - runscript primitive
380 @!cur_exp:integer; {the value of the expression just found}
381 @y
382 @!cur_exp:integer; {the value of the expression just found}
383 @!lua_cur_exp:integer; {the value of the Lua expression returned by runscript}
384 @z
385
386 @x [41.866] MFLua
387 q:=make_ellipse(major_axis,minor_axis,theta);
388 if (tx<>0)or(ty<>0) then @<Shift the coordinates of path |q|@>;
389 @y
390 mfluaPRE_make_ellipse(major_axis,minor_axis,theta,tx,ty,0);
391 q:=make_ellipse(major_axis,minor_axis,theta);
392 if (tx<>0)or(ty<>0) then @<Shift the coordinates of path |q|@>;
393 mfluaPOST_make_ellipse(major_axis,minor_axis,theta,tx,ty,q);
394 @z
395
396 @x [41.891] MFLua
397 make_choices(p);
398 @y
399 mfluaPRE_make_choices(p);
400 make_choices(p);
401 mfluaPOST_make_choices(p);
402 @z
403
404 @x [44.1064] MFLua
405 cur_wt:=w; rhs:=make_spec(rhs,max_offset(cur_pen),internal[tracing_specs]);
406 @<Check the turning number@>;
407 if max_offset(cur_pen)=0 then fill_spec(rhs)
408 else fill_envelope(rhs);
409 if lhs<>null then
410 begin rev_turns:=true;
411 lhs:=make_spec(lhs,max_offset(cur_pen),internal[tracing_specs]);
412 rev_turns:=false;
413 if max_offset(cur_pen)=0 then fill_spec(lhs)
414 else fill_envelope(lhs);
415 @y
416 cur_wt:=w; mfluaPRE_make_spec_rhs(rhs); rhs:=make_spec(rhs,max_offset(cur_pen),internal[tracing_specs]);mfluaPOST_make_spec_rhs(rhs);
417 @<Check the turning number@>;
418 if max_offset(cur_pen)=0 then begin mfluaPRE_fill_spec_rhs(rhs); fill_spec(rhs); mfluaPOST_fill_spec_rhs(rhs);end
419 else begin mfluaPRE_fill_envelope_rhs(rhs); fill_envelope(rhs); mfluaPOST_fill_envelope_rhs(rhs); end ;
420 if lhs<>null then
421 begin rev_turns:=true;
422 mfluaPRE_make_spec_lhs(lhs);
423 lhs:=make_spec(lhs,max_offset(cur_pen),internal[tracing_specs]);
424 mfluaPOST_make_spec_lhs(lhs);
425 rev_turns:=false;
426 if max_offset(cur_pen)=0 then begin mfluaPRE_fill_spec_lhs(lhs); fill_spec(lhs); mfluaPOST_fill_spec_lhs(lhs); end
427 else begin mfluaPRE_fill_envelope_lhs(lhs); fill_envelope(lhs); mfluaPOST_fill_envelope_lhs(lhs); end;
428 @z
429
430 @x [47.1165] MFLua
431 print_char("]"); update_terminal; {progress report}
432 @y
433 print_char("]"); update_terminal; {progress report}
434 mflua_printedges(" (just shipped out)",true,x_off,y_off);
435 @z
436
437 @x [49.1204] MFLua
438 @p begin @!{|start_here|}
439 @y
440 @p begin @!{|start_here|}
441 mflua_begin_program;
442 @z
443
444 @x [49.1204] MFLua
445 start_of_MF: @<Initialize the output routines@>;
446 @<Get the first line of input and prepare to start@>;
447 history:=spotless; {ready to go!}
448 if start_sym>0 then {insert the `\&{everyjob}' symbol}
449 begin cur_sym:=start_sym; back_input;
450 end;
451 main_control; {come to life}
452 final_cleanup; {prepare for death}
453 @y
454 mfluaPRE_start_of_MF;
455 start_of_MF: @<Initialize the output routines@>;
456 @<Get the first line of input and prepare to start@>;
457 history:=spotless; {ready to go!}
458 {This was the first sensor. Original comment: "remember to modify web2c/texmf.defines by adding mfuainitialize and then texmfmp.h and lib/texmfmp.c". Now obsolete}
459 mflua_initialize;
460 if start_sym>0 then {insert the `\&{everyjob}' symbol}
461 begin cur_sym:=start_sym; back_input;
462 end;
463 mfluaPRE_main_control;
464 main_control; {come to life}
465 mfluaPOST_main_control;
466 final_cleanup; {prepare for death}
467 mfluaPOST_final_cleanup;
468 @z
469
470 @x [49.1205] MFLua
471 end;
472 end;
473 @y
474 end;
475 mflua_end_program;
476 end;
477 @z
478
479 @x [51.1214] MFLua - additional sections to handle runscript
480 @* \[51] System-dependent changes.
481 @y
482 @ @<Pass a string to the Lua interpreter and put the result string into the input buffer@>=
483 begin get_x_next; scan_primary;
484 if cur_type<>string_type then
485 begin disp_err(null,"Not a string");
486 @.Not a string@>
487 help2("I'm going to flush this expression, since")@/
488 ("runscript should be followed by a known string.");
489 put_get_flush_error(0);
490 end
491 else begin back_input;
492 if length(cur_exp)>0 then @<As for scantokens, pretend we're reading a new one-line file@>;
493 end;
494 end
495
496 @ @<As for scantokens, pretend we're reading a new one-line file@>=
497 begin {begin\_file\_reading;} name:=2; {should be name:=3 but for the moment we keep 2}
498 k:=first+length(cur_exp);
499 j:=str_start[cur_exp]; limit:=k;
500 mflua_runscript(j,first,limit);
501 lua_cur_exp:=make_string;
502 if length(lua_cur_exp)> 0 then
503 begin
504 begin_file_reading;
505 add_str_ref(lua_cur_exp);
506 j:=str_start[lua_cur_exp]; k:=first+length(lua_cur_exp);limit:=k;
507 if k>=max_buf_stack then
508 begin if k>=buf_size then
509 begin max_buf_stack:=buf_size;
510 overflow("buffer size",buf_size);
511 @:METAFONT capacity exceeded buffer size}{\quad buffer size@>
512 end;
513 max_buf_stack:=k+1;
514 end;
515 while first<limit do
516 begin
517 {print(" loop");print\_ln;}
518 buffer[first]:=so(str_pool[j]); {print(so(str\_pool[j]));} incr(j); incr(first);
519 end;
520 buffer[limit]:="%"; first:=limit+1; loc:=start;
521 delete_str_ref(lua_cur_exp);
522 end;
523 delete_str_ref(lua_cur_exp);
524 {flush_string(lua_cur_exp);}
525 flush_cur_exp(0);
526 end
527 @* \[51] System-dependent changes.
528 @z