2
0

lparser.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. ** $Id: lparser.h,v 1.25 2000/09/29 12:42:13 roberto Exp roberto $
  3. ** LL(1) Parser and code generator for Lua
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef lparser_h
  7. #define lparser_h
  8. #include "lobject.h"
  9. #include "lzio.h"
  10. /*
  11. ** Expression descriptor
  12. */
  13. typedef enum {
  14. VGLOBAL,
  15. VLOCAL,
  16. VINDEXED,
  17. VEXP
  18. } expkind;
  19. typedef struct expdesc {
  20. expkind k;
  21. union {
  22. int index; /* VGLOBAL: `kstr' index of global name; VLOCAL: stack index */
  23. struct {
  24. int t; /* patch list of `exit when true' */
  25. int f; /* patch list of `exit when false' */
  26. } l;
  27. } u;
  28. } expdesc;
  29. /* state needed to generate code for a given function */
  30. typedef struct FuncState {
  31. Proto *f; /* current function header */
  32. struct FuncState *prev; /* enclosing function */
  33. struct LexState *ls; /* lexical state */
  34. struct lua_State *L; /* copy of the Lua state */
  35. int pc; /* next position to code */
  36. int lasttarget; /* `pc' of last `jump target' */
  37. int jlt; /* list of jumps to `lasttarget' */
  38. short stacklevel; /* number of values on activation register */
  39. short nactloc; /* number of active local variables */
  40. short nupvalues; /* number of upvalues */
  41. int lastline; /* line where last `lineinfo' was generated */
  42. struct Breaklabel *bl; /* chain of breakable blocks */
  43. expdesc upvalues[MAXUPVALUES]; /* upvalues */
  44. int actloc[MAXLOCALS]; /* local-variable stack (indices to locvars) */
  45. } FuncState;
  46. Proto *luaY_parser (lua_State *L, ZIO *z);
  47. #endif