luafaudes.cpp File Reference
#include "libfaudes.h"

Go to the source code of this file.

Macros

#define faudes_stdin_is_tty()   1
 
#define LUA_PROGNAME   "luafaudes"
 
#define LUA_INIT_VAR   "LUA_INIT"
 
#define LUA_INITVARVERSION   LUA_INIT_VAR
 
#define setsignal   signal
 
#define has_error   1 /* bad option */
 
#define has_i   2 /* -i */
 
#define has_v   4 /* -v */
 
#define has_e   8 /* -e */
 
#define has_E   16 /* -E */
 
#define has_x   32 /* //FAUDES: -x */
 
#define has_d   64 /* //FAUDES: -d */
 
#define LUA_PROMPT   "> "
 
#define LUA_PROMPT2   ">> "
 
#define LUA_MAXINPUT   512
 
#define lua_stdin_is_tty()   1 /* assume stdin is a tty */
 
#define lua_initreadline(L)   ((void)L)
 
#define lua_readline(L, b, p)
 
#define lua_saveline(L, line)   { (void)L; (void)line; }
 
#define lua_freeline(L, b)   { (void)L; (void)b; }
 
#define lua_exitreadline(L)   { (void)L; }
 
#define EOFMARK   "<eof>"
 
#define marklen   (sizeof(EOFMARK)/sizeof(char) - 1)
 

Functions

static void lstop (lua_State *L, lua_Debug *ar)
 
static void laction (int i)
 
static void print_usage (const char *badoption)
 
static void l_message (const char *pname, const char *msg)
 
static int report (lua_State *L, int status)
 
static int msghandler (lua_State *L)
 
static int docall (lua_State *L, int narg, int nres)
 
static void print_version (void)
 
static void createargtable (lua_State *L, char **argv, int argc, int script)
 
static int dochunk (lua_State *L, int status)
 
static int dofile (lua_State *L, const char *name)
 
static int dostring (lua_State *L, const char *s, const char *name)
 
static int dolibrary (lua_State *L, char *globname)
 
static int pushargs (lua_State *L)
 
static int handle_script (lua_State *L, char **argv)
 
static int collectargs (char **argv, int *first)
 
static int runargs (lua_State *L, char **argv, int n)
 
static int handle_luainit (lua_State *L)
 
static const char * get_prompt (lua_State *L, int firstline)
 
static int incomplete (lua_State *L, int status)
 
static int pushline (lua_State *L, int firstline)
 
static int addreturn (lua_State *L)
 
static int multiline (lua_State *L)
 
static int loadline (lua_State *L)
 
static void l_print (lua_State *L)
 
static void doREPL (lua_State *L)
 
static int pmain (lua_State *L)
 
int main (int argc, char **argv)
 

Variables

static lua_State * globalL = NULL
 
static const char * progname = LUA_PROGNAME
 

Detailed Description

Simple Lua stand-alone interpreter for lua/faudes

This lua interpreter is based on a plain copy of the original lua.c provided with the lua 5.4.8 distribution under an MIT license; see lua.h or http://www.lua.org

Changes to the original code are signed "//FAUDES". They include (a) loading of libFAUDES bindings; (b) libFAUDES specific additional options '-d' and '-x' (c) Mike Palls "Advanced-Readline patch" has been applied (and adapted) (d) be version agniostic to go with Lua 5.1.3 if need be

Thomas Moor, 2008, 2025.

Definition in file luafaudes.cpp.

Macro Definition Documentation

◆ EOFMARK

#define EOFMARK   "<eof>"

Definition at line 652 of file luafaudes.cpp.

◆ faudes_stdin_is_tty

#define faudes_stdin_is_tty ( )    1

Definition at line 35 of file luafaudes.cpp.

◆ has_d

#define has_d   64 /* //FAUDES: -d */

Definition at line 353 of file luafaudes.cpp.

◆ has_e

#define has_e   8 /* -e */

Definition at line 350 of file luafaudes.cpp.

◆ has_E

#define has_E   16 /* -E */

Definition at line 351 of file luafaudes.cpp.

◆ has_error

#define has_error   1 /* bad option */

Definition at line 347 of file luafaudes.cpp.

◆ has_i

#define has_i   2 /* -i */

Definition at line 348 of file luafaudes.cpp.

◆ has_v

#define has_v   4 /* -v */

Definition at line 349 of file luafaudes.cpp.

◆ has_x

#define has_x   32 /* //FAUDES: -x */

Definition at line 352 of file luafaudes.cpp.

◆ lua_exitreadline

#define lua_exitreadline (   L)    { (void)L; }

Definition at line 617 of file luafaudes.cpp.

◆ lua_freeline

#define lua_freeline (   L,
 
)    { (void)L; (void)b; }

Definition at line 616 of file luafaudes.cpp.

◆ LUA_INIT_VAR

#define LUA_INIT_VAR   "LUA_INIT"

Definition at line 53 of file luafaudes.cpp.

◆ lua_initreadline

#define lua_initreadline (   L)    ((void)L)

Definition at line 611 of file luafaudes.cpp.

◆ LUA_INITVARVERSION

#define LUA_INITVARVERSION   LUA_INIT_VAR

Definition at line 56 of file luafaudes.cpp.

◆ LUA_MAXINPUT

#define LUA_MAXINPUT   512

Definition at line 504 of file luafaudes.cpp.

◆ LUA_PROGNAME

#define LUA_PROGNAME   "luafaudes"

Definition at line 48 of file luafaudes.cpp.

◆ LUA_PROMPT

#define LUA_PROMPT   "> "

Definition at line 499 of file luafaudes.cpp.

◆ LUA_PROMPT2

#define LUA_PROMPT2   ">> "

Definition at line 500 of file luafaudes.cpp.

◆ lua_readline

#define lua_readline (   L,
  b,
 
)
Value:
((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \
fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */
#define LUA_MAXINPUT
Definition: luafaudes.cpp:504

Definition at line 612 of file luafaudes.cpp.

◆ lua_saveline

#define lua_saveline (   L,
  line 
)    { (void)L; (void)line; }

Definition at line 615 of file luafaudes.cpp.

◆ lua_stdin_is_tty

#define lua_stdin_is_tty ( )    1 /* assume stdin is a tty */

Definition at line 529 of file luafaudes.cpp.

◆ marklen

#define marklen   (sizeof(EOFMARK)/sizeof(char) - 1)

Definition at line 653 of file luafaudes.cpp.

◆ setsignal

#define setsignal   signal

Definition at line 79 of file luafaudes.cpp.

Function Documentation

◆ addreturn()

static int addreturn ( lua_State *  L)
static

Definition at line 700 of file luafaudes.cpp.

◆ collectargs()

static int collectargs ( char **  argv,
int *  first 
)
static

Definition at line 363 of file luafaudes.cpp.

◆ createargtable()

static void createargtable ( lua_State *  L,
char **  argv,
int  argc,
int  script 
)
static

Definition at line 245 of file luafaudes.cpp.

◆ docall()

static int docall ( lua_State *  L,
int  narg,
int  nres 
)
static

Definition at line 205 of file luafaudes.cpp.

◆ dochunk()

static int dochunk ( lua_State *  L,
int  status 
)
static

Definition at line 257 of file luafaudes.cpp.

◆ dofile()

static int dofile ( lua_State *  L,
const char *  name 
)
static

Definition at line 263 of file luafaudes.cpp.

◆ dolibrary()

static int dolibrary ( lua_State *  L,
char *  globname 
)
static

Definition at line 278 of file luafaudes.cpp.

◆ doREPL()

static void doREPL ( lua_State *  L)
static

Definition at line 774 of file luafaudes.cpp.

◆ dostring()

static int dostring ( lua_State *  L,
const char *  s,
const char *  name 
)
static

Definition at line 268 of file luafaudes.cpp.

◆ get_prompt()

static const char* get_prompt ( lua_State *  L,
int  firstline 
)
static

Definition at line 629 of file luafaudes.cpp.

◆ handle_luainit()

static int handle_luainit ( lua_State *  L)
static

Definition at line 477 of file luafaudes.cpp.

◆ handle_script()

static int handle_script ( lua_State *  L,
char **  argv 
)
static

Definition at line 332 of file luafaudes.cpp.

◆ incomplete()

static int incomplete ( lua_State *  L,
int  status 
)
static

Definition at line 661 of file luafaudes.cpp.

◆ l_message()

static void l_message ( const char *  pname,
const char *  msg 
)
static

Definition at line 159 of file luafaudes.cpp.

◆ l_print()

static void l_print ( lua_State *  L)
static

Definition at line 757 of file luafaudes.cpp.

◆ laction()

static void laction ( int  i)
static

Definition at line 100 of file luafaudes.cpp.

◆ loadline()

static int loadline ( lua_State *  L)
static

Definition at line 741 of file luafaudes.cpp.

◆ lstop()

static void lstop ( lua_State *  L,
lua_Debug *  ar 
)
static

Definition at line 87 of file luafaudes.cpp.

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 865 of file luafaudes.cpp.

◆ msghandler()

static int msghandler ( lua_State *  L)
static

Definition at line 184 of file luafaudes.cpp.

◆ multiline()

static int multiline ( lua_State *  L)
static

Definition at line 718 of file luafaudes.cpp.

◆ pmain()

static int pmain ( lua_State *  L)
static

Definition at line 799 of file luafaudes.cpp.

◆ print_usage()

static void print_usage ( const char *  badoption)
static

Definition at line 109 of file luafaudes.cpp.

◆ print_version()

static void print_version ( void  )
static

Definition at line 220 of file luafaudes.cpp.

◆ pushargs()

static int pushargs ( lua_State *  L)
static

Definition at line 305 of file luafaudes.cpp.

◆ pushline()

static int pushline ( lua_State *  L,
int  firstline 
)
static

Definition at line 675 of file luafaudes.cpp.

◆ report()

static int report ( lua_State *  L,
int  status 
)
static

Definition at line 169 of file luafaudes.cpp.

◆ runargs()

static int runargs ( lua_State *  L,
char **  argv,
int  n 
)
static

Definition at line 438 of file luafaudes.cpp.

Variable Documentation

◆ globalL

lua_State* globalL = NULL
static

Definition at line 59 of file luafaudes.cpp.

◆ progname

const char* progname = LUA_PROGNAME
static

Definition at line 61 of file luafaudes.cpp.

libFAUDES 2.33l --- 2025.09.16 --- c++ api documentaion by doxygen