コード例 #1
0
ファイル: clj.c プロジェクト: brandonbloom/libclj-ruby
static void reader_emit(const clj_Reader *reader, const clj_Node *node) {
  clj_rb_ReadData *data = (clj_rb_ReadData*)reader->data;
  ID id;
  VALUE s, value;
  VALUE one = rb_str_new_cstr("1"); // TODO: Delete me
  if (clj_is_atomic(node->type)) {
    s = wcs2rb(node->value);
    //TODO: begin shit code
    switch (node->type) {
      case CLJ_NUMBER:
        value = rb_funcall(data->target, sym_number, 5,
                           s, one, one, Qfalse, Qfalse);
        break;
      case CLJ_STRING:
        value = rb_funcall(data->target, sym_string, 1, s);
        break;
      case CLJ_CHARACTER:
        value = rb_funcall(data->target, sym_character, 1, s);
        break;
      case CLJ_KEYWORD:
        value = rb_funcall(data->target, sym_keyword, 3, s, one, one);
        break;
      case CLJ_SYMBOL:
        value = rb_funcall(data->target, sym_symbol, 3, s, one, one);
        break;
      //TODO: DEFAULT CASE!
    }
    //TODO: END shit code
    rb_funcall(data->target, sym_atomic, 1, value);
  } else if (clj_is_end(node->type)) {
    rb_funcall(data->target, sym_end_composite, 0);
  } else {
    switch (node->type) {
      case CLJ_LIST:
        id = sym_list_builder;
        break;
      case CLJ_VECTOR:
        id = sym_vector_builder;
        break;
      case CLJ_MAP:
        id = sym_map_builder;
        break;
      case CLJ_SET:
        id = sym_set_builder;
        break;
      default:
        assert(0); //TODO: Real error
      //TODO: DEFAULT CASE!
    }
    value = rb_funcall(data->target, id, 0);
    rb_funcall(data->target, sym_begin_composite, 1, value);
  }
}
コード例 #2
0
ファイル: clj.c プロジェクト: wildthink/planck
int clj_is_begin(clj_Type type) {
  return clj_is_composite(type) && !clj_is_end(type);
}