Project

General

Profile

Revision 7

Added by Willibald K. over 8 years ago

changing java, cpp, hpp files to unix line endings

View differences:

CompilerConfiguration.java
1
/**

2
  *

3
  *                      OOAS Compiler

4
  *

5
  *       Copyright 2015, AIT Austrian Institute of Technology.

6
  * This code is based on the C# Version of the OOAS Compiler, which is

7
  * copyright 2015 by the Institute of Software Technology, Graz University

8
  * of Technology with portions copyright by the AIT Austrian Institute of

9
  * Technology. All rights reserved.

10
  *

11
  * SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED.

12
  *

13
  * If you modify the file please update the list of contributors below to in-

14
  * clude your name. Please also stick to the coding convention of using TABs

15
  * to do the basic (block-level) indentation and spaces for anything after

16
  * that. (Enable the display of special chars and it should be pretty obvious

17
  * what this means.) Also, remove all trailing whitespace.

18
  *

19
  * Contributors:

20
  *               Willibald Krenn (AIT)

21
  *               Stephan Zimmerer (AIT)

22
  *               Markus Demetz (AIT)

23
  *               Christoph Czurda (AIT)

24
  *

25
  */

1
/**
2
  *
3
  *                      OOAS Compiler
4
  *
5
  *       Copyright 2015, AIT Austrian Institute of Technology.
6
  * This code is based on the C# Version of the OOAS Compiler, which is
7
  * copyright 2015 by the Institute of Software Technology, Graz University
8
  * of Technology with portions copyright by the AIT Austrian Institute of
9
  * Technology. All rights reserved.
10
  *
11
  * SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED.
12
  *
13
  * If you modify the file please update the list of contributors below to in-
14
  * clude your name. Please also stick to the coding convention of using TABs
15
  * to do the basic (block-level) indentation and spaces for anything after
16
  * that. (Enable the display of special chars and it should be pretty obvious
17
  * what this means.) Also, remove all trailing whitespace.
18
  *
19
  * Contributors:
20
  *               Willibald Krenn (AIT)
21
  *               Stephan Zimmerer (AIT)
22
  *               Markus Demetz (AIT)
23
  *               Christoph Czurda (AIT)
24
  *
25
  */
26 26

  
27 27

  
28
package org.momut.ooas;

29

  
30
import java.io.InputStream;

31
import java.io.OutputStream;

32

  
33
import org.momut.ooas.codegen.ast.IAstDuplicator;

28
package org.momut.ooas;
29

  
30
import java.io.InputStream;
31
import java.io.OutputStream;
32

  
33
import org.momut.ooas.codegen.ast.IAstDuplicator;
34 34
import org.momut.ooas.utils.exceptions.OoasCompilerRuntimeException;
35

  
36

  
37
public final class CompilerConfiguration {
38
	public enum LabelCompression { NoCompression, ActionsMethods, ActionsMethodsObjects, All }
39
	public enum Backend {Prolog, PrologSymbolic, Printer, CADP, CopyAST}
40
	private boolean configWriteable = true;
41
	private int searchDepth = 35;
42
	private String nameSpace = "as";
43
	private boolean quiet = false;
44
	private String namedTypePrefix = "";
45

  
46
	private final boolean streams;
47
	// options for non streaming interface
48
	private final Backend backend;
49
	private final String fileToParse;
50
	private final String outputToFile;
51
	// options for stream
52
	private final InputStream inputStream;
53
	private final OutputStream outputStream;
54
	private final String unitName;
55

  
56
	// compress options
57
	private LabelCompression compression;
58
	private IAstDuplicator<?> m_duplicator;
59

  
60

  
61
	private void checkWriteable() {
62
		if (!configWriteable)
63
			throw new OoasCompilerRuntimeException("CompilerConfig read-only.");
64
	}
65
	public boolean isWriteable() {return configWriteable;}
66
	void setWriteOnly(){
67
		configWriteable = false;
68
	}
69

  
70
	public boolean useStreams() {return streams;}
71
	public String getUnitName() {return unitName;}
72

  
73
	public String getFileToParse() {
74
		if (streams)
75
			throw new IllegalArgumentException("OOAS compiler was configured with input/output streams.");
76
		return fileToParse;
77
	}
78
	public String getFileToOutput() {
79
		if (streams)
80
			throw new IllegalArgumentException("OOAS compiler was configured with input/output streams.");
81
		return outputToFile;
82
	}
83

  
84
	public InputStream getInputStream() {
85
		if (!streams)
86
			throw new IllegalArgumentException("OOAS compiler was configured with input/output files.");
87
		return inputStream;
88
	}
89
	public OutputStream getOutputStream() {
90
		if (!streams)
91
			throw new IllegalArgumentException("OOAS compiler was configured with input/output files.");
92
		return outputStream;
93
	}
94

  
95
	public Backend getBackend() {return backend;}
96

  
97
	public int getMaxSearchDepth() {return searchDepth;}
98
	public CompilerConfiguration withMaxSearchDepth(int maxDepth) {
99
		checkWriteable();
100
		searchDepth = maxDepth;
101
		return this;
102
	}
103

  
104
	public String getNameSpace() {return nameSpace;}
105
	public CompilerConfiguration withNameSpace(String ns) {
106
		checkWriteable();
107
		nameSpace = ns;
108
		return this;
109
	}
110

  
111
	public boolean getQuiet() {return quiet;}
112
	public CompilerConfiguration withQuiet(boolean isQuiet){
113
		checkWriteable();
114
		quiet = isQuiet;
115
		return this;
116
	}
117

  
118
	public String getNamedTypePrefix() {return namedTypePrefix;}
119
	public CompilerConfiguration withNamedTypePrefix(String prfx) {
120
		checkWriteable();
121
		namedTypePrefix = prfx;
122
		return this;
123
	}
124

  
125
	public LabelCompression getLabelCompression() { return compression; }
126
	public CompilerConfiguration withLabelCompression(LabelCompression compression) {
127
		checkWriteable();
128
		this.compression = compression;
129
		return this;
130
	}
131

  
132
	public IAstDuplicator<?> getAstTarget() { return m_duplicator; }
133
	public CompilerConfiguration withAstTarget(IAstDuplicator<?> visitor) {
134
		m_duplicator = visitor;
135
		return this;
136
	}
137

  
138

  
139
	public CompilerConfiguration (String unitName, String parseFile, String outputFileName, Backend be) {
140
		fileToParse = parseFile;
141
		outputToFile = outputFileName;
142
		backend = be;
143
		streams = false;
144
		inputStream = null;
145
		outputStream = null;
146
		this.unitName = unitName;
147
		compression = LabelCompression.NoCompression;
148
	}
149

  
150
	public CompilerConfiguration (String unitName, InputStream input, OutputStream out, Backend be) {
151
		fileToParse = unitName;
152
		outputToFile = "";
153
		backend = be;
154
		streams = true;
155
		inputStream = input;
156
		outputStream = out;
157
		this.unitName = unitName;
158
		compression = LabelCompression.NoCompression;
159
	}
160

  
161
}
35

  
36

  
37
public final class CompilerConfiguration {
38
	public enum LabelCompression { NoCompression, ActionsMethods, ActionsMethodsObjects, All }
39
	public enum Backend {Prolog, PrologSymbolic, Printer, CADP, CopyAST}
40
	private boolean configWriteable = true;
41
	private int searchDepth = 35;
42
	private String nameSpace = "as";
43
	private boolean quiet = false;
44
	private String namedTypePrefix = "";
45

  
46
	private final boolean streams;
47
	// options for non streaming interface
48
	private final Backend backend;
49
	private final String fileToParse;
50
	private final String outputToFile;
51
	// options for stream
52
	private final InputStream inputStream;
53
	private final OutputStream outputStream;
54
	private final String unitName;
55

  
56
	// compress options
57
	private LabelCompression compression;
58
	private IAstDuplicator<?> m_duplicator;
59

  
60

  
61
	private void checkWriteable() {
62
		if (!configWriteable)
63
			throw new OoasCompilerRuntimeException("CompilerConfig read-only.");
64
	}
65
	public boolean isWriteable() {return configWriteable;}
66
	void setWriteOnly(){
67
		configWriteable = false;
68
	}
69

  
70
	public boolean useStreams() {return streams;}
71
	public String getUnitName() {return unitName;}
72

  
73
	public String getFileToParse() {
74
		if (streams)
75
			throw new IllegalArgumentException("OOAS compiler was configured with input/output streams.");
76
		return fileToParse;
77
	}
78
	public String getFileToOutput() {
79
		if (streams)
80
			throw new IllegalArgumentException("OOAS compiler was configured with input/output streams.");
81
		return outputToFile;
82
	}
83

  
84
	public InputStream getInputStream() {
85
		if (!streams)
86
			throw new IllegalArgumentException("OOAS compiler was configured with input/output files.");
87
		return inputStream;
88
	}
89
	public OutputStream getOutputStream() {
90
		if (!streams)
91
			throw new IllegalArgumentException("OOAS compiler was configured with input/output files.");
92
		return outputStream;
93
	}
94

  
95
	public Backend getBackend() {return backend;}
96

  
97
	public int getMaxSearchDepth() {return searchDepth;}
98
	public CompilerConfiguration withMaxSearchDepth(int maxDepth) {
99
		checkWriteable();
100
		searchDepth = maxDepth;
101
		return this;
102
	}
103

  
104
	public String getNameSpace() {return nameSpace;}
105
	public CompilerConfiguration withNameSpace(String ns) {
106
		checkWriteable();
107
		nameSpace = ns;
108
		return this;
109
	}
110

  
111
	public boolean getQuiet() {return quiet;}
112
	public CompilerConfiguration withQuiet(boolean isQuiet){
113
		checkWriteable();
114
		quiet = isQuiet;
115
		return this;
116
	}
117

  
118
	public String getNamedTypePrefix() {return namedTypePrefix;}
119
	public CompilerConfiguration withNamedTypePrefix(String prfx) {
120
		checkWriteable();
121
		namedTypePrefix = prfx;
122
		return this;
123
	}
124

  
125
	public LabelCompression getLabelCompression() { return compression; }
126
	public CompilerConfiguration withLabelCompression(LabelCompression compression) {
127
		checkWriteable();
128
		this.compression = compression;
129
		return this;
130
	}
131

  
132
	public IAstDuplicator<?> getAstTarget() { return m_duplicator; }
133
	public CompilerConfiguration withAstTarget(IAstDuplicator<?> visitor) {
134
		m_duplicator = visitor;
135
		return this;
136
	}
137

  
138

  
139
	public CompilerConfiguration (String unitName, String parseFile, String outputFileName, Backend be) {
140
		fileToParse = parseFile;
141
		outputToFile = outputFileName;
142
		backend = be;
143
		streams = false;
144
		inputStream = null;
145
		outputStream = null;
146
		this.unitName = unitName;
147
		compression = LabelCompression.NoCompression;
148
	}
149

  
150
	public CompilerConfiguration (String unitName, InputStream input, OutputStream out, Backend be) {
151
		fileToParse = unitName;
152
		outputToFile = "";
153
		backend = be;
154
		streams = true;
155
		inputStream = input;
156
		outputStream = out;
157
		this.unitName = unitName;
158
		compression = LabelCompression.NoCompression;
159
	}
160

  
161
}

Also available in: Unified diff