| 1 | package Zuzu::Token; | ||||||||||||
| 2 | |||||||||||||
| 3 | 78 | ▶ | use utf8; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | |||||||||||||
| 5 | 78 | our $VERSION = '0.007002'; | |||||||||||
| 6 | |||||||||||||
| 7 | 78 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | |||||||||||||
| 9 | 78 | has 'type' => ( is => 'rw' ); | |||||||||||
| 10 | 78 | has 'value' => ( is => 'rw' ); | |||||||||||
| 11 | 78 | has 'file' => ( is => 'rw' ); | |||||||||||
| 12 | 78 | has 'line' => ( is => 'rw' ); | |||||||||||
| 13 | 78 | has 'col' => ( is => 'rw' ); | |||||||||||
| 14 | |||||||||||||
| 15 | 2845991 | ▶ | sub is_type { | ||||||||||
|
Subroutine
is_type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 16 | 2845991 | my ( $self, $type ) = @_; | |||||||||||
| 17 | |||||||||||||
| 18 | 2845991 | return $self->type eq $type; | |||||||||||
| 19 | } | ||||||||||||
| 20 | |||||||||||||
| 21 | 1067688 | ▶ | sub is_KW { | ||||||||||
|
Subroutine
is_KW: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||
| 22 | 1067688 | my ( $self, $value ) = @_; | |||||||||||
| 23 | |||||||||||||
| 24 | 1067688 | ▶ | return 0 if !$self->is_type('KW'); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 25 | |||||||||||||
| 26 | 241751 | ▶ | return 1 if !defined $value; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 27 | |||||||||||||
| 28 | 222079 | ▶ | return ( $self->value // '' ) eq $value; | ||||||||||
|
Condition50%1/2
$self->value // ""
MC/DC0%0/1
$self->value // ""
$self->value
Truth table50%1/2
A
A= $self->value
| |||||||||||||
| 29 | } | ||||||||||||
| 30 | |||||||||||||
| 31 | 1172817 | ▶ | sub is_OP { | ||||||||||
|
Subroutine
is_OP: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||
| 32 | 1172817 | my ( $self, $value ) = @_; | |||||||||||
| 33 | |||||||||||||
| 34 | 1172817 | ▶ | return 0 if !$self->is_type('OP'); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 35 | |||||||||||||
| 36 | 747383 | ▶ | return 1 if !defined $value; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 37 | |||||||||||||
| 38 | 106543 | ▶ | return ( $self->value // '' ) eq $value; | ||||||||||
|
Condition50%1/2
$self->value // ""
MC/DC0%0/1
$self->value // ""
$self->value
Truth table50%1/2
A
A= $self->value
| |||||||||||||
| 39 | } | ||||||||||||
| 40 | |||||||||||||
| 41 | 103065 | ▶ | sub is_IDENT { $_[0]->is_type('IDENT') } | ||||||||||
|
Subroutine
is_IDENT: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 42 | |||||||||||||
| 43 | 73070 | ▶ | sub is_NUMBER { $_[0]->is_type('NUMBER') } | ||||||||||
|
Subroutine
is_NUMBER: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 44 | |||||||||||||
| 45 | 73463 | ▶ | sub is_STRING { $_[0]->is_type('STRING') } | ||||||||||
|
Subroutine
is_STRING: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 46 | |||||||||||||
| 47 | 61575 | ▶ | sub is_BOOL { $_[0]->is_type('BOOL') } | ||||||||||
|
Subroutine
is_BOOL: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 48 | |||||||||||||
| 49 | 59578 | ▶ | sub is_NULL { $_[0]->is_type('NULL') } | ||||||||||
|
Subroutine
is_NULL: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 50 | |||||||||||||
| 51 | 9148 | ▶ | sub is_EMPTY_SET { $_[0]->is_type('EMPTY_SET') } | ||||||||||
|
Subroutine
is_EMPTY_SET: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 52 | |||||||||||||
| 53 | 60652 | ▶ | sub is_REGEXP { $_[0]->is_type('REGEXP') } | ||||||||||
|
Subroutine
is_REGEXP: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 54 | |||||||||||||
| 55 | 40481 | ▶ | sub is_EOF { $_[0]->is_type('EOF') } | ||||||||||
|
Subroutine
is_EOF: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 56 | |||||||||||||
| 57 | =pod | ||||||||||||
| 58 | |||||||||||||
| 59 | =head1 NAME | ||||||||||||
| 60 | |||||||||||||
| 61 | Zuzu::Token - token object produced by the lexer | ||||||||||||
| 62 | |||||||||||||
| 63 | =head1 DESCRIPTION | ||||||||||||
| 64 | |||||||||||||
| 65 | Carries token type, value, and source location used by the parser and | ||||||||||||
| 66 | diagnostics. | ||||||||||||
| 67 | |||||||||||||
| 68 | =head1 INHERITANCE | ||||||||||||
| 69 | |||||||||||||
| 70 | Inherits from C<Moo::Object>. | ||||||||||||
| 71 | |||||||||||||
| 72 | =head1 ROLES | ||||||||||||
| 73 | |||||||||||||
| 74 | None. | ||||||||||||
| 75 | |||||||||||||
| 76 | =head1 ATTRIBUTES | ||||||||||||
| 77 | |||||||||||||
| 78 | =head2 type | ||||||||||||
| 79 | |||||||||||||
| 80 | Type: B<Str>. | ||||||||||||
| 81 | |||||||||||||
| 82 | Token category name (for example C<IDENT>, C<NUMBER>, or C<OP>). | ||||||||||||
| 83 | |||||||||||||
| 84 | =head2 value | ||||||||||||
| 85 | |||||||||||||
| 86 | Type: B<Any>. | ||||||||||||
| 87 | |||||||||||||
| 88 | Literal payload or symbol text associated with C<type>. | ||||||||||||
| 89 | |||||||||||||
| 90 | =head2 file | ||||||||||||
| 91 | |||||||||||||
| 92 | Type: B<Maybe[Str]>. | ||||||||||||
| 93 | |||||||||||||
| 94 | Source filename used for diagnostics. | ||||||||||||
| 95 | |||||||||||||
| 96 | =head2 line | ||||||||||||
| 97 | |||||||||||||
| 98 | Type: B<Int>. | ||||||||||||
| 99 | |||||||||||||
| 100 | 1-based source line number used for diagnostics. | ||||||||||||
| 101 | |||||||||||||
| 102 | =head2 col | ||||||||||||
| 103 | |||||||||||||
| 104 | Type: B<Int>. | ||||||||||||
| 105 | |||||||||||||
| 106 | 1-based source column number used for diagnostics. | ||||||||||||
| 107 | |||||||||||||
| 108 | =head1 METHODS | ||||||||||||
| 109 | |||||||||||||
| 110 | =head2 is_type | ||||||||||||
| 111 | |||||||||||||
| 112 | Returns true when C<type> matches the supplied type string. | ||||||||||||
| 113 | |||||||||||||
| 114 | =head2 is_KW | ||||||||||||
| 115 | |||||||||||||
| 116 | Returns true when this token is a C<KW> token. | ||||||||||||
| 117 | |||||||||||||
| 118 | When a value argument is supplied, also requires C<value> to match. | ||||||||||||
| 119 | |||||||||||||
| 120 | =head2 is_OP | ||||||||||||
| 121 | |||||||||||||
| 122 | Returns true when this token is an C<OP> token. | ||||||||||||
| 123 | |||||||||||||
| 124 | When a value argument is supplied, also requires C<value> to match. | ||||||||||||
| 125 | |||||||||||||
| 126 | =head2 is_IDENT | ||||||||||||
| 127 | |||||||||||||
| 128 | Returns true when this token is an C<IDENT> token. | ||||||||||||
| 129 | |||||||||||||
| 130 | =head2 is_NUMBER | ||||||||||||
| 131 | |||||||||||||
| 132 | Returns true when this token is an C<NUMBER> token. | ||||||||||||
| 133 | |||||||||||||
| 134 | =head2 is_STRING | ||||||||||||
| 135 | |||||||||||||
| 136 | Returns true when this token is an C<STRING> token. | ||||||||||||
| 137 | |||||||||||||
| 138 | =head2 is_BOOL | ||||||||||||
| 139 | |||||||||||||
| 140 | Returns true when this token is an C<BOOL> token. | ||||||||||||
| 141 | |||||||||||||
| 142 | =head2 is_NULL | ||||||||||||
| 143 | |||||||||||||
| 144 | Returns true when this token is an C<NULL> token. | ||||||||||||
| 145 | |||||||||||||
| 146 | =head2 is_EMPTY_SET | ||||||||||||
| 147 | |||||||||||||
| 148 | Returns true when this token is an C<EMPTY_SET> token. | ||||||||||||
| 149 | |||||||||||||
| 150 | =head2 is_EOF | ||||||||||||
| 151 | |||||||||||||
| 152 | Returns true when this token is an C<EOF> token. | ||||||||||||
| 153 | |||||||||||||
| 154 | =head1 SEE ALSO | ||||||||||||
| 155 | |||||||||||||
| 156 | Subclasses: none in this distribution. | ||||||||||||
| 157 | |||||||||||||
| 158 | =head1 COPYRIGHT AND LICENCE | ||||||||||||
| 159 | |||||||||||||
| 160 | B<< Zuzu::Token >> is copyright Toby Inkster. | ||||||||||||
| 161 | |||||||||||||
| 162 | It is free software; you may redistribute it and/or modify it under | ||||||||||||
| 163 | the terms of either the Artistic License 1.0 or the GNU General Public | ||||||||||||
| 164 | License version 2. | ||||||||||||
| 165 | |||||||||||||
| 166 | =cut | ||||||||||||
| 167 | |||||||||||||
| 168 | 78 | 1; | |||||||||||