Coder Social home page Coder Social logo

ada-lua's Introduction

ada-lua

An Ada binding for lua

Example

This Ada program shows how to execute a Lua script from Ada

--  The example show how to create a new lua state and launch a lua script

with Lua; use Lua;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Exceptions; use Ada.Exceptions;

function Main return Integer is
   S      : constant Lua_State := New_State;
   --  Here we create a new state using New_State function

   Status : Lua_Return_Code;

begin
   Open_Libs (S);
   --  Load the lua "standard" libraries

   Ada.Text_IO.Put_Line ("Load script");
   Load_File (S, "../example1.lua");
   --  Load a script. Note that loading a script does not execute it. This
   --  includes toplevel code.

   Ada.Text_IO.Put_Line ("Execute script");
   Status := Lua.PCall (S);

   if Status /= LUA_OK then
      --  An error occurs during the execution
      Put_Line (Status'Img);
      Put_Line (To_Ada (S, -1));
      return 1;
   end if;

   return 0;
exception
   when E : Lua_Error =>
      Put_Line (Exception_Message (E));
      return 1;
end Main;

ada-lua's People

Contributors

nikokrock avatar kbrei avatar patschkowski avatar fabien-chouteau avatar raph-amiard avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.