line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Language::P::Keywords; |
2
|
|
|
|
|
|
|
|
3
|
101
|
|
|
101
|
|
597
|
use Exporter 'import'; |
|
101
|
|
|
|
|
180
|
|
|
101
|
|
|
|
|
13918
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our( @KEYWORDS, @BUILTINS, @OVERRIDABLES ); |
6
|
|
|
|
|
|
|
BEGIN { |
7
|
101
|
|
|
101
|
|
560
|
our @KEYWORDS = qw(KEY_IF KEY_UNLESS KEY_ELSE KEY_ELSIF KEY_FOR KEY_FOREACH KEY_WHILE KEY_UNTIL KEY_CONTINUE KEY_DO OP_LAST OP_NEXT OP_REDO OP_GOTO OP_MY OP_OUR OP_STATE KEY_LOCAL KEY_SUB KEY_PACKAGE); |
8
|
101
|
|
|
|
|
338
|
our @BUILTINS = qw(KEY_EVAL KEY_PRINT KEY_DEFINED KEY_RETURN KEY_UNDEF KEY_MAP KEY_GREP); |
9
|
101
|
|
|
|
|
14040
|
our @OVERRIDABLES = qw(KEY_UNLINK KEY_GLOB KEY_READLINE KEY_DIE KEY_OPEN KEY_PIPE KEY_CHDIR KEY_RMDIR KEY_READLINE KEY_CLOSE KEY_BINMODE KEY_ABS KEY_WANTARRAY); |
10
|
|
|
|
|
|
|
}; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT = ( @KEYWORDS, @BUILTINS, @OVERRIDABLES, |
13
|
|
|
|
|
|
|
qw(@KEYWORDS @BUILTINS @OVERRIDABLES), |
14
|
|
|
|
|
|
|
qw(is_keyword is_builtin is_overridable is_id) |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
our %EXPORT_TAGS = |
17
|
|
|
|
|
|
|
( all => \@EXPORT, |
18
|
|
|
|
|
|
|
constants => [ @KEYWORDS, @BUILTINS, @OVERRIDABLES ], |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use constant + |
22
|
101
|
|
|
|
|
25143
|
{ ID_MASK => 0x00003, # 2 |
23
|
|
|
|
|
|
|
KEYWORD_MASK => 0x0007c, # 5 |
24
|
|
|
|
|
|
|
BUILTIN_MASK => 0x00f80, # 5 |
25
|
|
|
|
|
|
|
OVERRIDABLE_MASK => 0x1f000, # 5 |
26
|
101
|
|
|
101
|
|
605
|
}; |
|
101
|
|
|
|
|
172
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use constant + |
29
|
2020
|
|
|
|
|
4440
|
{ ( map { $KEYWORDS[$_] => ( $_ + 1 ) << 2 } 0 .. $#KEYWORDS ), |
|
707
|
|
|
|
|
1514
|
|
30
|
1313
|
|
|
|
|
94064
|
( map { $BUILTINS[$_] => ( $_ + 1 ) << 7 } 0 .. $#BUILTINS ), |
31
|
101
|
|
|
|
|
522
|
( map { $OVERRIDABLES[$_] => ( $_ + 1 ) << 12 } 0 .. $#OVERRIDABLES ), |
32
|
101
|
|
|
101
|
|
695
|
}; |
|
101
|
|
|
|
|
218
|
|
33
|
|
|
|
|
|
|
|
34
|
467
|
|
|
467
|
0
|
2533
|
sub is_keyword($) { $_[0] & KEYWORD_MASK } |
35
|
176
|
|
|
176
|
0
|
568
|
sub is_builtin($) { $_[0] & BUILTIN_MASK } |
36
|
183
|
|
|
183
|
0
|
890
|
sub is_overridable($) { $_[0] & OVERRIDABLE_MASK } |
37
|
0
|
|
|
0
|
0
|
|
sub is_id($) { $_[0] & ID_MASK } |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
our %KEYWORDS = |
40
|
|
|
|
|
|
|
( |
41
|
|
|
|
|
|
|
'unlink' => KEY_UNLINK, |
42
|
|
|
|
|
|
|
'print' => KEY_PRINT, |
43
|
|
|
|
|
|
|
'eval' => KEY_EVAL, |
44
|
|
|
|
|
|
|
'else' => KEY_ELSE, |
45
|
|
|
|
|
|
|
'until' => KEY_UNTIL, |
46
|
|
|
|
|
|
|
'elsif' => KEY_ELSIF, |
47
|
|
|
|
|
|
|
'unless' => KEY_UNLESS, |
48
|
|
|
|
|
|
|
'sub' => KEY_SUB, |
49
|
|
|
|
|
|
|
'glob' => KEY_GLOB, |
50
|
|
|
|
|
|
|
'grep' => KEY_GREP, |
51
|
|
|
|
|
|
|
'rmdir' => KEY_RMDIR, |
52
|
|
|
|
|
|
|
'next' => OP_NEXT, |
53
|
|
|
|
|
|
|
'abs' => KEY_ABS, |
54
|
|
|
|
|
|
|
'binmode' => KEY_BINMODE, |
55
|
|
|
|
|
|
|
'chdir' => KEY_CHDIR, |
56
|
|
|
|
|
|
|
'my' => OP_MY, |
57
|
|
|
|
|
|
|
'last' => OP_LAST, |
58
|
|
|
|
|
|
|
'close' => KEY_CLOSE, |
59
|
|
|
|
|
|
|
'defined' => KEY_DEFINED, |
60
|
|
|
|
|
|
|
'goto' => OP_GOTO, |
61
|
|
|
|
|
|
|
'die' => KEY_DIE, |
62
|
|
|
|
|
|
|
'pipe' => KEY_PIPE, |
63
|
|
|
|
|
|
|
'readline' => KEY_READLINE, |
64
|
|
|
|
|
|
|
'local' => KEY_LOCAL, |
65
|
|
|
|
|
|
|
'foreach' => KEY_FOREACH, |
66
|
|
|
|
|
|
|
'open' => KEY_OPEN, |
67
|
|
|
|
|
|
|
'map' => KEY_MAP, |
68
|
|
|
|
|
|
|
'our' => OP_OUR, |
69
|
|
|
|
|
|
|
'do' => KEY_DO, |
70
|
|
|
|
|
|
|
'return' => KEY_RETURN, |
71
|
|
|
|
|
|
|
'state' => OP_STATE, |
72
|
|
|
|
|
|
|
'undef' => KEY_UNDEF, |
73
|
|
|
|
|
|
|
'redo' => OP_REDO, |
74
|
|
|
|
|
|
|
'wantarray' => KEY_WANTARRAY, |
75
|
|
|
|
|
|
|
'package' => KEY_PACKAGE, |
76
|
|
|
|
|
|
|
'while' => KEY_WHILE, |
77
|
|
|
|
|
|
|
'continue' => KEY_CONTINUE, |
78
|
|
|
|
|
|
|
'for' => KEY_FOR, |
79
|
|
|
|
|
|
|
'if' => KEY_IF, |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |