diff options
author | Lua Team <team@lua.org> | 2003-04-11 12:00:00 +0000 |
---|---|---|
committer | repogen <> | 2003-04-11 12:00:00 +0000 |
commit | f0e4e22f5c119865eb5a8d3844a40df2d5980b3b (patch) | |
tree | c4df063a747e9c99f8aba1678588a030993780a9 /doc/lua.html | |
parent | 1981b7c90eb09e956e969cda5c473be4560af573 (diff) | |
download | lua-github-f0e4e22f5c119865eb5a8d3844a40df2d5980b3b.tar.gz |
Lua 5.05.0
Diffstat (limited to 'doc/lua.html')
-rw-r--r-- | doc/lua.html | 202 |
1 files changed, 113 insertions, 89 deletions
diff --git a/doc/lua.html b/doc/lua.html index ef861bb5..073d4b52 100644 --- a/doc/lua.html +++ b/doc/lua.html @@ -1,4 +1,4 @@ -<!-- lua.man,v 1.3 2000/09/04 21:41:28 lhf Exp --> +<!-- lua.man,v 1.8 2003/04/02 00:05:20 lhf Exp --> <HTML> <HEAD> <TITLE>LUA man page</TITLE> @@ -11,133 +11,157 @@ lua - Lua interpreter <H1>SYNOPSIS</H1> <B>lua</B> [ -<I>arguments</I> +<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, -as output by +in precompiled binary form. +(Precompiled binaries are output by <B>luac</B>, -the Lua compiler. +the Lua compiler.) <B>lua</B> can be used as a batch interpreter and also interactively. <P> -The -<I>arguments</I> -can be options, assignments, or filenames, -and are processed in order, -from left to right. +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. -<P> -An assignment is an argument of the form -<B>a=b</B>, -which assigns the string -.RB ` b ' -to the global variable -<B>a</B>. -Note that no quotes are needed around the string if it does not contain spaces -or other characters special to the shell. -This is for convenience only. -(In general, -you should be careful when using quotes and spaces on the command line -because they are usually handled by the shell.) -<P> -If the argument is neither an option nor an assignment, -then it is assumed to be a filename, -which is then loaded and executed. +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> +<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 the standard input as a file, +load and execute the standard input as a file, that is, not interactively, even when the standard input is a terminal. <P> -<B>-c</B> -close Lua before exiting. -<P> <B>-e "</B><I>stat"</I> execute statement <I>stat</I>. -You will need to quote +You need to quote <I>stat </I> -if it contains spaces or quotes. -<P> -<B>-f "</B><I>file"</I> -collect all remaining arguments as strings into a global table named -<B>arg</B> -and then execute -<I>file</I>. -The arguments in -<B>arg</B> -start at 0, -which contains the string -.RI ` file '. -The index of the last argument is stored in -<B>"arg.n"</B>. +if it contains spaces, quotes, +or other characters special to the shell. <P> <B>-i</B> -enter interactive mode, -displaying a prompt. -In this mode, -<B>lua</B> -reads lines from the standard input and executes them as they are read. -Each line must contain a complete statement. -To span a statement across several lines, end each line with a backslash -<B>`\e'</B>. -The prompt shown is the value of the global variable -<B>_PROMPT</B>, -if this value is a string. -So, -to change the prompt, -set -<B>_PROMPT</B> -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 prompt is ``> ''. -<P> -<B>-q</B> -enter interactive mode, -but without displaying a prompt. +enter interactive mode after +<I>script</I> +is executed. <P> -<B>-s</B><I>n</I> -set the stack size to -.IB n . -If present, -this must be the first option. -Note that -<I>n</I> -is in the same argument as -<B>-s</B>. -For example, -to specify a stack size of 2000, -use -<B>-s2000</B>. +<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> -print version information. +show version information. <H1>SEE ALSO</H1> <B>luac</B>(1) <BR> -<A HREF="http://www.tecgraf.puc-rio.br/lua/">http://www.tecgraf.puc-rio.br/lua/</A> +<A HREF="http://www.lua.org/">http://www.lua.org/</A> <H1>DIAGNOSTICS</H1> Error messages should be self explanatory. <H1>AUTHORS</H1> @@ -145,7 +169,7 @@ R. Ierusalimschy, L. H. de Figueiredo, and W. Celes -(<A HREF="mailto:lua@tecgraf.puc-rio.br">lua@tecgraf.puc-rio.br</A>) +(<A HREF="mailto:lua-NO-SPAM-THANKS@tecgraf.puc-rio.br">lua AT tecgraf.puc-rio.br</A>) <!-- EOF --> </BODY> </HTML> |