nseel-lextab.c 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /*
  2. Nullsoft Expression Evaluator Library (NS-EEL)
  3. Copyright (C) 1999-2003 Nullsoft, Inc.
  4. nseel-lextab.c
  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. #include "ns-eel-int.h"
  20. #define LEXSKIP (-1)
  21. static int _lmovb(struct lextab *lp, int c, int st)
  22. {
  23. int base;
  24. while ((base = lp->llbase[st]+c) > lp->llnxtmax ||
  25. (lp->llcheck[base] & 0377) != st) {
  26. if (st != lp->llendst) {
  27. base = lp->lldefault[st] & 0377;
  28. st = base;
  29. }
  30. else
  31. return(-1);
  32. }
  33. return(lp->llnext[base]&0377);
  34. }
  35. #define INTCONST 1
  36. #define DBLCONST 2
  37. #define HEXCONST 3
  38. #define VARIABLE 4
  39. #define OTHER 5
  40. static int _Alextab(compileContext *ctx, int __na__)
  41. {
  42. if (__na__ >= 0 && __na__ <= 19) nseel_count(ctx);
  43. switch (__na__)
  44. {
  45. case 0: ctx->yylval = nseel_translate(ctx,HEXCONST); return VALUE;
  46. case 1: ctx->yylval = nseel_translate(ctx,INTCONST); return VALUE;
  47. case 2: ctx->yylval = nseel_translate(ctx,INTCONST); return VALUE;
  48. case 3: ctx->yylval = nseel_translate(ctx,DBLCONST); return VALUE;
  49. case 4:
  50. case 5: nseel_setLastVar(ctx); ctx->yylval = nseel_lookup(ctx,&__na__); return __na__;
  51. case 6: return '+';
  52. case 7: return '-';
  53. case 8: return '*';
  54. case 9: return '/';
  55. case 10: return '%';
  56. case 11: return '&';
  57. case 12: return '|';
  58. case 13: return '(';
  59. case 14: return ')';
  60. case 15: return '=';
  61. case 16: return ',';
  62. case 17: return ';';
  63. }
  64. return (LEXSKIP);
  65. }
  66. static char _Flextab[] =
  67. {
  68. 1, 18, 17, 16, 15, 14, 13, 12,
  69. 11, 10, 9, 8, 7, 6, 4, 5,
  70. 5, 4, 4, 3, 3, 3, 3, 4,
  71. 0, 4, 5, 0, 5, 4, 1, 3,
  72. 0, 2, -1, 1, -1,
  73. };
  74. static char _Nlextab[] =
  75. {
  76. 36, 36, 36, 36, 36, 36, 36, 36,
  77. 36, 1, 36, 36, 36, 36, 36, 36,
  78. 36, 36, 36, 36, 36, 36, 36, 36,
  79. 36, 36, 36, 36, 36, 36, 36, 36,
  80. 1, 36, 36, 36, 36, 9, 8, 36,
  81. 6, 5, 11, 13, 3, 12, 19, 10,
  82. 30, 30, 30, 30, 30, 30, 30, 30,
  83. 30, 30, 36, 2, 36, 4, 36, 36,
  84. 36, 29, 29, 29, 29, 29, 29, 18,
  85. 18, 18, 18, 18, 18, 18, 18, 18,
  86. 18, 18, 18, 18, 18, 18, 18, 18,
  87. 18, 18, 18, 36, 36, 36, 36, 18,
  88. 36, 29, 29, 29, 29, 29, 23, 18,
  89. 18, 18, 18, 18, 18, 18, 18, 18,
  90. 18, 18, 18, 18, 18, 18, 14, 18,
  91. 18, 18, 18, 36, 7, 15, 15, 15,
  92. 15, 15, 15, 15, 15, 15, 15, 36,
  93. 36, 36, 36, 36, 36, 36, 17, 17,
  94. 17, 17, 17, 17, 17, 17, 17, 17,
  95. 17, 17, 17, 17, 17, 17, 17, 17,
  96. 17, 17, 17, 17, 17, 17, 17, 17,
  97. 36, 36, 36, 36, 17, 36, 17, 17,
  98. 17, 17, 17, 17, 17, 17, 17, 17,
  99. 17, 17, 17, 17, 17, 17, 17, 17,
  100. 17, 17, 17, 17, 17, 17, 17, 17,
  101. 15, 15, 15, 15, 15, 15, 15, 15,
  102. 15, 15, 36, 36, 36, 36, 36, 36,
  103. 36, 16, 16, 16, 16, 16, 16, 16,
  104. 16, 16, 16, 16, 16, 16, 16, 16,
  105. 16, 16, 16, 16, 16, 16, 16, 16,
  106. 16, 16, 16, 36, 36, 36, 36, 16,
  107. 36, 16, 16, 16, 16, 16, 16, 16,
  108. 16, 16, 16, 16, 16, 16, 16, 16,
  109. 16, 16, 16, 16, 16, 16, 16, 16,
  110. 16, 16, 16, 22, 22, 22, 22, 22,
  111. 22, 22, 22, 22, 22, 21, 21, 21,
  112. 21, 21, 21, 21, 21, 21, 21, 36,
  113. 20, 26, 26, 26, 26, 26, 26, 26,
  114. 26, 26, 26, 36, 36, 36, 36, 36,
  115. 36, 36, 25, 25, 25, 25, 25, 25,
  116. 36, 24, 36, 36, 36, 36, 36, 36,
  117. 20, 36, 36, 36, 36, 36, 36, 36,
  118. 36, 36, 36, 36, 36, 36, 36, 36,
  119. 36, 36, 25, 25, 25, 25, 25, 25,
  120. 36, 24, 26, 26, 26, 26, 26, 26,
  121. 26, 26, 26, 26, 36, 36, 36, 36,
  122. 36, 36, 36, 28, 28, 28, 28, 28,
  123. 28, 36, 27, 36, 36, 36, 36, 36,
  124. 36, 36, 36, 36, 36, 36, 36, 36,
  125. 36, 36, 36, 36, 36, 36, 36, 36,
  126. 36, 36, 36, 28, 28, 28, 28, 28,
  127. 28, 31, 27, 35, 35, 35, 35, 35,
  128. 35, 35, 35, 35, 35, 36, 36, 36,
  129. 36, 36, 36, 36, 34, 34, 34, 33,
  130. 34, 34, 36, 32, 36, 36, 36, 36,
  131. 36, 36, 36, 36, 36, 36, 36, 36,
  132. 36, 36, 36, 36, 36, 36, 36, 36,
  133. 36, 36, 36, 36, 34, 34, 34, 33,
  134. 34, 34, 36, 32, 34, 34, 34, 34,
  135. 34, 34, 34, 34, 34, 34, 36, 36,
  136. 36, 36, 36, 36, 36, 34, 34, 34,
  137. 34, 34, 34, 36, 32, 36, 36, 36,
  138. 36, 36, 36, 36, 36, 36, 36, 36,
  139. 36, 36, 36, 36, 36, 36, 36, 36,
  140. 36, 36, 36, 36, 36, 34, 34, 34,
  141. 34, 34, 34, 36, 32,
  142. };
  143. static char _Clextab[] =
  144. {
  145. -1, -1, -1, -1, -1, -1, -1, -1,
  146. -1, 0, -1, -1, -1, -1, -1, -1,
  147. -1, -1, -1, -1, -1, -1, -1, -1,
  148. -1, -1, -1, -1, -1, -1, -1, -1,
  149. 0, -1, -1, -1, -1, 0, 0, -1,
  150. 0, 0, 0, 0, 0, 0, 0, 0,
  151. 0, 0, 0, 0, 0, 0, 0, 0,
  152. 0, 0, -1, 0, -1, 0, -1, -1,
  153. -1, 0, 0, 0, 0, 0, 0, 0,
  154. 0, 0, 0, 0, 0, 0, 0, 0,
  155. 0, 0, 0, 0, 0, 0, 0, 0,
  156. 0, 0, 0, -1, -1, -1, -1, 0,
  157. -1, 0, 0, 0, 0, 0, 0, 0,
  158. 0, 0, 0, 0, 0, 0, 0, 0,
  159. 0, 0, 0, 0, 0, 0, 0, 0,
  160. 0, 0, 0, -1, 0, 14, 14, 14,
  161. 14, 14, 14, 14, 14, 14, 14, -1,
  162. -1, -1, -1, -1, -1, -1, 14, 14,
  163. 14, 14, 14, 14, 14, 14, 14, 14,
  164. 14, 14, 14, 14, 14, 14, 14, 14,
  165. 14, 14, 14, 14, 14, 14, 14, 14,
  166. -1, -1, -1, -1, 14, -1, 14, 14,
  167. 14, 14, 14, 14, 14, 14, 14, 14,
  168. 14, 14, 14, 14, 14, 14, 14, 14,
  169. 14, 14, 14, 14, 14, 14, 14, 14,
  170. 15, 15, 15, 15, 15, 15, 15, 15,
  171. 15, 15, -1, -1, -1, -1, -1, -1,
  172. -1, 15, 15, 15, 15, 15, 15, 15,
  173. 15, 15, 15, 15, 15, 15, 15, 15,
  174. 15, 15, 15, 15, 15, 15, 15, 15,
  175. 15, 15, 15, -1, -1, -1, -1, 15,
  176. -1, 15, 15, 15, 15, 15, 15, 15,
  177. 15, 15, 15, 15, 15, 15, 15, 15,
  178. 15, 15, 15, 15, 15, 15, 15, 15,
  179. 15, 15, 15, 19, 19, 19, 19, 19,
  180. 19, 19, 19, 19, 19, 20, 20, 20,
  181. 20, 20, 20, 20, 20, 20, 20, -1,
  182. 19, 23, 23, 23, 23, 23, 23, 23,
  183. 23, 23, 23, -1, -1, -1, -1, -1,
  184. -1, -1, 23, 23, 23, 23, 23, 23,
  185. -1, 23, -1, -1, -1, -1, -1, -1,
  186. 19, -1, -1, -1, -1, -1, -1, -1,
  187. -1, -1, -1, -1, -1, -1, -1, -1,
  188. -1, -1, 23, 23, 23, 23, 23, 23,
  189. -1, 23, 26, 26, 26, 26, 26, 26,
  190. 26, 26, 26, 26, -1, -1, -1, -1,
  191. -1, -1, -1, 26, 26, 26, 26, 26,
  192. 26, -1, 26, -1, -1, -1, -1, -1,
  193. -1, -1, -1, -1, -1, -1, -1, -1,
  194. -1, -1, -1, -1, -1, -1, -1, -1,
  195. -1, -1, -1, 26, 26, 26, 26, 26,
  196. 26, 30, 26, 30, 30, 30, 30, 30,
  197. 30, 30, 30, 30, 30, -1, -1, -1,
  198. -1, -1, -1, -1, 30, 30, 30, 30,
  199. 30, 30, -1, 30, -1, -1, -1, -1,
  200. -1, -1, -1, -1, -1, -1, -1, -1,
  201. -1, -1, -1, -1, -1, -1, -1, -1,
  202. -1, -1, -1, -1, 30, 30, 30, 30,
  203. 30, 30, -1, 30, 33, 33, 33, 33,
  204. 33, 33, 33, 33, 33, 33, -1, -1,
  205. -1, -1, -1, -1, -1, 33, 33, 33,
  206. 33, 33, 33, -1, 33, -1, -1, -1,
  207. -1, -1, -1, -1, -1, -1, -1, -1,
  208. -1, -1, -1, -1, -1, -1, -1, -1,
  209. -1, -1, -1, -1, -1, 33, 33, 33,
  210. 33, 33, 33, -1, 33,
  211. };
  212. static char _Dlextab[] =
  213. {
  214. 36, 36, 36, 36, 36, 36, 36, 36,
  215. 36, 36, 36, 36, 36, 36, 36, 36,
  216. 15, 14, 14, 36, 36, 20, 19, 14,
  217. 14, 23, 15, 15, 26, 23, 36, 19,
  218. 36, 36, 33, 30,
  219. };
  220. static int _Blextab[] =
  221. {
  222. 0, 0, 0, 0, 0, 0, 0, 0,
  223. 0, 0, 0, 0, 0, 0, 77, 152,
  224. 0, 0, 0, 227, 237, 0, 0, 249,
  225. 0, 0, 306, 0, 0, 0, 363, 0,
  226. 0, 420, 0, 0, 0,
  227. };
  228. struct lextab nseel_lextab = {
  229. 36,
  230. _Dlextab,
  231. _Nlextab,
  232. _Clextab,
  233. _Blextab,
  234. 524,
  235. _lmovb,
  236. _Flextab,
  237. _Alextab,
  238. 0,
  239. 0,
  240. 0,
  241. 0,
  242. };