TPath::Grammar - parses TPath expressions into ASTs
version 1.007
use TPath::Grammar qw(parse); my $ast = parse('/>a[child::b || @foo("bar")][-1]');
TPath::Grammar exposes a single function: parse. Parsing is a preliminary step to compiling the expression into an object that will select the tree nodes matching the expression.
TPath::Grammar
parse
TPath::Grammar is really intended for use by TPath modules, but if you want a parse tree, here's how to get it.
TPath
Also exportable from TPath::Grammar is %AXES, the set of axes understood by TPath expressions. See TPath for the list and explanation.
%AXES
Converts a TPath expression to a parse tree, normalizing boolean expressions and parentheses, unescaping escaped strings, folding constants, and otherwise optimizing the parse tree and preparing it for compilation.
parse throws an exception (dies) if the expression is is unparsable or, in some cases, contains an impossible condition, [1=2], for example. Otherwise, it returns a hashref.
[1=2]
David F. Houghton <dfhoughton@gmail.com>
This software is copyright (c) 2013 by David F. Houghton.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install TPath, copy and paste the appropriate command in to your terminal.
cpanm
cpanm TPath
CPAN shell
perl -MCPAN -e shell install TPath
For more information on module installation, please visit the detailed CPAN module installation guide.