Map<String, String> map = new HashMap<String, String>();
BNFTokenizerParams params = new BNFTokenizerParams();
params.setIncludeWhitespace(true);
params.setIncludeWhitespaceNewlines(true);
BNFToken token = tokenizer.tokens(str, params);
String start = "";
StringBuilder sb = new StringBuilder();
while (token != null) {
if (token.getType() == BNFTokenType.WHITESPACE_NEWLINE) {
if (hasText(start) && hasText(sb.toString())) {
map.put(start.trim(), sb.toString().trim());
}
start = "";
sb = new StringBuilder();
} else if (token.getStringValue().equals("=")) {
start = sb.toString();
sb = new StringBuilder();
} else {
sb.append(token.getStringValue());
}
token = token.getNextToken();
}
if (hasText(start) && hasText(sb.toString())) {
map.put(start.trim(), sb.toString().trim());
}