word_count_functor_flex.cpp 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576
  1. #line 2 "c:\\CVS\\boost\\libs\\spirit\\example\\lex\\word_count_functor_flex.cpp"
  2. /* A lexical scanner generated by flex */
  3. /* Scanner skeleton version:
  4. * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
  5. */
  6. #define FLEX_SCANNER
  7. #define YY_FLEX_MAJOR_VERSION 2
  8. #define YY_FLEX_MINOR_VERSION 5
  9. #include <stdio.h>
  10. #include <errno.h>
  11. /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
  12. #ifdef c_plusplus
  13. #ifndef __cplusplus
  14. #define __cplusplus
  15. #endif
  16. #endif
  17. #ifdef __cplusplus
  18. #include <stdlib.h>
  19. #ifndef _WIN32
  20. #include <unistd.h>
  21. #endif
  22. /* Use prototypes in function declarations. */
  23. #define YY_USE_PROTOS
  24. /* The "const" storage-class-modifier is valid. */
  25. #define YY_USE_CONST
  26. #else /* ! __cplusplus */
  27. #if __STDC__
  28. #define YY_USE_PROTOS
  29. #define YY_USE_CONST
  30. #endif /* __STDC__ */
  31. #endif /* ! __cplusplus */
  32. #ifdef __TURBOC__
  33. #pragma warn -rch
  34. #pragma warn -use
  35. #include <io.h>
  36. #include <stdlib.h>
  37. #define YY_USE_CONST
  38. #define YY_USE_PROTOS
  39. #endif
  40. #ifdef YY_USE_CONST
  41. #define yyconst const
  42. #else
  43. #define yyconst
  44. #endif
  45. #ifdef YY_USE_PROTOS
  46. #define YY_PROTO(proto) proto
  47. #else
  48. #define YY_PROTO(proto) ()
  49. #endif
  50. /* Returned upon end-of-file. */
  51. #define YY_NULL 0
  52. /* Promotes a possibly negative, possibly signed char to an unsigned
  53. * integer for use as an array index. If the signed char is negative,
  54. * we want to instead treat it as an 8-bit unsigned char, hence the
  55. * double cast.
  56. */
  57. #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
  58. /* Enter a start condition. This macro really ought to take a parameter,
  59. * but we do it the disgusting crufty way forced on us by the ()-less
  60. * definition of BEGIN.
  61. */
  62. #define BEGIN yy_start = 1 + 2 *
  63. /* Translate the current start state into a value that can be later handed
  64. * to BEGIN to return to the state. The YYSTATE alias is for lex
  65. * compatibility.
  66. */
  67. #define YY_START ((yy_start - 1) / 2)
  68. #define YYSTATE YY_START
  69. /* Action number for EOF rule of a given start state. */
  70. #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  71. /* Special action meaning "start processing a new file". */
  72. #define YY_NEW_FILE yyrestart( yyin )
  73. #define YY_END_OF_BUFFER_CHAR 0
  74. /* Size of default input buffer. */
  75. #define YY_BUF_SIZE 16384
  76. typedef struct yy_buffer_state *YY_BUFFER_STATE;
  77. extern int yyleng;
  78. extern FILE *yyin, *yyout;
  79. #define EOB_ACT_CONTINUE_SCAN 0
  80. #define EOB_ACT_END_OF_FILE 1
  81. #define EOB_ACT_LAST_MATCH 2
  82. /* The funky do-while in the following #define is used to turn the definition
  83. * int a single C statement (which needs a semi-colon terminator). This
  84. * avoids problems with code like:
  85. *
  86. * if ( condition_holds )
  87. * yyless( 5 );
  88. * else
  89. * do_something_else();
  90. *
  91. * Prior to using the do-while the compiler would get upset at the
  92. * "else" because it interpreted the "if" statement as being all
  93. * done when it reached the ';' after the yyless() call.
  94. */
  95. /* Return all but the first 'n' matched characters back to the input stream. */
  96. #define yyless(n) \
  97. do \
  98. { \
  99. /* Undo effects of setting up yytext. */ \
  100. *yy_cp = yy_hold_char; \
  101. YY_RESTORE_YY_MORE_OFFSET \
  102. yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
  103. YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  104. } \
  105. while ( 0 )
  106. #define unput(c) yyunput( c, yytext_ptr )
  107. /* The following is because we cannot portably get our hands on size_t
  108. * (without autoconf's help, which isn't available because we want
  109. * flex-generated scanners to compile on their own).
  110. */
  111. typedef unsigned int yy_size_t;
  112. struct yy_buffer_state
  113. {
  114. FILE *yy_input_file;
  115. char *yy_ch_buf; /* input buffer */
  116. char *yy_buf_pos; /* current position in input buffer */
  117. /* Size of input buffer in bytes, not including room for EOB
  118. * characters.
  119. */
  120. yy_size_t yy_buf_size;
  121. /* Number of characters read into yy_ch_buf, not including EOB
  122. * characters.
  123. */
  124. int yy_n_chars;
  125. /* Whether we "own" the buffer - i.e., we know we created it,
  126. * and can realloc() it to grow it, and should free() it to
  127. * delete it.
  128. */
  129. int yy_is_our_buffer;
  130. /* Whether this is an "interactive" input source; if so, and
  131. * if we're using stdio for input, then we want to use getc()
  132. * instead of fread(), to make sure we stop fetching input after
  133. * each newline.
  134. */
  135. int yy_is_interactive;
  136. /* Whether we're considered to be at the beginning of a line.
  137. * If so, '^' rules will be active on the next match, otherwise
  138. * not.
  139. */
  140. int yy_at_bol;
  141. /* Whether to try to fill the input buffer when we reach the
  142. * end of it.
  143. */
  144. int yy_fill_buffer;
  145. int yy_buffer_status;
  146. #define YY_BUFFER_NEW 0
  147. #define YY_BUFFER_NORMAL 1
  148. /* When an EOF's been seen but there's still some text to process
  149. * then we mark the buffer as YY_EOF_PENDING, to indicate that we
  150. * shouldn't try reading from the input source any more. We might
  151. * still have a bunch of tokens to match, though, because of
  152. * possible backing-up.
  153. *
  154. * When we actually see the EOF, we change the status to "new"
  155. * (via yyrestart()), so that the user can continue scanning by
  156. * just pointing yyin at a new input file.
  157. */
  158. #define YY_BUFFER_EOF_PENDING 2
  159. };
  160. static YY_BUFFER_STATE yy_current_buffer = 0;
  161. /* We provide macros for accessing buffer states in case in the
  162. * future we want to put the buffer states in a more general
  163. * "scanner state".
  164. */
  165. #define YY_CURRENT_BUFFER yy_current_buffer
  166. /* yy_hold_char holds the character lost when yytext is formed. */
  167. static char yy_hold_char;
  168. static int yy_n_chars; /* number of characters read into yy_ch_buf */
  169. int yyleng;
  170. /* Points to current character in buffer. */
  171. static char *yy_c_buf_p = (char *) 0;
  172. static int yy_init = 1; /* whether we need to initialize */
  173. static int yy_start = 0; /* start state number */
  174. /* Flag which is used to allow yywrap()'s to do buffer switches
  175. * instead of setting up a fresh yyin. A bit of a hack ...
  176. */
  177. static int yy_did_buffer_switch_on_eof;
  178. void yyrestart YY_PROTO(( FILE *input_file ));
  179. void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
  180. void yy_load_buffer_state YY_PROTO(( void ));
  181. YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
  182. void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
  183. void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
  184. void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
  185. #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
  186. YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
  187. YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
  188. YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
  189. static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
  190. static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
  191. static void yy_flex_free YY_PROTO(( void * ));
  192. #define yy_new_buffer yy_create_buffer
  193. #define yy_set_interactive(is_interactive) \
  194. { \
  195. if ( ! yy_current_buffer ) \
  196. yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
  197. yy_current_buffer->yy_is_interactive = is_interactive; \
  198. }
  199. #define yy_set_bol(at_bol) \
  200. { \
  201. if ( ! yy_current_buffer ) \
  202. yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
  203. yy_current_buffer->yy_at_bol = at_bol; \
  204. }
  205. #define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
  206. typedef unsigned char YY_CHAR;
  207. FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
  208. typedef int yy_state_type;
  209. extern char *yytext;
  210. #define yytext_ptr yytext
  211. static yy_state_type yy_get_previous_state YY_PROTO(( void ));
  212. static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
  213. static int yy_get_next_buffer YY_PROTO(( void ));
  214. static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
  215. /* Done after the current pattern has been matched and before the
  216. * corresponding action - sets up yytext.
  217. */
  218. #define YY_DO_BEFORE_ACTION \
  219. yytext_ptr = yy_bp; \
  220. yyleng = (int) (yy_cp - yy_bp); \
  221. yy_hold_char = *yy_cp; \
  222. *yy_cp = '\0'; \
  223. yy_c_buf_p = yy_cp;
  224. #define YY_NUM_RULES 4
  225. #define YY_END_OF_BUFFER 5
  226. static yyconst short int yy_accept[9] =
  227. { 0,
  228. 0, 0, 5, 1, 3, 2, 1, 0
  229. } ;
  230. static yyconst int yy_ec[256] =
  231. { 0,
  232. 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
  233. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  234. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  235. 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
  236. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  237. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  238. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  239. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  240. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  241. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  242. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  243. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  244. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  245. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  246. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  247. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  248. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  249. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  250. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  251. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  252. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  253. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  254. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  255. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  256. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  257. 1, 1, 1, 1, 1
  258. } ;
  259. static yyconst int yy_meta[4] =
  260. { 0,
  261. 1, 2, 2
  262. } ;
  263. static yyconst short int yy_base[10] =
  264. { 0,
  265. 0, 0, 5, 0, 6, 6, 0, 6, 3
  266. } ;
  267. static yyconst short int yy_def[10] =
  268. { 0,
  269. 8, 1, 8, 9, 8, 8, 9, 0, 8
  270. } ;
  271. static yyconst short int yy_nxt[10] =
  272. { 0,
  273. 4, 5, 6, 7, 8, 3, 8, 8, 8
  274. } ;
  275. static yyconst short int yy_chk[10] =
  276. { 0,
  277. 1, 1, 1, 9, 3, 8, 8, 8, 8
  278. } ;
  279. static yy_state_type yy_last_accepting_state;
  280. static char *yy_last_accepting_cpos;
  281. /* The intent behind this definition is that it'll catch
  282. * any uses of REJECT which flex missed.
  283. */
  284. #define REJECT reject_used_but_not_detected
  285. #define yymore() yymore_used_but_not_detected
  286. #define YY_MORE_ADJ 0
  287. #define YY_RESTORE_YY_MORE_OFFSET
  288. char *yytext;
  289. #line 1 "c:\\CVS\\boost\\libs\\spirit\\example\\lex\\word_count_functor.flex"
  290. #define INITIAL 0
  291. #line 2 "c:\\CVS\\boost\\libs\\spirit\\example\\lex\\word_count_functor.flex"
  292. // Copyright (c) 2001-2010 Hartmut Kaiser
  293. //
  294. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  295. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  296. #include <boost/timer.hpp>
  297. #if defined(_WIN32)
  298. #include <io.h>
  299. #endif
  300. #define ID_WORD 1000
  301. #define ID_EOL 1001
  302. #define ID_CHAR 1002
  303. #line 380 "c:\\CVS\\boost\\libs\\spirit\\example\\lex\\word_count_functor_flex.cpp"
  304. /* Macros after this point can all be overridden by user definitions in
  305. * section 1.
  306. */
  307. #ifndef YY_SKIP_YYWRAP
  308. #ifdef __cplusplus
  309. extern "C" int yywrap YY_PROTO(( void ));
  310. #else
  311. extern int yywrap YY_PROTO(( void ));
  312. #endif
  313. #endif
  314. #ifndef YY_NO_UNPUT
  315. static void yyunput YY_PROTO(( int c, char *buf_ptr ));
  316. #endif
  317. #ifndef yytext_ptr
  318. static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
  319. #endif
  320. #ifdef YY_NEED_STRLEN
  321. static int yy_flex_strlen YY_PROTO(( yyconst char * ));
  322. #endif
  323. #ifndef YY_NO_INPUT
  324. #ifdef __cplusplus
  325. static int yyinput YY_PROTO(( void ));
  326. #else
  327. static int input YY_PROTO(( void ));
  328. #endif
  329. #endif
  330. #if YY_STACK_USED
  331. static int yy_start_stack_ptr = 0;
  332. static int yy_start_stack_depth = 0;
  333. static int *yy_start_stack = 0;
  334. #ifndef YY_NO_PUSH_STATE
  335. static void yy_push_state YY_PROTO(( int new_state ));
  336. #endif
  337. #ifndef YY_NO_POP_STATE
  338. static void yy_pop_state YY_PROTO(( void ));
  339. #endif
  340. #ifndef YY_NO_TOP_STATE
  341. static int yy_top_state YY_PROTO(( void ));
  342. #endif
  343. #else
  344. #define YY_NO_PUSH_STATE 1
  345. #define YY_NO_POP_STATE 1
  346. #define YY_NO_TOP_STATE 1
  347. #endif
  348. #ifdef YY_MALLOC_DECL
  349. YY_MALLOC_DECL
  350. #else
  351. #if __STDC__
  352. #ifndef __cplusplus
  353. #include <stdlib.h>
  354. #endif
  355. #else
  356. /* Just try to get by without declaring the routines. This will fail
  357. * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
  358. * or sizeof(void*) != sizeof(int).
  359. */
  360. #endif
  361. #endif
  362. /* Amount of stuff to slurp up with each read. */
  363. #ifndef YY_READ_BUF_SIZE
  364. #define YY_READ_BUF_SIZE 8192
  365. #endif
  366. /* Copy whatever the last rule matched to the standard output. */
  367. #ifndef ECHO
  368. /* This used to be an fputs(), but since the string might contain NUL's,
  369. * we now use fwrite().
  370. */
  371. #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
  372. #endif
  373. /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
  374. * is returned in "result".
  375. */
  376. #ifndef YY_INPUT
  377. #define YY_INPUT(buf,result,max_size) \
  378. if ( yy_current_buffer->yy_is_interactive ) \
  379. { \
  380. int c = '*', n; \
  381. for ( n = 0; n < max_size && \
  382. (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
  383. buf[n] = (char) c; \
  384. if ( c == '\n' ) \
  385. buf[n++] = (char) c; \
  386. if ( c == EOF && ferror( yyin ) ) \
  387. YY_FATAL_ERROR( "input in flex scanner failed" ); \
  388. result = n; \
  389. } \
  390. else \
  391. { \
  392. errno=0; \
  393. while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
  394. { \
  395. if( errno != EINTR) \
  396. { \
  397. YY_FATAL_ERROR( "input in flex scanner failed" ); \
  398. break; \
  399. } \
  400. errno=0; \
  401. clearerr(yyin); \
  402. } \
  403. }
  404. #endif
  405. /* No semi-colon after return; correct usage is to write "yyterminate();" -
  406. * we don't want an extra ';' after the "return" because that will cause
  407. * some compilers to complain about unreachable statements.
  408. */
  409. #ifndef yyterminate
  410. #define yyterminate() return YY_NULL
  411. #endif
  412. /* Number of entries by which start-condition stack grows. */
  413. #ifndef YY_START_STACK_INCR
  414. #define YY_START_STACK_INCR 25
  415. #endif
  416. /* Report a fatal error. */
  417. #ifndef YY_FATAL_ERROR
  418. #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
  419. #endif
  420. /* Default declaration of generated scanner - a define so the user can
  421. * easily add parameters.
  422. */
  423. #ifndef YY_DECL
  424. #define YY_DECL int yylex YY_PROTO(( void ))
  425. #endif
  426. /* Code executed at the beginning of each rule, after yytext and yyleng
  427. * have been set up.
  428. */
  429. #ifndef YY_USER_ACTION
  430. #define YY_USER_ACTION
  431. #endif
  432. /* Code executed at the end of each rule. */
  433. #ifndef YY_BREAK
  434. #define YY_BREAK break;
  435. #endif
  436. #define YY_RULE_SETUP \
  437. YY_USER_ACTION
  438. YY_DECL
  439. {
  440. register yy_state_type yy_current_state;
  441. register char *yy_cp, *yy_bp;
  442. register int yy_act;
  443. #line 16 "c:\\CVS\\boost\\libs\\spirit\\example\\lex\\word_count_functor.flex"
  444. #line 544 "c:\\CVS\\boost\\libs\\spirit\\example\\lex\\word_count_functor_flex.cpp"
  445. if ( yy_init )
  446. {
  447. yy_init = 0;
  448. #ifdef YY_USER_INIT
  449. YY_USER_INIT;
  450. #endif
  451. if ( ! yy_start )
  452. yy_start = 1; /* first start state */
  453. if ( ! yyin )
  454. yyin = stdin;
  455. if ( ! yyout )
  456. yyout = stdout;
  457. if ( ! yy_current_buffer )
  458. yy_current_buffer =
  459. yy_create_buffer( yyin, YY_BUF_SIZE );
  460. yy_load_buffer_state();
  461. }
  462. while ( 1 ) /* loops until end-of-file is reached */
  463. {
  464. yy_cp = yy_c_buf_p;
  465. /* Support of yytext. */
  466. *yy_cp = yy_hold_char;
  467. /* yy_bp points to the position in yy_ch_buf of the start of
  468. * the current run.
  469. */
  470. yy_bp = yy_cp;
  471. yy_current_state = yy_start;
  472. yy_match:
  473. do
  474. {
  475. register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
  476. if ( yy_accept[yy_current_state] )
  477. {
  478. yy_last_accepting_state = yy_current_state;
  479. yy_last_accepting_cpos = yy_cp;
  480. }
  481. while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  482. {
  483. yy_current_state = (int) yy_def[yy_current_state];
  484. if ( yy_current_state >= 9 )
  485. yy_c = yy_meta[(unsigned int) yy_c];
  486. }
  487. yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
  488. ++yy_cp;
  489. }
  490. while ( yy_base[yy_current_state] != 6 );
  491. yy_find_action:
  492. yy_act = yy_accept[yy_current_state];
  493. if ( yy_act == 0 )
  494. { /* have to back up */
  495. yy_cp = yy_last_accepting_cpos;
  496. yy_current_state = yy_last_accepting_state;
  497. yy_act = yy_accept[yy_current_state];
  498. }
  499. YY_DO_BEFORE_ACTION;
  500. do_action: /* This label is used only to access EOF actions. */
  501. switch ( yy_act )
  502. { /* beginning of action switch */
  503. case 0: /* must back up */
  504. /* undo the effects of YY_DO_BEFORE_ACTION */
  505. *yy_cp = yy_hold_char;
  506. yy_cp = yy_last_accepting_cpos;
  507. yy_current_state = yy_last_accepting_state;
  508. goto yy_find_action;
  509. case 1:
  510. YY_RULE_SETUP
  511. #line 17 "c:\\CVS\\boost\\libs\\spirit\\example\\lex\\word_count_functor.flex"
  512. { return ID_WORD; }
  513. YY_BREAK
  514. case 2:
  515. YY_RULE_SETUP
  516. #line 18 "c:\\CVS\\boost\\libs\\spirit\\example\\lex\\word_count_functor.flex"
  517. { return ID_EOL; }
  518. YY_BREAK
  519. case 3:
  520. YY_RULE_SETUP
  521. #line 19 "c:\\CVS\\boost\\libs\\spirit\\example\\lex\\word_count_functor.flex"
  522. { return ID_CHAR; }
  523. YY_BREAK
  524. case 4:
  525. YY_RULE_SETUP
  526. #line 20 "c:\\CVS\\boost\\libs\\spirit\\example\\lex\\word_count_functor.flex"
  527. ECHO;
  528. YY_BREAK
  529. #line 647 "c:\\CVS\\boost\\libs\\spirit\\example\\lex\\word_count_functor_flex.cpp"
  530. case YY_STATE_EOF(INITIAL):
  531. yyterminate();
  532. case YY_END_OF_BUFFER:
  533. {
  534. /* Amount of text matched not including the EOB char. */
  535. int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
  536. /* Undo the effects of YY_DO_BEFORE_ACTION. */
  537. *yy_cp = yy_hold_char;
  538. YY_RESTORE_YY_MORE_OFFSET
  539. if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
  540. {
  541. /* We're scanning a new file or input source. It's
  542. * possible that this happened because the user
  543. * just pointed yyin at a new source and called
  544. * yylex(). If so, then we have to assure
  545. * consistency between yy_current_buffer and our
  546. * globals. Here is the right place to do so, because
  547. * this is the first action (other than possibly a
  548. * back-up) that will match for the new input source.
  549. */
  550. yy_n_chars = yy_current_buffer->yy_n_chars;
  551. yy_current_buffer->yy_input_file = yyin;
  552. yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
  553. }
  554. /* Note that here we test for yy_c_buf_p "<=" to the position
  555. * of the first EOB in the buffer, since yy_c_buf_p will
  556. * already have been incremented past the NUL character
  557. * (since all states make transitions on EOB to the
  558. * end-of-buffer state). Contrast this with the test
  559. * in input().
  560. */
  561. if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  562. { /* This was really a NUL. */
  563. yy_state_type yy_next_state;
  564. yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
  565. yy_current_state = yy_get_previous_state();
  566. /* Okay, we're now positioned to make the NUL
  567. * transition. We couldn't have
  568. * yy_get_previous_state() go ahead and do it
  569. * for us because it doesn't know how to deal
  570. * with the possibility of jamming (and we don't
  571. * want to build jamming into it because then it
  572. * will run more slowly).
  573. */
  574. yy_next_state = yy_try_NUL_trans( yy_current_state );
  575. yy_bp = yytext_ptr + YY_MORE_ADJ;
  576. if ( yy_next_state )
  577. {
  578. /* Consume the NUL. */
  579. yy_cp = ++yy_c_buf_p;
  580. yy_current_state = yy_next_state;
  581. goto yy_match;
  582. }
  583. else
  584. {
  585. yy_cp = yy_c_buf_p;
  586. goto yy_find_action;
  587. }
  588. }
  589. else switch ( yy_get_next_buffer() )
  590. {
  591. case EOB_ACT_END_OF_FILE:
  592. {
  593. yy_did_buffer_switch_on_eof = 0;
  594. if ( yywrap() )
  595. {
  596. /* Note: because we've taken care in
  597. * yy_get_next_buffer() to have set up
  598. * yytext, we can now set up
  599. * yy_c_buf_p so that if some total
  600. * hoser (like flex itself) wants to
  601. * call the scanner after we return the
  602. * YY_NULL, it'll still work - another
  603. * YY_NULL will get returned.
  604. */
  605. yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
  606. yy_act = YY_STATE_EOF(YY_START);
  607. goto do_action;
  608. }
  609. else
  610. {
  611. if ( ! yy_did_buffer_switch_on_eof )
  612. YY_NEW_FILE;
  613. }
  614. break;
  615. }
  616. case EOB_ACT_CONTINUE_SCAN:
  617. yy_c_buf_p =
  618. yytext_ptr + yy_amount_of_matched_text;
  619. yy_current_state = yy_get_previous_state();
  620. yy_cp = yy_c_buf_p;
  621. yy_bp = yytext_ptr + YY_MORE_ADJ;
  622. goto yy_match;
  623. case EOB_ACT_LAST_MATCH:
  624. yy_c_buf_p =
  625. &yy_current_buffer->yy_ch_buf[yy_n_chars];
  626. yy_current_state = yy_get_previous_state();
  627. yy_cp = yy_c_buf_p;
  628. yy_bp = yytext_ptr + YY_MORE_ADJ;
  629. goto yy_find_action;
  630. }
  631. break;
  632. }
  633. default:
  634. YY_FATAL_ERROR(
  635. "fatal flex scanner internal error--no action found" );
  636. } /* end of action switch */
  637. } /* end of scanning one token */
  638. } /* end of yylex */
  639. /* yy_get_next_buffer - try to read in a new buffer
  640. *
  641. * Returns a code representing an action:
  642. * EOB_ACT_LAST_MATCH -
  643. * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
  644. * EOB_ACT_END_OF_FILE - end of file
  645. */
  646. static int yy_get_next_buffer()
  647. {
  648. register char *dest = yy_current_buffer->yy_ch_buf;
  649. register char *source = yytext_ptr;
  650. register int number_to_move, i;
  651. int ret_val;
  652. if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
  653. YY_FATAL_ERROR(
  654. "fatal flex scanner internal error--end of buffer missed" );
  655. if ( yy_current_buffer->yy_fill_buffer == 0 )
  656. { /* Don't try to fill the buffer, so this is an EOF. */
  657. if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
  658. {
  659. /* We matched a single character, the EOB, so
  660. * treat this as a final EOF.
  661. */
  662. return EOB_ACT_END_OF_FILE;
  663. }
  664. else
  665. {
  666. /* We matched some text prior to the EOB, first
  667. * process it.
  668. */
  669. return EOB_ACT_LAST_MATCH;
  670. }
  671. }
  672. /* Try to read more data. */
  673. /* First move last chars to start of buffer. */
  674. number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
  675. for ( i = 0; i < number_to_move; ++i )
  676. *(dest++) = *(source++);
  677. if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
  678. /* don't do the read, it's not guaranteed to return an EOF,
  679. * just force an EOF
  680. */
  681. yy_current_buffer->yy_n_chars = yy_n_chars = 0;
  682. else
  683. {
  684. int num_to_read =
  685. yy_current_buffer->yy_buf_size - number_to_move - 1;
  686. while ( num_to_read <= 0 )
  687. { /* Not enough room in the buffer - grow it. */
  688. #ifdef YY_USES_REJECT
  689. YY_FATAL_ERROR(
  690. "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
  691. #else
  692. /* just a shorter name for the current buffer */
  693. YY_BUFFER_STATE b = yy_current_buffer;
  694. int yy_c_buf_p_offset =
  695. (int) (yy_c_buf_p - b->yy_ch_buf);
  696. if ( b->yy_is_our_buffer )
  697. {
  698. int new_size = b->yy_buf_size * 2;
  699. if ( new_size <= 0 )
  700. b->yy_buf_size += b->yy_buf_size / 8;
  701. else
  702. b->yy_buf_size *= 2;
  703. b->yy_ch_buf = (char *)
  704. /* Include room in for 2 EOB chars. */
  705. yy_flex_realloc( (void *) b->yy_ch_buf,
  706. b->yy_buf_size + 2 );
  707. }
  708. else
  709. /* Can't grow it, we don't own it. */
  710. b->yy_ch_buf = 0;
  711. if ( ! b->yy_ch_buf )
  712. YY_FATAL_ERROR(
  713. "fatal error - scanner input buffer overflow" );
  714. yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
  715. num_to_read = yy_current_buffer->yy_buf_size -
  716. number_to_move - 1;
  717. #endif
  718. }
  719. if ( num_to_read > YY_READ_BUF_SIZE )
  720. num_to_read = YY_READ_BUF_SIZE;
  721. /* Read in more data. */
  722. YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
  723. yy_n_chars, num_to_read );
  724. yy_current_buffer->yy_n_chars = yy_n_chars;
  725. }
  726. if ( yy_n_chars == 0 )
  727. {
  728. if ( number_to_move == YY_MORE_ADJ )
  729. {
  730. ret_val = EOB_ACT_END_OF_FILE;
  731. yyrestart( yyin );
  732. }
  733. else
  734. {
  735. ret_val = EOB_ACT_LAST_MATCH;
  736. yy_current_buffer->yy_buffer_status =
  737. YY_BUFFER_EOF_PENDING;
  738. }
  739. }
  740. else
  741. ret_val = EOB_ACT_CONTINUE_SCAN;
  742. yy_n_chars += number_to_move;
  743. yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  744. yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  745. yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
  746. return ret_val;
  747. }
  748. /* yy_get_previous_state - get the state just before the EOB char was reached */
  749. static yy_state_type yy_get_previous_state()
  750. {
  751. register yy_state_type yy_current_state;
  752. register char *yy_cp;
  753. yy_current_state = yy_start;
  754. for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
  755. {
  756. register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
  757. if ( yy_accept[yy_current_state] )
  758. {
  759. yy_last_accepting_state = yy_current_state;
  760. yy_last_accepting_cpos = yy_cp;
  761. }
  762. while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  763. {
  764. yy_current_state = (int) yy_def[yy_current_state];
  765. if ( yy_current_state >= 9 )
  766. yy_c = yy_meta[(unsigned int) yy_c];
  767. }
  768. yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
  769. }
  770. return yy_current_state;
  771. }
  772. /* yy_try_NUL_trans - try to make a transition on the NUL character
  773. *
  774. * synopsis
  775. * next_state = yy_try_NUL_trans( current_state );
  776. */
  777. #ifdef YY_USE_PROTOS
  778. static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
  779. #else
  780. static yy_state_type yy_try_NUL_trans( yy_current_state )
  781. yy_state_type yy_current_state;
  782. #endif
  783. {
  784. register int yy_is_jam;
  785. register char *yy_cp = yy_c_buf_p;
  786. register YY_CHAR yy_c = 1;
  787. if ( yy_accept[yy_current_state] )
  788. {
  789. yy_last_accepting_state = yy_current_state;
  790. yy_last_accepting_cpos = yy_cp;
  791. }
  792. while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  793. {
  794. yy_current_state = (int) yy_def[yy_current_state];
  795. if ( yy_current_state >= 9 )
  796. yy_c = yy_meta[(unsigned int) yy_c];
  797. }
  798. yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
  799. yy_is_jam = (yy_current_state == 8);
  800. return yy_is_jam ? 0 : yy_current_state;
  801. }
  802. #ifndef YY_NO_UNPUT
  803. #ifdef YY_USE_PROTOS
  804. static void yyunput( int c, register char *yy_bp )
  805. #else
  806. static void yyunput( c, yy_bp )
  807. int c;
  808. register char *yy_bp;
  809. #endif
  810. {
  811. register char *yy_cp = yy_c_buf_p;
  812. /* undo effects of setting up yytext */
  813. *yy_cp = yy_hold_char;
  814. if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  815. { /* need to shift things up to make room */
  816. /* +2 for EOB chars. */
  817. register int number_to_move = yy_n_chars + 2;
  818. register char *dest = &yy_current_buffer->yy_ch_buf[
  819. yy_current_buffer->yy_buf_size + 2];
  820. register char *source =
  821. &yy_current_buffer->yy_ch_buf[number_to_move];
  822. while ( source > yy_current_buffer->yy_ch_buf )
  823. *--dest = *--source;
  824. yy_cp += (int) (dest - source);
  825. yy_bp += (int) (dest - source);
  826. yy_current_buffer->yy_n_chars =
  827. yy_n_chars = yy_current_buffer->yy_buf_size;
  828. if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  829. YY_FATAL_ERROR( "flex scanner push-back overflow" );
  830. }
  831. *--yy_cp = (char) c;
  832. yytext_ptr = yy_bp;
  833. yy_hold_char = *yy_cp;
  834. yy_c_buf_p = yy_cp;
  835. }
  836. #endif /* ifndef YY_NO_UNPUT */
  837. #ifdef __cplusplus
  838. static int yyinput()
  839. #else
  840. static int input()
  841. #endif
  842. {
  843. int c;
  844. *yy_c_buf_p = yy_hold_char;
  845. if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
  846. {
  847. /* yy_c_buf_p now points to the character we want to return.
  848. * If this occurs *before* the EOB characters, then it's a
  849. * valid NUL; if not, then we've hit the end of the buffer.
  850. */
  851. if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  852. /* This was really a NUL. */
  853. *yy_c_buf_p = '\0';
  854. else
  855. { /* need more input */
  856. int offset = yy_c_buf_p - yytext_ptr;
  857. ++yy_c_buf_p;
  858. switch ( yy_get_next_buffer() )
  859. {
  860. case EOB_ACT_LAST_MATCH:
  861. /* This happens because yy_g_n_b()
  862. * sees that we've accumulated a
  863. * token and flags that we need to
  864. * try matching the token before
  865. * proceeding. But for input(),
  866. * there's no matching to consider.
  867. * So convert the EOB_ACT_LAST_MATCH
  868. * to EOB_ACT_END_OF_FILE.
  869. */
  870. /* Reset buffer status. */
  871. yyrestart( yyin );
  872. /* fall through */
  873. case EOB_ACT_END_OF_FILE:
  874. {
  875. if ( yywrap() )
  876. return EOF;
  877. if ( ! yy_did_buffer_switch_on_eof )
  878. YY_NEW_FILE;
  879. #ifdef __cplusplus
  880. return yyinput();
  881. #else
  882. return input();
  883. #endif
  884. }
  885. case EOB_ACT_CONTINUE_SCAN:
  886. yy_c_buf_p = yytext_ptr + offset;
  887. break;
  888. }
  889. }
  890. }
  891. c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
  892. *yy_c_buf_p = '\0'; /* preserve yytext */
  893. yy_hold_char = *++yy_c_buf_p;
  894. return c;
  895. }
  896. #ifdef YY_USE_PROTOS
  897. void yyrestart( FILE *input_file )
  898. #else
  899. void yyrestart( input_file )
  900. FILE *input_file;
  901. #endif
  902. {
  903. if ( ! yy_current_buffer )
  904. yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
  905. yy_init_buffer( yy_current_buffer, input_file );
  906. yy_load_buffer_state();
  907. }
  908. #ifdef YY_USE_PROTOS
  909. void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
  910. #else
  911. void yy_switch_to_buffer( new_buffer )
  912. YY_BUFFER_STATE new_buffer;
  913. #endif
  914. {
  915. if ( yy_current_buffer == new_buffer )
  916. return;
  917. if ( yy_current_buffer )
  918. {
  919. /* Flush out information for old buffer. */
  920. *yy_c_buf_p = yy_hold_char;
  921. yy_current_buffer->yy_buf_pos = yy_c_buf_p;
  922. yy_current_buffer->yy_n_chars = yy_n_chars;
  923. }
  924. yy_current_buffer = new_buffer;
  925. yy_load_buffer_state();
  926. /* We don't actually know whether we did this switch during
  927. * EOF (yywrap()) processing, but the only time this flag
  928. * is looked at is after yywrap() is called, so it's safe
  929. * to go ahead and always set it.
  930. */
  931. yy_did_buffer_switch_on_eof = 1;
  932. }
  933. #ifdef YY_USE_PROTOS
  934. void yy_load_buffer_state( void )
  935. #else
  936. void yy_load_buffer_state()
  937. #endif
  938. {
  939. yy_n_chars = yy_current_buffer->yy_n_chars;
  940. yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
  941. yyin = yy_current_buffer->yy_input_file;
  942. yy_hold_char = *yy_c_buf_p;
  943. }
  944. #ifdef YY_USE_PROTOS
  945. YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
  946. #else
  947. YY_BUFFER_STATE yy_create_buffer( file, size )
  948. FILE *file;
  949. int size;
  950. #endif
  951. {
  952. YY_BUFFER_STATE b;
  953. b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
  954. if ( ! b )
  955. YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  956. b->yy_buf_size = size;
  957. /* yy_ch_buf has to be 2 characters longer than the size given because
  958. * we need to put in 2 end-of-buffer characters.
  959. */
  960. b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
  961. if ( ! b->yy_ch_buf )
  962. YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  963. b->yy_is_our_buffer = 1;
  964. yy_init_buffer( b, file );
  965. return b;
  966. }
  967. #ifdef YY_USE_PROTOS
  968. void yy_delete_buffer( YY_BUFFER_STATE b )
  969. #else
  970. void yy_delete_buffer( b )
  971. YY_BUFFER_STATE b;
  972. #endif
  973. {
  974. if ( ! b )
  975. return;
  976. if ( b == yy_current_buffer )
  977. yy_current_buffer = (YY_BUFFER_STATE) 0;
  978. if ( b->yy_is_our_buffer )
  979. yy_flex_free( (void *) b->yy_ch_buf );
  980. yy_flex_free( (void *) b );
  981. }
  982. #ifndef _WIN32
  983. #include <unistd.h>
  984. #else
  985. #ifndef YY_ALWAYS_INTERACTIVE
  986. #ifndef YY_NEVER_INTERACTIVE
  987. extern int isatty YY_PROTO(( int ));
  988. #endif
  989. #endif
  990. #endif
  991. #ifdef YY_USE_PROTOS
  992. void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
  993. #else
  994. void yy_init_buffer( b, file )
  995. YY_BUFFER_STATE b;
  996. FILE *file;
  997. #endif
  998. {
  999. yy_flush_buffer( b );
  1000. b->yy_input_file = file;
  1001. b->yy_fill_buffer = 1;
  1002. #if YY_ALWAYS_INTERACTIVE
  1003. b->yy_is_interactive = 1;
  1004. #else
  1005. #if YY_NEVER_INTERACTIVE
  1006. b->yy_is_interactive = 0;
  1007. #else
  1008. b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
  1009. #endif
  1010. #endif
  1011. }
  1012. #ifdef YY_USE_PROTOS
  1013. void yy_flush_buffer( YY_BUFFER_STATE b )
  1014. #else
  1015. void yy_flush_buffer( b )
  1016. YY_BUFFER_STATE b;
  1017. #endif
  1018. {
  1019. if ( ! b )
  1020. return;
  1021. b->yy_n_chars = 0;
  1022. /* We always need two end-of-buffer characters. The first causes
  1023. * a transition to the end-of-buffer state. The second causes
  1024. * a jam in that state.
  1025. */
  1026. b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
  1027. b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
  1028. b->yy_buf_pos = &b->yy_ch_buf[0];
  1029. b->yy_at_bol = 1;
  1030. b->yy_buffer_status = YY_BUFFER_NEW;
  1031. if ( b == yy_current_buffer )
  1032. yy_load_buffer_state();
  1033. }
  1034. #ifndef YY_NO_SCAN_BUFFER
  1035. #ifdef YY_USE_PROTOS
  1036. YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
  1037. #else
  1038. YY_BUFFER_STATE yy_scan_buffer( base, size )
  1039. char *base;
  1040. yy_size_t size;
  1041. #endif
  1042. {
  1043. YY_BUFFER_STATE b;
  1044. if ( size < 2 ||
  1045. base[size-2] != YY_END_OF_BUFFER_CHAR ||
  1046. base[size-1] != YY_END_OF_BUFFER_CHAR )
  1047. /* They forgot to leave room for the EOB's. */
  1048. return 0;
  1049. b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
  1050. if ( ! b )
  1051. YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
  1052. b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
  1053. b->yy_buf_pos = b->yy_ch_buf = base;
  1054. b->yy_is_our_buffer = 0;
  1055. b->yy_input_file = 0;
  1056. b->yy_n_chars = b->yy_buf_size;
  1057. b->yy_is_interactive = 0;
  1058. b->yy_at_bol = 1;
  1059. b->yy_fill_buffer = 0;
  1060. b->yy_buffer_status = YY_BUFFER_NEW;
  1061. yy_switch_to_buffer( b );
  1062. return b;
  1063. }
  1064. #endif
  1065. #ifndef YY_NO_SCAN_STRING
  1066. #ifdef YY_USE_PROTOS
  1067. YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
  1068. #else
  1069. YY_BUFFER_STATE yy_scan_string( yy_str )
  1070. yyconst char *yy_str;
  1071. #endif
  1072. {
  1073. int len;
  1074. for ( len = 0; yy_str[len]; ++len )
  1075. ;
  1076. return yy_scan_bytes( yy_str, len );
  1077. }
  1078. #endif
  1079. #ifndef YY_NO_SCAN_BYTES
  1080. #ifdef YY_USE_PROTOS
  1081. YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
  1082. #else
  1083. YY_BUFFER_STATE yy_scan_bytes( bytes, len )
  1084. yyconst char *bytes;
  1085. int len;
  1086. #endif
  1087. {
  1088. YY_BUFFER_STATE b;
  1089. char *buf;
  1090. yy_size_t n;
  1091. int i;
  1092. /* Get memory for full buffer, including space for trailing EOB's. */
  1093. n = len + 2;
  1094. buf = (char *) yy_flex_alloc( n );
  1095. if ( ! buf )
  1096. YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
  1097. for ( i = 0; i < len; ++i )
  1098. buf[i] = bytes[i];
  1099. buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
  1100. b = yy_scan_buffer( buf, n );
  1101. if ( ! b )
  1102. YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
  1103. /* It's okay to grow etc. this buffer, and we should throw it
  1104. * away when we're done.
  1105. */
  1106. b->yy_is_our_buffer = 1;
  1107. return b;
  1108. }
  1109. #endif
  1110. #ifndef YY_NO_PUSH_STATE
  1111. #ifdef YY_USE_PROTOS
  1112. static void yy_push_state( int new_state )
  1113. #else
  1114. static void yy_push_state( new_state )
  1115. int new_state;
  1116. #endif
  1117. {
  1118. if ( yy_start_stack_ptr >= yy_start_stack_depth )
  1119. {
  1120. yy_size_t new_size;
  1121. yy_start_stack_depth += YY_START_STACK_INCR;
  1122. new_size = yy_start_stack_depth * sizeof( int );
  1123. if ( ! yy_start_stack )
  1124. yy_start_stack = (int *) yy_flex_alloc( new_size );
  1125. else
  1126. yy_start_stack = (int *) yy_flex_realloc(
  1127. (void *) yy_start_stack, new_size );
  1128. if ( ! yy_start_stack )
  1129. YY_FATAL_ERROR(
  1130. "out of memory expanding start-condition stack" );
  1131. }
  1132. yy_start_stack[yy_start_stack_ptr++] = YY_START;
  1133. BEGIN(new_state);
  1134. }
  1135. #endif
  1136. #ifndef YY_NO_POP_STATE
  1137. static void yy_pop_state()
  1138. {
  1139. if ( --yy_start_stack_ptr < 0 )
  1140. YY_FATAL_ERROR( "start-condition stack underflow" );
  1141. BEGIN(yy_start_stack[yy_start_stack_ptr]);
  1142. }
  1143. #endif
  1144. #ifndef YY_NO_TOP_STATE
  1145. static int yy_top_state()
  1146. {
  1147. return yy_start_stack[yy_start_stack_ptr - 1];
  1148. }
  1149. #endif
  1150. #ifndef YY_EXIT_FAILURE
  1151. #define YY_EXIT_FAILURE 2
  1152. #endif
  1153. #ifdef YY_USE_PROTOS
  1154. static void yy_fatal_error( yyconst char msg[] )
  1155. #else
  1156. static void yy_fatal_error( msg )
  1157. char msg[];
  1158. #endif
  1159. {
  1160. (void) fprintf( stderr, "%s\n", msg );
  1161. exit( YY_EXIT_FAILURE );
  1162. }
  1163. /* Redefine yyless() so it works in section 3 code. */
  1164. #undef yyless
  1165. #define yyless(n) \
  1166. do \
  1167. { \
  1168. /* Undo effects of setting up yytext. */ \
  1169. yytext[yyleng] = yy_hold_char; \
  1170. yy_c_buf_p = yytext + n; \
  1171. yy_hold_char = *yy_c_buf_p; \
  1172. *yy_c_buf_p = '\0'; \
  1173. yyleng = n; \
  1174. } \
  1175. while ( 0 )
  1176. /* Internal utility routines. */
  1177. #ifndef yytext_ptr
  1178. #ifdef YY_USE_PROTOS
  1179. static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
  1180. #else
  1181. static void yy_flex_strncpy( s1, s2, n )
  1182. char *s1;
  1183. yyconst char *s2;
  1184. int n;
  1185. #endif
  1186. {
  1187. register int i;
  1188. for ( i = 0; i < n; ++i )
  1189. s1[i] = s2[i];
  1190. }
  1191. #endif
  1192. #ifdef YY_NEED_STRLEN
  1193. #ifdef YY_USE_PROTOS
  1194. static int yy_flex_strlen( yyconst char *s )
  1195. #else
  1196. static int yy_flex_strlen( s )
  1197. yyconst char *s;
  1198. #endif
  1199. {
  1200. register int n;
  1201. for ( n = 0; s[n]; ++n )
  1202. ;
  1203. return n;
  1204. }
  1205. #endif
  1206. #ifdef YY_USE_PROTOS
  1207. static void *yy_flex_alloc( yy_size_t size )
  1208. #else
  1209. static void *yy_flex_alloc( size )
  1210. yy_size_t size;
  1211. #endif
  1212. {
  1213. return (void *) malloc( size );
  1214. }
  1215. #ifdef YY_USE_PROTOS
  1216. static void *yy_flex_realloc( void *ptr, yy_size_t size )
  1217. #else
  1218. static void *yy_flex_realloc( ptr, size )
  1219. void *ptr;
  1220. yy_size_t size;
  1221. #endif
  1222. {
  1223. /* The cast to (char *) in the following accommodates both
  1224. * implementations that use char* generic pointers, and those
  1225. * that use void* generic pointers. It works with the latter
  1226. * because both ANSI C and C++ allow castless assignment from
  1227. * any pointer type to void*, and deal with argument conversions
  1228. * as though doing an assignment.
  1229. */
  1230. return (void *) realloc( (char *) ptr, size );
  1231. }
  1232. #ifdef YY_USE_PROTOS
  1233. static void yy_flex_free( void *ptr )
  1234. #else
  1235. static void yy_flex_free( ptr )
  1236. void *ptr;
  1237. #endif
  1238. {
  1239. free( ptr );
  1240. }
  1241. #if YY_MAIN
  1242. int main()
  1243. {
  1244. yylex();
  1245. return 0;
  1246. }
  1247. #endif
  1248. #line 20 "c:\\CVS\\boost\\libs\\spirit\\example\\lex\\word_count_functor.flex"
  1249. bool count(int tok, int* c, int* w, int* l)
  1250. {
  1251. switch (tok) {
  1252. case ID_WORD: ++*w; *c += yyleng; break;
  1253. case ID_EOL: ++*l; ++*c; break;
  1254. case ID_CHAR: ++*c; break;
  1255. default:
  1256. return false;
  1257. }
  1258. return true;
  1259. }
  1260. int main(int argc, char* argv[])
  1261. {
  1262. int tok = EOF;
  1263. int c = 0, w = 0, l = 0;
  1264. yyin = fopen(1 == argc ? "word_count.input" : argv[1], "r");
  1265. if (NULL == yyin) {
  1266. fprintf(stderr, "Couldn't open input file!\n");
  1267. exit(-1);
  1268. }
  1269. boost::timer tim;
  1270. do {
  1271. tok = yylex();
  1272. if (!count(tok, &c, &w, &l))
  1273. break;
  1274. } while (EOF != tok);
  1275. printf("lines: %d, words: %d, characters: %d\n", l, w, c);
  1276. fclose(yyin);
  1277. return 0;
  1278. }
  1279. extern "C" int yywrap()
  1280. {
  1281. return 1;
  1282. }