parseNamedArgument method Null safety

NamedArgument? parseNamedArgument()

Implementation

NamedArgument? parseNamedArgument() {
  var name = parseIdentifier();
  if (name == null) return null;

  if (!next(TokenType.colon)) {
    errors.add(JaelError(JaelErrorSeverity.error,
        'Missing ":" in named argument.', name.span));
    return null;
  }

  var colon = _current, value = parseExpression(0) as Token?;

  if (value == null) {
    errors.add(JaelError(JaelErrorSeverity.error,
        'Missing expression in named argument.', colon.span));
    return null;
  }

  return NamedArgument(name, colon, value as Expression);
}