parseIf method

Statement parseIf()

Implementation

Statement parseIf() {
  int start = token?.startOffset??0;
  int line = token?.line??0;
  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 new IfStatement(condition, thenBody, elseBody)
    ..start = start
    ..end = endOffset
    ..line = line;
}