Classes | Macros | Typedefs | Functions | Variables
lparser.c File Reference
#include "lprefix.h"
#include <limits.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:

Go to the source code of this file.

Classes

struct  BlockCnt
 
struct  ConsControl
 
struct  LHS_assign
 

Macros

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

Typedefs

typedef struct BlockCnt BlockCnt
 
typedef struct ConsControl ConsControl
 

Functions

static Protoaddprototype (LexState *ls)
 
static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e)
 
static void adjustlocalvars (LexState *ls, int nvars)
 
static Upvaldescallocupvalue (FuncState *fs)
 
static void block (LexState *ls)
 
static int block_follow (LexState *ls, int withuntil)
 
static void body (LexState *ls, expdesc *e, int ismethod, int line)
 
static void breakstat (LexState *ls)
 
static void check (LexState *ls, int c)
 
static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v)
 
static void check_match (LexState *ls, int what, int who, int where)
 
static void check_readonly (LexState *ls, expdesc *e)
 
static void checklimit (FuncState *fs, int v, int l, const char *what)
 
static void checknext (LexState *ls, int c)
 
static void checkrepeated (LexState *ls, TString *name)
 
static void checktoclose (LexState *ls, int level)
 
static void close_func (LexState *ls)
 
static void closelistfield (FuncState *fs, ConsControl *cc)
 
static void codeclosure (LexState *ls, expdesc *v)
 
static void codename (LexState *ls, expdesc *e)
 
static void codestring (expdesc *e, TString *s)
 
static int cond (LexState *ls)
 
static void constructor (LexState *ls, expdesc *t)
 
static int createlabel (LexState *ls, TString *name, int line, int last)
 
static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isloop)
 
static l_noret error_expected (LexState *ls, int token)
 
static l_noret errorlimit (FuncState *fs, int limit, const char *what)
 
static void exp1 (LexState *ls)
 
static int explist (LexState *ls, expdesc *v)
 
static void expr (LexState *ls, expdesc *v)
 
static void exprstat (LexState *ls)
 
static void field (LexState *ls, ConsControl *cc)
 
static void fieldsel (LexState *ls, expdesc *v)
 
static Labeldescfindlabel (LexState *ls, TString *name)
 
static void fixforjump (FuncState *fs, int pc, int dest, int back)
 
static void forbody (LexState *ls, int base, int line, int nvars, int isgen)
 
static void forlist (LexState *ls, TString *indexname)
 
static void fornum (LexState *ls, TString *varname, int line)
 
static void forstat (LexState *ls, int line)
 
static void funcargs (LexState *ls, expdesc *f, int line)
 
static int funcname (LexState *ls, expdesc *v)
 
static void funcstat (LexState *ls, int line)
 
static BinOpr getbinopr (int op)
 
static int getlocalattribute (LexState *ls)
 
static Vardescgetlocalvardesc (FuncState *fs, int vidx)
 
static UnOpr getunopr (int op)
 
static void gotostat (LexState *ls)
 
static void ifstat (LexState *ls, int line)
 
static void init_exp (expdesc *e, expkind k, int i)
 
static void init_var (FuncState *fs, expdesc *e, int vidx)
 
static l_noret jumpscopeerror (LexState *ls, Labeldesc *gt)
 
static void labelstat (LexState *ls, TString *name, int line)
 
static void lastlistfield (FuncState *fs, ConsControl *cc)
 
static void leaveblock (FuncState *fs)
 
static void listfield (LexState *ls, ConsControl *cc)
 
static LocVarlocaldebuginfo (FuncState *fs, int vidx)
 
static void localfunc (LexState *ls)
 
static void localstat (LexState *ls)
 
int luaY_nvarstack (FuncState *fs)
 
LClosureluaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, Dyndata *dyd, const char *name, int firstchar)
 
static void mainfunc (LexState *ls, FuncState *fs)
 
static void markupval (FuncState *fs, int level)
 
static void movegotosout (FuncState *fs, BlockCnt *bl)
 
static int new_localvar (LexState *ls, TString *name)
 
static int newgotoentry (LexState *ls, TString *name, int line, int pc)
 
static int newlabelentry (LexState *ls, Labellist *l, TString *name, int line, int pc)
 
static int newupvalue (FuncState *fs, TString *name, expdesc *v)
 
static void open_func (LexState *ls, FuncState *fs, BlockCnt *bl)
 
static void parlist (LexState *ls)
 
static void primaryexp (LexState *ls, expdesc *v)
 
static void recfield (LexState *ls, ConsControl *cc)
 
static int registerlocalvar (LexState *ls, FuncState *fs, TString *varname)
 
static int reglevel (FuncState *fs, int nvar)
 
static void removevars (FuncState *fs, int tolevel)
 
static void repeatstat (LexState *ls, int line)
 
static void restassign (LexState *ls, struct LHS_assign *lh, int nvars)
 
static void retstat (LexState *ls)
 
static int searchupvalue (FuncState *fs, TString *name)
 
static int searchvar (FuncState *fs, TString *n, expdesc *var)
 
static void setvararg (FuncState *fs, int nparams)
 
static void simpleexp (LexState *ls, expdesc *v)
 
static void singlevar (LexState *ls, expdesc *var)
 
static void singlevaraux (FuncState *fs, TString *n, expdesc *var, int base)
 
static void solvegoto (LexState *ls, int g, Labeldesc *label)
 
static int solvegotos (LexState *ls, Labeldesc *lb)
 
static void statement (LexState *ls)
 
static void statlist (LexState *ls)
 
static TStringstr_checkname (LexState *ls)
 
static BinOpr subexpr (LexState *ls, expdesc *v, int limit)
 
static void suffixedexp (LexState *ls, expdesc *v)
 
static void test_then_block (LexState *ls, int *escapelist)
 
static int testnext (LexState *ls, int c)
 
static l_noret undefgoto (LexState *ls, Labeldesc *gt)
 
static void whilestat (LexState *ls, int line)
 
static void yindex (LexState *ls, expdesc *v)
 

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); }

Definition at line 122 of file lparser.c.

◆ enterlevel

#define enterlevel (   ls)    luaE_incCstack(ls->L)

Definition at line 492 of file lparser.c.

◆ eqstr

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

Definition at line 43 of file lparser.c.

◆ hasmultret

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

Definition at line 38 of file lparser.c.

◆ leavelevel

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

Definition at line 495 of file lparser.c.

◆ lparser_c

#define lparser_c

Definition at line 7 of file lparser.c.

◆ LUA_CORE

#define LUA_CORE

Definition at line 8 of file lparser.c.

◆ MAXVARS

#define MAXVARS   200

Definition at line 35 of file lparser.c.

◆ new_localvarliteral

#define new_localvarliteral (   ls,
 
)
Value:
luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char)) - 1));

Definition at line 208 of file lparser.c.

◆ UNARY_PRIORITY

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

Definition at line 1241 of file lparser.c.

Typedef Documentation

◆ BlockCnt

typedef struct BlockCnt BlockCnt

◆ ConsControl

typedef struct ConsControl ConsControl

Function Documentation

◆ addprototype()

static Proto* addprototype ( LexState ls)
static

Definition at line 686 of file lparser.c.

◆ adjust_assign()

static void adjust_assign ( LexState ls,
int  nvars,
int  nexps,
expdesc e 
)
static

Definition at line 470 of file lparser.c.

◆ adjustlocalvars()

static void adjustlocalvars ( LexState ls,
int  nvars 
)
static

Definition at line 311 of file lparser.c.

◆ allocupvalue()

static Upvaldesc* allocupvalue ( FuncState fs)
static

Definition at line 352 of file lparser.c.

◆ block()

static void block ( LexState ls)
static

Definition at line 1293 of file lparser.c.

◆ block_follow()

static int block_follow ( LexState ls,
int  withuntil 
)
static

Definition at line 776 of file lparser.c.

◆ body()

static void body ( LexState ls,
expdesc e,
int  ismethod,
int  line 
)
static

Definition at line 978 of file lparser.c.

◆ breakstat()

static void breakstat ( LexState ls)
static

Definition at line 1426 of file lparser.c.

◆ check()

static void check ( LexState ls,
int  c 
)
static

Definition at line 107 of file lparser.c.

◆ check_conflict()

static void check_conflict ( LexState ls,
struct LHS_assign lh,
expdesc v 
)
static

Definition at line 1319 of file lparser.c.

◆ check_match()

static void check_match ( LexState ls,
int  what,
int  who,
int  where 
)
static

Definition at line 130 of file lparser.c.

◆ check_readonly()

static void check_readonly ( LexState ls,
expdesc e 
)
static

Definition at line 277 of file lparser.c.

◆ checklimit()

static void checklimit ( FuncState fs,
int  v,
int  l,
const char *  what 
)
static

Definition at line 87 of file lparser.c.

◆ checknext()

static void checknext ( LexState ls,
int  c 
)
static

Definition at line 116 of file lparser.c.

◆ checkrepeated()

static void checkrepeated ( LexState ls,
TString name 
)
static

Definition at line 1436 of file lparser.c.

◆ checktoclose()

static void checktoclose ( LexState ls,
int  level 
)
static

Definition at line 1706 of file lparser.c.

◆ close_func()

static void close_func ( LexState ls)
static

Definition at line 744 of file lparser.c.

◆ closelistfield()

static void closelistfield ( FuncState fs,
ConsControl cc 
)
static

Definition at line 856 of file lparser.c.

◆ codeclosure()

static void codeclosure ( LexState ls,
expdesc v 
)
static

Definition at line 710 of file lparser.c.

◆ codename()

static void codename ( LexState ls,
expdesc e 
)
static

Definition at line 166 of file lparser.c.

◆ codestring()

static void codestring ( expdesc e,
TString s 
)
static

Definition at line 159 of file lparser.c.

◆ cond()

static int cond ( LexState ls)
static

Definition at line 1394 of file lparser.c.

◆ constructor()

static void constructor ( LexState ls,
expdesc t 
)
static

Definition at line 913 of file lparser.c.

◆ createlabel()

static int createlabel ( LexState ls,
TString name,
int  line,
int  last 
)
static

Definition at line 596 of file lparser.c.

◆ enterblock()

static void enterblock ( FuncState fs,
BlockCnt bl,
lu_byte  isloop 
)
static

Definition at line 630 of file lparser.c.

◆ error_expected()

static l_noret error_expected ( LexState ls,
int  token 
)
static

Definition at line 68 of file lparser.c.

◆ errorlimit()

static l_noret errorlimit ( FuncState fs,
int  limit,
const char *  what 
)
static

Definition at line 74 of file lparser.c.

◆ exp1()

static void exp1 ( LexState ls)
static

Definition at line 1505 of file lparser.c.

◆ explist()

static int explist ( LexState ls,
expdesc v 
)
static

Definition at line 1000 of file lparser.c.

◆ expr()

static void expr ( LexState ls,
expdesc v 
)
static

Definition at line 1278 of file lparser.c.

◆ exprstat()

static void exprstat ( LexState ls)
static

Definition at line 1784 of file lparser.c.

◆ field()

static void field ( LexState ls,
ConsControl cc 
)
static

Definition at line 891 of file lparser.c.

◆ fieldsel()

static void fieldsel ( LexState ls,
expdesc v 
)
static

Definition at line 799 of file lparser.c.

◆ findlabel()

static Labeldesc* findlabel ( LexState ls,
TString name 
)
static

Definition at line 532 of file lparser.c.

◆ fixforjump()

static void fixforjump ( FuncState fs,
int  pc,
int  dest,
int  back 
)
static

Definition at line 1518 of file lparser.c.

◆ forbody()

static void forbody ( LexState ls,
int  base,
int  line,
int  nvars,
int  isgen 
)
static

Definition at line 1532 of file lparser.c.

◆ forlist()

static void forlist ( LexState ls,
TString indexname 
)
static

Definition at line 1580 of file lparser.c.

◆ fornum()

static void fornum ( LexState ls,
TString varname,
int  line 
)
static

Definition at line 1557 of file lparser.c.

◆ forstat()

static void forstat ( LexState ls,
int  line 
)
static

Definition at line 1608 of file lparser.c.

◆ funcargs()

static void funcargs ( LexState ls,
expdesc f,
int  line 
)
static

Definition at line 1013 of file lparser.c.

◆ funcname()

static int funcname ( LexState ls,
expdesc v 
)
static

Definition at line 1758 of file lparser.c.

◆ funcstat()

static void funcstat ( LexState ls,
int  line 
)
static

Definition at line 1772 of file lparser.c.

◆ getbinopr()

static BinOpr getbinopr ( int  op)
static

Definition at line 1194 of file lparser.c.

◆ getlocalattribute()

static int getlocalattribute ( LexState ls)
static

Definition at line 1689 of file lparser.c.

◆ getlocalvardesc()

static Vardesc* getlocalvardesc ( FuncState fs,
int  vidx 
)
static

Definition at line 219 of file lparser.c.

◆ getunopr()

static UnOpr getunopr ( int  op)
static

Definition at line 1183 of file lparser.c.

◆ gotostat()

static void gotostat ( LexState ls)
static

Definition at line 1404 of file lparser.c.

◆ ifstat()

static void ifstat ( LexState ls,
int  line 
)
static

Definition at line 1663 of file lparser.c.

◆ init_exp()

static void init_exp ( expdesc e,
expkind  k,
int  i 
)
static

Definition at line 152 of file lparser.c.

◆ init_var()

static void init_var ( FuncState fs,
expdesc e,
int  vidx 
)
static

Definition at line 266 of file lparser.c.

◆ jumpscopeerror()

static l_noret jumpscopeerror ( LexState ls,
Labeldesc gt 
)
static

Definition at line 502 of file lparser.c.

◆ labelstat()

static void labelstat ( LexState ls,
TString name,
int  line 
)
static

Definition at line 1446 of file lparser.c.

◆ lastlistfield()

static void lastlistfield ( FuncState fs,
ConsControl cc 
)
static

Definition at line 868 of file lparser.c.

◆ leaveblock()

static void leaveblock ( FuncState fs)
static

Definition at line 660 of file lparser.c.

◆ listfield()

static void listfield ( LexState ls,
ConsControl cc 
)
static

Definition at line 884 of file lparser.c.

◆ localdebuginfo()

static LocVar* localdebuginfo ( FuncState fs,
int  vidx 
)
static

Definition at line 251 of file lparser.c.

◆ localfunc()

static void localfunc ( LexState ls)
static

Definition at line 1677 of file lparser.c.

◆ localstat()

static void localstat ( LexState ls)
static

Definition at line 1716 of file lparser.c.

◆ luaY_nvarstack()

int luaY_nvarstack ( FuncState fs)

Definition at line 243 of file lparser.c.

◆ luaY_parser()

LClosure* luaY_parser ( lua_State L,
ZIO z,
Mbuffer buff,
Dyndata dyd,
const char *  name,
int  firstchar 
)

Definition at line 1931 of file lparser.c.

◆ mainfunc()

static void mainfunc ( LexState ls,
FuncState fs 
)
static

Definition at line 1913 of file lparser.c.

◆ markupval()

static void markupval ( FuncState fs,
int  level 
)
static

Definition at line 410 of file lparser.c.

◆ movegotosout()

static void movegotosout ( FuncState fs,
BlockCnt bl 
)
static

Definition at line 616 of file lparser.c.

◆ new_localvar()

static int new_localvar ( LexState ls,
TString name 
)
static

Definition at line 193 of file lparser.c.

◆ newgotoentry()

static int newgotoentry ( LexState ls,
TString name,
int  line,
int  pc 
)
static

Definition at line 563 of file lparser.c.

◆ newlabelentry()

static int newlabelentry ( LexState ls,
Labellist l,
TString name,
int  line,
int  pc 
)
static

Definition at line 548 of file lparser.c.

◆ newupvalue()

static int newupvalue ( FuncState fs,
TString name,
expdesc v 
)
static

Definition at line 364 of file lparser.c.

◆ open_func()

static void open_func ( LexState ls,
FuncState fs,
BlockCnt bl 
)
static

Definition at line 717 of file lparser.c.

◆ parlist()

static void parlist ( LexState ls)
static

Definition at line 947 of file lparser.c.

◆ primaryexp()

static void primaryexp ( LexState ls,
expdesc v 
)
static

Definition at line 1068 of file lparser.c.

◆ recfield()

static void recfield ( LexState ls,
ConsControl cc 
)
static

Definition at line 835 of file lparser.c.

◆ registerlocalvar()

static int registerlocalvar ( LexState ls,
FuncState fs,
TString varname 
)
static

Definition at line 175 of file lparser.c.

◆ reglevel()

static int reglevel ( FuncState fs,
int  nvar 
)
static

Definition at line 229 of file lparser.c.

◆ removevars()

static void removevars ( FuncState fs,
int  tolevel 
)
static

Definition at line 328 of file lparser.c.

◆ repeatstat()

static void repeatstat ( LexState ls,
int  line 
)
static

Definition at line 1475 of file lparser.c.

◆ restassign()

static void restassign ( LexState ls,
struct LHS_assign lh,
int  nvars 
)
static

Definition at line 1363 of file lparser.c.

◆ retstat()

static void retstat ( LexState ls)
static

Definition at line 1802 of file lparser.c.

◆ searchupvalue()

static int searchupvalue ( FuncState fs,
TString name 
)
static

Definition at line 342 of file lparser.c.

◆ searchvar()

static int searchvar ( FuncState fs,
TString n,
expdesc var 
)
static

Definition at line 390 of file lparser.c.

◆ setvararg()

static void setvararg ( FuncState fs,
int  nparams 
)
static

Definition at line 941 of file lparser.c.

◆ simpleexp()

static void simpleexp ( LexState ls,
expdesc v 
)
static

Definition at line 1128 of file lparser.c.

◆ singlevar()

static void singlevar ( LexState ls,
expdesc var 
)
static

Definition at line 452 of file lparser.c.

◆ singlevaraux()

static void singlevaraux ( FuncState fs,
TString n,
expdesc var,
int  base 
)
static

Definition at line 424 of file lparser.c.

◆ solvegoto()

static void solvegoto ( LexState ls,
int  g,
Labeldesc label 
)
static

Definition at line 515 of file lparser.c.

◆ solvegotos()

static int solvegotos ( LexState ls,
Labeldesc lb 
)
static

Definition at line 573 of file lparser.c.

◆ statement()

static void statement ( LexState ls)
static

Definition at line 1834 of file lparser.c.

◆ statlist()

static void statlist ( LexState ls)
static

Definition at line 787 of file lparser.c.

◆ str_checkname()

static TString* str_checkname ( LexState ls)
static

Definition at line 143 of file lparser.c.

◆ subexpr()

static BinOpr subexpr ( LexState ls,
expdesc v,
int  limit 
)
static

Definition at line 1248 of file lparser.c.

◆ suffixedexp()

static void suffixedexp ( LexState ls,
expdesc v 
)
static

Definition at line 1090 of file lparser.c.

◆ test_then_block()

static void test_then_block ( LexState ls,
int *  escapelist 
)
static

Definition at line 1626 of file lparser.c.

◆ testnext()

static int testnext ( LexState ls,
int  c 
)
static

Definition at line 95 of file lparser.c.

◆ undefgoto()

static l_noret undefgoto ( LexState ls,
Labeldesc gt 
)
static

Definition at line 646 of file lparser.c.

◆ whilestat()

static void whilestat ( LexState ls,
int  line 
)
static

Definition at line 1456 of file lparser.c.

◆ yindex()

static void yindex ( LexState ls,
expdesc v 
)
static

Definition at line 810 of file lparser.c.

Variable Documentation

◆ left

lu_byte left

Definition at line 1226 of file lparser.c.

◆ 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

lu_byte right

Definition at line 1227 of file lparser.c.

luaX_newstring
TString * luaX_newstring(LexState *ls, const char *str, size_t l)
Definition: llex.c:134
new_localvar
static int new_localvar(LexState *ls, TString *name)
Definition: lparser.c:193


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Aug 11 2024 02:24:28