public Map<Variable, DI> parseItemDescription(String itemDescription) {
if (DomainConstants.BOT.equals(itemDescription))
return null;
Matcher matcher = DOMAIN_ITEM_PATTERN.matcher(itemDescription);
if (!matcher.matches())
throw new CommentParserException("Invalid domain value '%s'", itemDescription);
itemDescription = matcher.group(1).trim();
Map<Variable, DI> result = new HashMap<Variable, DI>();
// Map<Variable, DI> result = new HashMap<Variable, DI>();
while (itemDescription.length() > 0) {
Pair<Pair<String, DI>, String> res = getNextValue(itemDescription);
String variableName = res.left.left;
Variable var = match.getVariable(variableName);
if (var == null)
throw new RuntimeException("Unknown variable '" + variableName + "'");
if (result.containsKey(var))
throw new CommentParserException("Duplicate variable '%s'", variableName);
DI value = res.left.right;
result.put(var, value);
String newitemDescription = res.right;
if (newitemDescription.length() > 0 && itemDescription.indexOf(newitemDescription) <= 0)
throw new CommentParserException("An error!!");
itemDescription = newitemDescription;
}
return result;
}