lua/lparser.c File Reference

#include <string.h>
#include "lua.h"
#include "lcode.h"
#include "ldebug.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"

Go to the source code of this file.

Data Structures

struct  BlockCnt
struct  ConsControl
struct  LHS_assign

Defines

#define lparser_c
#define getlocvar(fs, i)   ((fs)->f->locvars[(fs)->actvar[i]])
#define enterlevel(ls)
#define leavelevel(ls)   ((ls)->nestlevel--)
#define check_condition(ls, c, msg)   { if (!(c)) luaX_syntaxerror(ls, msg); }
#define UNARY_PRIORITY   8
#define MAXEXPWHILE   100
#define EXTRAEXP   5

Functions

static void chunk (LexState *ls)
static void expr (LexState *ls, expdesc *v)
static void next (LexState *ls)
static void lookahead (LexState *ls)
static void error_expected (LexState *ls, int token)
static int testnext (LexState *ls, int c)
static void check (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 luaI_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 void new_localvarstr (LexState *ls, const char *name, int n)
static void create_local (LexState *ls, const char *name)
static int indexupvalue (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 TStringsinglevar (LexState *ls, expdesc *var, int base)
static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e)
static void code_params (LexState *ls, int nparams, int dots)
static void enterblock (FuncState *fs, BlockCnt *bl, int 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)
static void luaY_field (LexState *ls, expdesc *v)
static void luaY_index (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, 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 void cond (LexState *ls, expdesc *v)
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, expdesc *v)
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 breakstat (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 108 of file lparser.c.

Referenced by assignment(), luaY_parser(), and str_checkname().

#define enterlevel ( ls   ) 

Value:

if (++(ls)->nestlevel > LUA_MAXPARSERLEVEL) \
                luaX_syntaxerror(ls, "too many syntax levels");

Definition at line 31 of file lparser.c.

Referenced by chunk(), and subexpr().

#define EXTRAEXP   5

Definition at line 1067 of file lparser.c.

Referenced by whilestat().

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

Definition at line 28 of file lparser.c.

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

#define leavelevel ( ls   )     ((ls)->nestlevel--)

Definition at line 33 of file lparser.c.

Referenced by chunk(), and subexpr().

#define lparser_c

Definition at line 10 of file lparser.c.

#define MAXEXPWHILE   100

Definition at line 1060 of file lparser.c.

Referenced by whilestat().

#define UNARY_PRIORITY   8

Definition at line 886 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 182 of file lparser.c.

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

Referenced by code_params(), create_local(), forbody(), localfunc(), and localstat().

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 940 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 100 of file lparser.c.

References error_expected(), and testnext().

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 154 of file lparser.c.

References codestring(), and str_checkname().

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

static void chunk ( LexState ls  )  [static]

static void close_func ( LexState ls  )  [static]

static void closelistfield ( FuncState fs,
struct ConsControl cc 
) [static]

static void code_params ( LexState ls,
int  nparams,
int  dots 
) [static]

static void codestring ( LexState ls,
expdesc e,
TString s 
) [static]

Definition at line 147 of file lparser.c.

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

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

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

static void constructor ( LexState ls,
expdesc t 
) [static]

static void create_local ( LexState ls,
const char *  name 
) [static]

Definition at line 209 of file lparser.c.

References adjustlocalvars(), and new_localvarstr().

Referenced by body(), and code_params().

static void enterblock ( FuncState fs,
BlockCnt bl,
int  isbreakable 
) [static]

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

Definition at line 81 of file lparser.c.

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

Referenced by check(), and check_match().

static int exp1 ( LexState ls  )  [static]

Definition at line 1131 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 641 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 923 of file lparser.c.

References subexpr().

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

static void exprstat ( LexState ls  )  [static]

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 1305 of file lparser.c.

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

Referenced by funcstat().

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

Definition at line 1321 of file lparser.c.

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

Referenced by statement().

static BinOpr getbinopr ( int  op  )  [static]

static UnOpr getunopr ( int  op  )  [static]

Definition at line 840 of file lparser.c.

References 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 545 of file lparser.c.

References expr(), luaX_checklimit(), MAXARG_Bx, ConsControl::na, ConsControl::tostore, and ConsControl::v.

Referenced by constructor().

static void localfunc ( LexState ls  )  [static]

static void localstat ( LexState ls  )  [static]

static void lookahead ( LexState ls  )  [static]

Definition at line 73 of file lparser.c.

References LexState::lookahead, lua_assert, luaX_lex(), Token::seminfo, TK_EOS, and Token::token.

Referenced by constructor().

static int luaI_registerlocalvar ( LexState ls,
TString varname 
) [static]

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

Definition at line 451 of file lparser.c.

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

Referenced by funcname(), and primaryexp().

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

Definition at line 464 of file lparser.c.

References check, expr(), LexState::fs, luaK_exp2val(), and next.

Referenced by primaryexp(), and recfield().

Proto* luaY_parser ( lua_State L,
ZIO z,
Mbuffer buff 
)

static void markupval ( FuncState fs,
int  level 
) [static]

Definition at line 250 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 new_localvarstr ( LexState ls,
const char *  name,
int  n 
) [static]

Definition at line 202 of file lparser.c.

References LexState::L, luaS_new, and new_localvar().

Referenced by create_local(), forlist(), and fornum().

static void next ( LexState ls  )  [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 void removevars ( LexState ls,
int  tolevel 
) [static]

Definition at line 193 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 238 of file lparser.c.

References getlocvar, and FuncState::nactvar.

Referenced by singlevaraux().

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

static TString* singlevar ( LexState ls,
expdesc var,
int  base 
) [static]

Definition at line 286 of file lparser.c.

References LexState::fs, singlevaraux(), and str_checkname().

Referenced by funcname(), and prefixexp().

static void 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,
int  limit 
) [static]

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

Definition at line 1231 of file lparser.c.

References block(), check, cond(), next, and TK_THEN.

Referenced by ifstat().

static int testnext ( LexState ls,
int  c 
) [static]

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


Variable Documentation

Definition at line 876 of file lparser.c.

Referenced by expandRegular(), fsmStage(), subexpr(), and writeFile().

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

Referenced by subexpr().

Definition at line 877 of file lparser.c.

Referenced by subexpr().


Generated on Fri Dec 12 13:02:11 2008 for rpm by  doxygen 1.5.6