RetroArch
Classes | Macros | Typedefs | Functions | Variables
lparser.c File Reference
#include "lprefix.h"
#include <string.h>
#include "lua.h"
#include "lcode.h"
#include "ldebug.h"
#include "ldo.h"
#include "lfunc.h"
#include "llex.h"
#include "lmem.h"
#include "lobject.h"
#include "lopcodes.h"
#include "lparser.h"
#include "lstate.h"
#include "lstring.h"
#include "ltable.h"
Include dependency graph for lparser.c:

Classes

struct  BlockCnt
 
struct  ConsControl
 
struct  LHS_assign
 

Macros

#define lparser_c
 
#define LUA_CORE
 
#define MAXVARS   200
 
#define hasmultret(k)   ((k) == VCALL || (k) == VVARARG)
 
#define eqstr(a, b)   ((a) == (b))
 
#define check_condition(ls, c, msg)   { if (!(c)) luaX_syntaxerror(ls, msg); }
 
#define new_localvarliteral(ls, v)   new_localvarliteral_(ls, "" v, (sizeof(v)/sizeof(char))-1)
 
#define leavelevel(ls)   ((ls)->L->nCcalls--)
 
#define UNARY_PRIORITY   12 /* priority for unary operators */
 

Typedefs

typedef struct BlockCnt BlockCnt
 

Functions

static void statement (LexState *ls)
 
static void expr (LexState *ls, expdesc *v)
 
static l_noret semerror (LexState *ls, const char *msg)
 
static l_noret error_expected (LexState *ls, int token)
 
static l_noret errorlimit (FuncState *fs, int limit, const char *what)
 
static void checklimit (FuncState *fs, int v, int l, const char *what)
 
static int testnext (LexState *ls, int c)
 
static void check (LexState *ls, int c)
 
static void checknext (LexState *ls, int c)
 
static void check_match (LexState *ls, int what, int who, int where)
 
static TStringstr_checkname (LexState *ls)
 
static void init_exp (expdesc *e, expkind k, int i)
 
static void codestring (LexState *ls, expdesc *e, TString *s)
 
static void checkname (LexState *ls, expdesc *e)
 
static int registerlocalvar (LexState *ls, TString *varname)
 
static void new_localvar (LexState *ls, TString *name)
 
static void new_localvarliteral_ (LexState *ls, const char *name, size_t sz)
 
static LocVargetlocvar (FuncState *fs, int i)
 
static void adjustlocalvars (LexState *ls, int nvars)
 
static void removevars (FuncState *fs, int tolevel)
 
static int searchupvalue (FuncState *fs, TString *name)
 
static int newupvalue (FuncState *fs, TString *name, expdesc *v)
 
static int searchvar (FuncState *fs, TString *n)
 
static void markupval (FuncState *fs, int level)
 
static void singlevaraux (FuncState *fs, TString *n, expdesc *var, int base)
 
static void singlevar (LexState *ls, expdesc *var)
 
static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e)
 
static void enterlevel (LexState *ls)
 
static void closegoto (LexState *ls, int g, Labeldesc *label)
 
static int findlabel (LexState *ls, int g)
 
static int newlabelentry (LexState *ls, Labellist *l, TString *name, int line, int pc)
 
static void findgotos (LexState *ls, Labeldesc *lb)
 
static void movegotosout (FuncState *fs, BlockCnt *bl)
 
static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isloop)
 
static void breaklabel (LexState *ls)
 
static l_noret undefgoto (LexState *ls, Labeldesc *gt)
 
static void leaveblock (FuncState *fs)
 
static Protoaddprototype (LexState *ls)
 
static void codeclosure (LexState *ls, expdesc *v)
 
static void open_func (LexState *ls, FuncState *fs, BlockCnt *bl)
 
static void close_func (LexState *ls)
 
static int block_follow (LexState *ls, int withuntil)
 
static void statlist (LexState *ls)
 
static void fieldsel (LexState *ls, expdesc *v)
 
static void yindex (LexState *ls, expdesc *v)
 
static void recfield (LexState *ls, struct ConsControl *cc)
 
static void closelistfield (FuncState *fs, struct ConsControl *cc)
 
static void lastlistfield (FuncState *fs, struct ConsControl *cc)
 
static void listfield (LexState *ls, struct ConsControl *cc)
 
static void field (LexState *ls, struct ConsControl *cc)
 
static void constructor (LexState *ls, expdesc *t)
 
static void parlist (LexState *ls)
 
static void body (LexState *ls, expdesc *e, int ismethod, int line)
 
static int explist (LexState *ls, expdesc *v)
 
static void funcargs (LexState *ls, expdesc *f, int line)
 
static void primaryexp (LexState *ls, expdesc *v)
 
static void suffixedexp (LexState *ls, expdesc *v)
 
static void simpleexp (LexState *ls, expdesc *v)
 
static UnOpr getunopr (int op)
 
static BinOpr getbinopr (int op)
 
static BinOpr subexpr (LexState *ls, expdesc *v, int limit)
 
static void block (LexState *ls)
 
static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v)
 
static void assignment (LexState *ls, struct LHS_assign *lh, int nvars)
 
static int cond (LexState *ls)
 
static void gotostat (LexState *ls, int pc)
 
static void checkrepeated (FuncState *fs, Labellist *ll, TString *label)
 
static void skipnoopstat (LexState *ls)
 
static void labelstat (LexState *ls, TString *label, int line)
 
static void whilestat (LexState *ls, int line)
 
static void repeatstat (LexState *ls, int line)
 
static int exp1 (LexState *ls)
 
static void forbody (LexState *ls, int base, int line, int nvars, int isnum)
 
static void fornum (LexState *ls, TString *varname, int line)
 
static void forlist (LexState *ls, TString *indexname)
 
static void forstat (LexState *ls, int line)
 
static void test_then_block (LexState *ls, int *escapelist)
 
static void ifstat (LexState *ls, int line)
 
static void localfunc (LexState *ls)
 
static void localstat (LexState *ls)
 
static int funcname (LexState *ls, expdesc *v)
 
static void funcstat (LexState *ls, int line)
 
static void exprstat (LexState *ls)
 
static void retstat (LexState *ls)
 
static void mainfunc (LexState *ls, FuncState *fs)
 
LClosureluaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, Dyndata *dyd, const char *name, int firstchar)
 

Variables

struct {
   lu_byte   left
 
   lu_byte   right
 
priority []
 

Macro Definition Documentation

◆ check_condition

#define check_condition (   ls,
  c,
  msg 
)    { if (!(c)) luaX_syntaxerror(ls, msg); }

◆ eqstr

#define eqstr (   a,
  b 
)    ((a) == (b))

◆ hasmultret

#define hasmultret (   k)    ((k) == VCALL || (k) == VVARARG)

◆ leavelevel

#define leavelevel (   ls)    ((ls)->L->nCcalls--)

◆ lparser_c

#define lparser_c

◆ LUA_CORE

#define LUA_CORE

◆ MAXVARS

#define MAXVARS   200

◆ new_localvarliteral

#define new_localvarliteral (   ls,
  v 
)    new_localvarliteral_(ls, "" v, (sizeof(v)/sizeof(char))-1)

◆ UNARY_PRIORITY

#define UNARY_PRIORITY   12 /* priority for unary operators */

Typedef Documentation

◆ BlockCnt

typedef struct BlockCnt BlockCnt

Function Documentation

◆ addprototype()

static Proto* addprototype ( LexState ls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ adjust_assign()

static void adjust_assign ( LexState ls,
int  nvars,
int  nexps,
expdesc e 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ adjustlocalvars()

static void adjustlocalvars ( LexState ls,
int  nvars 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ assignment()

static void assignment ( LexState ls,
struct LHS_assign lh,
int  nvars 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ block()

static void block ( LexState ls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ block_follow()

static int block_follow ( LexState ls,
int  withuntil 
)
static
Here is the caller graph for this function:

◆ body()

static void body ( LexState ls,
expdesc e,
int  ismethod,
int  line 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ breaklabel()

static void breaklabel ( LexState ls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check()

static void check ( LexState ls,
int  c 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_conflict()

static void check_conflict ( LexState ls,
struct LHS_assign lh,
expdesc v 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_match()

static void check_match ( LexState ls,
int  what,
int  who,
int  where 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ checklimit()

static void checklimit ( FuncState fs,
int  v,
int  l,
const char *  what 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkname()

static void checkname ( LexState ls,
expdesc e 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ checknext()

static void checknext ( LexState ls,
int  c 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkrepeated()

static void checkrepeated ( FuncState fs,
Labellist ll,
TString label 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ close_func()

static void close_func ( LexState ls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ closegoto()

static void closegoto ( LexState ls,
int  g,
Labeldesc label 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ closelistfield()

static void closelistfield ( FuncState fs,
struct ConsControl cc 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ codeclosure()

static void codeclosure ( LexState ls,
expdesc v 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ codestring()

static void codestring ( LexState ls,
expdesc e,
TString s 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cond()

static int cond ( LexState ls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ constructor()

static void constructor ( LexState ls,
expdesc t 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ enterblock()

static void enterblock ( FuncState fs,
BlockCnt bl,
lu_byte  isloop 
)
static
Here is the caller graph for this function:

◆ enterlevel()

static void enterlevel ( LexState ls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ error_expected()

static l_noret error_expected ( LexState ls,
int  token 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ errorlimit()

static l_noret errorlimit ( FuncState fs,
int  limit,
const char *  what 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ exp1()

static int exp1 ( LexState ls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ explist()

static int explist ( LexState ls,
expdesc v 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ expr()

static void expr ( LexState ls,
expdesc v 
)
static
Here is the call graph for this function:

◆ exprstat()

static void exprstat ( LexState ls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ field()

static void field ( LexState ls,
struct ConsControl cc 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fieldsel()

static void fieldsel ( LexState ls,
expdesc v 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findgotos()

static void findgotos ( LexState ls,
Labeldesc lb 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findlabel()

static int findlabel ( LexState ls,
int  g 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ forbody()

static void forbody ( LexState ls,
int  base,
int  line,
int  nvars,
int  isnum 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ forlist()

static void forlist ( LexState ls,
TString indexname 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fornum()

static void fornum ( LexState ls,
TString varname,
int  line 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ forstat()

static void forstat ( LexState ls,
int  line 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ funcargs()

static void funcargs ( LexState ls,
expdesc f,
int  line 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ funcname()

static int funcname ( LexState ls,
expdesc v 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ funcstat()

static void funcstat ( LexState ls,
int  line 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getbinopr()

static BinOpr getbinopr ( int  op)
static
Here is the caller graph for this function:

◆ getlocvar()

static LocVar* getlocvar ( FuncState fs,
int  i 
)
static
Here is the caller graph for this function:

◆ getunopr()

static UnOpr getunopr ( int  op)
static
Here is the caller graph for this function:

◆ gotostat()

static void gotostat ( LexState ls,
int  pc 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ifstat()

static void ifstat ( LexState ls,
int  line 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_exp()

static void init_exp ( expdesc e,
expkind  k,
int  i 
)
static
Here is the caller graph for this function:

◆ labelstat()

static void labelstat ( LexState ls,
TString label,
int  line 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lastlistfield()

static void lastlistfield ( FuncState fs,
struct ConsControl cc 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ leaveblock()

static void leaveblock ( FuncState fs)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ listfield()

static void listfield ( LexState ls,
struct ConsControl cc 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ localfunc()

static void localfunc ( LexState ls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ localstat()

static void localstat ( LexState ls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ luaY_parser()

LClosure* luaY_parser ( lua_State L,
ZIO z,
Mbuffer buff,
Dyndata dyd,
const char *  name,
int  firstchar 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mainfunc()

static void mainfunc ( LexState ls,
FuncState fs 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ markupval()

static void markupval ( FuncState fs,
int  level 
)
static
Here is the caller graph for this function:

◆ movegotosout()

static void movegotosout ( FuncState fs,
BlockCnt bl 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ new_localvar()

static void new_localvar ( LexState ls,
TString name 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ new_localvarliteral_()

static void new_localvarliteral_ ( LexState ls,
const char *  name,
size_t  sz 
)
static
Here is the call graph for this function:

◆ newlabelentry()

static int newlabelentry ( LexState ls,
Labellist l,
TString name,
int  line,
int  pc 
)
static
Here is the caller graph for this function:

◆ newupvalue()

static int newupvalue ( FuncState fs,
TString name,
expdesc v 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ open_func()

static void open_func ( LexState ls,
FuncState fs,
BlockCnt bl 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parlist()

static void parlist ( LexState ls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ primaryexp()

static void primaryexp ( LexState ls,
expdesc v 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ recfield()

static void recfield ( LexState ls,
struct ConsControl cc 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerlocalvar()

static int registerlocalvar ( LexState ls,
TString varname 
)
static
Here is the caller graph for this function:

◆ removevars()

static void removevars ( FuncState fs,
int  tolevel 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ repeatstat()

static void repeatstat ( LexState ls,
int  line 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ retstat()

static void retstat ( LexState ls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ searchupvalue()

static int searchupvalue ( FuncState fs,
TString name 
)
static
Here is the caller graph for this function:

◆ searchvar()

static int searchvar ( FuncState fs,
TString n 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ semerror()

static l_noret semerror ( LexState ls,
const char *  msg 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ simpleexp()

static void simpleexp ( LexState ls,
expdesc v 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ singlevar()

static void singlevar ( LexState ls,
expdesc var 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ singlevaraux()

static void singlevaraux ( FuncState fs,
TString n,
expdesc var,
int  base 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ skipnoopstat()

static void skipnoopstat ( LexState ls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ statement()

static void statement ( LexState ls)
static
Here is the call graph for this function:

◆ statlist()

static void statlist ( LexState ls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ str_checkname()

static TString* str_checkname ( LexState ls)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ subexpr()

static BinOpr subexpr ( LexState ls,
expdesc v,
int  limit 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ suffixedexp()

static void suffixedexp ( LexState ls,
expdesc v 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_then_block()

static void test_then_block ( LexState ls,
int *  escapelist 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ testnext()

static int testnext ( LexState ls,
int  c 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ undefgoto()

static l_noret undefgoto ( LexState ls,
Labeldesc gt 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ whilestat()

static void whilestat ( LexState ls,
int  line 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ yindex()

static void yindex ( LexState ls,
expdesc v 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ left

◆ priority

const { ... } priority[]
Initial value:
= {
{10, 10}, {10, 10},
{11, 11}, {11, 11},
{14, 13},
{11, 11}, {11, 11},
{6, 6}, {4, 4}, {5, 5},
{7, 7}, {7, 7},
{9, 8},
{3, 3}, {3, 3}, {3, 3},
{3, 3}, {3, 3}, {3, 3},
{2, 2}, {1, 1}
}

◆ right