in reply to HOP::Lexer not doing what I expected
(n.b. string_lexer is just a routine in the module that wraps the input string in an iterator, and then calls make_lexer, so we don't have to do it by hand. The code we have to write just becomes a bit simpler.)use HOP::Lexer 'string_lexer'; my $text = 'xselectx'; my $lexer = string_lexer( $text, [KEYWORD => qr/select/i], [WORD => qr/\w+/ ] );
Tell me that the result it parses into is what you think makes sense. Because it doesn't make any sense to me at all:
['WORD','x'], ['KEYWORD','select'], ['WORD','x']
This is just so messed up.
update I just read cmarcelo's reply... You want me to swap the rules? OK...
Outcome:use HOP::Lexer 'string_lexer'; my $text = 'select xselectx'; my $lexer = string_lexer( $text, [WORD => qr/\w+/ ], [KEYWORD => qr/select/i], );
No good.['WORD','select'], ' ', ['WORD','xselectx']
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: HOP::Lexer not doing what I expected
by cmarcelo (Scribe) on Nov 11, 2006 at 22:11 UTC | |
by bart (Canon) on Nov 11, 2006 at 22:23 UTC | |
by cmarcelo (Scribe) on Nov 11, 2006 at 22:39 UTC |