-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.pl
executable file
·63 lines (46 loc) · 869 Bytes
/
main.pl
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
#!/usr/bin/perl
use strict;
use warnings;
use v5.10.1;
use experimental 'switch';
no warnings 'deprecated';
use Getopt::Long;
use Data::Dumper;
use lib './lib';
use Token;
use Lexer;
use Parser;
use Visitor;
use Registers_x86_16;
use Registers_x86_32;
use Registers_x86_64;
my $os = 'linux';
my $arch = 'x86_64';
my @files;
sub add_file {
push @files, $_[0];
}
GetOptions(
'arch=s' => \$arch,
'os=s' => \$os,
'<>' => \&add_file,
);
my $data;
if (scalar @files == 0){
$data = join '', <>;
} else {
$data = '';
for(@files) {
open FH, '<', $_;
$data = join '', <FH>;
close FH;
}
}
my $lex = Lexer->new($data);
my $tokens = $lex->scan_tokens;
#print join("\n", map {$_->{name}} @$tokens), "\n";
my $parser = Parser->new($tokens);
my $program = $parser->parse;
#print Dumper $program;
my $visitor = Visitor->new();
$visitor->visit($program);