Imported from ../lua-5.0.2.tar.gz.
[lua.git] / doc / luac.1
blobc6523060f837d01aa114ee4f369fbc5c4d505b78
1 .\" luac.man,v 1.25 2002/12/13 11:45:12 lhf Exp
2 .TH LUAC 1 "2002/12/13 11:45:12"
3 .SH NAME
4 luac \- Lua compiler
5 .SH SYNOPSIS
6 .B luac
8 .I options
9 ] [
10 .I filenames
12 .SH DESCRIPTION
13 .B luac
14 is the Lua compiler.
15 It translates programs written in the Lua programming language
16 into binary files that can be latter loaded and executed.
17 .LP
18 The main advantages of precompiling chunks are:
19 faster loading,
20 protecting source code from user changes,
21 and
22 off-line syntax checking.
23 .LP
24 Pre-compiling does not imply faster execution
25 because in Lua chunks are always compiled into bytecodes before being executed.
26 .B luac
27 simply allows those bytecodes to be saved in a file for later execution.
28 .LP
29 .B luac
30 produces a single output file containing the bytecodes
31 for all source files given.
32 By default,
33 the output file is named
34 .BR luac.out ,
35 but you can change this with the
36 .B \-o
37 option.
38 .LP
39 The binary files created by
40 .B luac
41 are portable to all architectures with the same word size.
42 This means that
43 binary files created on a 32-bit platform (such as Intel)
44 can be read without change in another 32-bit platform (such as Sparc),
45 even if the byte order (``endianness'') is different.
46 On the other hand,
47 binary files created on a 16-bit platform cannot be read in a 32-bit platform,
48 nor vice-versa.
49 .LP
50 In the command line,
51 you can mix
52 text files containing Lua source and
53 binary files containing precompiled chunks.
54 This is useful to combine several precompiled chunks,
55 even from different (but compatible) platforms,
56 into a single precompiled chunk.
57 .LP
58 You can use
59 .B "\-"
60 to indicate the standard input as a source file
61 and
62 .B "\--"
63 to signal the end of options
64 (that is,
65 all remaining arguments will be treated as files even if they start with
66 .BR "\-" ).
67 .LP
68 The internal format of the binary files produced by
69 .B luac
70 is likely to change when a new version of Lua is released.
71 So,
72 save the source files of all Lua programs that you precompile.
73 .LP
74 .SH OPTIONS
75 Options must be separate.
76 .TP
77 .B \-l
78 produce a listing of the compiled bytecode for Lua's virtual machine.
79 Listing bytecodes is useful to learn about Lua's virtual machine.
80 If no files are given, then
81 .B luac
82 loads
83 .B luac.out
84 and lists its contents.
85 .TP
86 .BI \-o " file"
87 output to
88 .IR file ,
89 instead of the default
90 .BR luac.out .
91 The output file may be a source file because
92 all files are loaded before the output file is written.
93 Be careful not to overwrite precious files.
94 .TP
95 .B \-p
96 load files but do not generate any output file.
97 Used mainly for syntax checking and for testing precompiled chunks:
98 corrupted files will probably generate errors when loaded.
99 Lua always performs a thorough integrity test on precompiled chunks.
100 Bytecode that passes this test is completely safe,
101 in the sense that it will not break the interpreter.
102 However,
103 there is no guarantee that such code does anything sensible.
104 (None can be given, because the halting problem is unsolvable.)
105 If no files are given, then
106 .B luac
107 loads
108 .B luac.out
109 and tests its contents.
110 No messages are displayed if the file passes the integrity test.
112 .B \-s
113 strip debug information before writing the output file.
114 This saves some space in very large chunks,
115 but if errors occur when running these chunks,
116 then the error messages may not contain the full information they usually do
117 (line numbers and names of locals are lost).
119 .B \-v
120 show version information.
121 .SH FILES
122 .TP 15
123 .B luac.out
124 default output file
125 .SH "SEE ALSO"
126 .BR lua (1)
128 http://www.lua.org/
129 .SH DIAGNOSTICS
130 Error messages should be self explanatory.
131 .SH AUTHORS
132 L. H. de Figueiredo,
133 R. Ierusalimschy and
134 W. Celes
135 (lua@tecgraf.puc-rio.br)
136 .\" EOF