| 1 | =head1 NAME | ||||||||||
| 2 | |||||||||||
| 3 | PPIx::Regexp::Structure::Code - Represent one of the code structures. | ||||||||||
| 4 | |||||||||||
| 5 | =head1 SYNOPSIS | ||||||||||
| 6 | |||||||||||
| 7 | use PPIx::Regexp::Dumper; | ||||||||||
| 8 | PPIx::Regexp::Dumper->new( 'qr{(?{print "hello sailor\n")}smx' ) | ||||||||||
| 9 | ->print(); | ||||||||||
| 10 | |||||||||||
| 11 | =head1 INHERITANCE | ||||||||||
| 12 | |||||||||||
| 13 | C<PPIx::Regexp::Structure::Code> is a | ||||||||||
| 14 | L<PPIx::Regexp::Structure|PPIx::Regexp::Structure>. | ||||||||||
| 15 | |||||||||||
| 16 | C<PPIx::Regexp::Structure::Code> has no descendants. | ||||||||||
| 17 | |||||||||||
| 18 | =head1 DESCRIPTION | ||||||||||
| 19 | |||||||||||
| 20 | This class represents one of the code structures, either | ||||||||||
| 21 | |||||||||||
| 22 | (?{ code }) | ||||||||||
| 23 | |||||||||||
| 24 | or | ||||||||||
| 25 | |||||||||||
| 26 | (??{ code }) | ||||||||||
| 27 | |||||||||||
| 28 | =head1 METHODS | ||||||||||
| 29 | |||||||||||
| 30 | This class provides no public methods beyond those provided by its | ||||||||||
| 31 | superclass. | ||||||||||
| 32 | |||||||||||
| 33 | =cut | ||||||||||
| 34 | |||||||||||
| 35 | package PPIx::Regexp::Structure::Code; | ||||||||||
| 36 | |||||||||||
| 37 | 9 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 38 | 9 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 39 | |||||||||||
| 40 | 9 | ▶ | use base qw{ PPIx::Regexp::Structure }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 41 | |||||||||||
| 42 | 9 | ▶ | use PPIx::Regexp::Constant qw{ @CARP_NOT }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 43 | |||||||||||
| 44 | 9 | our $VERSION = '0.092'; | |||||||||
| 45 | |||||||||||
| 46 | # The only child of this structure should be a single | ||||||||||
| 47 | # PPIx::Regexp::Token::Code. Anything else gets turned into the | ||||||||||
| 48 | # appropriate ::Unknown object. | ||||||||||
| 49 | 9 | ▶ | sub __PPIX_LEXER__finalize { | ||||||||
|
Subroutine
__PPIX_LEXER__finalize: called CC=4 SCAR=14.2
| |||||||||||
| 50 | 9 | my ( $self ) = @_; # $lexer unused | |||||||||
| 51 | |||||||||||
| 52 | 9 | my $count; | |||||||||
| 53 | 9 | my $errors = 0; | |||||||||
| 54 | |||||||||||
| 55 | 9 | foreach my $kid ( $self->children() ) { | |||||||||
| 56 | |||||||||||
| 57 | 10 | ▶ | if ( $kid->isa( 'PPIx::Regexp::Token::Code' ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | 9 | ▶ | $count++ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | or next; | ||||||||||
| 60 | 0 | $errors++; | |||||||||
| 61 | 0 | $kid->__error( | |||||||||
| 62 | 'Code structure can contain only one code token' ); | ||||||||||
| 63 | } else { | ||||||||||
| 64 | |||||||||||
| 65 | 1 | $errors++; | |||||||||
| 66 | |||||||||||
| 67 | 1 | $kid->__error( | |||||||||
| 68 | 'Code structure may not contain a ' . ref $kid ); | ||||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | } | ||||||||||
| 72 | 9 | return $errors; | |||||||||
| 73 | } | ||||||||||
| 74 | |||||||||||
| 75 | 9 | 1; | |||||||||
| 76 | |||||||||||
| 77 | __END__ | ||||||||||