diff options
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/contents.html | 123 | ||||
| -rw-r--r-- | doc/logo.gif | bin | 0 -> 4232 bytes | |||
| -rw-r--r-- | doc/lua.1 | 167 | ||||
| -rw-r--r-- | doc/lua.html | 175 | ||||
| -rw-r--r-- | doc/luac.1 | 136 | ||||
| -rw-r--r-- | doc/luac.html | 144 | ||||
| -rw-r--r-- | doc/readme.html | 31 |
7 files changed, 776 insertions, 0 deletions
diff --git a/doc/contents.html b/doc/contents.html new file mode 100644 index 00000000..06bd6fb4 --- /dev/null +++ b/doc/contents.html @@ -0,0 +1,123 @@ +<HTML> +<HEAD> +<TITLE>Lua: 5.0 reference manual - contents</TITLE> +</HEAD> + +<BODY BGCOLOR="#FFFFFF"> + +<HR> +<H1> +<A HREF="http://www.lua.org/home.html"><IMG SRC="logo.gif" ALT="Lua" BORDER=0></A> +Reference manual for Lua 5.0 +</H1> + +<A HREF="manual.html">Lua 5.0 Reference Manual</A> +[ +<A HREF="manual.html">top</A> +| +<A HREF="http://www.lua.org/ftp/refman-5.0.ps.gz">ps</A> +| +<A HREF="http://www.lua.org/ftp/refman-5.0.pdf">pdf</A> +] +<P> + +<SMALL> +<A HREF="http://www.lua.org/copyright.html">Copyright</A> +© 2003 Tecgraf, PUC-Rio. All rights reserved.</SMALL> +<HR> + +<UL> +<LI><A HREF="manual.html#1">1 - Introduction</A> +<LI><A HREF="manual.html#2">2 - The Language</A> +<UL> +<LI><A HREF="manual.html#2.1">2.1 - Lexical Conventions</A> +<LI><A HREF="manual.html#2.2">2.2 - Values and Types</A> +<UL> +<LI><A HREF="manual.html#2.2.1">2.2.1 - Coercion</A> +</UL> +<LI><A HREF="manual.html#2.3">2.3 - Variables</A> +<LI><A HREF="manual.html#2.4">2.4 - Statements</A> +<UL> +<LI><A HREF="manual.html#2.4.1">2.4.1 - Chunks</A> +<LI><A HREF="manual.html#2.4.2">2.4.2 - Blocks</A> +<LI><A HREF="manual.html#2.4.3">2.4.3 - Assignment</A> +<LI><A HREF="manual.html#2.4.4">2.4.4 - Control Structures</A> +<LI><A HREF="manual.html#2.4.5">2.4.5 - For Statement</A> +<LI><A HREF="manual.html#2.4.6">2.4.6 - Function Calls as Statements</A> +<LI><A HREF="manual.html#2.4.7">2.4.7 - Local Declarations</A> +</UL> +<LI><A HREF="manual.html#2.5">2.5 - Expressions</A> +<UL> +<LI><A HREF="manual.html#2.5.1">2.5.1 - Arithmetic Operators</A> +<LI><A HREF="manual.html#2.5.2">2.5.2 - Relational Operators</A> +<LI><A HREF="manual.html#2.5.3">2.5.3 - Logical Operators</A> +<LI><A HREF="manual.html#2.5.4">2.5.4 - Concatenation</A> +<LI><A HREF="manual.html#2.5.5">2.5.5 - Precedence</A> +<LI><A HREF="manual.html#2.5.6">2.5.6 - Table Constructors</A> +<LI><A HREF="manual.html#2.5.7">2.5.7 - Function Calls</A> +<LI><A HREF="manual.html#2.5.8">2.5.8 - Function Definitions</A> +</UL> +</UL> +<UL> +<LI><A HREF="manual.html#2.6">2.6 - Visibility Rules</A> +<LI><A HREF="manual.html#2.7">2.7 - Error Handling</A> +<LI><A HREF="manual.html#2.8">2.8 - Metatables</A> +<LI><A HREF="manual.html#2.9">2.9 - Garbage Collection</A> +<UL> +<LI><A HREF="manual.html#2.9.1">2.9.1 - Garbage-Collection Metamethods</A> +<LI><A HREF="manual.html#2.9.2">2.9.2 - Weak Tables</A> +</UL> +<LI><A HREF="manual.html#2.10">2.10 - Coroutines</A> +</UL> +<LI><A HREF="manual.html#3">3 - The Application Program Interface</A> +<UL> +<LI><A HREF="manual.html#3.1">3.1 - States</A> +<LI><A HREF="manual.html#3.2">3.2 - The Stack and Indices</A> +<LI><A HREF="manual.html#3.3">3.3 - Stack Manipulation</A> +<LI><A HREF="manual.html#3.4">3.4 - Querying the Stack</A> +<LI><A HREF="manual.html#3.5">3.5 - Getting Values from the Stack</A> +<LI><A HREF="manual.html#3.6">3.6 - Pushing Values onto the Stack</A> +<LI><A HREF="manual.html#3.7">3.7 - Controlling Garbage Collection</A> +<LI><A HREF="manual.html#3.8">3.8 - Userdata</A> +<LI><A HREF="manual.html#3.9">3.9 - Metatables</A> +<LI><A HREF="manual.html#3.10">3.10 - Loading Lua Chunks</A> +<LI><A HREF="manual.html#3.11">3.11 - Manipulating Tables</A> +<LI><A HREF="manual.html#3.12">3.12 - Manipulating Environments</A> +<LI><A HREF="manual.html#3.13">3.13 - Using Tables as Arrays</A> +<LI><A HREF="manual.html#3.14">3.14 - Calling Functions</A> +<LI><A HREF="manual.html#3.15">3.15 - Protected Calls</A> +<LI><A HREF="manual.html#3.16">3.16 - Defining C Functions</A> +<LI><A HREF="manual.html#3.17">3.17 - Defining C Closures</A> +<LI><A HREF="manual.html#3.18">3.18 - Registry</A> +<LI><A HREF="manual.html#3.19">3.19 - Error Handling in C</A> +<LI><A HREF="manual.html#3.20">3.20 - Threads</A> +</UL> +<LI><A HREF="manual.html#4">4 - The Debug Interface</A> +<UL> +<LI><A HREF="manual.html#4.1">4.1 - Stack and Function Information</A> +<LI><A HREF="manual.html#4.2">4.2 - Manipulating Local Variables and Upvalues</A> +<LI><A HREF="manual.html#4.3">4.3 - Hooks</A> +</UL> +<LI><A HREF="manual.html#5">5 - Standard Libraries</A> +<UL> +<LI><A HREF="manual.html#5.1">5.1 - Basic Functions</A> +<LI><A HREF="manual.html#5.2">5.2 - Coroutine Manipulation</A> +<LI><A HREF="manual.html#5.3">5.3 - String Manipulation</A> +<LI><A HREF="manual.html#5.4">5.4 - Table Manipulation</A> +<LI><A HREF="manual.html#5.5">5.5 - Mathematical Functions</A> +<LI><A HREF="manual.html#5.6">5.6 - Input and Output Facilities</A> +<LI><A HREF="manual.html#5.7">5.7 - Operating System Facilities</A> +<LI><A HREF="manual.html#5.8">5.8 - The Reflexive Debug Interface</A> +</UL> +<LI><A HREF="manual.html#6">6 - Lua Stand-alone</A> +<LI><A HREF="manual.html#BNF">The Complete Syntax of Lua</A> +</UL> + +<HR> +<SMALL> +Last update: +Wed May 7 18:34:34 EST 2003 +</SMALL> + +</BODY> +</HTML> diff --git a/doc/logo.gif b/doc/logo.gif Binary files differnew file mode 100644 index 00000000..2f5e4ac2 --- /dev/null +++ b/doc/logo.gif diff --git a/doc/lua.1 b/doc/lua.1 new file mode 100644 index 00000000..c9bba7d7 --- /dev/null +++ b/doc/lua.1 @@ -0,0 +1,167 @@ +.\" lua.man,v 1.8 2003/04/02 00:05:20 lhf Exp +.TH LUA 1 "2003/04/02 00:05:20" +.SH NAME +lua \- Lua interpreter +.SH SYNOPSIS +.B lua +[ +.I options +] +[ +.I script +[ +.I args +] +] +.SH DESCRIPTION +.B lua +is the stand-alone Lua interpreter. +It loads and executes Lua programs, +either in textual source form or +in precompiled binary form. +(Precompiled binaries are output by +.BR luac , +the Lua compiler.) +.B lua +can be used as a batch interpreter and also interactively. +.LP +The given +.I options +(see below) +are executed and then +the Lua program in file +.I script +is loaded and executed. +The given +.I args +are available to +.I script +as strings in a global table named +.BR arg . +If these arguments contain spaces or other characters special to the shell, +then they should be quoted +(but note that the quotes will be removed by the shell). +The arguments in +.B arg +start at 0, +which contains the string +.RI ` script '. +The index of the last argument is stored in +.BR "arg.n" . +The arguments given in the command line before +.IR script , +including the name of the interpreter, +are available in negative indices in +.BR arg . +.LP +At the very start, +before even handling the command line, +.B lua +executes the contents of the environment variable +.BR LUA_INIT , +if it is defined. +If the value of +.B LUA_INIT +is of the form +.RI `@ filename ', +then +.I filename +is executed. +Otherwise, the string is assumed to be a Lua statement and is executed. +.LP +Options start with +.B \- +and are described below. +You can use +.B "\--" +to signal the end of options. +.LP +If no arguments are given, +then +.B "\-v \-i" +is assumed when the standard input is a terminal; +otherwise, +.B "\-" +is assumed. +.LP +In interactive mode, +.B lua +prompts the user, +reads lines from the standard input, +and executes them as they are read. +If a line does not contain a complete statement, +then a secondary prompt is displayed and +lines are read until a complete statement is formed or +a syntax error is found. +So, one way to interrupt the reading of an incomplete statement is +to force a syntax error: +adding a +.B `;' +in the middle of a statement is a sure way of forcing a syntax error +(except inside multiline strings and comments; these must be closed explicitly). +If a line starts with +.BR `=' , +then +.B lua +displays the values of all the expressions in the remainder of the +line. The expressions must be separated by commas. +The primary prompt is the value of the global variable +.BR _PROMPT , +if this value is a string; +otherwise, the default prompt is used. +Similarly, the secondary prompt is the value of the global variable +.BR _PROMPT2 . +So, +to change the prompts, +set the corresponding variable to a string of your choice. +You can do that after calling the interpreter +or on the command line with +.BR "_PROMPT" "=\'lua: \'" , +for example. +(Note the need for quotes, because the string contains a space.) +The default prompts are ``> '' and ``>> ''. +.SH OPTIONS +.TP +.B \- +load and execute the standard input as a file, +that is, +not interactively, +even when the standard input is a terminal. +.TP +.BI \-e " stat" +execute statement +.IR stat . +You need to quote +.I stat +if it contains spaces, quotes, +or other characters special to the shell. +.TP +.B \-i +enter interactive mode after +.I script +is executed. +.TP +.BI \-l " file" +call +.BI require( file ) +before executing +.IR script. +Typically used to load libraries +(hence the letter +.IR l ). +.TP +.B \-v +show version information. +.SH "SEE ALSO" +.BR luac (1) +.br +http://www.lua.org/ +.SH DIAGNOSTICS +Error messages should be self explanatory. +.SH AUTHORS +R. Ierusalimschy, +L. H. de Figueiredo, +and +W. Celes +(lua@tecgraf.puc-rio.br) +.\" EOF diff --git a/doc/lua.html b/doc/lua.html new file mode 100644 index 00000000..073d4b52 --- /dev/null +++ b/doc/lua.html @@ -0,0 +1,175 @@ +<!-- lua.man,v 1.8 2003/04/02 00:05:20 lhf Exp --> +<HTML> +<HEAD> +<TITLE>LUA man page</TITLE> +</HEAD> + +<BODY BGCOLOR="#FFFFFF"> + +<H1>NAME</H1> +lua - Lua interpreter +<H1>SYNOPSIS</H1> +<B>lua</B> +[ +<I>options</I> +] +[ +<I>script</I> +[ +<I>args</I> +] +] +<H1>DESCRIPTION</H1> +<B>lua</B> +is the stand-alone Lua interpreter. +It loads and executes Lua programs, +either in textual source form or +in precompiled binary form. +(Precompiled binaries are output by +<B>luac</B>, +the Lua compiler.) +<B>lua</B> +can be used as a batch interpreter and also interactively. +<P> +The given +<I>options</I> +(see below) +are executed and then +the Lua program in file +<I>script</I> +is loaded and executed. +The given +<I>args</I> +are available to +<I>script</I> +as strings in a global table named +<B>arg</B>. +If these arguments contain spaces or other characters special to the shell, +then they should be quoted +(but note that the quotes will be removed by the shell). +The arguments in +<B>arg</B> +start at 0, +which contains the string +`<I>script</I>'. +The index of the last argument is stored in +<B>"arg.n"</B>. +The arguments given in the command line before +<I>script</I>, +including the name of the interpreter, +are available in negative indices in +<B>arg</B>. +<P> +At the very start, +before even handling the command line, +<B>lua</B> +executes the contents of the environment variable +<B>LUA_INIT</B>, +if it is defined. +If the value of +<B>LUA_INIT</B> +is of the form +`@<I>filename</I>', +then +<I>filename</I> +is executed. +Otherwise, the string is assumed to be a Lua statement and is executed. +<P> +Options start with +<B>-</B> +and are described below. +You can use +<B>"--"</B> +to signal the end of options. +<P> +If no arguments are given, +then +<B>"-v -i"</B> +is assumed when the standard input is a terminal; +otherwise, +<B>"-"</B> +is assumed. +<P> +In interactive mode, +<B>lua</B> +prompts the user, +reads lines from the standard input, +and executes them as they are read. +If a line does not contain a complete statement, +then a secondary prompt is displayed and +lines are read until a complete statement is formed or +a syntax error is found. +So, one way to interrupt the reading of an incomplete statement is +to force a syntax error: +adding a +<B>`;' </B> +in the middle of a statement is a sure way of forcing a syntax error +(except inside multiline strings and comments; these must be closed explicitly). +If a line starts with +<B>`='</B>, +then +<B>lua</B> +displays the values of all the expressions in the remainder of the +line. The expressions must be separated by commas. +The primary prompt is the value of the global variable +<B>_PROMPT</B>, +if this value is a string; +otherwise, the default prompt is used. +Similarly, the secondary prompt is the value of the global variable +<B>_PROMPT2</B>. +So, +to change the prompts, +set the corresponding variable to a string of your choice. +You can do that after calling the interpreter +or on the command line with +<B>"_PROMPT" "=\'lua: \'"</B>, +for example. +(Note the need for quotes, because the string contains a space.) +The default prompts are ``> '' and ``>> ''. +<H1>OPTIONS</H1> +<P> +<B>-</B> +load and execute the standard input as a file, +that is, +not interactively, +even when the standard input is a terminal. +<P> +<B>-e "</B><I>stat"</I> +execute statement +<I>stat</I>. +You need to quote +<I>stat </I> +if it contains spaces, quotes, +or other characters special to the shell. +<P> +<B>-i</B> +enter interactive mode after +<I>script</I> +is executed. +<P> +<B>-l "</B><I>file"</I> +call +<B>require( file</B><I>)</I> +before executing +<I></I>script. +Typically used to load libraries +(hence the letter +<I>l</I>). +<P> +<B>-v</B> +show version information. +<H1>SEE ALSO</H1> +<B>luac</B>(1) +<BR> +<A HREF="http://www.lua.org/">http://www.lua.org/</A> +<H1>DIAGNOSTICS</H1> +Error messages should be self explanatory. +<H1>AUTHORS</H1> +R. Ierusalimschy, +L. H. de Figueiredo, +and +W. Celes +(<A HREF="mailto:lua-NO-SPAM-THANKS@tecgraf.puc-rio.br">lua AT tecgraf.puc-rio.br</A>) +<!-- EOF --> +</BODY> +</HTML> diff --git a/doc/luac.1 b/doc/luac.1 new file mode 100644 index 00000000..c6523060 --- /dev/null +++ b/doc/luac.1 @@ -0,0 +1,136 @@ +.\" luac.man,v 1.25 2002/12/13 11:45:12 lhf Exp +.TH LUAC 1 "2002/12/13 11:45:12" +.SH NAME +luac \- Lua compiler +.SH SYNOPSIS +.B luac +[ +.I options +] [ +.I filenames +] +.SH DESCRIPTION +.B luac +is the Lua compiler. +It translates programs written in the Lua programming language +into binary files that can be latter loaded and executed. +.LP +The main advantages of precompiling chunks are: +faster loading, +protecting source code from user changes, +and +off-line syntax checking. +.LP +Pre-compiling does not imply faster execution +because in Lua chunks are always compiled into bytecodes before being executed. +.B luac +simply allows those bytecodes to be saved in a file for later execution. +.LP +.B luac +produces a single output file containing the bytecodes +for all source files given. +By default, +the output file is named +.BR luac.out , +but you can change this with the +.B \-o +option. +.LP +The binary files created by +.B luac +are portable to all architectures with the same word size. +This means that +binary files created on a 32-bit platform (such as Intel) +can be read without change in another 32-bit platform (such as Sparc), +even if the byte order (``endianness'') is different. +On the other hand, +binary files created on a 16-bit platform cannot be read in a 32-bit platform, +nor vice-versa. +.LP +In the command line, +you can mix +text files containing Lua source and +binary files containing precompiled chunks. +This is useful to combine several precompiled chunks, +even from different (but compatible) platforms, +into a single precompiled chunk. +.LP +You can use +.B "\-" +to indicate the standard input as a source file +and +.B "\--" +to signal the end of options +(that is, +all remaining arguments will be treated as files even if they start with +.BR "\-" ). +.LP +The internal format of the binary files produced by +.B luac +is likely to change when a new version of Lua is released. +So, +save the source files of all Lua programs that you precompile. +.LP +.SH OPTIONS +Options must be separate. +.TP +.B \-l +produce a listing of the compiled bytecode for Lua's virtual machine. +Listing bytecodes is useful to learn about Lua's virtual machine. +If no files are given, then +.B luac +loads +.B luac.out +and lists its contents. +.TP +.BI \-o " file" +output to +.IR file , +instead of the default +.BR luac.out . +The output file may be a source file because +all files are loaded before the output file is written. +Be careful not to overwrite precious files. +.TP +.B \-p +load files but do not generate any output file. +Used mainly for syntax checking and for testing precompiled chunks: +corrupted files will probably generate errors when loaded. +Lua always performs a thorough integrity test on precompiled chunks. +Bytecode that passes this test is completely safe, +in the sense that it will not break the interpreter. +However, +there is no guarantee that such code does anything sensible. +(None can be given, because the halting problem is unsolvable.) +If no files are given, then +.B luac +loads +.B luac.out +and tests its contents. +No messages are displayed if the file passes the integrity test. +.TP +.B \-s +strip debug information before writing the output file. +This saves some space in very large chunks, +but if errors occur when running these chunks, +then the error messages may not contain the full information they usually do +(line numbers and names of locals are lost). +.TP +.B \-v +show version information. +.SH FILES +.TP 15 +.B luac.out +default output file +.SH "SEE ALSO" +.BR lua (1) +.br +http://www.lua.org/ +.SH DIAGNOSTICS +Error messages should be self explanatory. +.SH AUTHORS +L. H. de Figueiredo, +R. Ierusalimschy and +W. Celes +(lua@tecgraf.puc-rio.br) +.\" EOF diff --git a/doc/luac.html b/doc/luac.html new file mode 100644 index 00000000..3a71622e --- /dev/null +++ b/doc/luac.html @@ -0,0 +1,144 @@ +<!-- luac.man,v 1.25 2002/12/13 11:45:12 lhf Exp --> +<HTML> +<HEAD> +<TITLE>LUAC man page</TITLE> +</HEAD> + +<BODY BGCOLOR="#FFFFFF"> + +<H1>NAME</H1> +luac - Lua compiler +<H1>SYNOPSIS</H1> +<B>luac</B> +[ +<I>options</I> +] [ +<I>filenames</I> +] +<H1>DESCRIPTION</H1> +<B>luac</B> +is the Lua compiler. +It translates programs written in the Lua programming language +into binary files that can be latter loaded and executed. +<P> +The main advantages of precompiling chunks are: +faster loading, +protecting source code from user changes, +and +off-line syntax checking. +<P> +Pre-compiling does not imply faster execution +because in Lua chunks are always compiled into bytecodes before being executed. +<B>luac</B> +simply allows those bytecodes to be saved in a file for later execution. +<P> +<B>luac</B> +produces a single output file containing the bytecodes +for all source files given. +By default, +the output file is named +<B>luac.out</B>, +but you can change this with the +<B>-o</B> +option. +<P> +The binary files created by +<B>luac</B> +are portable to all architectures with the same word size. +This means that +binary files created on a 32-bit platform (such as Intel) +can be read without change in another 32-bit platform (such as Sparc), +even if the byte order (``endianness'') is different. +On the other hand, +binary files created on a 16-bit platform cannot be read in a 32-bit platform, +nor vice-versa. +<P> +In the command line, +you can mix +text files containing Lua source and +binary files containing precompiled chunks. +This is useful to combine several precompiled chunks, +even from different (but compatible) platforms, +into a single precompiled chunk. +<P> +You can use +<B>"-"</B> +to indicate the standard input as a source file +and +<B>"--"</B> +to signal the end of options +(that is, +all remaining arguments will be treated as files even if they start with +<B>"-"</B>). +<P> +The internal format of the binary files produced by +<B>luac</B> +is likely to change when a new version of Lua is released. +So, +save the source files of all Lua programs that you precompile. +<P> +<H1>OPTIONS</H1> +Options must be separate. +<P> +<B>-l</B> +produce a listing of the compiled bytecode for Lua's virtual machine. +Listing bytecodes is useful to learn about Lua's virtual machine. +If no files are given, then +<B>luac</B> +loads +<B>luac.out</B> +and lists its contents. +<P> +<B>-o "</B><I>file"</I> +output to +<I>file</I>, +instead of the default +<B>luac.out</B>. +The output file may be a source file because +all files are loaded before the output file is written. +Be careful not to overwrite precious files. +<P> +<B>-p</B> +load files but do not generate any output file. +Used mainly for syntax checking and for testing precompiled chunks: +corrupted files will probably generate errors when loaded. +Lua always performs a thorough integrity test on precompiled chunks. +Bytecode that passes this test is completely safe, +in the sense that it will not break the interpreter. +However, +there is no guarantee that such code does anything sensible. +(None can be given, because the halting problem is unsolvable.) +If no files are given, then +<B>luac</B> +loads +<B>luac.out</B> +and tests its contents. +No messages are displayed if the file passes the integrity test. +<P> +<B>-s</B> +strip debug information before writing the output file. +This saves some space in very large chunks, +but if errors occur when running these chunks, +then the error messages may not contain the full information they usually do +(line numbers and names of locals are lost). +<P> +<B>-v</B> +show version information. +<H1>FILES</H1> +<P> +<B>luac.out</B> +default output file +<H1>SEE ALSO</H1> +<B>lua</B>(1) +<BR> +<A HREF="http://www.lua.org/">http://www.lua.org/</A> +<H1>DIAGNOSTICS</H1> +Error messages should be self explanatory. +<H1>AUTHORS</H1> +L. H. de Figueiredo, +R. Ierusalimschy and +W. Celes +(<A HREF="mailto:lua-NO-SPAM-THANKS@tecgraf.puc-rio.br">lua AT tecgraf.puc-rio.br</A>) +<!-- EOF --> +</BODY> +</HTML> diff --git a/doc/readme.html b/doc/readme.html new file mode 100644 index 00000000..2eab9202 --- /dev/null +++ b/doc/readme.html @@ -0,0 +1,31 @@ +<HTML> +<HEAD> +<TITLE>Lua documentation</TITLE> +</HEAD> + +<BODY BGCOLOR="#FFFFFF"> + +<HR> +<H1> +<A HREF="http://www.lua.org/"><IMG SRC="logo.gif" ALT="Lua" BORDER=0></A> +Documentation +</H1> + +<UL> +<LI><A HREF="http://www.lua.org/">Official web site</A> +<LI><A HREF="contents.html">Reference manual</A> +<LI><A HREF="lua.html">lua man page</A> +<LI><A HREF="luac.html">luac man page</A> +<LI><A HREF="../README">lua/README</A> +<LI><A HREF="../etc/README">lua/etc/README</A> +<LI><A HREF="../test/README">lua/test/README</A> +</UL> + +<HR> +<SMALL> +Last update: +Wed Dec 22 13:55:42 BRST 2004 +</SMALL> + +</BODY> +</HTML> |
