001: // This file is part of KeY - Integrated Deductive Software Design
002: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
003: // Universitaet Koblenz-Landau, Germany
004: // Chalmers University of Technology, Sweden
005: //
006: // The KeY system is protected by the GNU General Public License.
007: // See LICENSE.TXT for details.
008: //
009: //
010: //
011:
012: package de.uka.ilkd.key.counterexample;
013:
014: import java.io.FileNotFoundException;
015: import java.io.IOException;
016: import java.io.RandomAccessFile;
017: import java.util.StringTokenizer;
018:
019: /**
020: * This class is the storage for global configuration data
021: * of the counterexample subpackage. In the future it might
022: * even have a nice editable window instead of a configuration file
023: *
024: * You can use these to optimize your tests during runtime.
025: * These configurations are stored in a separate textfile with
026: * the name supplied by 'configfilename'
027: * -Size of Domain
028: * -Arguments to call Mgtp with
029: * -which Axioms to use
030: * -etc.
031: *
032: * @author Sonja Pieper
033: * @version 0.1, created 08/08/01
034: */
035:
036: public class Configuration {
037:
038: //the actual configuration data
039:
040: /**
041: * Flag for use of the optimized axiom transformation
042: */
043: boolean optimize;
044:
045: /**
046: * Flag which determines wether there is a lemma?
047: */
048: boolean test;
049:
050: /**
051: * Number of constructors allowed in constructorterms
052: */
053: int domainmax;
054:
055: /**
056: * Max number of parameters for which parameter rewriting
057: * will be generated
058: */
059: int maxargs;
060:
061: /**
062: * String of ones and zeroes indicating which axioms to use
063: */
064: String useaxioms;
065:
066: /**
067: * File in which to save the generated calculus for debugging f.e.
068: */
069: String filename;
070:
071: /**
072: * Runtime parameters for the call of Mgtp, possible params: ext, verbose ...
073: */
074: String[] args;
075:
076: /**
077: * Flag that determines wether to produce tex-output
078: */
079: boolean tex;
080:
081: /**
082: * Name of the file in which all the configurations are stored now.
083: */
084: private String configfilename;
085:
086: /**
087: * creates a new configuration from the file specified by filename.
088: * @param filename this should be the name of the file in which
089: * your configuration is stored for example "max"
090: */
091: public Configuration(String filename) {
092: configfilename = filename;
093: }
094:
095: /**
096: * this method reads the configuration and stores it in the
097: * respective fields. it is called by the constructor, so you
098: * don't need to worry about it.
099: */
100: public void readConfig() {
101: try {
102:
103: RandomAccessFile raf = new RandomAccessFile(configfilename,
104: "r");
105:
106: //die configzeilen auslesen, s.o.:
107: domainmax = (new Integer(raf.readLine())).intValue();
108: String conf = raf.readLine();
109: useaxioms = raf.readLine();
110: maxargs = (new Integer(raf.readLine())).intValue();
111: filename = raf.readLine();
112: test = (raf.readLine()).startsWith("test");
113: optimize = (raf.readLine()).startsWith("opt");
114: tex = (raf.readLine()).startsWith("tex");
115: raf.close();
116:
117: //Debug Output:
118: System.out.println("Size of Domain is " + domainmax);
119: System.out.println("Mgtp Args are " + conf);
120: System.out.println("Rewriting " + maxargs + " Arguments");
121: System.out.println("Output will be saved to " + filename
122: + ".mg");
123:
124: //Die Argumente muessen noch in einen Array
125: //einsortiert werden:
126: StringTokenizer st = new StringTokenizer(conf, ",");
127: args = new String[st.countTokens() + 1];
128: args[0] = "ext"; //wichtig! Ist erforderlich fuer das Kalkuel
129: int i = 1;
130: while (st.hasMoreElements()) {
131: args[i] = st.nextToken();
132: i++;
133: }
134:
135: System.out.println("Arguments sorted.");
136: } catch (FileNotFoundException e) {
137: System.out.println("Error getting max: Filenotfound");
138: } catch (IOException e) {
139: System.out.println("Error reading max: Ausgabefehler");
140: }
141:
142: }
143:
144: /**
145: * with this method you can set all configuration data to default values.
146: */
147: public void setDefault() {
148: domainmax = 2;
149: args = new String[1];
150: args[0] = "ext";
151: useaxioms = "11111111111111111111111111";
152: maxargs = 2;
153: filename = "default";
154: test = false;
155: optimize = true;
156: tex = false;
157: }
158:
159: public void changeConfiguration() {//@@@ maybe with window one day in the future
160: //do nothing now
161: }
162:
163: }
|