App-GitFind
view release on metacpan or search on metacpan
lib/App/GitFind/cmdline.pm view on Meta::CPAN
# }}}1
# Documentation {{{1
=head1 NAME
App::GitFind::cmdline - Command-line parser for git-find
=head1 SYNOPSIS
Generate the .pm file:
yapp -m App::GitFind::cmdline -o lib/App/GitFind/cmdline.pm support/cmdline.yp
And then:
use App::GitFind::cmdline;
App::GitFind::cmdline::Parse(\@ARGV);
For debugging output, define C<$SHOW_AST> before the C<use> statement:
BEGIN { $App::GitFind::cmdline::SHOW_AST = 1; }
=head1 FUNCTIONS
=cut
# }}}1
# Helpers for the parser {{{1
# Merge any number of hashrefs together and return a hashref
sub _merge {
state $merger = Hash::Merge->new('RETAINMENT_PRECEDENT');
$merger->set_clone_behavior(false); # No cloning
my $retval = {};
for(@_) {
next unless ref eq 'HASH';
$retval = $merger->merge($retval, $_);
}
return $retval;
}
# Check for { expr => FOO }
sub _is_single_expr {
return false unless @_ eq 1;
my $h = $_[0];
return false unless ref $h eq 'HASH';
return false unless keys(%$h) eq 1;
return false unless (keys %$h)[0] eq 'expr';
return true;
}
# }}}1
sub new {
my($class)=shift;
ref($class)
and $class=ref($class);
my($self)=$class->SUPER::new( yyversion => '1.21',
yystates =>
[
{#State 0
ACTIONS => {
'REV' => 11,
'TEST' => 10,
'SWITCH' => 5,
'LPAREN' => 4,
'NOT' => 2,
'ACTION' => 3
},
DEFAULT => -1,
GOTOS => {
'switches_and_revs' => 9,
'expr' => 6,
'cmdline' => 8,
'element' => 7,
'maybeexprplus' => 1
}
},
{#State 1
DEFAULT => -2
},
{#State 2
ACTIONS => {
'expr4' => 12
}
},
{#State 3
DEFAULT => -22
},
{#State 4
ACTIONS => {
'TEST' => 10,
'LPAREN' => 4,
'ACTION' => 3,
'NOT' => 2
},
GOTOS => {
'element' => 7,
'expr' => 13
}
},
{#State 5
DEFAULT => -4
},
{#State 6
ACTIONS => {
'SWITCH' => 5,
'OR' => 15,
'REV' => 11,
'TEST' => 10,
'ACTION' => 3,
'NOT' => 21,
'COMMA' => 20,
'LPAREN' => 19,
'AND' => 18
},
DEFAULT => -9,
GOTOS => {
( run in 0.503 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )