Beispiel #1
0
//
// read a storage set from within the set
PyObject *PyStorageSet_readSet   (PyObject *self, PyObject *args) { 
  char *key = PyStorageSet_readParseKey(args);
  if(key == NULL)
    return NULL;
  else
    return newPyStorageSet(read_set(((PyStorageSet *)self)->set, key));
}
Beispiel #2
0
int get_event_set(char *event_set, int wait) {
	int len;
	char link_path[BUF_SIZE];
	char file_path[BUF_SIZE];
	desc common_desc;

	common_desc = init_env(inot_dir, file_path, link_path);
	if ((common_desc.inot < 0) || (common_desc.file < 0) || \
			(common_desc.dir < 0) || (common_desc.link < 0)) {
		common_close(&common_desc);
		return -1;
	}
	if(test_actions(inot_dir, file_path, link_path) < 0) {
		common_close(&common_desc);
		return -1;
	}
	if (wait) {
		do_wait();
	}
	len = read_set(common_desc.inot, event_set);
	common_close(&common_desc);
#ifdef NODEL
	if (! (fDelete(file_path) == 0 &&
		fDelete(link_path) == 0 &&
		fRemDir(inot_dir) == 0))
		return -1;
#endif
	return len;
}
Beispiel #3
0
static char read_tag(FILE *txt)
  {
  char c,var[256],set[256];
  int i;

  i = fscanf(txt,"%[^> ] %c",var,&c);
  while(c<33 && i != EOF) c = i = fgetc(txt);
  if (c !='>') ungetc(c,txt);
  _strupr(var);
  if (!strcmp(var,PARAGRAPH))
     {
     break_line();
     break_line();
     return 1;
     }
  if (!strcmp(var,BREAKLINE))
     {
     break_line();
     return 1;
     }
  if (!strcmp(var,IMAGE))
     {
     char pic_name[50] =" ";
     char alig = 0;
     int line = 0,lsize = 0;

     while (c !='>')
        {
        c = read_set(txt,var,set);
        if (!strcmp(var,SRC)) strncpy(pic_name,set,49);
        else if (!strcmp(var,ALIGN))
           {
           if (!strcmp(set,ALEFT)) alig = 1;
           else if (!strcmp(set,ARIGHT)) alig = 2;
           else if (!strcmp(set,ACENTER)) alig = 0;
           }
        else if (!strcmp(var,PIC_LINE)) sscanf(set,"%d",&line);
        else if (!strcmp(var,PIC_LSIZ)) sscanf(set,"%d",&lsize);
        }
     if (pic_name[0]!= 0)
        insert_picture(pic_name,alig,line,lsize);
     return 0;
     }
  if (!strcmp(var,CENTER1)) center++;
  else if (!strcmp(var,CENTER2))
     {
     if (center>0) center--;
     }
  else if (!strcmp(var,DISTEND1)) distend++;
  else if (!strcmp(var,DISTEND2))
     {
     if (distend>0) distend--;
     }
  return 0;
  }
Beispiel #4
0
void
Controller::process_updates()
{
	const uint32_t read_space = _updates->read_space();

	uint64_t subject;
	URIInt   key;
	Atom     value;
	for (uint32_t i = 0; i < read_space; ) {
		i += read_set(_updates, &subject, &key, &value);
		_model.set(subject, key, value);
	}
}
Beispiel #5
0
macro_fn getmacro(int c) {
  if (c == '"') {
    return read_string;
  } else if (c == '(') {
    return read_list;
  } else if (c == ')') {
    // lambda's are awesome!
    // but! note that this is only ok as long as the capture list is empty
    // TODO: and i should probably make sure this doesn't incur any
    // run time overhead as apposed to using pure functions
    return [] (std::istream &) -> std::shared_ptr<Object> {
      throw "Unmatched delimiter: )";
    };
  } else if (c == '[') {
    return read_vector;
  } else if (c == ']') {
    return [] (std::istream &) -> std::shared_ptr<Object> {
      throw "Unmatched delimiter: ]";
    };
  } else if (c == '{') {
    return read_map;
  } else if (c == '}') {
    return [] (std::istream &) -> std::shared_ptr<Object> {
      throw "Unmatched delimiter: }";
    };
  } else if (c == '\'') {
    return [] (std::istream &in) -> std::shared_ptr<Object> {
      return wrap_read(in, Symbol::create("quote"));
    };
  } else if (c == '@') {
    return [] (std::istream &in) -> std::shared_ptr<Object> {
      return wrap_read(in, Symbol::create("clojure.core", "deref"));
    };
  } else if (c == ';') {
    return read_comment;
  } else if (c == '\\') {
    return read_character;
  } else if (c == '^') {
    return read_meta;
  } else if (c == '`') {
    return [] (std::istream &in) -> std::shared_ptr<Object> {
      throw "TODO: implement syntax quote reader";
    };
  } else if (c == '~') {
    // unquote reader
    return [] (std::istream &in) -> std::shared_ptr<Object> {
      int ch = in.get();
      if (in.eof()) {
        throw "EOF while reading character";
      }
      if (ch == '@') {
        return wrap_read(in, UNQUOTE_SPLICING);
      } else {
        in.unget();
        return wrap_read(in, UNQUOTE);
      }
    };
  }  else if (c == '%') {
    return [] (std::istream &in) -> std::shared_ptr<Object> {
      throw "TODO: implement arg reader";
    };
  } else if (c == '#') {
    // dispatch macro reader (lambda)
    // TODO: is this over-using lambdas? what is the overhead of a lambda
    // over a pure function, esp if the function is being called via a ptr
    return [] (std::istream &in) -> std::shared_ptr<Object> {
      int c = in.get();
      if (in.eof()) {
        throw "EOF while reading character";
      }
      if (c == '{') {
        return read_set(in);
      } else if (c == '^') {
        return read_meta(in);
      } else if (c == '\'') {
        return wrap_read(in, Symbol::create("var"));
      } else if (c == '"') {
        return read_regex(in);
      } else if (c == '(') {
        throw "TODO: implement function reader";
      } else if (c == '=') {
        throw "TODO: implement eval reader";
      } else if (c == '!') {
        return read_comment(in);
      } else if (c == '<') {
        throw "Unreadable form";
      } else if (c == '_') {
        read(in, true, Object::nil, true);
        return NOOP;
      } else {
        // try ctor reader
        // TODO: implement ctor reader
      }
      throw "No dispatch macro for: " + std::string{ (char)c };
    };
  } else {
    return 0;
  }
}
Beispiel #6
0
AST_expr* readASTExpr(BufferedReader* reader) {
    uint8_t type = reader->readByte();
    if (VERBOSITY("parsing") >= 3)
        printf("type = %d\n", type);
    if (type == 0)
        return NULL;

    uint8_t checkbyte = reader->readByte();
    assert(checkbyte == 0xae);

    switch (type) {
        case AST_TYPE::Attribute:
            return read_attribute(reader);
        case AST_TYPE::BinOp:
            return read_binop(reader);
        case AST_TYPE::BoolOp:
            return read_boolop(reader);
        case AST_TYPE::Call:
            return read_call(reader);
        case AST_TYPE::Compare:
            return read_compare(reader);
        case AST_TYPE::Dict:
            return read_dict(reader);
        case AST_TYPE::DictComp:
            return read_dictcomp(reader);
        case AST_TYPE::ExtSlice:
            return read_extslice(reader);
        case AST_TYPE::GeneratorExp:
            return read_generatorexp(reader);
        case AST_TYPE::IfExp:
            return read_ifexp(reader);
        case AST_TYPE::Index:
            return read_index(reader);
        case AST_TYPE::Lambda:
            return read_lambda(reader);
        case AST_TYPE::List:
            return read_list(reader);
        case AST_TYPE::ListComp:
            return read_listcomp(reader);
        case AST_TYPE::Name:
            return read_name(reader);
        case AST_TYPE::Num:
            return read_num(reader);
        case AST_TYPE::Repr:
            return read_repr(reader);
        case AST_TYPE::Set:
            return read_set(reader);
        case AST_TYPE::SetComp:
            return read_setcomp(reader);
        case AST_TYPE::Slice:
            return read_slice(reader);
        case AST_TYPE::Str:
            return read_str(reader);
        case AST_TYPE::Subscript:
            return read_subscript(reader);
        case AST_TYPE::Tuple:
            return read_tuple(reader);
        case AST_TYPE::UnaryOp:
            return read_unaryop(reader);
        case AST_TYPE::Yield:
            return read_yield(reader);
        default:
            fprintf(stderr, "Unknown expr node type (parser.cpp:" STRINGIFY(__LINE__) "): %d\n", type);
            abort();
            break;
    }
}