parseExpressionOrLabeledStatement method

Statement parseExpressionOrLabeledStatement()

Implementation

Statement parseExpressionOrLabeledStatement() {
  int? start = token!
      .startOffset; // Note: not the same as exp.start due to removal of parentheses
  Expression exp = parseExpression();
  if (token!.type == Token.COLON &&
      exp is NameExpression &&
      exp.start == start) {
    Name name = exp.name;
    next(); // skip the colon
    Statement inner = parseStatement();
    return LabeledStatement(name, inner);
  } else {
    consumeSemicolon();
    return ExpressionStatement(exp)
      ..start = start
      ..end = endOffset
      ..line = exp.line;
  }
}