xref: /redis-3.2.3/deps/lua/doc/luac.html (revision 21d3294c)
1*21d3294cSantirez<!-- $Id: luac.man,v 1.28 2006/01/06 16:03:34 lhf Exp $ -->
2*21d3294cSantirez<HTML>
3*21d3294cSantirez<HEAD>
4*21d3294cSantirez<TITLE>LUAC man page</TITLE>
5*21d3294cSantirez<LINK REL="stylesheet" TYPE="text/css" HREF="lua.css">
6*21d3294cSantirez</HEAD>
7*21d3294cSantirez
8*21d3294cSantirez<BODY BGCOLOR="#FFFFFF">
9*21d3294cSantirez
10*21d3294cSantirez<H2>NAME</H2>
11*21d3294cSantirezluac - Lua compiler
12*21d3294cSantirez<H2>SYNOPSIS</H2>
13*21d3294cSantirez<B>luac</B>
14*21d3294cSantirez[
15*21d3294cSantirez<I>options</I>
16*21d3294cSantirez] [
17*21d3294cSantirez<I>filenames</I>
18*21d3294cSantirez]
19*21d3294cSantirez<H2>DESCRIPTION</H2>
20*21d3294cSantirez<B>luac</B>
21*21d3294cSantirezis the Lua compiler.
22*21d3294cSantirezIt translates programs written in the Lua programming language
23*21d3294cSantirezinto binary files that can be later loaded and executed.
24*21d3294cSantirez<P>
25*21d3294cSantirezThe main advantages of precompiling chunks are:
26*21d3294cSantirezfaster loading,
27*21d3294cSantirezprotecting source code from accidental user changes,
28*21d3294cSantirezand
29*21d3294cSantirezoff-line syntax checking.
30*21d3294cSantirez<P>
31*21d3294cSantirezPrecompiling does not imply faster execution
32*21d3294cSantirezbecause in Lua chunks are always compiled into bytecodes before being executed.
33*21d3294cSantirez<B>luac</B>
34*21d3294cSantirezsimply allows those bytecodes to be saved in a file for later execution.
35*21d3294cSantirez<P>
36*21d3294cSantirezPrecompiled chunks are not necessarily smaller than the corresponding source.
37*21d3294cSantirezThe main goal in precompiling is faster loading.
38*21d3294cSantirez<P>
39*21d3294cSantirezThe binary files created by
40*21d3294cSantirez<B>luac</B>
41*21d3294cSantirezare portable only among architectures with the same word size and byte order.
42*21d3294cSantirez<P>
43*21d3294cSantirez<B>luac</B>
44*21d3294cSantirezproduces a single output file containing the bytecodes
45*21d3294cSantirezfor all source files given.
46*21d3294cSantirezBy default,
47*21d3294cSantirezthe output file is named
48*21d3294cSantirez<B>luac.out</B>,
49*21d3294cSantirezbut you can change this with the
50*21d3294cSantirez<B>-o</B>
51*21d3294cSantirezoption.
52*21d3294cSantirez<P>
53*21d3294cSantirezIn the command line,
54*21d3294cSantirezyou can mix
55*21d3294cSantireztext files containing Lua source and
56*21d3294cSantirezbinary files containing precompiled chunks.
57*21d3294cSantirezThis is useful because several precompiled chunks,
58*21d3294cSantirezeven from different (but compatible) platforms,
59*21d3294cSantirezcan be combined into a single precompiled chunk.
60*21d3294cSantirez<P>
61*21d3294cSantirezYou can use
62*21d3294cSantirez<B>'-'</B>
63*21d3294cSantirezto indicate the standard input as a source file
64*21d3294cSantirezand
65*21d3294cSantirez<B>'--'</B>
66*21d3294cSantirezto signal the end of options
67*21d3294cSantirez(that is,
68*21d3294cSantirezall remaining arguments will be treated as files even if they start with
69*21d3294cSantirez<B>'-'</B>).
70*21d3294cSantirez<P>
71*21d3294cSantirezThe internal format of the binary files produced by
72*21d3294cSantirez<B>luac</B>
73*21d3294cSantirezis likely to change when a new version of Lua is released.
74*21d3294cSantirezSo,
75*21d3294cSantirezsave the source files of all Lua programs that you precompile.
76*21d3294cSantirez<P>
77*21d3294cSantirez<H2>OPTIONS</H2>
78*21d3294cSantirezOptions must be separate.
79*21d3294cSantirez<P>
80*21d3294cSantirez<B>-l</B>
81*21d3294cSantirezproduce a listing of the compiled bytecode for Lua's virtual machine.
82*21d3294cSantirezListing bytecodes is useful to learn about Lua's virtual machine.
83*21d3294cSantirezIf no files are given, then
84*21d3294cSantirez<B>luac</B>
85*21d3294cSantirezloads
86*21d3294cSantirez<B>luac.out</B>
87*21d3294cSantirezand lists its contents.
88*21d3294cSantirez<P>
89*21d3294cSantirez<B>-o </B><I>file</I>
90*21d3294cSantirezoutput to
91*21d3294cSantirez<I>file</I>,
92*21d3294cSantirezinstead of the default
93*21d3294cSantirez<B>luac.out</B>.
94*21d3294cSantirez(You can use
95*21d3294cSantirez<B>'-'</B>
96*21d3294cSantirezfor standard output,
97*21d3294cSantirezbut not on platforms that open standard output in text mode.)
98*21d3294cSantirezThe output file may be a source file because
99*21d3294cSantirezall files are loaded before the output file is written.
100*21d3294cSantirezBe careful not to overwrite precious files.
101*21d3294cSantirez<P>
102*21d3294cSantirez<B>-p</B>
103*21d3294cSantirezload files but do not generate any output file.
104*21d3294cSantirezUsed mainly for syntax checking and for testing precompiled chunks:
105*21d3294cSantirezcorrupted files will probably generate errors when loaded.
106*21d3294cSantirezLua always performs a thorough integrity test on precompiled chunks.
107*21d3294cSantirezBytecode that passes this test is completely safe,
108*21d3294cSantirezin the sense that it will not break the interpreter.
109*21d3294cSantirezHowever,
110*21d3294cSantirezthere is no guarantee that such code does anything sensible.
111*21d3294cSantirez(None can be given, because the halting problem is unsolvable.)
112*21d3294cSantirezIf no files are given, then
113*21d3294cSantirez<B>luac</B>
114*21d3294cSantirezloads
115*21d3294cSantirez<B>luac.out</B>
116*21d3294cSantirezand tests its contents.
117*21d3294cSantirezNo messages are displayed if the file passes the integrity test.
118*21d3294cSantirez<P>
119*21d3294cSantirez<B>-s</B>
120*21d3294cSantirezstrip debug information before writing the output file.
121*21d3294cSantirezThis saves some space in very large chunks,
122*21d3294cSantirezbut if errors occur when running a stripped chunk,
123*21d3294cSantirezthen the error messages may not contain the full information they usually do.
124*21d3294cSantirezFor instance,
125*21d3294cSantirezline numbers and names of local variables are lost.
126*21d3294cSantirez<P>
127*21d3294cSantirez<B>-v</B>
128*21d3294cSantirezshow version information.
129*21d3294cSantirez<H2>FILES</H2>
130*21d3294cSantirez<P>
131*21d3294cSantirez<B>luac.out</B>
132*21d3294cSantirezdefault output file
133*21d3294cSantirez<H2>SEE ALSO</H2>
134*21d3294cSantirez<B>lua</B>(1)
135*21d3294cSantirez<BR>
136*21d3294cSantirez<A HREF="http://www.lua.org/">http://www.lua.org/</A>
137*21d3294cSantirez<H2>DIAGNOSTICS</H2>
138*21d3294cSantirezError messages should be self explanatory.
139*21d3294cSantirez<H2>AUTHORS</H2>
140*21d3294cSantirezL. H. de Figueiredo,
141*21d3294cSantirezR. Ierusalimschy and
142*21d3294cSantirezW. Celes
143*21d3294cSantirez<!-- EOF -->
144*21d3294cSantirez</BODY>
145*21d3294cSantirez</HTML>
146