protected internal void ParseList(Token token, ICodeNode parentNode, PascalTokenType terminator, PascalErrorCode errorCode)
{
// Loop to parse each statement until the END token or the end of the source file.
while (!(token is EofToken) && (token.type != terminator))
{
// Parse a statement. The parent node adopts the statement node.
ICodeNode statementNode = Parse(token);
parentNode.AddChild(statementNode);
token = CurrentToken();
TokenType tokenType = token.type;
// Look for semicolon between statements.
if (tokenType == PascalTokenType.SEMICOLON)
token = NextToken();
// If at the start of the next assignment statement, then missing a semicolon.
else if (tokenType == PascalTokenType.IDENTIFIER)
errorHandler.flag(token, PascalErrorCode.MISSING_SEMICOLON, this);
else if (tokenType != terminator)
{
errorHandler.flag(token, PascalErrorCode.UNEXPECTED_TOKEN, this);
token = NextToken();
}
}
if (token.type == terminator)
token = NextToken();
else
errorHandler.flag(token, errorCode, this);
}