XML-XSH
view release on metacpan or search on metacpan
lib/XML/XSH/Grammar.pm view on Meta::CPAN
match_typedargs:
{
$return = ((@arg and $arg[0]<=$#arg and $arg[$arg[0]]=~m/^%/)
? $arg[$arg[0]] : undef)
}
xpath match_typedargs[$arg[0]+1,@arg[1..$#arg]]
{
$return=(defined($item[3]) ? [$item[2],@{$item[3]}] : undef);
}
|
{
$return = ((@arg and $arg[0]<=$#arg and $arg[$arg[0]]=~m/^\$/)
? $arg[$arg[0]] : undef)
}
expression match_typedargs[$arg[0]+1,@arg[1..$#arg]]
{
$return=(defined($item[3]) ? [$item[2],@{$item[3]}] : undef);
}
|
{
$return= (($arg[0]==$#arg+1) ? [] : undef);
}
subroutine_arguments:
{
if (exists($XML::XSH::Functions::_defs{$arg[0]})) {
$return=[ @{$XML::XSH::Functions::_defs{$arg[0]}} ];
shift @$return;
} else {
$return=undef;
}
}
| <error:Call to undefined subroutine $arg[0]!>
call_command:
<rulevar:@args>
| /(call)\s/ <commit> ID subroutine_arguments[$item[3]] match_typedargs[1,@{$item[4]}]
{
$return=[\&XML::XSH::Functions::call,$item[3],$item[5]]
}
xslt_params:
/(params|parameters)\s/ param(s)
{ $item[2] }
param:
/[^=\s]+/ '=' expression
{ [$item[1],$item[3]] }
nodetype:
/element|attribute|attributes|text|cdata|pi|comment|chunk|entity_reference/
namespace:
/namespace\s/ expression
{ $item[2] }
loc:
/after\s/
{ "after" }
| /before\s/
{ "before" }
| /(in)?to\s/
{ "into" }
| /(append(ing)?|as\s+(a\s+)child(\s+of)?)\s/
{ "append" }
| /(prepend(ing)?|(as\s+)(the\s+)first(\s+child(\s+of)?)?)\s/
{ "prepend" }
| /(replace|instead( of)?)\s/
{ "replace" }
perl_code:
<perl_codeblock>
| perl_expression
encoding_param:
/encoding\s/ expression
{ $item[2] }
xpaxis:
/[-a-z]+::/
xpnodetest:
/node\(\)|text\(\)|comment\(\)|processing-instruction\(\)|[^\(\[\/\"\'\&\;\s]+/
xplocationstep:
xpaxis(?) <skip:""> xpnodetest
{ [ (@{$item[1]} ? $item[1][0] : 'child::'),$item[3] ] }
xpstep:
xplocationstep <skip:""> xpfilter(?)
{ [ @{$item[1]}, @{$item[3]}] }
stream_select:
/select\s/ xp block
{ [$item[2],$item[3]] }
_EO_GRAMMAR_
( run in 0.610 second using v1.01-cache-2.11-cpan-39bf76dae61 )