line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mylisp::Grammar; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
14
|
use 5.012; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
5
|
no warnings 'experimental'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use Exporter; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
77
|
|
7
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
8
|
|
|
|
|
|
|
our @EXPORT = qw(get_my_grammar); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub get_my_grammar { |
11
|
|
|
|
|
|
|
return <<'EOF' |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
door = ^ |_ _pod Expr|+ $ ; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
_ = |\s+ _comm|+ ; |
16
|
|
|
|
|
|
|
_pod = '=pod' ~ '=end' ; |
17
|
|
|
|
|
|
|
_comm = '#' ~ $$ ; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Expr = '(' |_ atom|+ ')' ; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
atom = | |
22
|
|
|
|
|
|
|
Expr Array Hash |
23
|
|
|
|
|
|
|
Int Kstr Lstr Str String Char |
24
|
|
|
|
|
|
|
Aindex Arange Ocall |
25
|
|
|
|
|
|
|
Oper Ns Arg Var Sub |
26
|
|
|
|
|
|
|
| ; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Array = '[' |_ \, atom|+ ']' ; |
29
|
|
|
|
|
|
|
Hash = '{' |_ \, Pair|+ '}' ; |
30
|
|
|
|
|
|
|
Pair = |Kstr Str Sub| \s* '=>' \s* atom ; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Int = \-? \d+ ; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Kstr = \: [\w\-:]+ ; |
35
|
|
|
|
|
|
|
Lstr = \'\'\' ~ { \'\'\' } ; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Str = \' |schars char|+ \' ; |
38
|
|
|
|
|
|
|
schars = [^\\']+ ; |
39
|
|
|
|
|
|
|
char = \\ . ; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
String = \" |Chars Char Scalar|+ \" ; |
42
|
|
|
|
|
|
|
Chars = [^\\"$]+ ; |
43
|
|
|
|
|
|
|
Char = \\ . ; |
44
|
|
|
|
|
|
|
Scalar = '$' [\a\-]+ ; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Aindex = Var {'[' |Int Kstr Scalar| ']'}+ ; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Arange = Var '[' |Int Scalar| ':' |Int Scalar|? ']' ; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Ocall = Var \. Sub ; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Oper = [\-+=><!~|&]+ ; |
53
|
|
|
|
|
|
|
Ns = name {'::' name}+ ; |
54
|
|
|
|
|
|
|
Arg = [$@%] name ':' type ; |
55
|
|
|
|
|
|
|
Sub = name ; |
56
|
|
|
|
|
|
|
Var = [$@%] name ; |
57
|
|
|
|
|
|
|
name = [\a\-]+ ; |
58
|
|
|
|
|
|
|
type = [\a\-?+]+ ; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
EOF |
61
|
0
|
|
|
0
|
0
|
|
} |
62
|
|
|
|
|
|
|
1; |