prenav - Navigate a PPIx::Regexp parse tree
prenav 's/(\w+)/\u$1/g' prenav> find_first Token::CharClass::Simple PPIx::Regexp::Token::CharClass::Simple \w prenav> dump verbose 1 PPIx::Regexp::Token::CharClass::Simple '\\w' significant can_be_quantified prenav> parent PPIx::Regexp::Structure::Capture (\w+) prenav> exit
This script takes as its argument a string to be parsed as a regular expression, and prompts the user for navigation commands. A navigation command is any method that returns another element in the parse tree.
Unless documented otherwise, all commands apply to the current object. Initially the current object is the PPIx::Regexp object generated by the parse. Once a navigation command is issued, the object navigated to becomes the current object. If the navigation command does not specify an object (e.g. child 5 when the current object has fewer than 5 children) the current object remains unchanged.
child 5
In addition to the navigation methods, any method that returns a scalar value can be used as a command. The value returned will be displayed.
In addition to all the above, the following commands are recognized:
This command wraps the PPIx::Regexp->capture_names() method, joining the results into a comma-delimited string.
This command dumps the current object. Options to PPIx::Regexp::Dumper->new() may be specified as arguments to the command. See the SYNOPSIS for an example.
This comamnd terminates the script.
This command displays this documentation.
If you supply a module name as an argument, the documentation for that module will be displayed.
nav
This command displays the method calls and arguments needed to navigate from the root of the parse tree to the current object. Yes, this is a perfectly good method, but we wrap the results of that method in some semi-nice formatting.
Any arguments are ignored
parse s/ ( \w+ ) foo \1 /bar/smx
This command provides another regular expression to parse. If the parse succeeds, the previous regular expression is abandoned, and the new PPIx::Regexp object becomes the current object.
The new regular expression is taken to be everything on the line after the whit espace after the word parse. It should not be quoted.
parse
This command selects the top-level object as the current object. The top command does the same thing, but top does it by running through the parent chain, where reset simply slam-dunks the retained PPIx::Regexp object.
top
reset
Support is by the author. Please file bug reports at http://rt.cpan.org, or in electronic mail to the author.
Thomas R. Wyant, III wyant at cpan dot org
Copyright (C) 2009-2019 by Thomas R. Wyant, III
This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For more details, see the full text of the licenses in the directory LICENSES.
This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.
To install PPIx::Regexp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PPIx::Regexp
CPAN shell
perl -MCPAN -e shell install PPIx::Regexp
For more information on module installation, please visit the detailed CPAN module installation guide.