lparser.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. ** $Id: lparser.h,v 1.15 2000/04/05 17:51:58 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 `lasttarged' */
  38. int stacklevel; /* number of values on activation register */
  39. int nlocalvar; /* number of active local variables */
  40. int nupvalues; /* number of upvalues */
  41. int nvars; /* number of entries in f->locvars (-1 if no debug information) */
  42. int lastsetline; /* line where last SETLINE was issued */
  43. struct Breaklabel *bl; /* chain of breakable blocks */
  44. expdesc upvalues[MAXUPVALUES]; /* upvalues */
  45. TString *localvar[MAXLOCALS]; /* store local variable names */
  46. } FuncState;
  47. Proto *luaY_parser (lua_State *L, ZIO *z);
  48. #endif