parseIf method

Statement parseIf()

Implementation

Statement parseIf() {
  int? start = token!.startOffset;
  int? line = token!.line;
  assert(token!.text == 'if');
  consume(Token.NAME);
  consume(Token.LPAREN);
  Expression condition = parseExpression();
  consume(Token.RPAREN);
  Statement thenBody = parseStatement();
  Statement? elseBody;
  if (tryName('else')) {
    elseBody = parseStatement();
  }
  return IfStatement(condition, thenBody, elseBody)
    ..start = start
    ..end = endOffset
    ..line = line;
}