Example #1
0
// Check the parameters are proper parameters and not
// something nasty let in by the case method value parsing.
static ast_result_t check_params(ast_t* params)
{
  assert(params != NULL);
  ast_result_t result = AST_OK;

  // Check each parameter.
  for(ast_t* p = ast_child(params); p != NULL; p = ast_sibling(p))
  {
    if(ast_id(p) == TK_ELLIPSIS)
      continue;

    AST_GET_CHILDREN(p, id, type, def_arg);

    if(ast_id(id) != TK_ID)
    {
      ast_error(p, "expected parameter name");
      result = AST_ERROR;
    }
    else if(ast_name(id)[0] != '$' && !check_id_param(id))
    {
      result = AST_ERROR;
    }

    if(ast_id(type) == TK_NONE)
    {
      ast_error(type, "expected parameter type");
      result = AST_ERROR;
    }
  }

  return result;
}
Example #2
0
static ast_result_t syntax_param(ast_t* ast)
{
  if(!check_id_param(ast_child(ast)))
    return AST_ERROR;

  return AST_OK;
}