# lua/lparser.c File Reference

`#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.

## Data Structures

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 TString * | str_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)
Proto * | luaY_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,
|  | i |  | ) | ((fs)->f->locvars[(fs)->actvar[i]])

Definition at line 32 of file lparser.c.

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

#define hasmultret | ( | k |  | ) | ((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,
|  | m |  | ) | 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,
|  | n |  | ) | 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]`

Definition at line 256 of file lparser.c.

References FuncState::freereg, LexState::fs, hasmultret, expdesc::k, luaK_exp2nextreg(), luaK_nil(), luaK_reserveregs(), luaK_setreturns(), and VVOID.

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

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]`

Definition at line 57 of file lparser.c.

References getstr, TString::len, luaX_newstring(), Token::seminfo, LexState::t, TK_NAME, TK_STRING, Token::token, SemInfo::ts, and TString::tsv.

Referenced by close_func().

static void assignment | ( | LexState * | ls,
|  | struct LHS_assign * | lh,
|  | int | nvars |
| ) |  |  | `[static]`

Definition at line 931 of file lparser.c.

References adjust_assign(), check_condition, check_conflict(), checknext(), explist1(), FuncState::freereg, LexState::fs, init_exp(), expdesc::k, LexState::L, luaK_setoneret(), luaK_storevar(), luaY_checklimit, lua_State::nCcalls, LHS_assign::prev, primaryexp(), testnext(), LHS_assign::v, VINDEXED, VLOCAL, and VNONRELOC.

Referenced by exprstat().

static void block | ( | LexState * | ls | ) | `[static]`

Definition at line 881 of file lparser.c.

References BlockCnt::breaklist, chunk(), enterblock(), LexState::fs, leaveblock(), lua_assert, and NO_JUMP.

Referenced by forbody(), ifstat(), rdSignature(), rpmReadHeader(), statement(), test_then_block(), and whilestat().

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]`

Definition at line 576 of file lparser.c.

References adjustlocalvars(), check_match(), checknext(), chunk(), close_func(), FuncState::f, Proto::lastlinedefined, Proto::linedefined, LexState::linenumber, new_localvarliteral, open_func(), parlist(), pushclosure(), TK_END, and TK_FUNCTION.

Referenced by addSource(), funcstat(), localfunc(), runScript(), setPathDefault(), and simpleexp().

static void breakstat | ( | LexState * | ls | ) | `[static]`

Definition at line 975 of file lparser.c.

References FuncState::bl, BlockCnt::breaklist, LexState::fs, BlockCnt::isbreakable, luaK_codeABC(), luaK_concat(), luaK_jump(), luaX_syntaxerror(), BlockCnt::nactvar, OP_CLOSE, BlockCnt::previous, and BlockCnt::upval.

Referenced by repeatstat(), and statement().

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]`

Definition at line 908 of file lparser.c.

References FuncState::freereg, LexState::fs, expdesc::k, luaK_codeABC(), luaK_reserveregs(), OP_MOVE, LHS_assign::prev, expdesc::s, expdesc::u, LHS_assign::v, and VINDEXED.

Referenced by assignment().

static void check_match | ( | LexState * | ls,
|  | int | what,
|  | int | who,
|  | int | where |
| ) |  |  | `[static]`

Definition at line 104 of file lparser.c.

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

Referenced by body(), constructor(), forstat(), funcargs(), ifstat(), prefixexp(), repeatstat(), statement(), and whilestat().

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]`

Definition at line 1325 of file lparser.c.

References block_follow(), enterlevel(), FuncState::f, FuncState::freereg, LexState::fs, leavelevel, lua_assert, Proto::maxstacksize, FuncState::nactvar, statement(), LexState::t, testnext(), and Token::token.

Referenced by block(), body(), luaY_parser(), and repeatstat().

static void close_func | ( | LexState * | ls | ) | `[static]`

Definition at line 356 of file lparser.c.

References anchor_token(), FuncState::bl, Proto::code, FuncState::f, LexState::fs, Proto::k, LexState::L, Proto::lineinfo, Proto::locvars, lua_assert, luaG_checkcode(), luaK_ret(), luaM_reallocvector, FuncState::nk, FuncState::nlocvars, FuncState::np, Proto::nups, Proto::p, FuncState::pc, FuncState::prev, removevars(), Proto::sizecode, Proto::sizek, Proto::sizelineinfo, Proto::sizelocvars, Proto::sizep, Proto::sizeupvalues, lua_State::top, and Proto::upvalues.

Referenced by body(), and luaY_parser().

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

Definition at line 464 of file lparser.c.

References expdesc::k, LFIELDS_PER_FLUSH, luaK_exp2nextreg(), luaK_setlist(), ConsControl::na, expdesc::s, ConsControl::t, ConsControl::tostore, expdesc::u, ConsControl::v, and VVOID.

Referenced by constructor().

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]`

Definition at line 498 of file lparser.c.

References check_match(), checknext(), closelistfield(), Proto::code, FuncState::f, LexState::fs, init_exp(), expdesc::k, lastlistfield(), LexState::linenumber, listfield(), LexState::lookahead, lua_assert, luaK_codeABC(), luaK_exp2nextreg(), luaO_int2fb(), luaX_lookahead(), ConsControl::na, ConsControl::nh, OP_NEWTABLE, recfield(), SETARG_B, SETARG_C, LexState::t, ConsControl::t, testnext(), TK_NAME, Token::token, ConsControl::tostore, ConsControl::v, VRELOCABLE, and VVOID.

Referenced by funcargs(), and simpleexp().

static void enterblock | ( | FuncState * | fs,
|  | BlockCnt * | bl,
|  | lu_byte | isbreakable |
| ) |  |  | `[static]`

Definition at line 285 of file lparser.c.

References FuncState::bl, BlockCnt::breaklist, FuncState::freereg, BlockCnt::isbreakable, lua_assert, FuncState::nactvar, BlockCnt::nactvar, NO_JUMP, BlockCnt::previous, and BlockCnt::upval.

Referenced by block(), forbody(), forstat(), repeatstat(), and whilestat().

static void enterlevel | ( | LexState * | ls | ) | `[static]`

Definition at line 276 of file lparser.c.

References LexState::L, 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, luaO_pushfstring(), luaX_syntaxerror(), and luaX_token2str().

Referenced by check(), and check_match().

static void errorlimit | ( | FuncState * | fs,
|  | int | limit,
|  | const char * | what |
| ) |  |  | `[static]`

Definition at line 71 of file lparser.c.

References FuncState::f, FuncState::L, Proto::linedefined, FuncState::ls, luaO_pushfstring(), and luaX_lexerror().

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 cpioHeaderWrite(), funcname(), handlePreambleTag(), and primaryexp().

static void forbody | ( | LexState * | ls,
|  | int | base,
|  | int | line,
|  | int | nvars,
|  | int | isnum |
| ) |  |  | `[static]`

Definition at line 1046 of file lparser.c.

References adjustlocalvars(), block(), checknext(), enterblock(), LexState::fs, leaveblock(), luaK_codeABC(), luaK_codeAsBx, luaK_fixline(), luaK_jump(), luaK_patchlist(), luaK_patchtohere(), luaK_reserveregs(), NO_JUMP, OP_FORLOOP, OP_FORPREP, OP_TFORLOOP, and TK_DO.

Referenced by forlist(), and fornum().

static void forlist | ( | LexState * | ls,
|  | TString * | indexname |
| ) |  |  | `[static]`

Definition at line 1089 of file lparser.c.

References adjust_assign(), checknext(), explist1(), forbody(), FuncState::freereg, LexState::fs, LexState::linenumber, luaK_checkstack(), new_localvar(), new_localvarliteral, str_checkname(), testnext(), and TK_IN.

Referenced by forstat().

static void fornum | ( | LexState * | ls,
|  | TString * | varname,
|  | int | line |
| ) |  |  | `[static]`

Definition at line 1067 of file lparser.c.

References checknext(), exp1(), forbody(), FuncState::freereg, LexState::fs, luaK_codeABx(), luaK_numberK(), luaK_reserveregs(), new_localvar(), new_localvarliteral, OP_LOADK, and testnext().

Referenced by forstat().

static void forstat | ( | LexState * | ls,
|  | int | line |
| ) |  |  | `[static]`

Definition at line 1112 of file lparser.c.

References check_match(), enterblock(), forlist(), fornum(), LexState::fs, leaveblock(), luaX_next(), luaX_syntaxerror(), str_checkname(), LexState::t, TK_END, TK_FOR, TK_IN, and Token::token.

Referenced by statement().

static void funcargs | ( | LexState * | ls,
|  | expdesc * | f |
| ) |  |  | `[static]`

Definition at line 609 of file lparser.c.

References check_match(), codestring(), constructor(), explist1(), FuncState::freereg, LexState::fs, hasmultret, init_exp(), expdesc::k, LexState::lastline, LexState::linenumber, lua_assert, luaK_codeABC(), luaK_exp2nextreg(), luaK_fixline(), luaK_setmultret, luaX_next(), luaX_syntaxerror(), OP_CALL, expdesc::s, Token::seminfo, LexState::t, TK_STRING, Token::token, SemInfo::ts, expdesc::u, VCALL, VNONRELOC, and VVOID.

Referenced by primaryexp().

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().

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]`

Definition at line 788 of file lparser.c.

References OPR_ADD, OPR_AND, OPR_CONCAT, OPR_DIV, OPR_EQ, OPR_GE, OPR_GT, OPR_LE, OPR_LT, OPR_MOD, OPR_MUL, OPR_NE, OPR_NOBINOPR, OPR_OR, OPR_POW, OPR_SUB, TK_AND, TK_CONCAT, TK_EQ, TK_GE, TK_LE, TK_NE, and TK_OR.

Referenced by subexpr().

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]`

Definition at line 1141 of file lparser.c.

References block(), check_match(), LexState::fs, luaK_concat(), luaK_jump(), luaK_patchtohere(), luaX_next(), NO_JUMP, LexState::t, test_then_block(), TK_ELSE, TK_ELSEIF, TK_END, TK_IF, and Token::token.

Referenced by statement().

static int indexupvalue | ( | FuncState * | fs,
|  | TString * | name,
|  | expdesc * | v |
| ) |  |  | `[static]`

Definition at line 183 of file lparser.c.

References cast_byte, FuncState::f, upvaldesc::info, expdesc::k, upvaldesc::k, FuncState::L, lua_assert, luaC_objbarrier, luaM_growvector, luaY_checklimit, MAX_INT, Proto::nups, expdesc::s, Proto::sizeupvalues, expdesc::u, Proto::upvalues, FuncState::upvalues, VLOCAL, and VUPVAL.

Referenced by singlevaraux().

static void init_exp | ( | expdesc * | e,
|  | expkind | k,
|  | int | i |
| ) |  |  | `[static]`

Definition at line 126 of file lparser.c.

References expdesc::f, expdesc::k, NO_JUMP, expdesc::s, expdesc::t, and expdesc::u.

Referenced by assignment(), codestring(), constructor(), funcargs(), localfunc(), pushclosure(), simpleexp(), and singlevaraux().

static void lastlistfield | ( | FuncState * | fs,
|  | struct ConsControl * | cc |
| ) |  |  | `[static]`

Definition at line 475 of file lparser.c.

References hasmultret, expdesc::k, luaK_exp2nextreg(), luaK_setlist(), luaK_setmultret, ConsControl::na, expdesc::s, ConsControl::t, ConsControl::tostore, expdesc::u, ConsControl::v, and VVOID.

Referenced by constructor().

static void leaveblock | ( | FuncState * | fs | ) | `[static]`

Definition at line 296 of file lparser.c.

References FuncState::bl, BlockCnt::breaklist, FuncState::freereg, BlockCnt::isbreakable, FuncState::ls, lua_assert, luaK_codeABC(), luaK_patchtohere(), FuncState::nactvar, BlockCnt::nactvar, OP_CLOSE, BlockCnt::previous, removevars(), and BlockCnt::upval.

Referenced by block(), forbody(), forstat(), repeatstat(), and whilestat().

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]`

Definition at line 1165 of file lparser.c.

References adjustlocalvars(), body(), FuncState::freereg, LexState::fs, getlocvar, init_exp(), LexState::linenumber, luaK_reserveregs(), luaK_storevar(), FuncState::nactvar, new_localvar(), FuncState::pc, str_checkname(), LHS_assign::v, and VLOCAL.

Referenced by statement().

static void localstat | ( | LexState * | ls | ) | `[static]`

Definition at line 1179 of file lparser.c.

References adjust_assign(), adjustlocalvars(), explist1(), expdesc::k, new_localvar(), str_checkname(), testnext(), and VVOID.

Referenced by statement().

Proto* luaY_parser | ( | lua_State * | L,
|  | ZIO * | z,
|  | Mbuffer * | buff,
|  | const char * | name |
| ) |  |  |

Definition at line 383 of file lparser.c.

References LexState::buff, check, chunk(), close_func(), FuncState::f, LexState::fs, Proto::is_vararg, lua_assert, luaS_new, luaX_next(), luaX_setinput(), Proto::nups, open_func(), FuncState::prev, TK_EOS, and VARARG_ISVARARG.

Referenced by f_parser().

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]`

Definition at line 160 of file lparser.c.

References FuncState::actvar, cast, LexState::fs, luaY_checklimit, FuncState::nactvar, and registerlocalvar().

Referenced by forlist(), fornum(), localfunc(), localstat(), and parlist().

static void open_func | ( | LexState * | ls,
|  | FuncState * | fs |
| ) |  |  | `[static]`

Definition at line 328 of file lparser.c.

References FuncState::bl, FuncState::f, FuncState::freereg, LexState::fs, FuncState::h, incr_top, FuncState::jpc, FuncState::L, LexState::L, FuncState::lasttarget, FuncState::ls, luaF_newproto(), luaH_new(), Proto::maxstacksize, FuncState::nactvar, FuncState::nk, FuncState::nlocvars, NO_JUMP, FuncState::np, FuncState::pc, FuncState::prev, sethvalue2s, setptvalue2s, LexState::source, Proto::source, and lua_State::top.

Referenced by body(), and luaY_parser().

static void parlist | ( | LexState * | ls | ) | `[static]`

Definition at line 543 of file lparser.c.

References adjustlocalvars(), cast_byte, FuncState::f, LexState::fs, Proto::is_vararg, luaK_reserveregs(), luaX_next(), luaX_syntaxerror(), FuncState::nactvar, new_localvar(), new_localvarliteral, Proto::numparams, str_checkname(), LexState::t, testnext(), TK_DOTS, TK_NAME, Token::token, VARARG_HASARG, VARARG_ISVARARG, and VARARG_NEEDSARG.

Referenced by body().

static void prefixexp | ( | LexState * | ls,
|  | expdesc * | v |
| ) |  |  | `[static]`

Definition at line 667 of file lparser.c.

References check_match(), expr(), LexState::fs, LexState::linenumber, luaK_dischargevars(), luaX_next(), luaX_syntaxerror(), singlevar(), LexState::t, TK_NAME, and Token::token.

Referenced by primaryexp().

static void primaryexp | ( | LexState * | ls,
|  | expdesc * | v |
| ) |  |  | `[static]`

Definition at line 690 of file lparser.c.

References checkname(), field(), LexState::fs, funcargs(), luaK_exp2anyreg(), luaK_exp2nextreg(), luaK_indexed(), luaK_self(), luaX_next(), prefixexp(), LexState::t, TK_STRING, Token::token, and yindex().

Referenced by assignment(), exprstat(), and simpleexp().

static void pushclosure | ( | LexState * | ls,
|  | FuncState * | func,
|  | expdesc * | v |
| ) |  |  | `[static]`

Definition at line 310 of file lparser.c.

References FuncState::f, LexState::fs, upvaldesc::info, init_exp(), upvaldesc::k, LexState::L, luaC_objbarrier, luaK_codeABC(), luaK_codeABx(), luaM_growvector, MAXARG_Bx, FuncState::np, Proto::nups, OP_CLOSURE, OP_GETUPVAL, OP_MOVE, Proto::p, Proto::sizep, FuncState::upvalues, VLOCAL, and VRELOCABLE.

Referenced by body().

static void recfield | ( | LexState * | ls,
|  | struct ConsControl * | cc |
| ) |  |  | `[static]`

Definition at line 443 of file lparser.c.

References checkname(), checknext(), expr(), FuncState::freereg, LexState::fs, luaK_codeABC(), luaK_exp2RK(), luaY_checklimit, MAX_INT, ConsControl::nh, OP_SETTABLE, expdesc::s, ConsControl::t, LexState::t, TK_NAME, Token::token, expdesc::u, and yindex().

Referenced by constructor().

static int registerlocalvar | ( | LexState * | ls,
|  | TString * | varname |
| ) |  |  | `[static]`

Definition at line 143 of file lparser.c.

References FuncState::f, LexState::fs, LexState::L, Proto::locvars, luaC_objbarrier, luaM_growvector, FuncState::nlocvars, Proto::sizelocvars, and LocVar::varname.

Referenced by new_localvar().

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]`

Definition at line 1010 of file lparser.c.

References breakstat(), check_match(), chunk(), cond(), enterblock(), LexState::fs, leaveblock(), luaK_getlabel(), luaK_jump(), luaK_patchlist(), luaK_patchtohere(), luaX_next(), TK_REPEAT, TK_UNTIL, and BlockCnt::upval.

Referenced by statement().

static void retstat | ( | LexState * | ls | ) | `[static]`

Definition at line 1238 of file lparser.c.

References block_follow(), explist1(), FuncState::freereg, LexState::fs, GETARG_A, getcode, hasmultret, expdesc::k, lua_assert, luaK_exp2anyreg(), luaK_exp2nextreg(), luaK_ret(), luaK_setmultret, luaX_next(), FuncState::nactvar, OP_TAILCALL, SET_OPCODE, LexState::t, Token::token, and VCALL.

Referenced by statement().

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]`

Definition at line 727 of file lparser.c.

References body(), check_condition, codestring(), constructor(), FuncState::f, LexState::fs, init_exp(), Proto::is_vararg, LexState::linenumber, luaK_codeABC(), luaX_next(), expdesc::nval, OP_VARARG, primaryexp(), SemInfo::r, Token::seminfo, LexState::t, TK_DOTS, TK_FALSE, TK_FUNCTION, TK_NIL, TK_NUMBER, TK_STRING, TK_TRUE, Token::token, SemInfo::ts, expdesc::u, VARARG_NEEDSARG, VFALSE, VKNUM, VNIL, VTRUE, and VVARARG.

Referenced by subexpr().

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]`

Definition at line 224 of file lparser.c.

References indexupvalue(), init_exp(), expdesc::k, markupval(), NO_REG, FuncState::prev, expdesc::s, searchvar(), expdesc::u, VGLOBAL, VLOCAL, and VUPVAL.

Referenced by singlevar().

static int statement | ( | LexState * | ls | ) | `[static]`

Definition at line 1271 of file lparser.c.

References block(), breakstat(), check_match(), exprstat(), forstat(), funcstat(), ifstat(), LexState::linenumber, localfunc(), localstat(), luaX_next(), repeatstat(), retstat(), LexState::t, testnext(), TK_BREAK, TK_DO, TK_END, TK_FOR, TK_FUNCTION, TK_IF, TK_LOCAL, TK_REPEAT, TK_RETURN, TK_WHILE, Token::token, and whilestat().

Referenced by chunk().

static TString* str_checkname | ( | LexState * | ls | ) | `[static]`

Definition at line 117 of file lparser.c.

References check, luaX_next(), Token::seminfo, LexState::t, TK_NAME, and SemInfo::ts.

Referenced by checkname(), forlist(), forstat(), localfunc(), localstat(), parlist(), and singlevar().

static BinOpr subexpr | ( | LexState * | ls,
|  | expdesc * | v,
|  | unsigned int | limit |
| ) |  |  | `[static]`

Definition at line 828 of file lparser.c.

References enterlevel(), LexState::fs, getbinopr(), getunopr(), leavelevel, left, luaK_infix(), luaK_posfix(), luaK_prefix(), luaX_next(), OPR_NOBINOPR, OPR_NOUNOPR, priority, right, simpleexp(), LexState::t, Token::token, and UNARY_PRIORITY.

Referenced by expr().

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]`

Definition at line 80 of file lparser.c.

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

Referenced by assignment(), check_match(), chunk(), constructor(), explist1(), forlist(), fornum(), localstat(), parlist(), and statement().

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

Definition at line 991 of file lparser.c.

References block(), check_match(), checknext(), cond(), enterblock(), LexState::fs, leaveblock(), luaK_getlabel(), luaK_jump(), luaK_patchlist(), luaK_patchtohere(), luaX_next(), TK_DO, TK_END, and TK_WHILE.

Referenced by statement().

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

lu_byte left

Definition at line 811 of file lparser.c.

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

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

Referenced by subexpr().

lu_byte right

Definition at line 812 of file lparser.c.

Referenced by subexpr().