line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mylisp; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
48610
|
use 5.012; |
|
1
|
|
|
|
|
5
|
|
4
|
1
|
|
|
1
|
|
5
|
no warnings "experimental"; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Exporter; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
67
|
|
7
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
8
|
|
|
|
|
|
|
our @EXPORT = |
9
|
|
|
|
|
|
|
qw(mylisp_repl get_mylisp_parser mylisp_to_ast); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '2.01'; |
12
|
1
|
|
|
1
|
|
282
|
use Spp::Builtin; |
|
1
|
|
|
|
|
174470
|
|
|
1
|
|
|
|
|
211
|
|
13
|
1
|
|
|
1
|
|
332
|
use Spp::Tools; |
|
1
|
|
|
|
|
2113
|
|
|
1
|
|
|
|
|
99
|
|
14
|
1
|
|
|
1
|
|
278
|
use Spp; |
|
1
|
|
|
|
|
11057
|
|
|
1
|
|
|
|
|
64
|
|
15
|
1
|
|
|
1
|
|
336
|
use Mylisp::Grammar; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
16
|
1
|
|
|
1
|
|
285
|
use Mylisp::OptAst; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
121
|
|
17
|
1
|
|
|
1
|
|
237
|
use Mylisp::Lint; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
61
|
|
18
|
1
|
|
|
1
|
|
269
|
use Mylisp::LintAst; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
106
|
|
19
|
1
|
|
|
1
|
|
268
|
use Mylisp::ToPerl; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
142
|
|
20
|
1
|
|
|
1
|
|
247
|
use Mylisp::ToMylisp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
77
|
|
21
|
1
|
|
|
1
|
|
264
|
use Mylisp::ToGo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
290
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub mylisp_repl { |
24
|
0
|
|
|
0
|
0
|
|
my $parser = get_mylisp_parser(); |
25
|
0
|
|
|
|
|
|
say 'This is Mylisp REPL, type enter to exit.'; |
26
|
0
|
|
|
|
|
|
while (1) { |
27
|
0
|
|
|
|
|
|
print '>> '; |
28
|
0
|
|
|
|
|
|
my $line = <STDIN>; |
29
|
0
|
0
|
|
|
|
|
exit() if ord($line) == 10; |
30
|
0
|
|
|
|
|
|
my ($match, $ok) = match_text($parser, $line); |
31
|
0
|
0
|
|
|
|
|
if ($ok) { |
32
|
0
|
|
|
|
|
|
say '.. ', see_ast($match); |
33
|
0
|
|
|
|
|
|
my $ast = opt_mylisp_ast($match); |
34
|
0
|
|
|
|
|
|
say '.. ', see_ast($ast); |
35
|
0
|
|
|
|
|
|
my $lint = new_lint($line); |
36
|
0
|
|
|
|
|
|
say 'golang -> ', ast_to_go($ast); |
37
|
0
|
|
|
|
|
|
say 'perl -> ', ast_to_perl_repl($ast); |
38
|
0
|
|
|
|
|
|
say 'mylisp-> ', ast_to_mylisp($ast); |
39
|
|
|
|
|
|
|
} |
40
|
0
|
|
|
|
|
|
else { say $match } |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub get_mylisp_parser { |
45
|
0
|
|
|
0
|
0
|
|
my $grammar = get_mylisp_grammar(); |
46
|
0
|
|
|
|
|
|
return grammar_to_ast($grammar); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub mylisp_to_ast { |
50
|
0
|
|
|
0
|
0
|
|
my $code = shift; |
51
|
0
|
|
|
|
|
|
my $parser = get_mylisp_parser(); |
52
|
0
|
|
|
|
|
|
my ($match, $ok) = match_text($parser, $code); |
53
|
0
|
0
|
|
|
|
|
if ($ok) { return opt_mylisp_ast($match) } |
|
0
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
else { error($match) } |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
1; |