If I have the following in my flex file, what does it do?
[\\[\\];] { return yytext[0]; }
If I have the following in my flex file, what does it do?
[\\[\\];] { return yytext[0]; }
If it was in Perl, it would match any of '[', ']', or ';' -- I imagine it's the same in flex. The outer "[...]" defines a character range, i.e. matches any one of the specified characters: the backslashes escape the inner "[]" so that they just mean literal brackets.
It matches a token consisting of one of the characters [
, ]
or ;
. @AAT is is right in his explanation, though terminology wise "character class" is more common than "character range".
return yytext[0];
returns the first character of the matched token. Since the regexp here matches only single character tokens, it returns the matched token itself as a character.