Example #1
0
builder_t* builder_create(const char* description)
{
  if(description == NULL)
    return NULL;

  source_t* source = source_open_string(description);
  symtab_t* symtab = symtab_new();

  ast_t* ast = build_ast(source, symtab);

  if(ast == NULL)
  {
    // Error, tidy up
    source_close(source);
    symtab_free(symtab);
    return NULL;
  }

  // Success, create builder
  builder_t* builder = POOL_ALLOC(builder_t);

  builder->sources = NULL;
  builder->defs = symtab;
  builder->dummy_root = ast_blank(TK_TEST);

  ast_add(builder->dummy_root, ast);
  add_source(builder, source);

  return builder;
}
Example #2
0
// Attempt to parse the specified source code and add it to the given AST
// @return true on success, false on error
static bool parse_source_code(ast_t* package, const char* src,
  pass_opt_t* options)
{
  assert(src != NULL);
  source_t* source = source_open_string(src);
  assert(source != NULL);

  return module_passes(package, options, source);
}
Example #3
0
// Attempt to parse the specified source code and add it to the given AST
// @return true on success, false on error
static bool parse_source_code(ast_t* package, const char* src,
  pass_opt_t* options)
{
  assert(src != NULL);
  assert(options != NULL);

  if(options->print_filenames)
    printf("Opening magic source\n");

  source_t* source = source_open_string(src);
  assert(source != NULL);

  return module_passes(package, options, source);
}
Example #4
0
static ast_t* builder_add_ast(builder_t* builder, const char* description)
{
  assert(builder != NULL);
  assert(description != NULL);

  source_t* source = source_open_string(description);
  ast_t* ast = build_ast(source, builder->defs);

  if(ast == NULL)
  {
    // Error, tidy up
    source_close(source);
    return NULL;
  }

  // Success, add new source to builder
  add_source(builder, source);

  return ast;
}