genTransMFormFunc.pl revision 42c01284bba8d7c8d995c8dfb96ace57d28ed1bc
# usage:
# substitute ##<WORD> with Haskell code snippits
use strict;
my $disclaimer = '"Remove this trace when Results from map_sign are available\\n"';
# subtitutions with common parts of Modal- and CASL-formulas
my %substs =
("�!modalAx" =>
"inlineAxioms Modal \"modality empty\\n".
"pred p,q:()\\n".
". ",
"�!caslAx" =>
"inlineAxioms CASL \"sort world \\n".
"pred rel : world * world\\n".
"forall w1 : world \\n. ");
my $input = "";
# Argument processing
###unless ($infile eq "DEBUG") {
print STDERR "Generating $outfile1\n";
# open the first two files
# perform the substitutions
while (<IN>) {
s/$key\"/$substs{$key}/ge;
}
print OUT $_;
}
close IN;
close OUT;
# call outlineAxioms and get the result imidiately
if($? >> 8) {
print STDERR "outlineAxioms detected an error\n";
exit 5;
}
###}
###if ($input eq "") {
### $input = join("",<STDIN>);
###}
# process the output of outlineAxioms (further called input)
$input =~ s/^\s*\[\(\[\[//s;
$input =~ s/(\})\]\]\)\]\s*$/$1/s;
# print "$input\n";
# split the input into pairs
print STDERR "Generating $outfile\n";
# open the outputfile and print out the header
print OUT '{- look but don\'t touch !!
import Common.PrettyPrint
import Common.AS_Annotation
-- CASL
import CASL.Logic_CASL
import CASL.AS_Basic_CASL
-- ModalCASL
',
'transSchemaMFormula mapT world rel vars anMF =
let '.
join("\n ",map {'w'.$_.' = vars !! '.($_-1);} (1,2,3,4,5)).
' in
';
# print "Pair: $pair\n";
my $moda_i = 0;
# split each pair into raw pattern and raw result
#print STDERR " $pattern => $result\n";
# pattern is the left hand side of the case '->'
# Each field of NamedSen is substituted by a variable
# And then NamedSen is transformend to a tuple
# remove line breaks and spaces
# add variables foreach modality
# substitute formula variables with underscore
# only 'p','q' and 'r' are recognized
# substitute nullRange with underscore
# remove all stuff that s not needed from the pattern
# closing brace
$pattern =~ s/\}\s*$//o;
# NamedSen Constructor, opening brace and first selector
#print STDERR "222: $pattern\n";
# new isAxiom field
# sentence selctor
#print STDERR "223: $pattern\n";
# All empty lists in the pattern are substituted by underscores
# the result is in the right format and only white spaces / line
# breaks are removed
my $list = "";
$list = "[$list";
$list =~ s/,$/]/o;
}
print OUT
}
';
close OUT;