Send
Close Add comments:
(status displays here)
Got it! This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
Lua and lua-lpeg
1. Lua and lua-lpeg
2. Lua
Lua is a powerful, efficient, lightweight, embeddable scripting language. It supports procedural programming, object-oriented programming, functional programming, data-driven programming, and data description. "Lua" (pronounced LOO-ah) means "Moon" in Portuguese. As such, it is neither an acronym nor an abbreviation, but a noun. From the Lua web site is at
https:///lua.org .
3. Wikipedia
4. CentOS installation
The following Linux command(s) install lua.
sudo yum -y installlua
The following Linux command(s) install lua-lpeg.
sudo yum -y install epel-release
sudo yum -y install lua-lpeg
Note: The first command allows the installation of sofware not in the main repository. If that command has been done before, a notice may be displayed.
5. Verify the version
The following Linux command(s) check the installed version of lua.
lua -v
On
2019-08-04 the output was as follows.
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
There are more recent Lua versions but this one will suffice for the present purposes.
6. Interactive mode
The following Linux command(s) enter interactive mode.
lua
Then type the following commands interactively, pressing
Enter after each command. Press
Ctrl-D to exit interactive mode.
require("lpeg")
If no error message is displayed,
lua-lpeg has been installed.
7. Hello world in Lua
The file type of a
Lua program file is
lua.
The following Linux command(s) create/edit a hello program in the your home directory using the nano text editor.
nano ~/hello.lua
Create the following program text in the editor that will output the text "Hello world"
print("Hello world")
To exit with save, remember to press
Ctrl-X, then "
y" (for yes) and
Enter to exit.
The following Linux command(s) run the program.
lua ~/hello.lua
The output should be as follows.
Hello world
8. End of page