help-flex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binary scanner not matching character ranges


From: Bruce Lilly
Subject: Re: Binary scanner not matching character ranges
Date: Fri, 17 Dec 2004 18:11:03 -0500
User-agent: KMail/1.7.2

On Fri December 17 2004 15:42, Shaun Jackman wrote:
> I'm writing a binary scanner for the Telnet protocol, which is deadly
> simple. The escape sequence 0xff preceeds a two or three byte command,
> and everything else is a normal character. The rule explicit
> "\xff\xec" is matching, but all the rules with a '.' in them are not
> matching. For example, the input sequence 0xff 0xfd 0x03 is being
> matched by the last rule three times, rather than the fourth rule,
> "\xff\xfd.".[...]
> 
> "\xff\xec" return xEOF;
> "\xff\xfb." yylval = yytext[2]; return WILL;
> "\xff\xfc." yylval = yytext[2]; return WONT;
> "\xff\xfd." yylval = yytext[2]; return DO;
> "\xff\xfe." yylval = yytext[2]; return DONT;
> "\xff\xff" return 255;
> "\xff." yylval = yytext[1]; return IAC;
> . return yytext[0];

Note that a dot in a quoted string matches a literal
dot character, whereas an unquoted dot matches any
character except a newline.  So input 0xff 0xfd 0x03
does *NOT* match "\xff\xfd." (but 0xff 0xfd 0x2e
would).  Lacking a match with any other rule, each
of 0xff, 0xfd, and 0x03 match the lone dot rule.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]