Changeset 30c5aab for perl


Ignore:
Timestamp:
Mar 7, 2010, 6:54:59 PM (14 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.6, release-1.7, release-1.8, release-1.9
Children:
d64f963
Parents:
2d232ed
git-author:
David Benjamin <davidben@mit.edu> (02/27/10 22:16:24)
git-committer:
David Benjamin <davidben@mit.edu> (03/07/10 18:54:59)
Message:
Add function for point-less parses

Often, you don't care very much about the point when you do the parse.
We rename existing tokenize to tokenize_with_point and add tokenize that
does point-less parses.

Signed-off-by: David Benjamin <davidben@mit.edu>
Location:
perl/lib/BarnOwl
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • perl/lib/BarnOwl/Completion/Context.pm

    r2d232ed r30c5aab  
    4141use base qw(Class::Accessor::Fast);
    4242use Carp qw(croak);
    43 use BarnOwl::Parse qw(tokenize);
     43use BarnOwl::Parse qw(tokenize_with_point);
    4444
    4545__PACKAGE__->mk_ro_accessors(qw(line point words word word_point
     
    5454    my $point = length ($before_point);
    5555    my ($words, $word, $word_point,
    56         $word_start, $word_end) = tokenize($line, $point);
     56        $word_start, $word_end) = tokenize_with_point($line, $point);
    5757    push @$words, '' if scalar @$words <= $word;
    5858
  • perl/lib/BarnOwl/Parse.pm

    r2d232ed r30c5aab  
    55
    66use base qw(Exporter);
    7 our @EXPORT_OK = qw(tokenize);
     7our @EXPORT_OK = qw(tokenize tokenize_with_point);
    88
    99# TODO: have the main function return whether or not it was a valid parse, with
     
    3333my $space  = qr{[ \t]};
    3434
    35 sub tokenize {
     35sub tokenize_with_point {
    3636    my $line = shift;
    3737    my $point = shift;
     
    9494    return (\@words, $cword, $word_point, $cword_start, $cword_end);
    9595}
     96
     97sub tokenize {
     98    my $line = shift;
     99
     100    my ($words, $word, $word_point,
     101        $word_start, $word_end) = tokenize_with_point($line, 0);
     102    return $words;
     103}
Note: See TracChangeset for help on using the changeset viewer.