lparser.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. ** $Id: lparser.h,v 1.9 2000/03/03 18:53:17 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. /* maximum number of local variables */
  11. #ifndef MAXLOCALS
  12. #define MAXLOCALS 200 /* arbitrary limit (<=MAXARG_B) */
  13. #endif
  14. /* maximum number of upvalues */
  15. #ifndef MAXUPVALUES
  16. #define MAXUPVALUES 32 /* arbitrary limit (<=MAXARG_B) */
  17. #endif
  18. /* maximum number of variables in the left side of an assignment */
  19. #ifndef MAXVARSLH
  20. #define MAXVARSLH 100 /* arbitrary limit (<=MAXARG_B) */
  21. #endif
  22. /* maximum number of parameters in a function */
  23. #ifndef MAXPARAMS
  24. #define MAXPARAMS 100 /* arbitrary limit (<=MAXLOCALS) */
  25. #endif
  26. /* maximum stack size in a function */
  27. #ifndef MAXSTACK
  28. #define MAXSTACK 256 /* arbitrary limit (<=MAXARG_A) */
  29. #endif
  30. /*
  31. ** Expression descriptor
  32. */
  33. typedef enum {
  34. VGLOBAL,
  35. VLOCAL,
  36. VINDEXED,
  37. VEXP
  38. } expkind;
  39. typedef struct expdesc {
  40. expkind k;
  41. union {
  42. int index; /* VGLOBAL: `kstr' index of global name; VLOCAL: stack index */
  43. struct {
  44. int t; /* patch list of `exit when true' */
  45. int f; /* patch list of `exit when false' */
  46. } l;
  47. } u;
  48. } expdesc;
  49. /* state needed to generate code for a given function */
  50. typedef struct FuncState {
  51. TProtoFunc *f; /* current function header */
  52. struct FuncState *prev; /* enclosing function */
  53. int pc; /* next position to code */
  54. int lasttarget; /* `pc' of last `jump target' */
  55. int stacksize; /* number of values on activation register */
  56. int nlocalvar; /* number of active local variables */
  57. int nupvalues; /* number of upvalues */
  58. int nvars; /* number of entries in f->locvars (-1 if no debug information) */
  59. int lastsetline; /* line where last SETLINE was issued */
  60. expdesc upvalues[MAXUPVALUES]; /* upvalues */
  61. TaggedString *localvar[MAXLOCALS]; /* store local variable names */
  62. } FuncState;
  63. TProtoFunc *luaY_parser (lua_State *L, ZIO *z);
  64. #endif