Mercurial > pub > Impl
diff Lib/IMPL/Text/Parser/Player.pm @ 40:ac21a032e7a9
bnf parser in progress
author | Sergey |
---|---|
date | Thu, 10 Dec 2009 17:43:39 +0300 |
parents | 4f5a6a1bfb0e |
children | c442eb67fa22 |
line wrap: on
line diff
--- a/Lib/IMPL/Text/Parser/Player.pm Tue Dec 08 17:28:06 2009 +0300 +++ b/Lib/IMPL/Text/Parser/Player.pm Thu Dec 10 17:43:39 2009 +0300 @@ -19,7 +19,7 @@ BEGIN { private _direct property _data => prop_all; - private _direct property _position => prop_all; + private _direct property _current => prop_all; public _direct property Punctuation => prop_all; public _direct property Delimier => prop_all; } @@ -27,10 +27,18 @@ sub LoadString { my ($this,$string) = @_; - while ($string =~ /($rxDelim)|($rxPunct)|(.*?)/g) { - + my $rxDelim = /(\s+|[.,;!-+*~$^&|%()`@\\\/])/; + + my $line = 0; - } + $this->{$_data} = [ + map { + $line++; + map { + [$line,$_] + } split $rxDelim, $_ + } split /\n/, $string + ] } sub PlayChunk { @@ -42,9 +50,27 @@ sub MatchRegexp { my ($this,$rx) = @_; - if ($this->{$_data} =~ $rx) { + if ($this->{$_current}{token} =~ $rx) { } } +sub moveNext { + my ($this) = @_; + + my $pos = $this->{$_current}{pos}; + + $pos ++; + + if ($pos < @{$this->{$_data}}) { + + $this->{$_current} = { + pos => $pos + }; + + } else { + return undef; + } +} + 1;