view Lib/IMPL/Text/Parser/Chunk.pm @ 148:e6447ad85cb4

DOM objects now have a schema and schemaSource properties RegExp now can launder data Improved post to DOM transformation (multiple values a now supported) Added new axes to navigation queries: ancestor and descendant minor changes and bug fixes
author wizard
date Mon, 16 Aug 2010 08:26:44 +0400
parents 16ada169ca75
children 4267a2ac3d46
line wrap: on
line source

package IMPL::Text::Parser::Chunk;
use strict;
use warnings;

use base qw(IMPL::Object IMPL::Object::Autofill);

use IMPL::Class::Property;
use IMPL::Class::Property::Direct;

use constant {
    OP_REGEXP => 1,
    OP_STRING => 2,
    OP_REFERENCE => 3,
    OP_CHUNK => 4,
    OP_SWITCH => 5,
    OP_REPEAT => 7
};

BEGIN {
    public _direct property chunkName => prop_get;
    public _direct property opStream => prop_get;
}

sub Regexp {
    my ($this,$rx) = @_;
    
    if (ref $rx eq 'Regexp') {
        
    } elsif (not ref $rx) {
        $rx = q/$rx/;
    } else {
        die new IMPL::InvalidArgumentException('A regular expression required');
    }
    
    push @{$this->{$opStream}}, [OP_REGEXP, $rx];
}

sub String {
    my ($this,$str) = @_;
    
    die new IMPL::InvalidArgumentException("A simple value is required") if ref $str;
    
    push @{$this->{$opStream}}, [OP_STRING, $str];
}

sub Reference {
    my ($this,$ref) = @_;
    
    die new IMPL::InvalidArgumentException("A simple value is reqiured") if ref $ref;
    
    push @{$this->{$opStream}}, [OP_REFERENCE, $ref];
}

sub Chunk {
    my ($this,$chunk) = @_;
    
    die new IMPL::InvalidArgumentException unless UNIVERSAL::isa($chunk,'IMPL::Text::Parser::Chunk');
    
    push @{$this->{$opStream}}, [OP_CHUNK, $chunk];
}

sub Switch {
    my $this = shift;
    
    push @{$this->{$opStream}}, [OP_SWITCH, @_];
}

sub Repeat {
    my ($this,$chunk,$min,$max) = @_;
    
    die new IMPL::InvalidArgumentException unless UNIVERSAL::isa($chunk,'IMPL::Text::Parser::Chunk');
    
    push @{$this->{$opStream}}, [OP_REPEAT, $chunk, $min, $max ];
}

1;

__END__

=pod

=head1 DESCRIPTION
Именованный поток операций

=head1 MEMBERS

=level

=item C<<$obj->>>

=back

=cut