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

Text parser
author Sergey
date Tue, 08 Dec 2009 17:28:06 +0300
parents
children ac21a032e7a9
comparison
equal deleted inserted replaced
38:d660fb38b7cc 39:4f5a6a1bfb0e
1 package IMPL::Text::Parser::Player;
2 use strict;
3 use warnings;
4
5 use base qw(IMPL::Object);
6 use IMPL::Class::Property;
7 use IMPL::Class::Property::Direct;
8
9 use IMPL::Text::Parser::Chunk;
10
11 my %opCodesMap = (
12 IMPL::Text::Parser::Chunk::OP_REGEXP , &MatchRegexp ,
13 IMPL::Text::Parser::Chunk::OP_STRING , &MatchString ,
14 IMPL::Text::Parser::Chunk::OP_REFERENCE , &MatchReference ,
15 IMPL::Text::Parser::Chunk::OP_CHUNK , &PlayChunk ,
16 IMPL::Text::Parser::Chunk::OP_SWITCH , &MatchSwitch ,
17 IMPL::Text::Parser::Chunk::OP_REPEAT , &MatchRepeat
18 );
19
20 BEGIN {
21 private _direct property _data => prop_all;
22 private _direct property _position => prop_all;
23 public _direct property Punctuation => prop_all;
24 public _direct property Delimier => prop_all;
25 }
26
27 sub LoadString {
28 my ($this,$string) = @_;
29
30 while ($string =~ /($rxDelim)|($rxPunct)|(.*?)/g) {
31
32
33 }
34 }
35
36 sub PlayChunk {
37 my ($this,$chunk) = @_;
38
39 $opCodesMap{shift @$_}->(@$_) foreach @{$chunk->opStream};
40 }
41
42 sub MatchRegexp {
43 my ($this,$rx) = @_;
44
45 if ($this->{$_data} =~ $rx) {
46
47 }
48 }
49
50 1;