Ejemplo n.º 1
0
ast_t* ast_from_float(ast_t* ast, double value)
{
  assert(ast != NULL);
  token_t* t = token_dup(ast->t);
  token_set_id(t, TK_FLOAT);
  token_set_float(t, value);

  ast_t* new_ast = ast_token(t);
  set_scope_no_parent(new_ast, ast->parent);
  return new_ast;
}
Ejemplo n.º 2
0
// Replace the current ID token with an abstract keyword, if it is one
static ast_token_id keyword_replace(build_parser_t* builder)
{
  assert(builder != NULL);

  token_id keyword_id = lexer_is_abstract_keyword(token_string(builder->token));
  if(keyword_id == TK_LEX_ERROR)
    return AT_ID;

  token_set_id(builder->token, keyword_id);
  return AT_TOKEN;
}
Ejemplo n.º 3
0
ast_t* ast_from_int(ast_t* ast, uint64_t value)
{
  assert(ast != NULL);
  token_t* t = token_dup(ast->t);
  token_set_id(t, TK_INT);

  lexint_t lexint = {value, 0};
  token_set_int(t, &lexint);

  ast_t* new_ast = ast_token(t);
  set_scope_no_parent(new_ast, ast->parent);
  return new_ast;
}
Ejemplo n.º 4
0
ast_t* ast_from_string(ast_t* ast, const char* name)
{
  if(name == NULL)
    return ast_from(ast, TK_NONE);

  token_t* t = token_dup(ast->t);
  token_set_id(t, TK_ID);
  token_set_string(t, name, 0);

  ast_t* new_ast = ast_token(t);
  set_scope_no_parent(new_ast, ast->parent);
  return new_ast;
}
Ejemplo n.º 5
0
void ast_erase(ast_t* ast)
{
  assert(ast != NULL);

  ast_t* child = ast->child;

  while(child != NULL)
  {
    ast_t* next = child->sibling;
    ast_free(child);
    child = next;
  }

  ast->child = NULL;
  token_set_id(ast->t, TK_NONE);
}
Ejemplo n.º 6
0
ast_t* ast_setid(ast_t* ast, token_id id)
{
  assert(ast != NULL);
  token_set_id(ast->t, id);
  return ast;
}