code generation bugfix

This commit is contained in:
Andrey 2022-04-18 12:22:50 -04:00
parent 7883f43ca8
commit 1eafeb3ed1
3 changed files with 14 additions and 6 deletions

Binary file not shown.

View File

@ -121,7 +121,11 @@ public class ConfigDefinition {
String keyName = args[i + 1];
// yes, we take three parameters here thus pre-increment!
String fileName = args[++i + 1];
state.variableRegistry.register(keyName, IoUtil2.readFile(fileName));
try {
state.variableRegistry.register(keyName, IoUtil2.readFile(fileName));
} catch (RuntimeException e) {
throw new IllegalStateException("While processing " + fileName, e);
}
state.inputFiles.add(fileName);
case KEY_FIRING:
firingEnumFileName = args[i + 1];

View File

@ -150,10 +150,14 @@ public class VariableRegistry {
}
public void register(String var, String param) {
String value = doRegister(var, param);
if (value == null)
return;
tryToRegisterAsInteger(var, value);
try {
String value = doRegister(var, param);
if (value == null)
return;
tryToRegisterAsInteger(var, value);
} catch (RuntimeException e) {
throw new IllegalStateException("While [" + var + "][" + param + "]", e);
}
}
@Nullable
@ -165,7 +169,7 @@ public class VariableRegistry {
}
value = applyVariables(value);
int multPosition = value.indexOf(MULT_TOKEN);
if (!isQuoted(value, '"') && multPosition != -1) {
if (!value.contains("\n") && !isQuoted(value, '"') && multPosition != -1) {
Integer first = Integer.valueOf(value.substring(0, multPosition).trim());
Integer second = Integer.valueOf(value.substring(multPosition + 1).trim());
value = String.valueOf(first * second);