DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(flex.info.gz) How do I skip as many chars as possible?

Info Catalog (flex.info.gz) How do I use my own I/O classes in a C++ scanner? (flex.info.gz) FAQ (flex.info.gz) deleteme00
 
 How do I skip as many chars as possible?
 ========================================
 
 How do I skip as many chars as possible - without interfering with the
 other patterns?
 
    In the example below, we want to skip over characters until we see
 the phrase "endskip". The following will _NOT_ work correctly (do you
 see why not?)
 
 
      /* INCORRECT SCANNER */
      %x SKIP
      %%
      <INITIAL>startskip   BEGIN(SKIP);
      ...
      <SKIP>"endskip"       BEGIN(INITIAL);
      <SKIP>.*             ;
 
    The problem is that the pattern .* will eat up the word "endskip."
 The simplest (but slow) fix is:
 
 
      <SKIP>"endskip"      BEGIN(INITIAL);
      <SKIP>.              ;
 
    The fix involves making the second rule match more, without making
 it match "endskip" plus something else.  So for example:
 
 
      <SKIP>"endskip"     BEGIN(INITIAL);
      <SKIP>[^e]+         ;
      <SKIP>.		        ;/* so you eat up e's, too */
 
Info Catalog (flex.info.gz) How do I use my own I/O classes in a C++ scanner? (flex.info.gz) FAQ (flex.info.gz) deleteme00
automatically generated byinfo2html