forked from sassbalint/clause-boundary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToken.pm
77 lines (62 loc) · 2.37 KB
/
Token.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package Token;
use strict;
use Strc;
our @ISA = ( 'Strc' );
# --- egyebek: a lényeg
# param: egy Term
# retur: hogy ez a Token kielégíti-e a Term-et
# ez egy tipikus proxy eljárás :)
sub satisfies {
my $self = shift;
my $term = shift;
( $term->isa( 'Term' ) )
? $self->_satisfies( $term )
: "$Exception::msg Token::satisfies requires a Term to satisfy.";
}
sub _satisfies {
my $self = shift;
my $term = shift;
my $ok = 1;
#print
# "\n[" . $term->comp . '] ' .
# $term->info . ' ' .
# $self->as_string . ' ' .
# $term->position->as_string . ' =? ' .
# $self->position->as_string . ' ';
# a típusnak mindenképp stimmelnie kell, nem lehet tagadni (!) XXX
if ( not $self->type->satisfies( $term->type ) ) {
return '';
}
if ( $term->comp eq '=' ) { # hc XXX
if ( $term->form and $self->form ne $term->form ) { $ok = ''; }
elsif ( $term->capit and $self->capit ne $term->capit ) { $ok = ''; }
elsif ( $term->lemma and $self->lemma ne $term->lemma ) { $ok = ''; }
elsif ( not $self->msd->satisfies( $term->msd ) ) { $ok = ''; }
elsif ( $term->position->begpos ne '' and
$self->position->begpos ne $term->position->begpos ) { $ok = ''; }
# XXX ez a Position::satisfies-be való
} elsif ( $term->comp eq '!' ) { # hc XXX
if ( $term->form and $self->form eq $term->form ) { $ok = ''; }
elsif ( $term->capit and $self->capit eq $term->capit ) { $ok = ''; }
elsif ( $term->lemma and $self->lemma eq $term->lemma ) { $ok = ''; }
elsif ( $term->msd->ok and
$self->msd->satisfies( $term->msd ) ) { $ok = ''; }
elsif ( $term->position->begpos ne '' and
$self->position->begpos eq $term->position->begpos ) { $ok = ''; }
# XXX ez a Position::satisfies-be való
} elsif ( $term->comp eq '~' ) { # hc XXX
# XXX XXX XXX CSAK ezekre megy: form, lemma
# XXX XXX XXX a többire '='-ként viselkedik
my $tf = $term->form;
my $tl = $term->lemma;
if ( $term->form and ( $self->form !~ m/$tf/ ) ) { $ok = ''; }
elsif ( $term->capit and $self->capit ne $term->capit ) { $ok = ''; }
elsif ( $term->lemma and ( $self->lemma !~ m/$tl/ ) ) { $ok = ''; }
elsif ( not $self->msd->satisfies( $term->msd ) ) { $ok = ''; }
elsif ( $term->position->begpos ne '' and
$self->position->begpos ne $term->position->begpos ) { $ok = ''; }
# XXX ez a Position::satisfies-be való
}
$ok;
}
1;