Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

Main.java

00001 package edu.ksu.cis.bandera.abstraction.pvs;
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  * Bandera, a Java(TM) analysis and transformation toolkit           *
00005  * Copyright (C) 1999, 2000   Corina Pasareanu (pcorina@cis.ksu.edu) *
00006  * All rights reserved.                                              *
00007  *                                                                   *
00008  * This work was done as a project in the SAnToS Laboratory,         *
00009  * Department of Computing and Information Sciences, Kansas State    *
00010  * University, USA (http://www.cis.ksu.edu/santos).                  *
00011  * It is understood that any modification not identified as such is  *
00012  * not covered by the preceding statement.                           *
00013  *                                                                   *
00014  * This work is free software; you can redistribute it and/or        *
00015  * modify it under the terms of the GNU Library General Public       *
00016  * License as published by the Free Software Foundation; either      *
00017  * version 2 of the License, or (at your option) any later version.  *
00018  *                                                                   *
00019  * This work is distributed in the hope that it will be useful,      *
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *
00022  * Library General Public License for more details.                  *
00023  *                                                                   *
00024  * You should have received a copy of the GNU Library General Public *
00025  * License along with this toolkit; if not, write to the             *
00026  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,      *
00027  * Boston, MA  02111-1307, USA.                                      *
00028  *                                                                   *
00029  * Java is a trademark of Sun Microsystems, Inc.                     *
00030  *                                                                   *
00031  * To submit a bug report, send a comment, or get the latest news on *
00032  * this project and other SAnToS projects, please visit the web-site *
00033  *                http://www.cis.ksu.edu/santos                      *
00034  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00035 import java.io.*;
00036 import java.util.*;
00037 
00038 class Main {
00039 
00040 
00041 public static void main(String[] args) {
00042 
00043   PrintWriter f_pvs, f_prf, f_el;
00044 
00045 
00046 
00047   try {
00048 
00049   
00050   FileInputStream spec = new FileInputStream(args[0]);
00051   if(spec==null) 
00052     { System.err.println("Error: Unable to open specification file");
00053           return;
00054     }
00055   parser parser_obj = new parser(new Yylex(spec));
00056   parser_obj.parse();
00057   if(parser_obj.npredicates != parser_obj.tokens.size()) {
00058     System.err.println("Error: wrong tokens set!"); return;
00059   }
00060   spec.close();
00061   
00062   f_pvs = new PrintWriter(new OutputStreamWriter(
00063               new  FileOutputStream("abstraction.pvs")));
00064   f_prf = new PrintWriter(new OutputStreamWriter(
00065               new  FileOutputStream("abstraction.prf")));
00066   f_el  = new PrintWriter(new OutputStreamWriter(
00067               new  FileOutputStream("abstraction.el")));
00068 
00069   if(f_pvs == null || f_prf == null || f_el == null)
00070               { System.err.println("Error: Unable to open tmp file");
00071                 return;
00072               }
00073 
00074   if (parser_obj.basic_type==sym.INT) PVS.begin_int(f_pvs);
00075   else PVS.begin_float(f_pvs);
00076   parser_obj.tree.print_PVS(f_pvs);
00077 
00078   PVS.check(f_pvs,parser_obj.npredicates);
00079 
00080   PVS.rest(f_pvs,parser_obj.npredicates,parser_obj.basic_type);
00081 
00082   PVS.prf(f_prf,parser_obj.npredicates,parser_obj.basic_type);
00083 
00084   f_el.println("(prove-pvs-file \"abstraction\")");
00085 
00086   f_prf.close();
00087   f_pvs.close();
00088   f_el.close();
00089  
00090 
00091   PVS.execAndWait("pvs -batch -q -l abstraction.el -v 1");
00092 
00093   PrintWriter f_spec = new PrintWriter(new OutputStreamWriter(
00094               new  FileOutputStream(parser_obj.name+"Abstraction.basl")));
00095 
00096   if(f_spec == null)
00097           { System.err.println("Error: Unable to open tmp file");
00098                 return;
00099               }
00100 
00101   /* antet of generated BASL file */
00102   if(parser_obj.basic_type==sym.INT)
00103     f_spec.print("abstraction "+parser_obj.name+" extends integral\n begin\n");
00104   else
00105     f_spec.print("abstraction "+parser_obj.name+" extends real\n begin\n");
00106 
00107   f_spec.print("  TOKENS = { ");
00108   for(int i=0;i<parser_obj.npredicates-1;i++)
00109     f_spec.print(parser_obj.tokens.elementAt(i)+" , ");
00110   f_spec.print(parser_obj.tokens.elementAt(parser_obj.npredicates-1)+" }; ");
00111 
00112   PVS.check_BASL(f_spec,parser_obj.npredicates,parser_obj.tokens);
00113 
00114   f_spec.print("\n\n  abstract("+parser_obj.variable+")\n  begin\n");
00115   parser_obj.tree.print_BASL(f_spec);
00116   f_spec.print("  end\n\n");
00117 
00118 
00119   PVS.rest_BASL(f_spec,parser_obj.npredicates,parser_obj.basic_type,
00120         parser_obj.tokens);
00121   f_spec.close();
00122 
00123   //Pvs_Spec.rest_spec(PVS.commandOut);
00124 
00125   } catch (Exception e) {
00126         e.printStackTrace();
00127   }
00128 }
00129 }

Generated at Thu Feb 7 06:50:15 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001