1
0

ns-eel-int.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. Nullsoft Expression Evaluator Library (NS-EEL)
  3. Copyright (C) 1999-2003 Nullsoft, Inc.
  4. ns-eel-int.h: internal code definition header.
  5. This software is provided 'as-is', without any express or implied
  6. warranty. In no event will the authors be held liable for any damages
  7. arising from the use of this software.
  8. Permission is granted to anyone to use this software for any purpose,
  9. including commercial applications, and to alter it and redistribute it
  10. freely, subject to the following restrictions:
  11. 1. The origin of this software must not be misrepresented; you must not
  12. claim that you wrote the original software. If you use this software
  13. in a product, an acknowledgment in the product documentation would be
  14. appreciated but is not required.
  15. 2. Altered source versions must be plainly marked as such, and must not be
  16. misrepresented as being the original software.
  17. 3. This notice may not be removed or altered from any source distribution.
  18. */
  19. #ifndef __NS_EELINT_H__
  20. #define __NS_EELINT_H__
  21. #include "ns-eel.h"
  22. #include "ns-eel-addfuncs.h"
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. #define FN_ASSIGN 0
  27. #define FN_MULTIPLY 1
  28. #define FN_DIVIDE 2
  29. #define FN_MODULO 3
  30. #define FN_ADD 4
  31. #define FN_SUB 5
  32. #define FN_AND 6
  33. #define FN_OR 7
  34. #define FN_UMINUS 8
  35. #define FN_UPLUS 9
  36. #define MATH_SIMPLE 0
  37. #define MATH_FN 1
  38. #define YYSTYPE int
  39. typedef struct
  40. {
  41. double **varTable_Values;
  42. char **varTable_Names;
  43. int varTable_numBlocks;
  44. int errVar;
  45. int colCount;
  46. int result;
  47. char last_error_string[256];
  48. YYSTYPE yylval;
  49. int yychar; /* the lookahead symbol */
  50. int yynerrs; /* number of parse errors so far */
  51. char yytext[256];
  52. char lastVar[256];
  53. char *llsave[16]; /* Look ahead buffer */
  54. char llbuf[100]; /* work buffer */
  55. char *llp1;// = &llbuf[0]; /* pointer to next avail. in token */
  56. char *llp2;// = &llbuf[0]; /* pointer to end of lookahead */
  57. char *llend;// = &llbuf[0]; /* pointer to end of token */
  58. char *llebuf;// = &llbuf[sizeof llbuf];
  59. int lleof;
  60. int yyline;// = 0;
  61. void *tmpblocks_head,*blocks_head;
  62. int computTableTop; // make it abort on potential overflow =)
  63. int l_stats[4]; // source bytes, static code bytes, call code bytes, data bytes
  64. void *userfunc_data[64];
  65. }
  66. compileContext;
  67. typedef struct {
  68. char *name;
  69. void *afunc;
  70. void *func_e;
  71. int nParams;
  72. NSEEL_PPPROC pProc;
  73. } functionType;
  74. extern functionType *nseel_getFunctionFromTable(int idx);
  75. int nseel_createCompiledValue(compileContext *ctx, double value, double *addrValue);
  76. int nseel_createCompiledFunction1(compileContext *ctx, int fntype, int fn, int code);
  77. int nseel_createCompiledFunction2(compileContext *ctx, int fntype, int fn, int code1, int code2);
  78. int nseel_createCompiledFunction3(compileContext *ctx, int fntype, int fn, int code1, int code2, int code3);
  79. extern double nseel_globalregs[100];
  80. void nseel_resetVars(compileContext *ctx);
  81. double *nseel_getVarPtr(compileContext *ctx, char *varName);
  82. double *nseel_registerVar(compileContext *ctx, char *varName);
  83. // other shat
  84. int nseel_setVar(compileContext *ctx, int varNum);
  85. int nseel_getVar(compileContext *ctx, int varNum);
  86. void *nseel_compileExpression(compileContext *ctx, char *txt);
  87. #define VALUE 258
  88. #define IDENTIFIER 259
  89. #define FUNCTION1 260
  90. #define FUNCTION2 261
  91. #define FUNCTION3 262
  92. #define UMINUS 263
  93. #define UPLUS 264
  94. int nseel_translate(compileContext *ctx, int type);
  95. void nseel_count(compileContext *ctx);
  96. void nseel_setLastVar(compileContext *ctx);
  97. int nseel_lookup(compileContext *ctx, int *typeOfObject);
  98. int nseel_yyerror(compileContext *ctx);
  99. int nseel_yylex(compileContext *ctx, char **exp);
  100. int nseel_yyparse(compileContext *ctx, char *exp);
  101. void nseel_llinit(compileContext *ctx);
  102. int nseel_gettoken(compileContext *ctx, char *lltb, int lltbsiz);
  103. struct lextab {
  104. int llendst; /* Last state number */
  105. char *lldefault; /* Default state table */
  106. char *llnext; /* Next state table */
  107. char *llcheck; /* Check table */
  108. int *llbase; /* Base table */
  109. int llnxtmax; /* Last in next table */
  110. int (*llmove)(); /* Move between states */
  111. char *llfinal; /* Final state descriptions */
  112. int (*llactr)(); /* Action routine */
  113. int *lllook; /* Look ahead vector if != NULL */
  114. char *llign; /* Ignore char vec if != NULL */
  115. char *llbrk; /* Break char vec if != NULL */
  116. char *llill; /* Illegal char vec if != NULL */
  117. };
  118. extern struct lextab nseel_lextab;
  119. #ifdef __cplusplus
  120. }
  121. #endif
  122. #endif//__NS_EELINT_H__