|
24 | 24 | import org.kframework.main.Main; |
25 | 25 | import org.kframework.parser.InputModes; |
26 | 26 | import org.kframework.parser.ProductionReference; |
| 27 | +import org.kframework.parser.binary.BinaryParser; |
27 | 28 | import org.kframework.parser.concrete2kore.ParseInModule; |
28 | 29 | import org.kframework.parser.concrete2kore.generator.RuleGrammarGenerator; |
29 | | -import org.kframework.parser.binary.BinaryParser; |
30 | 30 | import org.kframework.parser.json.JsonParser; |
31 | 31 | import org.kframework.parser.kore.KoreParser; |
| 32 | +import org.kframework.utils.StringUtil; |
32 | 33 | import org.kframework.utils.errorsystem.KEMException; |
33 | 34 | import org.kframework.utils.errorsystem.KException; |
34 | 35 | import org.kframework.utils.errorsystem.KExceptionManager; |
35 | 36 | import org.kframework.utils.errorsystem.ParseFailedException; |
36 | 37 | import org.kframework.utils.file.FileUtil; |
37 | 38 | import org.kframework.utils.file.TTYInfo; |
38 | | -import org.kframework.utils.StringUtil; |
39 | 39 | import scala.Tuple2; |
40 | 40 |
|
41 | 41 | import java.io.BufferedReader; |
|
49 | 49 | import java.util.HashMap; |
50 | 50 | import java.util.List; |
51 | 51 | import java.util.Map; |
52 | | -import java.util.function.Consumer; |
53 | 52 | import java.util.Set; |
| 53 | +import java.util.function.Consumer; |
54 | 54 | import java.util.stream.Collectors; |
55 | 55 |
|
56 | 56 | import scala.Option; |
@@ -95,7 +95,20 @@ public static K deserialize(String stringToParse, InputModes inputMode) { |
95 | 95 |
|
96 | 96 | /* Parsing code from KRun: */ |
97 | 97 |
|
98 | | - public K externalParse(String parser, String value, Sort startSymbol, Source source, CompiledDefinition compiledDef) { |
| 98 | + public K KRunParse(CompiledDefinition compiledDef, KRunOptions options, TTYInfo tty) { |
| 99 | + String pgmFileName = options.configurationCreation.pgm(); |
| 100 | + K program; |
| 101 | + if (options.configurationCreation.term()) { |
| 102 | + program = externalParse(options.configurationCreation.parser(compiledDef.executionModule().name(), files), |
| 103 | + pgmFileName, compiledDef.programStartSymbol, Source.apply("<parameters>"), compiledDef); |
| 104 | + } else { |
| 105 | + program = parseConfigVars(options, compiledDef, tty); |
| 106 | + } |
| 107 | + |
| 108 | + return program; |
| 109 | + } |
| 110 | + |
| 111 | + private K externalParse(String parser, String value, Sort startSymbol, Source source, CompiledDefinition compiledDef) { |
99 | 112 | List<String> tokens = new ArrayList<>(Arrays.asList(parser.split(" "))); |
100 | 113 | tokens.add(value); |
101 | 114 | Map<String, String> environment = new HashMap<>(); |
@@ -163,11 +176,11 @@ private void checkConfigVars(Set<KToken> inputConfigVars, CompiledDefinition com |
163 | 176 | } |
164 | 177 | } |
165 | 178 |
|
166 | | - public KApply plugConfigVars(CompiledDefinition compiledDef, Map<KToken, K> output) { |
| 179 | + private KApply plugConfigVars(CompiledDefinition compiledDef, Map<KToken, K> output) { |
167 | 180 | return KApply(compiledDef.topCellInitializer, output.entrySet().stream().map(e -> KApply(KLabel("_|->_"), e.getKey(), e.getValue())).reduce(KApply(KLabel(".Map")), (a, b) -> KApply(KLabel("_Map_"), a, b))); |
168 | 181 | } |
169 | 182 |
|
170 | | - public static String getStdinBuffer(boolean ttyStdin) { |
| 183 | + private static String getStdinBuffer(boolean ttyStdin) { |
171 | 184 | String buffer = ""; |
172 | 185 |
|
173 | 186 | try { |
|
0 commit comments