File: Token.pm

package info (click to toggle)
libcompiler-lexer-perl 0.23-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 612 kB
  • sloc: cpp: 5,127; perl: 1,167; makefile: 3
file content (89 lines) | stat: -rw-r--r-- 1,412 bytes parent folder | download | duplicates (2)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
package Compiler::Lexer::Token;
use strict;
use warnings;

my $FIELDS = [qw/
    stype
    type
    kind
    line
    name
    data
    has_warnings
/];

{
    no strict 'refs';
    foreach my $field (@$FIELDS) {
        *{__PACKAGE__ . '::' . $field} = sub {
            my ($self, $value) = @_;
            return $self->{$field} unless defined $value;
            $self->{$field} = $value;
        };
    }
}

1;
__END__

=encoding utf-8

=for stopwords stype

=head1 NAME

Compiler::Lexer::Token - Token object for Compiler::Lexer

=head1 SYNOPSIS

Compiler::Lexer::Token includes the following members.

=over

=item stype

constant of Compiler::Lexer::SyntaxType

=item type

constant of Compiler::Lexer::TokenType

=item kind

constant of Compiler::Lexer::Kind

=item name

name of Compiler::Lexer::TokenType

=item data

raw data

=item has_warnings

flag of whether unknown keyword or not

=back

=head1 METHODS

support simple get/set accessors like Class::Accessor::Fast

example:

  my $type = $token->type;                            # get accessor
  $token->type(Compiler::Lexer::TokenType::T_RegExp); # set accessor

=head1 AUTHOR

Masaaki Goshima (goccy) E<lt>goccy(at)cpan.orgE<gt>

=head1 LICENSE AND COPYRIGHT

Copyright (c) 2013, Masaaki Goshima (goccy). All rights reserved.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=cut