if (line.length() == 0)
continue;
if ( line.charAt(0) == '[') {
if (line.charAt(line.length() - 1) != ']')
throw new ParseException("Unclosed stanza: \"" + line + "\"" );
String stanzaname = line.substring(1, line.length() - 1);
if (stanzaname.length() < 1)
throw new ParseException("Empty stanza: \"" +line+"\"");
currentStanza = stanzaname;
//System.out.println("stanza: " + currentStanza);
triggerNewStanza(currentStanza);
} else {
// a content line
SOPair pair;
pair = unescape(line, ':', 0, true);
//sSystem.out.println(pair);
String name = pair.str;
int lineEnd = findUnescaped(line, '!', 0, line.length(), true);
if (lineEnd == -1)
lineEnd = line.length();
// find nested values
NestedValue nv = null;
int trailingStartIndex = -1;
int trailingEndIndex = -1;
for (int i = lineEnd - 1; i >= 0; i--) {
if (Character.isWhitespace(line.charAt(i))) {
// keep going until we see non-whitespace
} else if (line.charAt(i) == '}') {
// if the first thing we see is a closing brace,
// we have a trailing modifier
if (i >= 1 && line.charAt(i - 1) == '\\')
continue;
trailingEndIndex = i;
break;
} else
break;
}
if (trailingEndIndex != -1) {
for (int i = trailingEndIndex - 1; i >= 0; i--) {
if (line.charAt(i) == '{') {
if (i >= 1 && line.charAt(i - 1) == '\\')
continue;
trailingStartIndex = i + 1;
}
}
}
int valueStopIndex;
if (trailingStartIndex == -1 && trailingEndIndex != -1)
throw new ParseException("Unterminated trailing modifier. " + line);
else if (trailingStartIndex != -1) {
valueStopIndex = trailingStartIndex - 1;
String trailing = line.substring(trailingStartIndex,
trailingEndIndex).trim();
nv = new NestedValue();
getNestedValue(nv, trailing, 0);
} else
valueStopIndex = lineEnd;
String value = line.substring(pair.index + 1, valueStopIndex).trim();
/*
* if (nv != null) System.err.println("nv = "+nv+", value =
* |"+value+"|");
*/
if (value.length() == 0)
throw new ParseException("Tag found with no value "+ line);
if ( isSynonym(name)){
Synonym synonym = parseSynonym(name,value);
triggerNewSynonym(synonym);
} else {