in reply to HOP::Lexer not doing what I expected
Order is important:
------------- 8< --------- my $lexer = make_lexer( sub { shift @sql }, # iterator [ DQUOTED => qr/"[^"]+"/ ], [ QUOTED => qr/'[^']*'/ ], [ DQWORD => qr/"\w+"/ ], [ WORD => qr/\w+/i ], [ COMMA => qr/,/ ], [ SPACE => qr/\s+/, sub {} ], ); ------------- 8< ---------
Prints:
['WORD','select'], ['WORD','case'], ['WORD','when'], ['WORD','a'], '=', ['WORD','b'], ['WORD','then'], ['QUOTED','\'c\''], ['WORD','else'], ['QUOTED','\'d\''], ['WORD','end'], ['DQUOTED','"tough_one"'], ['COMMA',','], ['WORD','e'], ['WORD','as'], ['DQUOTED','"even tougher"'], ['WORD','from'], ['WORD','mytable']
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: HOP::Lexer not doing what I expected
by Corion (Patriarch) on Nov 11, 2006 at 18:50 UTC | |
by bart (Canon) on Nov 11, 2006 at 18:55 UTC | |
by cmarcelo (Scribe) on Nov 11, 2006 at 19:41 UTC | |
|
Re^2: HOP::Lexer not doing what I expected
by ikegami (Patriarch) on Nov 11, 2006 at 18:49 UTC | |
by GrandFather (Saint) on Nov 11, 2006 at 19:03 UTC |