public override Statement ParseNoNewContext(Parser parser)
{
var result = new IfStatement();
var labelled = parser.Labels(result);
// Consume the if keyword.
parser.Expect(KeywordToken.If);
// Read the left parenthesis.
parser.Expect(PunctuatorToken.LeftParenthesis);
// Parse the condition.
result.Condition = parser.ParseExpression(PunctuatorToken.RightParenthesis);
// Read the right parenthesis.
parser.Expect(PunctuatorToken.RightParenthesis);
// Read the statements that will be executed when the condition is true.
result.IfClause = parser.ParseStatement();
// Optionally, read the else statement.
if (parser.nextToken == KeywordToken.Else)
{
// Consume the else keyword.
parser.Consume();
// Read the statements that will be executed when the condition is false.
result.ElseClause = parser.ParseStatement();
}
return(labelled);
}