in reply to Object Query Languages and Parsers
@tokens = ...; $tokens = join '', map { $tokenToChar{ $_->type } }, @tokens; if ($tokens =~ / ($IDENT)($DOT $IDENT)* /x) { my @captured = map { [ @tokens[ $-[$_], $+[$_] ] } 1..$#-; my ($head, $tail) = @catpured; }
This worked beautifully. Since a three to four hundered character QL string could be represented by, maybe, 80 tokens, the token string is very small. All the regexes are on single chars so backtracking is minimized. And I could use character classes [$TOK1 $TOK2] to simulate token classes. All in all, it seems like a very efficient approach. I may even be able to apply this technique to P::RD.
Thank you rhesa. I will read through the P::RD FAQ on optimization!
And thanks for all of the feedback so far.
Ted Young
($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Object Query Languages and Parsers
by Gilimanjaro (Hermit) on Apr 23, 2006 at 23:13 UTC |