Skip to content

0.2 Getting started

Adam Lindberg edited this page Dec 17, 2022 · 13 revisions

Luerl works as a library embedded in a host simple called the embedding program. The host program can invoke functions to execute a piece of Lua code, can write and read Lua variables, and call Erlang functions by Lua code.

Through the use of Erlang, Luerl can be augmented to cope with a wide range of different domains, creating a customized language sharing a syntactical framework.

2.1 Installing Luerl

Luerl implement standard Lua 5.3 in pure Erlang to start using the project you need to include the luerl library as new dependency on your OTP application.

2.1.1 Rebar

With Rebar 3, you can either install luerl from hex.pm or from GitHub directly (for more info on Rebar dependencies, see the dependency documentation).

Add luerl as a dependency to your project rebar.config file using one of the two options below.

Hex

{deps, [luerl]}.

GitHub

{deps, [{luerl, {git, "git://github.com/rvirding/luerl.git", {branch, "develop"}}}]}.

2.1.2 Erlang.mk

Or use Erlang.mk to setup quickly your environment, build the code and project release.

Create a Makefile and include luerl to the project dependencies.

DEPS = luerl

2.1.3 Source code

$ git clone https://github.com/rvirding/luerl.git

2.2 Getting started

For a quick starting tutorial we're going to use Erlang.mk to setup quickly our environment, build our code and start or stop the project release.

Erlang.mk is very easy to setup: create a folder, put Erlang.mk in it, and write a Makefile:

include erlang.mk

For a step by step:

$ mkdir luerl_demo

$ cd luerl_demo

$ curl https://erlang.mk/erlang.mk -o erlang.mk

Create a Makefile and copy the next code snippet, there you can make the correct changes to reflect your project needs.

PROJECT = ophelia
DEPS = luerl
include erlang.mk

$ make

From that point you can create an src/ folder or start using http://erlang.mk/ templates - User guide.