| 3 |
tristanc |
1 |
<!-- $Id: luac.man,v 1.28 2006/01/06 16:03:34 lhf Exp $ -->
|
|
|
2 |
<HTML>
|
|
|
3 |
<HEAD>
|
|
|
4 |
<TITLE>LUAC man page</TITLE>
|
|
|
5 |
<LINK REL="stylesheet" TYPE="text/css" HREF="lua.css">
|
|
|
6 |
</HEAD>
|
|
|
7 |
|
|
|
8 |
<BODY BGCOLOR="#FFFFFF">
|
|
|
9 |
|
|
|
10 |
<H2>NAME</H2>
|
|
|
11 |
luac - Lua compiler
|
|
|
12 |
<H2>SYNOPSIS</H2>
|
|
|
13 |
<B>luac</B>
|
|
|
14 |
[
|
|
|
15 |
<I>options</I>
|
|
|
16 |
] [
|
|
|
17 |
<I>filenames</I>
|
|
|
18 |
]
|
|
|
19 |
<H2>DESCRIPTION</H2>
|
|
|
20 |
<B>luac</B>
|
|
|
21 |
is the Lua compiler.
|
|
|
22 |
It translates programs written in the Lua programming language
|
|
|
23 |
into binary files that can be later loaded and executed.
|
|
|
24 |
<P>
|
|
|
25 |
The main advantages of precompiling chunks are:
|
|
|
26 |
faster loading,
|
|
|
27 |
protecting source code from accidental user changes,
|
|
|
28 |
and
|
|
|
29 |
off-line syntax checking.
|
|
|
30 |
<P>
|
|
|
31 |
Precompiling does not imply faster execution
|
|
|
32 |
because in Lua chunks are always compiled into bytecodes before being executed.
|
|
|
33 |
<B>luac</B>
|
|
|
34 |
simply allows those bytecodes to be saved in a file for later execution.
|
|
|
35 |
<P>
|
|
|
36 |
Precompiled chunks are not necessarily smaller than the corresponding source.
|
|
|
37 |
The main goal in precompiling is faster loading.
|
|
|
38 |
<P>
|
|
|
39 |
The binary files created by
|
|
|
40 |
<B>luac</B>
|
|
|
41 |
are portable only among architectures with the same word size and byte order.
|
|
|
42 |
<P>
|
|
|
43 |
<B>luac</B>
|
|
|
44 |
produces a single output file containing the bytecodes
|
|
|
45 |
for all source files given.
|
|
|
46 |
By default,
|
|
|
47 |
the output file is named
|
|
|
48 |
<B>luac.out</B>,
|
|
|
49 |
but you can change this with the
|
|
|
50 |
<B>-o</B>
|
|
|
51 |
option.
|
|
|
52 |
<P>
|
|
|
53 |
In the command line,
|
|
|
54 |
you can mix
|
|
|
55 |
text files containing Lua source and
|
|
|
56 |
binary files containing precompiled chunks.
|
|
|
57 |
This is useful because several precompiled chunks,
|
|
|
58 |
even from different (but compatible) platforms,
|
|
|
59 |
can be combined into a single precompiled chunk.
|
|
|
60 |
<P>
|
|
|
61 |
You can use
|
|
|
62 |
<B>'-'</B>
|
|
|
63 |
to indicate the standard input as a source file
|
|
|
64 |
and
|
|
|
65 |
<B>'--'</B>
|
|
|
66 |
to signal the end of options
|
|
|
67 |
(that is,
|
|
|
68 |
all remaining arguments will be treated as files even if they start with
|
|
|
69 |
<B>'-'</B>).
|
|
|
70 |
<P>
|
|
|
71 |
The internal format of the binary files produced by
|
|
|
72 |
<B>luac</B>
|
|
|
73 |
is likely to change when a new version of Lua is released.
|
|
|
74 |
So,
|
|
|
75 |
save the source files of all Lua programs that you precompile.
|
|
|
76 |
<P>
|
|
|
77 |
<H2>OPTIONS</H2>
|
|
|
78 |
Options must be separate.
|
|
|
79 |
<P>
|
|
|
80 |
<B>-l</B>
|
|
|
81 |
produce a listing of the compiled bytecode for Lua's virtual machine.
|
|
|
82 |
Listing bytecodes is useful to learn about Lua's virtual machine.
|
|
|
83 |
If no files are given, then
|
|
|
84 |
<B>luac</B>
|
|
|
85 |
loads
|
|
|
86 |
<B>luac.out</B>
|
|
|
87 |
and lists its contents.
|
|
|
88 |
<P>
|
|
|
89 |
<B>-o </B><I>file</I>
|
|
|
90 |
output to
|
|
|
91 |
<I>file</I>,
|
|
|
92 |
instead of the default
|
|
|
93 |
<B>luac.out</B>.
|
|
|
94 |
(You can use
|
|
|
95 |
<B>'-'</B>
|
|
|
96 |
for standard output,
|
|
|
97 |
but not on platforms that open standard output in text mode.)
|
|
|
98 |
The output file may be a source file because
|
|
|
99 |
all files are loaded before the output file is written.
|
|
|
100 |
Be careful not to overwrite precious files.
|
|
|
101 |
<P>
|
|
|
102 |
<B>-p</B>
|
|
|
103 |
load files but do not generate any output file.
|
|
|
104 |
Used mainly for syntax checking and for testing precompiled chunks:
|
|
|
105 |
corrupted files will probably generate errors when loaded.
|
|
|
106 |
Lua always performs a thorough integrity test on precompiled chunks.
|
|
|
107 |
Bytecode that passes this test is completely safe,
|
|
|
108 |
in the sense that it will not break the interpreter.
|
|
|
109 |
However,
|
|
|
110 |
there is no guarantee that such code does anything sensible.
|
|
|
111 |
(None can be given, because the halting problem is unsolvable.)
|
|
|
112 |
If no files are given, then
|
|
|
113 |
<B>luac</B>
|
|
|
114 |
loads
|
|
|
115 |
<B>luac.out</B>
|
|
|
116 |
and tests its contents.
|
|
|
117 |
No messages are displayed if the file passes the integrity test.
|
|
|
118 |
<P>
|
|
|
119 |
<B>-s</B>
|
|
|
120 |
strip debug information before writing the output file.
|
|
|
121 |
This saves some space in very large chunks,
|
|
|
122 |
but if errors occur when running a stripped chunk,
|
|
|
123 |
then the error messages may not contain the full information they usually do.
|
|
|
124 |
For instance,
|
|
|
125 |
line numbers and names of local variables are lost.
|
|
|
126 |
<P>
|
|
|
127 |
<B>-v</B>
|
|
|
128 |
show version information.
|
|
|
129 |
<H2>FILES</H2>
|
|
|
130 |
<P>
|
|
|
131 |
<B>luac.out</B>
|
|
|
132 |
default output file
|
|
|
133 |
<H2>SEE ALSO</H2>
|
|
|
134 |
<B>lua</B>(1)
|
|
|
135 |
<BR>
|
|
|
136 |
<A HREF="http://www.lua.org/">http://www.lua.org/</A>
|
|
|
137 |
<H2>DIAGNOSTICS</H2>
|
|
|
138 |
Error messages should be self explanatory.
|
|
|
139 |
<H2>AUTHORS</H2>
|
|
|
140 |
L. H. de Figueiredo,
|
|
|
141 |
R. Ierusalimschy and
|
|
|
142 |
W. Celes
|
|
|
143 |
<!-- EOF -->
|
|
|
144 |
</BODY>
|
|
|
145 |
</HTML>
|