# HG changeset patch # User Sergey # Date 1260456219 -10800 # Node ID ac21a032e7a9127a2faa2c256ca2344ad95336a2 # Parent 4f5a6a1bfb0e4e4156d7f920ec846929ea061ae9 bnf parser in progress diff -r 4f5a6a1bfb0e -r ac21a032e7a9 Lib/IMPL/Text/Parser/Player.pm --- 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;