Re: [Flex-help] Where does the longest or first match apply?
flex is a tool for generating scanners
Brought to you by:
wlestes
From: Chris v. <che...@gm...> - 2013-10-29 19:16:58
|
Your code snippet works fine for me. Or at least, it behaves the way you expect, because the message I'm getting from flex is: :5: warning, rule cannot be matched Thus, the [[:space:]] rule is indeed winning. I'm not sure why yours is unrecognizing and fatally erroring.. I'm using flex 2.5.35 on redhat. -Chris On Tue, Oct 29, 2013 at 8:11 AM, Arthur Schwarz <asc...@at...>wrote: > Section 7 says "When the generated scanner is run, it analyzes its input > looking for strings which match any of its patterns. If it finds more than > one match, it takes the one matching the most text (for trailing context > rules, this includes the length of the trailing part, even though it will > then be returned to the input). If it finds two or more matches of the same > length, the rule listed first in the flex input file is chosen." > > The following code generates the following errors. Any idea why? > > [:space:] natches [ \f\n\r\t\v] and \n is a subset of this pattern. But > using the 'longest' or the 'first' as a scanning rule the construct should > be legal and in the case of a '\n' being seen the [[:space:]] rule should > be chosen (the matches are equal, the first pattern is [[:space:]]). > > %option main > > %% > [[:space:]]+ > \n > > :5: unrecognized rule > :5: fatal parse error > > > > ------------------------------------------------------------------------------ > Android is increasing in popularity, but the open development platform that > developers love is also attractive to malware creators. Download this white > paper to learn more about secure code signing practices that can help keep > Android apps secure. > http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk > _______________________________________________ > Flex-help mailing list > Fle...@li... > https://lists.sourceforge.net/lists/listinfo/flex-help > |