State NextStateInDirective () {
for (; position < content.Length; position++) {
char c = content[position];
if (c == '\r') {
if (position + 1 < content.Length && content[position + 1] == '\n')
position++;
nextStateLocation = nextStateLocation.AddLine();
} else if (c == '\n') {
nextStateLocation = nextStateLocation.AddLine();
} else if (Char.IsLetter (c)) {
return State.DirectiveName;
} else if (c == '=') {
nextStateLocation = nextStateLocation.AddCol ();
position++;
return State.DirectiveValue;
} else if (c == '#' && position + 1 < content.Length && content[position+1] == '>') {
position+=2;
TagEndLocation = nextStateLocation.AddCols (2);
nextStateLocation = nextStateLocation.AddCols (3);
//skip newlines directly after directives
if ((position += IsNewLine()) > 0) {
nextStateLocation = nextStateLocation.AddLine();
}
return State.Content;
} else if (!Char.IsWhiteSpace (c)) {
throw new ParserException ("Directive ended unexpectedly with character '" + c + "'", nextStateLocation);
} else {
nextStateLocation = nextStateLocation.AddCol ();
}
}
throw new ParserException ("Unexpected end of file.", nextStateLocation);
}