un.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. function yyrefill(void)
  2. {
  3. let yyn;
  4. while ((yybuflen - yypos) < 512)
  5. {
  6. yybuflen *= 2;
  7. yybuf = realloc(yybuf, yybuflen);
  8. }
  9. {
  10. let yyc = getchar();
  11. yyn = EOF === yyc ? 0 : ((yybuf + yypos) = yyc, 1);
  12. ;
  13. }
  14. ;
  15. if (!yyn)
  16. return 0;
  17. yylimit += yyn;
  18. return 1;
  19. }
  20. function yymatchDot(void)
  21. {
  22. if ((yypos >= yylimit) && (!yyrefill()))
  23. return 0;
  24. ++yypos;
  25. return 1;
  26. }
  27. function yymatchChar(c)
  28. {
  29. if ((yypos >= yylimit) && (!yyrefill()))
  30. return 0;
  31. if (yybuf[yypos] === c)
  32. {
  33. ++yypos;
  34. ;
  35. return 1;
  36. }
  37. ;
  38. return 0;
  39. }
  40. function yymatchString(s)
  41. {
  42. let yysav = yypos;
  43. while (s)
  44. {
  45. if ((yypos >= yylimit) && (!yyrefill()))
  46. return 0;
  47. if (yybuf[yypos] !== (s))
  48. {
  49. yypos = yysav;
  50. return 0;
  51. }
  52. ++s;
  53. ++yypos;
  54. }
  55. return 1;
  56. }
  57. function yymatchClass(bits)
  58. {
  59. let c;
  60. if ((yypos >= yylimit) && (!yyrefill()))
  61. return 0;
  62. c = yybuf[yypos];
  63. if (bits[c >> 3] & (1 << (c & 7)))
  64. {
  65. ++yypos;
  66. ;
  67. return 1;
  68. }
  69. ;
  70. return 0;
  71. }
  72. function yyDo(action, begin, end)
  73. {
  74. while (yythunkpos >= yythunkslen)
  75. {
  76. yythunkslen *= 2;
  77. yythunks = realloc(yythunks, (sizeof(yythunk)) * yythunkslen);
  78. }
  79. yythunks[yythunkpos].begin = begin;
  80. yythunks[yythunkpos].end = end;
  81. yythunks[yythunkpos].action = action;
  82. ++yythunkpos;
  83. }
  84. function yyText(begin, end)
  85. {
  86. let yyleng = end - begin;
  87. if (yyleng <= 0)
  88. yyleng = 0;
  89. else
  90. {
  91. while (yytextlen < (yyleng - 1))
  92. {
  93. yytextlen *= 2;
  94. yytext = realloc(yytext, yytextlen);
  95. }
  96. memcpy(yytext, yybuf + begin, yyleng);
  97. }
  98. yytext[yyleng] = '\0';
  99. return yyleng;
  100. }
  101. function yyDone(void)
  102. {
  103. let pos;
  104. for (pos = 0; pos < yythunkpos; ++pos)
  105. {
  106. let thunk = yythunks[pos];
  107. let yyleng = thunk.end ? yyText(thunk.begin, thunk.end) : thunk.begin;
  108. ;
  109. thunk.action(yytext, yyleng);
  110. }
  111. yythunkpos = 0;
  112. }
  113. function yyCommit()
  114. {
  115. if (yylimit -= yypos)
  116. {
  117. memmove(yybuf, yybuf + yypos, yylimit);
  118. }
  119. yybegin -= yypos;
  120. yyend -= yypos;
  121. yypos = (yythunkpos = 0);
  122. }
  123. function yyAccept(tp0)
  124. {
  125. if (tp0)
  126. {
  127. fprintf(stderr, 'accept denied at %d\n', tp0);
  128. return 0;
  129. }
  130. else
  131. {
  132. yyDone();
  133. yyCommit();
  134. }
  135. return 1;
  136. }
  137. function yyPush(text, count)
  138. {
  139. if (text)
  140. {
  141. }
  142. yyval += count;
  143. }
  144. function yyPop(text, count)
  145. {
  146. if (text)
  147. {
  148. }
  149. yyval -= count;
  150. }
  151. function yySet(text, count)
  152. {
  153. if (text)
  154. {
  155. }
  156. yyval[count] = yy;
  157. }
  158. function yy_2_start(yytext, yyleng)
  159. {
  160. if (yytext)
  161. {
  162. }
  163. if (yyleng)
  164. {
  165. }
  166. ;
  167. putchar(yytext[0]);
  168. ;
  169. }
  170. function yy_1_start(yytext, yyleng)
  171. {
  172. if (yytext)
  173. {
  174. }
  175. if (yyleng)
  176. {
  177. }
  178. ;
  179. printf('%s', getlogin());
  180. ;
  181. }
  182. function yy_start()
  183. {
  184. let yypos0 = yypos;
  185. let yythunkpos0 = yythunkpos;
  186. ;
  187. {
  188. let yypos2 = yypos;
  189. let yythunkpos2 = yythunkpos;
  190. if (!yymatchString('username'))
  191. // FIXME: goto l3;
  192. yyDo(yy_1_start, yybegin, yyend);
  193. // FIXME: goto l2;
  194. l3:
  195. ;
  196. yypos = yypos2;
  197. yythunkpos = yythunkpos2;
  198. yyText(yybegin, yyend);
  199. if (!((yybegin = yypos, 1)))
  200. // FIXME: goto l1;
  201. if (!yymatchDot())
  202. // FIXME: goto l1;
  203. yyText(yybegin, yyend);
  204. if (!((yyend = yypos, 1)))
  205. // FIXME: goto l1;
  206. yyDo(yy_2_start, yybegin, yyend);
  207. }
  208. l2:
  209. ;
  210. ;
  211. return 1;
  212. l1:
  213. ;
  214. yypos = yypos0;
  215. yythunkpos = yythunkpos0;
  216. ;
  217. return 0;
  218. }
  219. function yyparsefrom(yystart)
  220. {
  221. let yyok;
  222. if (!yybuflen)
  223. {
  224. yybuflen = 1024;
  225. yybuf = malloc(yybuflen);
  226. yytextlen = 1024;
  227. yytext = malloc(yytextlen);
  228. yythunkslen = 32;
  229. yythunks = malloc((sizeof(yythunk)) * yythunkslen);
  230. yyvalslen = 32;
  231. yyvals = malloc((sizeof(int)) * yyvalslen);
  232. yybegin = (yyend = (yypos = (yylimit = (yythunkpos = 0))));
  233. }
  234. yybegin = (yyend = yypos);
  235. yythunkpos = 0;
  236. yyval = yyvals;
  237. yyok = yystart();
  238. if (yyok)
  239. yyDone();
  240. yyCommit();
  241. return yyok;
  242. yyrefill;
  243. yymatchDot;
  244. yymatchChar;
  245. yymatchString;
  246. yymatchClass;
  247. yyDo;
  248. yyText;
  249. yyDone;
  250. yyCommit;
  251. yyAccept;
  252. yyPush;
  253. yyPop;
  254. yySet;
  255. yytextmax;
  256. }
  257. function yyparse(void)
  258. {
  259. return yyparsefrom(yy_start);
  260. }
  261. function main()
  262. {
  263. while (yyparse())
  264. ;
  265. return 0;
  266. }