Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

494 lines
11 KiB

  1. // Copyright (c) 1993-1999 Microsoft Corporation
  2. #define YY_DEFAULT_ACTION ECHO;
  3. #define FLEX_USE_ECS
  4. #define FLEX_USE_MECS
  5. /* A lexical scanner generated by flex */
  6. #include "flexskel.h"
  7. #define INITIAL 0
  8. /***
  9. *** lexer for preprocessing the parser driver generated by yacc, in
  10. *** order to convert the big switch statement into individual semantic
  11. *** functions
  12. ***/
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #include <malloc.h>
  17. #include "lex.h"
  18. #include "gram.h"
  19. #define VC_PRINTF( x ) /** printf(x) **/
  20. void LexInstall_ID( void );
  21. void LexInstall_Number( void );
  22. int IsToken( void );
  23. lextype_t yylval;
  24. int Line = 0;
  25. int Incase = 0;
  26. int ActionSensed = 0;
  27. char LocalBuffer[ 100 ];
  28. #define YY_JAM 40
  29. #define YY_JAM_BASE 65
  30. #define YY_TEMPLATE 41
  31. static char l[41] =
  32. { 0,
  33. -2, -2, 6, 5, 4, 1, 6, 4, 1, 0,
  34. 0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
  35. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  36. 0, 0, 0, 0, 0, 0, 0, 0, 3, 0
  37. } ;
  38. static char e[128] =
  39. { 0,
  40. 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
  41. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  42. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  43. 1, 4, 1, 1, 1, 1, 1, 1, 1, 1,
  44. 1, 5, 1, 1, 1, 1, 6, 7, 7, 7,
  45. 7, 7, 7, 7, 7, 7, 7, 1, 8, 1,
  46. 1, 1, 1, 1, 9, 9, 9, 9, 10, 9,
  47. 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
  48. 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
  49. 1, 1, 1, 1, 9, 1, 11, 12, 13, 14,
  50. 15, 16, 9, 9, 17, 9, 18, 9, 9, 19,
  51. 20, 9, 9, 21, 22, 23, 9, 9, 9, 9,
  52. 9, 9, 1, 1, 24, 1, 1
  53. } ;
  54. static char m[25] =
  55. { 0,
  56. 1, 1, 1, 1, 1, 1, 2, 1, 2, 2,
  57. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  58. 2, 2, 2, 1
  59. } ;
  60. static short int b[43] =
  61. { 0,
  62. 0, 24, 65, 65, 58, 0, 60, 56, 0, 50,
  63. 40, 45, 48, 40, 49, 47, 7, 65, 51, 8,
  64. 12, 33, 33, 42, 25, 28, 39, 31, 28, 17,
  65. 22, 18, 18, 12, 15, 31, 17, 18, 65, 65,
  66. 53, 13
  67. } ;
  68. static short int d[43] =
  69. { 0,
  70. 41, 41, 40, 40, 40, 42, 40, 40, 42, 40,
  71. 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
  72. 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
  73. 40, 40, 40, 40, 40, 40, 40, 40, 40,-32767,
  74. 40, 40
  75. } ;
  76. static short int n[90] =
  77. { 0,
  78. 3, 3, 4, 3, 3, 3, 5, 3, 17, 21,
  79. 17, 21, 19, 21, 9, 21, 36, 22, 36, 37,
  80. 39, 22, 38, 7, 3, 3, 4, 3, 3, 3,
  81. 5, 3, 36, 35, 36, 37, 34, 33, 32, 31,
  82. 30, 29, 28, 27, 26, 25, 24, 7, 17, 18,
  83. 17, 23, 19, 6, 6, 20, 16, 15, 14, 13,
  84. 12, 11, 8, 10, 8, 40, 40, 40, 40, 40,
  85. 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
  86. 40, 40, 40, 40, 40, 40, 40, 40, 40
  87. } ;
  88. static short int c[90] =
  89. { 0,
  90. 1, 1, 1, 1, 1, 1, 1, 1, 17, 20,
  91. 17, 20, 17, 21, 42, 21, 35, 20, 35, 35,
  92. 38, 21, 37, 1, 2, 2, 2, 2, 2, 2,
  93. 2, 2, 36, 34, 36, 36, 33, 32, 31, 30,
  94. 29, 28, 27, 26, 25, 24, 23, 2, 16, 16,
  95. 16, 22, 16, 41, 41, 19, 15, 14, 13, 12,
  96. 11, 10, 8, 7, 5, 40, 40, 40, 40, 40,
  97. 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
  98. 40, 40, 40, 40, 40, 40, 40, 40, 40
  99. } ;
  100. /* these declarations have to come after the section 1 code or lint gets
  101. * confused about whether the variables are used
  102. */
  103. FILE *yyin, *yyout;
  104. /* these variables are all declared out here so that section 3 code can
  105. * manipulate them
  106. */
  107. static int yy_start, yy_b_buf_p, yy_c_buf_p, yy_e_buf_p;
  108. static int yy_saw_eof, yy_init = 1;
  109. /* yy_ch_buf has to be 1 character longer than YY_BUF_SIZE, since when
  110. * setting up yytext we can try to put a '\0' just past the end of the
  111. * matched text
  112. */
  113. static char yy_ch_buf[YY_BUF_SIZE + 1];
  114. static int yy_st_buf[YY_BUF_SIZE];
  115. static char yy_hold_char;
  116. char *yytext;
  117. static int yyleng;
  118. YY_DECL
  119. {
  120. int yy_n_chars, yy_lp, yy_iii, yy_buf_pos, yy_act;
  121. #ifdef FLEX_REJECT_ENABLED
  122. int yy_full_match;
  123. #endif
  124. if ( yy_init )
  125. {
  126. VC_PRINTF( "Init\n");
  127. YY_INIT;
  128. yy_start = 1;
  129. yy_init = 0;
  130. }
  131. goto get_next_token;
  132. do_action:
  133. VC_PRINTF( "do_action\n");
  134. #ifdef FLEX_REJECT_ENABLED
  135. /* remember matched text in case we back up due to trailing context */
  136. yy_full_match = yy_c_buf_p;
  137. #endif
  138. for ( ; ; )
  139. {
  140. YY_DO_BEFORE_ACTION
  141. VC_PRINTF( "For loop \n");
  142. #ifdef FLEX_DEBUG
  143. fprintf( stderr, "--accepting rule #%d\n", yy_act );
  144. #endif
  145. switch ( yy_act )
  146. {
  147. case 1:
  148. {
  149. int Token;
  150. VC_PRINTF(" Case 1\n");
  151. if( Token = IsToken() )
  152. {
  153. return Token;
  154. }
  155. else
  156. LexInstall_ID();
  157. return ID;
  158. }
  159. break;
  160. case 2:
  161. {
  162. VC_PRINTF(" Case 2\n");
  163. Line++;
  164. return TOKEN_END_CASE;
  165. }
  166. break;
  167. case 3:
  168. {
  169. VC_PRINTF(" Case 3\n");
  170. Line++;
  171. return TOKEN_END_CASE;
  172. }
  173. break;
  174. case 4:
  175. {
  176. VC_PRINTF(" Case 4\n");
  177. LexInstall_Number();
  178. return NUMBER;
  179. }
  180. break;
  181. case 5:
  182. {
  183. VC_PRINTF(" Case 5\n");
  184. Line++;
  185. yylval.yycharval = '\n';
  186. return TOKEN_CHAR;
  187. }
  188. break;
  189. case 6:
  190. {
  191. VC_PRINTF(" Case 6\n");
  192. yylval.yycharval = yytext[0];
  193. return TOKEN_CHAR;
  194. }
  195. break;
  196. case 7:
  197. YY_DEFAULT_ACTION;
  198. YY_BREAK
  199. case YY_NEW_FILE:
  200. break; /* begin reading from new file */
  201. case YY_END_TOK:
  202. return ( YY_END_TOK );
  203. default:
  204. YY_FATAL_ERROR( "fatal flex scanner internal error" );
  205. }
  206. get_next_token:
  207. {
  208. register int yy_curst;
  209. register char yy_sym;
  210. VC_PRINTF( "Get_next_token 1\n");
  211. YY_DO_BEFORE_SCAN
  212. /* set up to begin running DFA */
  213. yy_curst = yy_start;
  214. if ( yy_ch_buf[yy_c_buf_p] == '\n' )
  215. ++yy_curst;
  216. /* yy_b_buf_p points to the position in yy_ch_buf
  217. * of the start of the current run.
  218. */
  219. yy_b_buf_p = yy_c_buf_p + 1;
  220. VC_PRINTF( "Get_next_token 2\n");
  221. do /* until the machine jams */
  222. {
  223. if ( yy_c_buf_p == yy_e_buf_p )
  224. { /* need more input */
  225. if ( yy_e_buf_p >= YY_BUF_LIM )
  226. { /* not enough room to do another read */
  227. /* see if we can make some room for more chars */
  228. VC_PRINTF( "Get_next_token 4\n");
  229. yy_n_chars = yy_e_buf_p - yy_b_buf_p;
  230. if ( yy_n_chars >= 0 )
  231. /* shift down buffer to make room */
  232. for ( yy_iii = 0; yy_iii <= yy_n_chars; ++yy_iii )
  233. {
  234. VC_PRINTF( "Get_next_token 5\n");
  235. yy_buf_pos = yy_b_buf_p + yy_iii;
  236. yy_ch_buf[yy_iii] = yy_ch_buf[yy_buf_pos];
  237. yy_st_buf[yy_iii] = yy_st_buf[yy_buf_pos];
  238. }
  239. yy_b_buf_p = 0;
  240. yy_e_buf_p = yy_n_chars;
  241. if ( yy_e_buf_p >= YY_BUF_LIM )
  242. YY_FATAL_ERROR( "flex input buffer overflowed" );
  243. yy_c_buf_p = yy_e_buf_p;
  244. }
  245. else if ( yy_saw_eof )
  246. {
  247. VC_PRINTF( "Get_next_token 6\n");
  248. saweof: if ( yy_b_buf_p > yy_e_buf_p )
  249. {
  250. if ( yywrap() )
  251. {
  252. yy_act = YY_END_TOK;
  253. goto do_action;
  254. }
  255. else
  256. {
  257. YY_INIT;
  258. yy_act = YY_NEW_FILE;
  259. goto do_action;
  260. }
  261. }
  262. else /* do a jam to eat up more input */
  263. {
  264. #ifndef FLEX_INTERACTIVE_SCANNER
  265. /* we're going to decrement yy_c_buf_p upon doing
  266. * the jam. In this case, that's wrong, since
  267. * it points to the last non-jam character. So
  268. * we increment it now to counter the decrement.
  269. */
  270. ++yy_c_buf_p;
  271. #endif
  272. VC_PRINTF( "Get_next_token 7\n");
  273. break;
  274. }
  275. }
  276. VC_PRINTF( "Get_next_token 8\n");
  277. YY_INPUT( (yy_ch_buf + yy_c_buf_p + 1), yy_n_chars,
  278. YY_MAX_LINE );
  279. if ( yy_n_chars == YY_NULL )
  280. {
  281. VC_PRINTF( "Get_next_token 9\n");
  282. if ( yy_saw_eof )
  283. YY_FATAL_ERROR( "flex scanner saw EOF twice - shouldn't happen" );
  284. yy_saw_eof = 1;
  285. goto saweof;
  286. }
  287. yy_e_buf_p += yy_n_chars;
  288. }
  289. ++yy_c_buf_p;
  290. #ifdef FLEX_USE_ECS
  291. yy_sym = e[yy_ch_buf[yy_c_buf_p]];
  292. #else
  293. yy_sym = yy_ch_buf[yy_c_buf_p];
  294. #endif
  295. VC_PRINTF( "Get_next_token 10\n");
  296. #ifdef FLEX_FULL_TABLE
  297. yy_curst = n[yy_curst][yy_sym];
  298. #else /* get next state from compressed table */
  299. while ( c[b[yy_curst] + yy_sym] != yy_curst )
  300. {
  301. yy_curst = d[yy_curst];
  302. #ifdef FLEX_USE_MECS
  303. /* we've arrange it so that templates are never chained
  304. * to one another. This means we can afford make a
  305. * very simple test to see if we need to convert to
  306. * yy_sym's meta-equivalence class without worrying
  307. * about erroneously looking up the meta-equivalence
  308. * class twice
  309. */
  310. if ( yy_curst >= YY_TEMPLATE )
  311. yy_sym = m[yy_sym];
  312. #endif
  313. }
  314. yy_curst = n[b[yy_curst] + yy_sym];
  315. #endif
  316. VC_PRINTF( "Get_next_token 11\n");
  317. yy_st_buf[yy_c_buf_p] = yy_curst;
  318. }
  319. #ifdef FLEX_INTERACTIVE_SCANNER
  320. while ( b[yy_curst] != YY_JAM_BASE );
  321. #else
  322. while ( yy_curst != YY_JAM );
  323. --yy_c_buf_p; /* put back character we jammed on */
  324. #endif
  325. if ( yy_c_buf_p >= yy_b_buf_p )
  326. { /* we matched some text */
  327. yy_curst = yy_st_buf[yy_c_buf_p];
  328. yy_lp = l[yy_curst];
  329. #ifdef FLEX_REJECT_ENABLED
  330. find_rule: /* we branch to this label when doing a REJECT */
  331. #endif
  332. for ( ; ; ) /* until we find what rule we matched */
  333. {
  334. #ifdef FLEX_REJECT_ENABLED
  335. if ( yy_lp && yy_lp < l[yy_curst + 1] )
  336. {
  337. yy_act = a[yy_lp];
  338. goto do_action; /* "continue 2" */
  339. }
  340. #else
  341. if ( yy_lp )
  342. {
  343. yy_act = yy_lp;
  344. goto do_action; /* "continue 2" */
  345. }
  346. #endif
  347. if ( --yy_c_buf_p < yy_b_buf_p )
  348. break;
  349. yy_curst = yy_st_buf[yy_c_buf_p];
  350. yy_lp = l[yy_curst];
  351. }
  352. }
  353. YY_FATAL_ERROR( "no match in flex scanner - possible NULL in input" );
  354. }
  355. }
  356. /*NOTREACHED*/
  357. }
  358. /****************************************************************************
  359. * utility routines
  360. ****************************************************************************/
  361. /**************************************************************************
  362. *** install parser value stack
  363. **************************************************************************/
  364. void
  365. LexInstall_ID()
  366. {
  367. strncpy( LocalBuffer, yytext, yyleng );
  368. LocalBuffer[ yyleng ] = '\0';
  369. yylval.yystring = LocalBuffer;
  370. }
  371. void
  372. LexInstall_Number()
  373. {
  374. yylval.yynumber = atoi(yytext);
  375. }
  376. /**************************************************************************
  377. *** token search
  378. **************************************************************************/
  379. int
  380. IsToken()
  381. {
  382. static char *pTokens[] =
  383. {
  384. "case"
  385. ,"___a_r_u_myact"
  386. ,"___a_r_u_start"
  387. ,"___a_r_u_end"
  388. };
  389. static int Tokens[] =
  390. {
  391. TOKEN_CASE
  392. ,TOKEN_MYACT
  393. ,TOKEN_START
  394. ,TOKEN_END
  395. };
  396. int i = 0;
  397. int Token;
  398. while( i < sizeof(pTokens) / sizeof(char *) )
  399. {
  400. if(strcmp( pTokens[i] , yytext ) == 0 )
  401. {
  402. Token = Tokens[i];
  403. if(Token == TOKEN_CASE)
  404. {
  405. if(!ActionSensed || Incase)
  406. return 0;
  407. }
  408. return Token;
  409. }
  410. ++i;
  411. }
  412. return 0;
  413. }