view Lib/IMPL/Text/Parser/Player.pm @ 39:4f5a6a1bfb0e

Text parser
author Sergey
date Tue, 08 Dec 2009 17:28:06 +0300
parents
children ac21a032e7a9
line wrap: on
line source

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

use base qw(IMPL::Object);
use IMPL::Class::Property;
use IMPL::Class::Property::Direct;

use IMPL::Text::Parser::Chunk;

my %opCodesMap = (
    IMPL::Text::Parser::Chunk::OP_REGEXP , &MatchRegexp ,
    IMPL::Text::Parser::Chunk::OP_STRING , &MatchString ,
    IMPL::Text::Parser::Chunk::OP_REFERENCE , &MatchReference ,
    IMPL::Text::Parser::Chunk::OP_CHUNK , &PlayChunk ,
    IMPL::Text::Parser::Chunk::OP_SWITCH , &MatchSwitch ,
    IMPL::Text::Parser::Chunk::OP_REPEAT , &MatchRepeat
);

BEGIN {
    private _direct property _data => prop_all;
    private _direct property _position => prop_all;
    public _direct property Punctuation => prop_all;
    public _direct property Delimier => prop_all;
}

sub LoadString {
    my ($this,$string) = @_;
    
    while ($string =~ /($rxDelim)|($rxPunct)|(.*?)/g) {
        
    
    }
}

sub PlayChunk {
    my ($this,$chunk) = @_;
    
    $opCodesMap{shift @$_}->(@$_) foreach @{$chunk->opStream};
}

sub MatchRegexp {
    my ($this,$rx) = @_;
    
    if ($this->{$_data} =~ $rx) {
        
    }
}

1;