More examples, better defaults
grammar_separated is grammar but with all functions exposed
This commit is contained in:
39
testing/mex/convert.plx
Normal file
39
testing/mex/convert.plx
Normal file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/perl
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
my %structure = (
|
||||
Environment => (),
|
||||
InitialEntities => (),
|
||||
Context => (),
|
||||
Reactions => (),
|
||||
);
|
||||
|
||||
open FILE, $ARGV[0] or die $!;
|
||||
my @data = <FILE>;
|
||||
my $data = "@data";
|
||||
|
||||
$data =~ /myentities\(\[([^\]]*)\]\)/s;
|
||||
$structure{InitialEntities} = $1;
|
||||
|
||||
$data =~ /myenvironment\(\"\[([^\]]*)\]\"\)/s;
|
||||
$structure{Environment} = $1;
|
||||
|
||||
$data =~ /mycontext\(\"\[([^\]]*)\]\"\)/s;
|
||||
$structure{Context} = $1;
|
||||
|
||||
my $line;
|
||||
for $line (@data) {
|
||||
$_ = $line;
|
||||
if (/react.*\]\),?$/) {
|
||||
s/react\(\[(.*?)\],\[(.*?)\],\[(.*?)\]\),?/[{$1}, {$2}, {$3}]/;
|
||||
chomp $_;
|
||||
$structure{Reactions} .= "$_;\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print ("Environment: [", $structure{Environment}, "]\n");
|
||||
print ("Initial Entities: {", $structure{InitialEntities} ,"}\n");
|
||||
print ("Context: [", $structure{Context}, "]\n");
|
||||
print ("Reactions: (\n", $structure{Reactions}, ")\n");
|
||||
Reference in New Issue
Block a user