Mercurial > pub > Impl
diff Lib/IMPL/Text/Parser/Chunk.pm @ 39:4f5a6a1bfb0e
Text parser
author | Sergey |
---|---|
date | Tue, 08 Dec 2009 17:28:06 +0300 |
parents | c529d386d80e |
children | 16ada169ca75 |
line wrap: on
line diff
--- a/Lib/IMPL/Text/Parser/Chunk.pm Mon Nov 23 17:57:07 2009 +0300 +++ b/Lib/IMPL/Text/Parser/Chunk.pm Tue Dec 08 17:28:06 2009 +0300 @@ -2,7 +2,7 @@ use strict; use warnings; -use base qw(IMPL::Object); +use base qw(IMPL::Object IMPL::Object::Autofill); use IMPL::Class::Property; use IMPL::Class::Property::Direct; @@ -12,8 +12,8 @@ OP_STRING => 2, OP_REFERENCE => 3, OP_CHUNK => 4, - OP_THROW => 5, - OP_TRYCATCH => 6 + OP_SWITCH => 5, + OP_REPEAT => 7 }; BEGIN { @@ -59,42 +59,35 @@ push @{$this->{$opStream}}, [OP_CHUNK, $chunk]; } -sub Throw { - my ($this, $msg) = @_; +sub Switch { + my $this = shift; - push @{$this->{$opStream}}, [OP_THROW, $msg]; -} - -sub TryCatch { - my ($this,$chunkTry,$chunkCatch) = @_; - - push @{$this->{$opStream}}, [OP_TRYCATCH, $chunkTry, $chunkCatch]; + push @{$this->{$opStream}}, [OP_SWITCH, @_]; } -sub compile { - my ($this) = @_; - - my $text = ''; +sub Repeat { + my ($this,$chunk,$min,$max) = @_; - if ($this->{$opStream}) { - foreach my $op (@{$this->{$opStream}}) { - my $code = shift @$op; - - if ($code == OP_REGEXP) { - - } elsif ($code == OP_STRING) { - - } elsif ($code == OP_REFERENCE) { - - } elsif ($code == OP_CHUNK) { - - } elsif ($code == OP_THROW) { - - } elsif ($code == OP_TRYCATCH) { - - } - } - } + 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 \ No newline at end of file