line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lox::Token; |
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
4
|
1
|
|
|
1
|
|
4
|
use Lox::TokenType (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
223
|
|
5
|
|
|
|
|
|
|
our $VERSION = 0.02; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
10
|
|
|
10
|
0
|
18
|
my ($class, $args) = @_; |
9
|
|
|
|
|
|
|
return bless { |
10
|
|
|
|
|
|
|
literal => $args->{literal}, |
11
|
|
|
|
|
|
|
lexeme => $args->{lexeme}, |
12
|
|
|
|
|
|
|
column => $args->{column}, |
13
|
|
|
|
|
|
|
type => $args->{type}, |
14
|
|
|
|
|
|
|
line => $args->{line}, |
15
|
10
|
|
|
|
|
52
|
}, $class; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub to_string { |
19
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
20
|
|
|
|
|
|
|
return sprintf '%3d:%3d %-12s %s %s', |
21
|
|
|
|
|
|
|
$self->{line}, |
22
|
|
|
|
|
|
|
$self->{column}, |
23
|
|
|
|
|
|
|
Lox::TokenType::type($self->{type}), |
24
|
|
|
|
|
|
|
$self->{lexeme}, |
25
|
0
|
|
|
|
|
0
|
$self->{literal}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
0
|
0
|
0
|
sub literal { $_[0]->{literal} } |
29
|
2
|
|
|
2
|
0
|
7
|
sub lexeme { $_[0]->{lexeme} } |
30
|
0
|
|
|
0
|
0
|
0
|
sub column { $_[0]->{column} } |
31
|
2
|
|
|
2
|
0
|
11
|
sub type { $_[0]->{type} } |
32
|
0
|
|
|
0
|
0
|
|
sub line { $_[0]->{line} } |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub accept { |
35
|
0
|
|
|
0
|
0
|
|
my ($self, $caller) = @_; |
36
|
0
|
|
|
|
|
|
$caller->visit_token($self); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |