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

Translator.java

00001 package gov.nasa.arc.ase.ltl;
00002 
00003 // Written by Dimitra Giannakopoulou, 19 Jan 2001
00004 import gov.nasa.arc.ase.util.graph.*;
00005 import gov.nasa.arc.ase.jpf.JPFErrorException;
00006 import java.io.*;
00007 
00008 public class Translator
00009 {
00010 
00011   public static void main(String[] args) 
00012   {
00013     String formula = null;
00014     String fname = null;
00015 
00016     if(args.length == 2) {
00017       formula = args[0];
00018       fname = args[1];
00019     } else if(args.length == 1) {
00020       formula = args[0];
00021     } else {
00022       BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
00023 
00024       System.out.println("\nPlease enter LTL formula followed by enter");
00025       try {
00026     formula = input.readLine();
00027       } catch (IOException e) {
00028     System.out.println(" => <input error:" + e.getMessage() + ">");
00029       }
00030     }
00031 
00032     if(fname == null)
00033       translate(formula).save(Graph.FSP_FORMAT);
00034     else
00035       try {
00036     translate(formula).save(fname);
00037       } catch(IOException e) {
00038     System.out.println("Can't save file: " + fname);
00039       }
00040   }  
00041   public static Graph translate(String formula) {
00042     try {
00043       Formula ltl = Formula.parse(formula);
00044       Node init = Node.createInitial(ltl);
00045       State[] states = (init.expand(new Automaton())).structForRuntAnalysis();
00046       return Automaton.SMoutput(states);
00047     } catch(ParseErrorException e) {
00048       throw new JPFErrorException("parse error: " + e.getMessage());
00049     }
00050   }  
00051 }

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