Interpreter document (lua.html)
lua - Lua interpreter
lua independent Lua interpreter. It loads and executes Lua program, the program can be a text source code form, or by the Lua compiler output luac precompiled binary form. lua can be used as a batch interpreter, also be used as an interactive interpreter.
Parameters can be options, assignments, file name, they are executed in sequence from left to right.
Underlined option - start, as described below.
An assignment is a = b as a form of argument that the string 'b' is assigned to the global variable a. Note that if it does not contain spaces or other special characters for the shell, it is not required quotation marks. This is for convenience only. (In general, you should pay attention to when using quotation marks and spaces on the command line, because they are usually processed by the shell.)
If the argument is neither an option nor the assignment, then it is considered to be a file name, and then be loaded and executed.
If no arguments are given, and the standard input is a terminal that it is the "-v -i". Otherwise, that is the -.
- As the standard input file is loaded, that is, not interactively, even if the standard input is a terminal.
Former -c Exit Closes Lua.
-e "stat" statement is executed stat. You need to enclose it in quotation marks if it contains spaces or quotation marks, then.
-f "file" all remaining arguments as a string collection to a global table called arg and execute the file. In arg parameter from zero, it contains the string 'file'. Index of the last parameter is stored in the "arg.n" in.
-i enters interactive mode, a prompt is displayed. In this mode, lua line that reads from standard input and execute them. Each line must contain a complete sentence. To make a sentence span multiple lines, each line can end a backslash '\ e'. See the prompt global variable _PROMPT, if this value is a string. So, to change the prompt, you can put _PROMPT set to a string of your choice. You can then call the interpreter to do this, for example, or write "_PROMPT = \ 'lua: \'" on the command line (Note that you need in quotes, because the string contains a space.). The default prompt is ">."
-q enter interactive mode, but does not display a prompt.
-sn set the stack size to n. If there is, it must be the first option. Note that n and -s in the same parameter. For example, to set a stack size of 2000, you can use -s2000.
-v Output version information.
Error messages should be self-describing.
R. Ierusalimschy, L. H. de Figueiredo, and W. Celes (email@example.com)
The client is a simple
It can be loaded from the command line executable files by file name, you can also enter load executable lines of text from the standard.
Note that if the latter case, each line must contain a complete statement.
For example, the function can not cross.
lua The readme Readme
This is lua, a simple lua interpreter.
It can be used as a batch interpreter or may be used interchangeably.
It has nroff help manual and ../../doc directory html file.
Here are some options that can be identified:
- As a standard input file execution
Former -c Exit Closes Lua
-e stat execution string `stat '
-f name executable file `name 'and the remaining arguments are placed in the table` arg'
-i enters interactive mode with the prompt
-q enter interactive mode without prompt
-sNUM set the stack size to NUM (must be the first option)
-v output version information
a = b set the global variable `a 'string of` b'
executable file name `name '
If the option is not given, it reads lines from the standard input and execute them. Therefore, each line must contain a complete sentence. To make a sentence span multiple lines can be added at the end of each line backslash '\'.
To change the prompt, you can put _PROMPT set to any value you want. You can then call the interpreter to do this, for example, or you can write lua _PROMPT on the command line = "lua:" -i
Note that in this case you need "-i".
You must pay attention when using quotation marks on the command line, because they are usually handled by the shell.
When the Lua as a separate language, the interpreter well.
If you need a minimum of interpreter, see ../../etc/min.c.
If your application requires a simple function to export a new Lua (which is a very common scenario), then you can use the interpreter (substantially without modification), as follows:
First, define a function
void myinit (lua_State * L)
In your own code. In this function, you should do any initialization of your application need to export your application to Lua.
Then, add a call lua.c, after the tag
"Add your libraries here"
After the position.
Of course, you can use any name replace "myinit".