line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Language::MinCaml; |
2
|
2
|
|
|
2
|
|
14
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
110
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
26
|
use 5.8.1; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
86
|
|
6
|
2
|
|
|
2
|
|
1049
|
use Language::MinCaml::Code; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
20
|
|
7
|
2
|
|
|
2
|
|
1373
|
use Language::MinCaml::Lexer; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
91
|
|
8
|
2
|
|
|
2
|
|
2929
|
use Language::MinCaml::Parser; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
77
|
|
9
|
2
|
|
|
2
|
|
19
|
use Language::MinCaml::Type; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
18
|
|
10
|
2
|
|
|
2
|
|
1407
|
use Language::MinCaml::TypeInferrer; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Language::MinCaml::Evaluator; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _interpret { |
14
|
|
|
|
|
|
|
my($class, $code) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $lexer = Language::MinCaml::Lexer->new($code); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $parser = Language::MinCaml::Parser->new; |
19
|
|
|
|
|
|
|
my $root_node = $parser->parse($lexer); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $inferrer = Language::MinCaml::TypeInferrer->new; |
22
|
|
|
|
|
|
|
$inferrer->infer($root_node, |
23
|
|
|
|
|
|
|
(print_int => Type_Fun([Type_Int()], Type_Unit()), |
24
|
|
|
|
|
|
|
print_float => Type_Fun([Type_Float()], Type_Unit()))); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $evaluator = Language::MinCaml::Evaluator->new; |
27
|
|
|
|
|
|
|
$evaluator->evaluate($root_node, |
28
|
|
|
|
|
|
|
(print_int => sub { print shift; return; }, |
29
|
|
|
|
|
|
|
print_float => sub { print shift; return; })); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub interpret_string { |
33
|
|
|
|
|
|
|
my($class, $string) = @_; |
34
|
|
|
|
|
|
|
$class->_interpret(Language::MinCaml::Code->from_string($string)); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub interpret_file { |
38
|
|
|
|
|
|
|
my($class, $file_path) = @_; |
39
|
|
|
|
|
|
|
$class->_interpret(Language::MinCaml::Code->from_file($file_path)); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
__END__ |