lparser.c File Reference

Go to the source code of this file.

Classes

struct  BlockCnt
struct  ConsControl
struct  LHS_assign

Defines

#define lparser_c
#define LUA_CORE
#define hasmultret(k)   ((k) == VCALL || (k) == VVARARG)
#define getlocvar(fs, i)   ((fs)->f->locvars[(fs)->actvar[i]])
#define luaY_checklimit(fs, v, l, m)   if ((v)>(l)) errorlimit(fs,l,m)
#define check_condition(ls, c, msg)   { if (!(c)) luaX_syntaxerror(ls, msg); }
#define new_localvarliteral(ls, v, n)   new_localvar(ls, luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char))-1), n)
#define leavelevel(ls)   ((ls)->L->nCcalls--)
#define UNARY_PRIORITY   8

Functions

static void chunk (LexState *ls)
static void expr (LexState *ls, expdesc *v)
static void anchor_token (LexState *ls)
static void error_expected (LexState *ls, int token)
static void errorlimit (FuncState *fs, int limit, 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, int n)
static void adjustlocalvars (LexState *ls, int nvars)
static void removevars (LexState *ls, int tolevel)
static int indexupvalue (FuncState *fs, TString *name, expdesc *v)
static int searchvar (FuncState *fs, TString *n)
static void markupval (FuncState *fs, int level)
static int 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 enterblock (FuncState *fs, BlockCnt *bl, lu_byte isbreakable)
static void leaveblock (FuncState *fs)
static void pushclosure (LexState *ls, FuncState *func, expdesc *v)
static void open_func (LexState *ls, FuncState *fs)
static void close_func (LexState *ls)
ProtoluaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name)
static void field (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 constructor (LexState *ls, expdesc *t)
static void parlist (LexState *ls)
static void body (LexState *ls, expdesc *e, int needself, int line)
static int explist1 (LexState *ls, expdesc *v)
static void funcargs (LexState *ls, expdesc *f)
static void prefixexp (LexState *ls, expdesc *v)
static void primaryexp (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, unsigned int limit)
static int block_follow (int token)
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 breakstat (LexState *ls)
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 int test_then_block (LexState *ls)
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 int statement (LexState *ls)

Variables

struct {
   lu_byte   left
   lu_byte   right
priority []

Define Documentation

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

Definition at line 100 of file lparser.c.

Referenced by assignment(), and simpleexp().

#define getlocvar ( fs,
 )     ((fs)->f->locvars[(fs)->actvar[i]])

Definition at line 32 of file lparser.c.

Referenced by adjustlocalvars(), localfunc(), removevars(), and searchvar().

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

Definition at line 30 of file lparser.c.

Referenced by adjust_assign(), funcargs(), lastlistfield(), and retstat().

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

Definition at line 282 of file lparser.c.

Referenced by chunk(), and subexpr().

#define lparser_c

Definition at line 10 of file lparser.c.

#define LUA_CORE

Definition at line 11 of file lparser.c.

#define luaY_checklimit ( fs,
v,
l,
 )     if ((v)>(l)) errorlimit(fs,l,m)

Definition at line 34 of file lparser.c.

Referenced by assignment(), indexupvalue(), listfield(), new_localvar(), and recfield().

#define new_localvarliteral ( ls,
v,
 )     new_localvar(ls, luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char))-1), n)

Definition at line 156 of file lparser.c.

Referenced by body(), forlist(), fornum(), and parlist().

#define UNARY_PRIORITY   8

Definition at line 821 of file lparser.c.

Referenced by subexpr().


Function Documentation

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

Definition at line 167 of file lparser.c.

References cast_byte, LexState::fs, getlocvar, FuncState::nactvar, and FuncState::pc.

Referenced by body(), forbody(), localfunc(), localstat(), and parlist().

static void anchor_token ( LexState ls  )  [static]
static void assignment ( LexState ls,
struct LHS_assign lh,
int  nvars 
) [static]
static void block ( LexState ls  )  [static]
static int block_follow ( int  token  )  [static]

Definition at line 871 of file lparser.c.

References TK_ELSE, TK_ELSEIF, TK_END, TK_EOS, and TK_UNTIL.

Referenced by chunk(), and retstat().

static void body ( LexState ls,
expdesc e,
int  needself,
int  line 
) [static]
static void breakstat ( LexState ls  )  [static]
static void check ( LexState ls,
int  c 
) [static]

Definition at line 89 of file lparser.c.

References error_expected(), LexState::t, and Token::token.

static void check_conflict ( LexState ls,
struct LHS_assign lh,
expdesc v 
) [static]
static void check_match ( LexState ls,
int  what,
int  who,
int  where 
) [static]
static void checkname ( LexState ls,
expdesc e 
) [static]

Definition at line 138 of file lparser.c.

References codestring(), and str_checkname().

Referenced by field(), primaryexp(), and recfield().

static void checknext ( LexState ls,
int  c 
) [static]

Definition at line 94 of file lparser.c.

References check, and luaX_next().

Referenced by assignment(), body(), constructor(), forbody(), forlist(), fornum(), recfield(), test_then_block(), whilestat(), and yindex().

static void chunk ( LexState ls  )  [static]
static void close_func ( LexState ls  )  [static]
static void closelistfield ( FuncState fs,
struct ConsControl cc 
) [static]
static void codestring ( LexState ls,
expdesc e,
TString s 
) [static]

Definition at line 133 of file lparser.c.

References LexState::fs, init_exp(), luaK_stringK(), and VK.

Referenced by checkname(), funcargs(), and simpleexp().

static int cond ( LexState ls  )  [static]

Definition at line 965 of file lparser.c.

References expr(), expdesc::f, LexState::fs, expdesc::k, luaK_goiftrue(), LHS_assign::v, VFALSE, and VNIL.

Referenced by repeatstat(), test_then_block(), and whilestat().

static void constructor ( LexState ls,
expdesc t 
) [static]
static void enterblock ( FuncState fs,
BlockCnt bl,
lu_byte  isbreakable 
) [static]
static void enterlevel ( LexState ls  )  [static]

Definition at line 276 of file lparser.c.

References LexState::L, LUAI_MAXCCALLS, luaX_lexerror(), and lua_State::nCcalls.

Referenced by chunk(), and subexpr().

static void error_expected ( LexState ls,
int  token 
) [static]

Definition at line 65 of file lparser.c.

References LexState::L, LUA_QS, luaO_pushfstring(), luaX_syntaxerror(), and luaX_token2str().

Referenced by check(), and check_match().

static void errorlimit ( FuncState fs,
int  limit,
const char *  what 
) [static]
static int exp1 ( LexState ls  )  [static]

Definition at line 1036 of file lparser.c.

References expr(), LexState::fs, expdesc::k, and luaK_exp2nextreg().

Referenced by fornum().

static int explist1 ( LexState ls,
expdesc v 
) [static]

Definition at line 596 of file lparser.c.

References expr(), LexState::fs, luaK_exp2nextreg(), and testnext().

Referenced by assignment(), forlist(), funcargs(), localstat(), and retstat().

static void expr ( LexState ls,
expdesc v 
) [static]

Definition at line 856 of file lparser.c.

References subexpr().

Referenced by cond(), exp1(), explist1(), listfield(), prefixexp(), recfield(), and yindex().

static void exprstat ( LexState ls  )  [static]

Definition at line 1224 of file lparser.c.

References assignment(), LexState::fs, getcode, expdesc::k, LHS_assign::prev, primaryexp(), SETARG_C, LHS_assign::v, and VCALL.

Referenced by statement().

static void field ( LexState ls,
expdesc v 
) [static]

Definition at line 407 of file lparser.c.

References checkname(), LexState::fs, luaK_exp2anyreg(), luaK_indexed(), and luaX_next().

Referenced by funcname(), and primaryexp().

static void forbody ( LexState ls,
int  base,
int  line,
int  nvars,
int  isnum 
) [static]
static void forlist ( LexState ls,
TString indexname 
) [static]
static void fornum ( LexState ls,
TString varname,
int  line 
) [static]
static void forstat ( LexState ls,
int  line 
) [static]
static void funcargs ( LexState ls,
expdesc f 
) [static]
static int funcname ( LexState ls,
expdesc v 
) [static]

Definition at line 1198 of file lparser.c.

References field(), singlevar(), LexState::t, and Token::token.

Referenced by funcstat(), loader_C(), loader_Croot(), and mkfuncname().

static void funcstat ( LexState ls,
int  line 
) [static]

Definition at line 1212 of file lparser.c.

References body(), LexState::fs, funcname(), luaK_fixline(), luaK_storevar(), luaX_next(), and LHS_assign::v.

Referenced by statement().

static BinOpr getbinopr ( int  op  )  [static]
static UnOpr getunopr ( int  op  )  [static]

Definition at line 778 of file lparser.c.

References OPR_LEN, OPR_MINUS, OPR_NOT, OPR_NOUNOPR, and TK_NOT.

Referenced by subexpr().

static void ifstat ( LexState ls,
int  line 
) [static]
static int indexupvalue ( FuncState fs,
TString name,
expdesc v 
) [static]
static void init_exp ( expdesc e,
expkind  k,
int  i 
) [static]
static void lastlistfield ( FuncState fs,
struct ConsControl cc 
) [static]
static void leaveblock ( FuncState fs  )  [static]
static void listfield ( LexState ls,
struct ConsControl cc 
) [static]

Definition at line 490 of file lparser.c.

References expr(), LexState::fs, luaY_checklimit, MAX_INT, ConsControl::na, ConsControl::tostore, and ConsControl::v.

Referenced by constructor().

static void localfunc ( LexState ls  )  [static]
static void localstat ( LexState ls  )  [static]
Proto* luaY_parser ( lua_State L,
ZIO z,
Mbuffer buff,
const char *  name 
)
static void markupval ( FuncState fs,
int  level 
) [static]

Definition at line 217 of file lparser.c.

References FuncState::bl, BlockCnt::nactvar, BlockCnt::previous, and BlockCnt::upval.

Referenced by singlevaraux().

static void new_localvar ( LexState ls,
TString name,
int  n 
) [static]
static void open_func ( LexState ls,
FuncState fs 
) [static]
static void parlist ( LexState ls  )  [static]
static void prefixexp ( LexState ls,
expdesc v 
) [static]
static void primaryexp ( LexState ls,
expdesc v 
) [static]
static void pushclosure ( LexState ls,
FuncState func,
expdesc v 
) [static]
static void recfield ( LexState ls,
struct ConsControl cc 
) [static]
static int registerlocalvar ( LexState ls,
TString varname 
) [static]
static void removevars ( LexState ls,
int  tolevel 
) [static]

Definition at line 176 of file lparser.c.

References LexState::fs, getlocvar, FuncState::nactvar, and FuncState::pc.

Referenced by close_func(), and leaveblock().

static void repeatstat ( LexState ls,
int  line 
) [static]
static void retstat ( LexState ls  )  [static]
static int searchvar ( FuncState fs,
TString n 
) [static]

Definition at line 207 of file lparser.c.

References getlocvar, and FuncState::nactvar.

Referenced by singlevaraux().

static void simpleexp ( LexState ls,
expdesc v 
) [static]
static void singlevar ( LexState ls,
expdesc var 
) [static]

Definition at line 248 of file lparser.c.

References LexState::fs, luaK_stringK(), expdesc::s, singlevaraux(), str_checkname(), expdesc::u, and VGLOBAL.

Referenced by funcname(), and prefixexp().

static int singlevaraux ( FuncState fs,
TString n,
expdesc var,
int  base 
) [static]
static int statement ( LexState ls  )  [static]
static TString* str_checkname ( LexState ls  )  [static]
static BinOpr subexpr ( LexState ls,
expdesc v,
unsigned int  limit 
) [static]
static int test_then_block ( LexState ls  )  [static]

Definition at line 1130 of file lparser.c.

References block(), checknext(), cond(), luaX_next(), and TK_THEN.

Referenced by ifstat().

static int testnext ( LexState ls,
int  c 
) [static]
static void whilestat ( LexState ls,
int  line 
) [static]
static void yindex ( LexState ls,
expdesc v 
) [static]

Definition at line 418 of file lparser.c.

References checknext(), expr(), LexState::fs, luaK_exp2val(), and luaX_next().

Referenced by primaryexp(), and recfield().


Variable Documentation

struct { ... } priority[] [static]

Referenced by subexpr().


ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:50:00 2011 by Doxygen 1.6.1