nseel-lextab.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. /*
  2. Expression Evaluator Library (NS-EEL) v2
  3. Copyright (C) 2004-2008 Cockos Incorporated
  4. Copyright (C) 1999-2003 Nullsoft, Inc.
  5. nseel-lextab.c
  6. This software is provided 'as-is', without any express or implied
  7. warranty. In no event will the authors be held liable for any damages
  8. arising from the use of this software.
  9. Permission is granted to anyone to use this software for any purpose,
  10. including commercial applications, and to alter it and redistribute it
  11. freely, subject to the following restrictions:
  12. 1. The origin of this software must not be misrepresented; you must not
  13. claim that you wrote the original software. If you use this software
  14. in a product, an acknowledgment in the product documentation would be
  15. appreciated but is not required.
  16. 2. Altered source versions must be plainly marked as such, and must not be
  17. misrepresented as being the original software.
  18. 3. This notice may not be removed or altered from any source distribution.
  19. */
  20. #include "ns-eel-int.h"
  21. #define LEXSKIP (-1)
  22. static int _lmovb(struct lextab *lp, int c, int st)
  23. {
  24. int base;
  25. while ((base = lp->llbase[st]+c) > lp->llnxtmax ||
  26. (lp->llcheck[base] & 0377) != st) {
  27. if (st != lp->llendst) {
  28. base = lp->lldefault[st] & 0377;
  29. st = base;
  30. }
  31. else
  32. return(-1);
  33. }
  34. return(lp->llnext[base]&0377);
  35. }
  36. #define INTCONST 1
  37. #define DBLCONST 2
  38. #define HEXCONST 3
  39. #define VARIABLE 4
  40. #define OTHER 5
  41. static int _Alextab(compileContext *ctx, int __na__)
  42. {
  43. // fucko: JF> 17 -> 19?
  44. if (__na__ >= 0 && __na__ <= 17)
  45. nseel_count(ctx);
  46. switch (__na__)
  47. {
  48. case 0:
  49. *ctx->yytext = 0;
  50. nseel_gettoken(ctx,ctx->yytext, sizeof(ctx->yytext));
  51. if (ctx->yytext[0] < '0' || ctx->yytext[0] > '9') // not really a hex value, lame
  52. {
  53. nseel_setLastVar(ctx); ctx->yylval = nseel_lookup(ctx,&__na__); return __na__;
  54. }
  55. ctx->yylval = nseel_translate(ctx,HEXCONST);
  56. return VALUE;
  57. case 1: ctx->yylval = nseel_translate(ctx,INTCONST); return VALUE;
  58. case 2: ctx->yylval = nseel_translate(ctx,INTCONST); return VALUE;
  59. case 3: ctx->yylval = nseel_translate(ctx,DBLCONST); return VALUE;
  60. case 4:
  61. case 5: nseel_setLastVar(ctx); ctx->yylval = nseel_lookup(ctx,&__na__); return __na__;
  62. case 6: return '+';
  63. case 7: return '-';
  64. case 8: return '*';
  65. case 9: return '/';
  66. case 10: return '%';
  67. case 11: return '&';
  68. case 12: return '|';
  69. case 13: return '(';
  70. case 14: return ')';
  71. case 15: return '=';
  72. case 16: return ',';
  73. case 17: return ';';
  74. }
  75. return (LEXSKIP);
  76. }
  77. static char _Flextab[] =
  78. {
  79. 1, 18, 17, 16, 15, 14, 13, 12,
  80. 11, 10, 9, 8, 7, 6, 4, 5,
  81. 5, 4, 4, 3, 3, 3, 3, 4,
  82. 0, 4, 5, 0, 5, 4, 1, 3,
  83. 0, 2, -1, 1, -1,
  84. };
  85. static char _Nlextab[] =
  86. {
  87. 36, 36, 36, 36, 36, 36, 36, 36,
  88. 36, 1, 36, 36, 36, 36, 36, 36,
  89. 36, 36, 36, 36, 36, 36, 36, 36,
  90. 36, 36, 36, 36, 36, 36, 36, 36,
  91. 1, 36, 36, 36, 36, 9, 8, 36,
  92. 6, 5, 11, 13, 3, 12, 19, 10,
  93. 30, 30, 30, 30, 30, 30, 30, 30,
  94. 30, 30, 36, 2, 36, 4, 36, 36,
  95. 36, 29, 29, 29, 29, 29, 29, 18,
  96. 18, 18, 18, 18, 18, 18, 18, 18,
  97. 18, 18, 18, 18, 18, 18, 18, 18,
  98. 18, 18, 18, 36, 36, 36, 36, 18,
  99. 36, 29, 29, 29, 29, 29, 23, 18,
  100. 18, 18, 18, 18, 18, 18, 18, 18,
  101. 18, 18, 18, 18, 18, 18, 14, 18,
  102. 18, 18, 18, 36, 7, 15, 15, 15,
  103. 15, 15, 15, 15, 15, 15, 15, 36,
  104. 36, 36, 36, 36, 36, 36, 17, 17,
  105. 17, 17, 17, 17, 17, 17, 17, 17,
  106. 17, 17, 17, 17, 17, 17, 17, 17,
  107. 17, 17, 17, 17, 17, 17, 17, 17,
  108. 36, 36, 36, 36, 17, 36, 17, 17,
  109. 17, 17, 17, 17, 17, 17, 17, 17,
  110. 17, 17, 17, 17, 17, 17, 17, 17,
  111. 17, 17, 17, 17, 17, 17, 17, 17,
  112. 15, 15, 15, 15, 15, 15, 15, 15,
  113. 15, 15, 36, 36, 36, 36, 36, 36,
  114. 36, 16, 16, 16, 16, 16, 16, 16,
  115. 16, 16, 16, 16, 16, 16, 16, 16,
  116. 16, 16, 16, 16, 16, 16, 16, 16,
  117. 16, 16, 16, 36, 36, 36, 36, 16,
  118. 36, 16, 16, 16, 16, 16, 16, 16,
  119. 16, 16, 16, 16, 16, 16, 16, 16,
  120. 16, 16, 16, 16, 16, 16, 16, 16,
  121. 16, 16, 16, 22, 22, 22, 22, 22,
  122. 22, 22, 22, 22, 22, 21, 21, 21,
  123. 21, 21, 21, 21, 21, 21, 21, 36,
  124. 20, 26, 26, 26, 26, 26, 26, 26,
  125. 26, 26, 26, 36, 36, 36, 36, 36,
  126. 36, 36, 25, 25, 25, 25, 25, 25,
  127. 36, 24, 36, 36, 36, 36, 36, 36,
  128. 20, 36, 36, 36, 36, 36, 36, 36,
  129. 36, 36, 36, 36, 36, 36, 36, 36,
  130. 36, 36, 25, 25, 25, 25, 25, 25,
  131. 36, 24, 26, 26, 26, 26, 26, 26,
  132. 26, 26, 26, 26, 36, 36, 36, 36,
  133. 36, 36, 36, 28, 28, 28, 28, 28,
  134. 28, 36, 27, 36, 36, 36, 36, 36,
  135. 36, 36, 36, 36, 36, 36, 36, 36,
  136. 36, 36, 36, 36, 36, 36, 36, 36,
  137. 36, 36, 36, 28, 28, 28, 28, 28,
  138. 28, 31, 27, 35, 35, 35, 35, 35,
  139. 35, 35, 35, 35, 35, 36, 36, 36,
  140. 36, 36, 36, 36, 34, 34, 34, 33,
  141. 34, 34, 36, 32, 36, 36, 36, 36,
  142. 36, 36, 36, 36, 36, 36, 36, 36,
  143. 36, 36, 36, 36, 36, 36, 36, 36,
  144. 36, 36, 36, 36, 34, 34, 34, 33,
  145. 34, 34, 36, 32, 34, 34, 34, 34,
  146. 34, 34, 34, 34, 34, 34, 36, 36,
  147. 36, 36, 36, 36, 36, 34, 34, 34,
  148. 34, 34, 34, 36, 32, 36, 36, 36,
  149. 36, 36, 36, 36, 36, 36, 36, 36,
  150. 36, 36, 36, 36, 36, 36, 36, 36,
  151. 36, 36, 36, 36, 36, 34, 34, 34,
  152. 34, 34, 34, 36, 32,
  153. };
  154. static char _Clextab[] =
  155. {
  156. -1, -1, -1, -1, -1, -1, -1, -1,
  157. -1, 0, -1, -1, -1, -1, -1, -1,
  158. -1, -1, -1, -1, -1, -1, -1, -1,
  159. -1, -1, -1, -1, -1, -1, -1, -1,
  160. 0, -1, -1, -1, -1, 0, 0, -1,
  161. 0, 0, 0, 0, 0, 0, 0, 0,
  162. 0, 0, 0, 0, 0, 0, 0, 0,
  163. 0, 0, -1, 0, -1, 0, -1, -1,
  164. -1, 0, 0, 0, 0, 0, 0, 0,
  165. 0, 0, 0, 0, 0, 0, 0, 0,
  166. 0, 0, 0, 0, 0, 0, 0, 0,
  167. 0, 0, 0, -1, -1, -1, -1, 0,
  168. -1, 0, 0, 0, 0, 0, 0, 0,
  169. 0, 0, 0, 0, 0, 0, 0, 0,
  170. 0, 0, 0, 0, 0, 0, 0, 0,
  171. 0, 0, 0, -1, 0, 14, 14, 14,
  172. 14, 14, 14, 14, 14, 14, 14, -1,
  173. -1, -1, -1, -1, -1, -1, 14, 14,
  174. 14, 14, 14, 14, 14, 14, 14, 14,
  175. 14, 14, 14, 14, 14, 14, 14, 14,
  176. 14, 14, 14, 14, 14, 14, 14, 14,
  177. -1, -1, -1, -1, 14, -1, 14, 14,
  178. 14, 14, 14, 14, 14, 14, 14, 14,
  179. 14, 14, 14, 14, 14, 14, 14, 14,
  180. 14, 14, 14, 14, 14, 14, 14, 14,
  181. 15, 15, 15, 15, 15, 15, 15, 15,
  182. 15, 15, -1, -1, -1, -1, -1, -1,
  183. -1, 15, 15, 15, 15, 15, 15, 15,
  184. 15, 15, 15, 15, 15, 15, 15, 15,
  185. 15, 15, 15, 15, 15, 15, 15, 15,
  186. 15, 15, 15, -1, -1, -1, -1, 15,
  187. -1, 15, 15, 15, 15, 15, 15, 15,
  188. 15, 15, 15, 15, 15, 15, 15, 15,
  189. 15, 15, 15, 15, 15, 15, 15, 15,
  190. 15, 15, 15, 19, 19, 19, 19, 19,
  191. 19, 19, 19, 19, 19, 20, 20, 20,
  192. 20, 20, 20, 20, 20, 20, 20, -1,
  193. 19, 23, 23, 23, 23, 23, 23, 23,
  194. 23, 23, 23, -1, -1, -1, -1, -1,
  195. -1, -1, 23, 23, 23, 23, 23, 23,
  196. -1, 23, -1, -1, -1, -1, -1, -1,
  197. 19, -1, -1, -1, -1, -1, -1, -1,
  198. -1, -1, -1, -1, -1, -1, -1, -1,
  199. -1, -1, 23, 23, 23, 23, 23, 23,
  200. -1, 23, 26, 26, 26, 26, 26, 26,
  201. 26, 26, 26, 26, -1, -1, -1, -1,
  202. -1, -1, -1, 26, 26, 26, 26, 26,
  203. 26, -1, 26, -1, -1, -1, -1, -1,
  204. -1, -1, -1, -1, -1, -1, -1, -1,
  205. -1, -1, -1, -1, -1, -1, -1, -1,
  206. -1, -1, -1, 26, 26, 26, 26, 26,
  207. 26, 30, 26, 30, 30, 30, 30, 30,
  208. 30, 30, 30, 30, 30, -1, -1, -1,
  209. -1, -1, -1, -1, 30, 30, 30, 30,
  210. 30, 30, -1, 30, -1, -1, -1, -1,
  211. -1, -1, -1, -1, -1, -1, -1, -1,
  212. -1, -1, -1, -1, -1, -1, -1, -1,
  213. -1, -1, -1, -1, 30, 30, 30, 30,
  214. 30, 30, -1, 30, 33, 33, 33, 33,
  215. 33, 33, 33, 33, 33, 33, -1, -1,
  216. -1, -1, -1, -1, -1, 33, 33, 33,
  217. 33, 33, 33, -1, 33, -1, -1, -1,
  218. -1, -1, -1, -1, -1, -1, -1, -1,
  219. -1, -1, -1, -1, -1, -1, -1, -1,
  220. -1, -1, -1, -1, -1, 33, 33, 33,
  221. 33, 33, 33, -1, 33,
  222. };
  223. static char _Dlextab[] =
  224. {
  225. 36, 36, 36, 36, 36, 36, 36, 36,
  226. 36, 36, 36, 36, 36, 36, 36, 36,
  227. 15, 14, 14, 36, 36, 20, 19, 14,
  228. 14, 23, 15, 15, 26, 23, 36, 19,
  229. 36, 36, 33, 30,
  230. };
  231. static int _Blextab[] =
  232. {
  233. 0, 0, 0, 0, 0, 0, 0, 0,
  234. 0, 0, 0, 0, 0, 0, 77, 152,
  235. 0, 0, 0, 227, 237, 0, 0, 249,
  236. 0, 0, 306, 0, 0, 0, 363, 0,
  237. 0, 420, 0, 0, 0,
  238. };
  239. struct lextab nseel_lextab = {
  240. 36,
  241. _Dlextab,
  242. _Nlextab,
  243. _Clextab,
  244. _Blextab,
  245. 524,
  246. _lmovb,
  247. _Flextab,
  248. _Alextab,
  249. 0,
  250. 0,
  251. 0,
  252. 0,
  253. };