-
Notifications
You must be signed in to change notification settings - Fork 0
/
tnew.pl
executable file
·46 lines (33 loc) · 888 Bytes
/
tnew.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
#!/usr/local/bin/perl
#
# An ambitious project (so far unnamed) to create a general-purpose dynamic
# systems simulation package using Perl and PDL, with the object of simulating
# the Biome-BGC model and its successors.
#
use strict;
use warnings;
use Data::Dumper;
use madgrammar;
my ($outputname);
$Data::Dumper::Terse = 1;
$Data::Dumper::Indent = 1;
my $parser = madgrammar->new();
$parser->init_parser();
# take the input from the command line arguments
# or from STDIN
if ( @ARGV > 0 ) {
$parser->use_input($ARGV[0]);
($outputname = $ARGV[0]) =~ s/.mad$//;
$outputname .= ".output";
}
else {
$parser->use_input();
}
# parse the input and get the AST
my $tree = $parser->YYParse();
if ( defined $tree ) {
open OF, ">$outputname" or warn "Could not write output file: $!\n";
print OF Dumper($tree);
close OF;
print $tree->str(), "\n";
}