本文整理汇总了C++中parse_tree函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_tree函数的具体用法?C++ parse_tree怎么用?C++ parse_tree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_tree函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: parse_tree
//////////////////////////////////////////////////////////////////////////
// parse_tree
//////////////////////////////////////////////////////////////////////////
void parse_tree(token_vector &tokens, token_vector &tree, TokenType until)
{
while(! tokens.empty())
{
token_ptr token = tokens[0] ;
tokens.erase(tokens.begin()) ;
if (token->gettype() == TOKEN_TYPE_FOR)
{
token_vector children ;
parse_tree(tokens, children, TOKEN_TYPE_ENDFOR) ;
token->set_children(children) ;
}
else if (token->gettype() == TOKEN_TYPE_IF)
{
token_vector children ;
parse_tree(tokens, children, TOKEN_TYPE_ENDIF) ;
token->set_children(children) ;
}
else if (token->gettype() == until)
{
return ;
}
tree.push_back(token) ;
}
}
开发者ID:kimlavoie,项目名称:BeepBeepPingus,代码行数:28,代码来源:cpptempl.cpp
示例2: reset_tree
static int reset_tree(struct tree *tree, const struct checkout_opts *o,
int worktree, int *writeout_error)
{
struct unpack_trees_options opts;
struct tree_desc tree_desc;
memset(&opts, 0, sizeof(opts));
opts.head_idx = -1;
opts.update = worktree;
opts.skip_unmerged = !worktree;
opts.reset = 1;
opts.merge = 1;
opts.fn = oneway_merge;
opts.verbose_update = o->show_progress;
opts.src_index = &the_index;
opts.dst_index = &the_index;
parse_tree(tree);
init_tree_desc(&tree_desc, tree->buffer, tree->size);
switch (unpack_trees(1, &tree_desc, &opts)) {
case -2:
*writeout_error = 1;
/*
* We return 0 nevertheless, as the index is all right
* and more importantly we have made best efforts to
* update paths in the work tree, and we cannot revert
* them.
*/
/* fallthrough */
case 0:
return 0;
default:
return 128;
}
}
开发者ID:Noffica,项目名称:git,代码行数:34,代码来源:checkout.c
示例3: fsck_walk_tree
static int fsck_walk_tree(struct tree *tree, fsck_walk_func walk, void *data)
{
struct tree_desc desc;
struct name_entry entry;
int res = 0;
if (parse_tree(tree))
return -1;
init_tree_desc(&desc, tree->buffer, tree->size);
while (tree_entry(&desc, &entry)) {
int result;
if (S_ISGITLINK(entry.mode))
continue;
if (S_ISDIR(entry.mode))
result = walk(&lookup_tree(entry.sha1)->object, OBJ_TREE, data);
else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode))
result = walk(&lookup_blob(entry.sha1)->object, OBJ_BLOB, data);
else {
result = error("in tree %s: entry %s has bad mode %.6o\n",
sha1_to_hex(tree->object.sha1), entry.path, entry.mode);
}
if (result < 0)
return result;
if (!res)
res = result;
}
return res;
}
开发者ID:xq-sunny,项目名称:git,代码行数:30,代码来源:fsck.c
示例4: main
int main(int argc, char *argv[])
{
struct rooted_tree *tree;
struct parameters params;
static struct rooted_tree * (*process_tree)(struct rooted_tree *, set_t *);
params = get_params(argc, argv);
switch (params.mode) {
case PRUNE_DIRECT:
process_tree = process_tree_direct;
break;
case PRUNE_REVERSE:
process_tree = process_tree_reverse;
break;
default:
assert (0);
}
while (NULL != (tree = parse_tree())) {
tree = process_tree(tree, params.prune_labels);
dump_newick(tree->root);
destroy_all_rnodes(NULL);
destroy_tree(tree);
}
destroy_set(params.prune_labels);
return 0;
}
开发者ID:Linhua-Sun,项目名称:newick_utils,代码行数:30,代码来源:prune.c
示例5: create_base_index
static void create_base_index(const struct commit *current_head)
{
struct tree *tree;
struct unpack_trees_options opts;
struct tree_desc t;
if (!current_head) {
discard_cache();
return;
}
memset(&opts, 0, sizeof(opts));
opts.head_idx = 1;
opts.index_only = 1;
opts.merge = 1;
opts.src_index = &the_index;
opts.dst_index = &the_index;
opts.fn = oneway_merge;
tree = parse_tree_indirect(current_head->object.sha1);
if (!tree)
die(_("failed to unpack HEAD tree object"));
parse_tree(tree);
init_tree_desc(&t, tree->buffer, tree->size);
if (unpack_trees(1, &t, &opts))
exit(128); /* We've already reported the error, finish dying */
}
开发者ID:AresDice,项目名称:git,代码行数:27,代码来源:commit.c
示例6: map_sha1_file
struct object *parse_object(unsigned char *sha1)
{
unsigned long mapsize;
void *map = map_sha1_file(sha1, &mapsize);
if (map) {
char type[100];
unsigned long size;
void *buffer = unpack_sha1_file(map, mapsize, type, &size);
if (!buffer)
return NULL;
if (check_sha1_signature(sha1, buffer, size, type) < 0)
printf("sha1 mismatch %s\n", sha1_to_hex(sha1));
munmap(map, mapsize);
if (!strcmp(type, "blob")) {
struct blob *ret = lookup_blob(sha1);
parse_blob(ret);
return &ret->object;
} else if (!strcmp(type, "tree")) {
struct tree *ret = lookup_tree(sha1);
parse_tree(ret);
return &ret->object;
} else if (!strcmp(type, "commit")) {
struct commit *ret = lookup_commit(sha1);
parse_commit(ret);
return &ret->object;
} else if (!strcmp(type, "tag")) {
struct tag *ret = lookup_tag(sha1);
parse_tag(ret);
return &ret->object;
} else {
return NULL;
}
}
return NULL;
}
开发者ID:ahappyforest,项目名称:git,代码行数:35,代码来源:object.c
示例7: main
int main(int argc, char *argv[])
{
struct rooted_tree *tree;
struct hash *rename_map;
struct parameters params;
params = get_params(argc, argv);
rename_map = read_map(params.map_filename);
while (NULL != (tree = parse_tree())) {
process_tree(tree, rename_map, params);
destroy_tree(tree, DONT_FREE_NODE_DATA);
}
struct llist *keys = hash_keys(rename_map);
if (NULL == keys) { perror(NULL); exit(EXIT_FAILURE); }
struct list_elem *e;
for (e = keys->head; NULL != e; e = e->next) {
char *key = (char *) e->data;
char *val = hash_get(rename_map, key);
free(val);
}
destroy_llist(keys);
destroy_hash(rename_map);
return 0;
}
开发者ID:gatoravi,项目名称:MFAST,代码行数:28,代码来源:rename.c
示例8: checkout
static int checkout(void)
{
unsigned char sha1[20];
char *head;
struct lock_file *lock_file;
struct unpack_trees_options opts;
struct tree *tree;
struct tree_desc t;
int err = 0, fd;
if (option_no_checkout)
return 0;
head = resolve_refdup("HEAD", sha1, 1, NULL);
if (!head) {
warning(_("remote HEAD refers to nonexistent ref, "
"unable to checkout.\n"));
return 0;
}
if (!strcmp(head, "HEAD")) {
if (advice_detached_head)
detach_advice(sha1_to_hex(sha1));
} else {
if (prefixcmp(head, "refs/heads/"))
die(_("HEAD not found below refs/heads!"));
}
free(head);
/* We need to be in the new work tree for the checkout */
setup_work_tree();
lock_file = xcalloc(1, sizeof(struct lock_file));
fd = hold_locked_index(lock_file, 1);
memset(&opts, 0, sizeof opts);
opts.update = 1;
opts.merge = 1;
opts.fn = oneway_merge;
opts.verbose_update = (option_verbosity >= 0);
opts.src_index = &the_index;
opts.dst_index = &the_index;
tree = parse_tree_indirect(sha1);
parse_tree(tree);
init_tree_desc(&t, tree->buffer, tree->size);
if (unpack_trees(1, &t, &opts) < 0)
die(_("unable to checkout working tree"));
if (write_cache(fd, active_cache, active_nr) ||
commit_locked_index(lock_file))
die(_("unable to write new index file"));
err |= run_hook(NULL, "post-checkout", sha1_to_hex(null_sha1),
sha1_to_hex(sha1), "1", NULL);
if (!err && option_recursive)
err = run_command_v_opt(argv_submodule, RUN_GIT_CMD);
return err;
}
开发者ID:pniebla,项目名称:test-repo-console,代码行数:60,代码来源:clone.c
示例9: prime_cache_tree_rec
static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree)
{
struct tree_desc desc;
struct name_entry entry;
int cnt;
hashcpy(it->sha1, tree->object.sha1);
init_tree_desc(&desc, tree->buffer, tree->size);
cnt = 0;
while (tree_entry(&desc, &entry)) {
if (!S_ISDIR(entry.mode))
cnt++;
else {
struct cache_tree_sub *sub;
struct tree *subtree = lookup_tree(entry.sha1);
if (!subtree->object.parsed)
parse_tree(subtree);
sub = cache_tree_sub(it, entry.path);
sub->cache_tree = cache_tree();
prime_cache_tree_rec(sub->cache_tree, subtree);
cnt += sub->cache_tree->entry_count;
}
}
it->entry_count = cnt;
}
开发者ID:777,项目名称:test-proj,代码行数:25,代码来源:cache-tree.c
示例10: process_tree
static int process_tree(struct walker *walker, struct tree *tree)
{
struct tree_desc desc;
struct name_entry entry;
if (parse_tree(tree))
return -1;
init_tree_desc(&desc, tree->buffer, tree->size);
while (tree_entry(&desc, &entry)) {
struct object *obj = NULL;
/* submodule commits are not stored in the superproject */
if (S_ISGITLINK(entry.mode))
continue;
if (S_ISDIR(entry.mode)) {
struct tree *tree = lookup_tree(entry.sha1);
if (tree)
obj = &tree->object;
}
else {
struct blob *blob = lookup_blob(entry.sha1);
if (blob)
obj = &blob->object;
}
if (!obj || process(walker, obj))
return -1;
}
free(tree->buffer);
tree->buffer = NULL;
tree->size = 0;
tree->object.parsed = 0;
return 0;
}
开发者ID:AsherBond,项目名称:MondocosmOS-Dependencies,代码行数:34,代码来源:walker.c
示例11: read_tree_trivial
static int read_tree_trivial(unsigned char *common, unsigned char *head,
unsigned char *one)
{
int i, nr_trees = 0;
struct tree *trees[MAX_UNPACK_TREES];
struct tree_desc t[MAX_UNPACK_TREES];
struct unpack_trees_options opts;
memset(&opts, 0, sizeof(opts));
opts.head_idx = 2;
opts.src_index = &the_index;
opts.dst_index = &the_index;
opts.update = 1;
opts.verbose_update = 1;
opts.trivial_merges_only = 1;
opts.merge = 1;
trees[nr_trees] = parse_tree_indirect(common);
if (!trees[nr_trees++])
return -1;
trees[nr_trees] = parse_tree_indirect(head);
if (!trees[nr_trees++])
return -1;
trees[nr_trees] = parse_tree_indirect(one);
if (!trees[nr_trees++])
return -1;
opts.fn = threeway_merge;
cache_tree_free(&active_cache_tree);
for (i = 0; i < nr_trees; i++) {
parse_tree(trees[i]);
init_tree_desc(t+i, trees[i]->buffer, trees[i]->size);
}
if (unpack_trees(nr_trees, t, &opts))
return -1;
return 0;
}
开发者ID:carey94tt,项目名称:git,代码行数:35,代码来源:merge.c
示例12: test_parse
void test_parse(cstring_t s) {
int num_lexemes, size_lexemes;
LEXEME* lexemes = lex_str(s, &num_lexemes, &size_lexemes);
int ender;
LexTree* tree = parse_tree(lexemes, num_lexemes, &ender);
//printLexTree(tree, 0);
JSON* j = parse(tree);
print_json(j);
}
开发者ID:rpasta42,项目名称:JSON_IPC,代码行数:12,代码来源:main.c
示例13: solid_repl
void solid_repl()
{
size_t n = 256;
char *buffer = (char *) malloc(sizeof(char) * n);
solid_vm *vm = make_solid_vm();
set_namespace(get_current_namespace(vm), solid_str("compile"), define_c_function(solid_compile));
set_namespace(get_current_namespace(vm), solid_str("import"), define_c_function(solid_import));
while (printf("%s", "solid> "), getline(&buffer, &n, stdin) != -1) {
solid_object *curexpr = parse_tree(parse_expr(buffer));
solid_call_func(vm, curexpr);
push_stack(vm, vm->regs[255]);
solid_print(vm);
}
}
开发者ID:AngelFishy,项目名称:Solid,代码行数:14,代码来源:solid.c
示例14: parse
//////////////////////////////////////////////////////////////////////////
// parse
//////////////////////////////////////////////////////////////////////////
wstring parse(wstring templ_text, data_map &data)
{
token_vector tokens ;
tokenize(templ_text, tokens) ;
token_vector tree ;
parse_tree(tokens, tree) ;
std::vector<wstring> nodes ;
for (size_t i = 0 ; i < tree.size() ; ++i)
{
nodes.push_back(tree[i]->gettext(data));
}
return boost::join(nodes, L"") ;
}
开发者ID:kimlavoie,项目名称:BeepBeepPingus,代码行数:17,代码来源:cpptempl.cpp
示例15: checkout_fast_forward
int checkout_fast_forward(const unsigned char *head,
const unsigned char *remote,
int overwrite_ignore)
{
struct tree *trees[MAX_UNPACK_TREES];
struct unpack_trees_options opts;
struct tree_desc t[MAX_UNPACK_TREES];
int i, nr_trees = 0;
struct dir_struct dir;
struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
refresh_cache(REFRESH_QUIET);
hold_locked_index(lock_file, 1);
memset(&trees, 0, sizeof(trees));
memset(&opts, 0, sizeof(opts));
memset(&t, 0, sizeof(t));
if (overwrite_ignore) {
memset(&dir, 0, sizeof(dir));
dir.flags |= DIR_SHOW_IGNORED;
setup_standard_excludes(&dir);
opts.dir = &dir;
}
opts.head_idx = 1;
opts.src_index = &the_index;
opts.dst_index = &the_index;
opts.update = 1;
opts.verbose_update = 1;
opts.merge = 1;
opts.fn = twoway_merge;
setup_unpack_trees_porcelain(&opts, "merge");
trees[nr_trees] = parse_tree_indirect(head);
if (!trees[nr_trees++])
return -1;
trees[nr_trees] = parse_tree_indirect(remote);
if (!trees[nr_trees++])
return -1;
for (i = 0; i < nr_trees; i++) {
parse_tree(trees[i]);
init_tree_desc(t+i, trees[i]->buffer, trees[i]->size);
}
if (unpack_trees(nr_trees, t, &opts))
return -1;
if (write_locked_index(&the_index, lock_file, COMMIT_LOCK))
die(_("unable to write new index file"));
return 0;
}
开发者ID:0369,项目名称:git,代码行数:50,代码来源:merge.c
示例16: main
int main(int argc, char *argv[])
{
if (argc > 1) {
solid_object *mainfunc = parse_tree(parse_file(argv[1]));
solid_vm *vm = make_solid_vm();
set_namespace(get_current_namespace(vm), solid_str("compile"), define_c_function(solid_compile));
set_namespace(get_current_namespace(vm), solid_str("import"), define_c_function(solid_import));
solid_call_func(vm, mainfunc);
} else {
solid_repl();
}
return 0;
}
开发者ID:AngelFishy,项目名称:Solid,代码行数:14,代码来源:solid.c
示例17: main
int main(int argc, char *argv[])
{
struct rooted_tree *tree;
struct parameters params;
params = get_params(argc, argv);
while (NULL != (tree = parse_tree())) {
/* tree is free()d in process_tree(), as derooting is
* compatible with ordinary free()ing (with destroy_tree()),
* but rerooting is not. */
process_tree(tree, params);
}
destroy_llist(params.labels);
return 0;
}
开发者ID:gatoravi,项目名称:MFAST,代码行数:16,代码来源:reroot.c
示例18: stdin_diff_trees
/* Diff two trees. */
static int stdin_diff_trees(struct tree *tree1, const char *p)
{
struct object_id oid;
struct tree *tree2;
if (!isspace(*p++) || parse_oid_hex(p, &oid, &p) || *p)
return error("Need exactly two trees, separated by a space");
tree2 = lookup_tree(&oid);
if (!tree2 || parse_tree(tree2))
return -1;
printf("%s %s\n", oid_to_hex(&tree1->object.oid),
oid_to_hex(&tree2->object.oid));
diff_tree_oid(&tree1->object.oid, &tree2->object.oid,
"", &log_tree_opt.diffopt);
log_tree_diff_flush(&log_tree_opt);
return 0;
}
开发者ID:Litttle-butterfly,项目名称:git,代码行数:17,代码来源:diff-tree.c
示例19: stdin_diff_trees
/* Diff two trees. */
static int stdin_diff_trees(struct tree *tree1, char *line, int len)
{
unsigned char sha1[20];
struct tree *tree2;
if (len != 82 || !isspace(line[40]) || get_sha1_hex(line + 41, sha1))
return error("Need exactly two trees, separated by a space");
tree2 = lookup_tree(sha1);
if (!tree2 || parse_tree(tree2))
return -1;
printf("%s %s\n", sha1_to_hex(tree1->object.sha1),
sha1_to_hex(tree2->object.sha1));
diff_tree_sha1(tree1->object.sha1, tree2->object.sha1,
"", &log_tree_opt.diffopt);
log_tree_diff_flush(&log_tree_opt);
return 0;
}
开发者ID:00027jang27,项目名称:git,代码行数:17,代码来源:diff-tree.c
示例20: checkout_fast_forward
static int checkout_fast_forward(unsigned char *head, unsigned char *remote)
{
struct tree *trees[MAX_UNPACK_TREES];
struct unpack_trees_options opts;
struct tree_desc t[MAX_UNPACK_TREES];
int i, fd, nr_trees = 0;
struct dir_struct dir;
struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
refresh_cache(REFRESH_QUIET);
fd = hold_locked_index(lock_file, 1);
memset(&trees, 0, sizeof(trees));
memset(&opts, 0, sizeof(opts));
memset(&t, 0, sizeof(t));
memset(&dir, 0, sizeof(dir));
dir.flags |= DIR_SHOW_IGNORED;
dir.exclude_per_dir = ".gitignore";
opts.dir = &dir;
opts.head_idx = 1;
opts.src_index = &the_index;
opts.dst_index = &the_index;
opts.update = 1;
opts.verbose_update = 1;
opts.merge = 1;
opts.fn = twoway_merge;
opts.msgs = get_porcelain_error_msgs();
trees[nr_trees] = parse_tree_indirect(head);
if (!trees[nr_trees++])
return -1;
trees[nr_trees] = parse_tree_indirect(remote);
if (!trees[nr_trees++])
return -1;
for (i = 0; i < nr_trees; i++) {
parse_tree(trees[i]);
init_tree_desc(t+i, trees[i]->buffer, trees[i]->size);
}
if (unpack_trees(nr_trees, t, &opts))
return -1;
if (write_cache(fd, active_cache, active_nr) ||
commit_locked_index(lock_file))
die("unable to write new index file");
return 0;
}
开发者ID:samv,项目名称:git,代码行数:47,代码来源:builtin-merge.c
注:本文中的parse_tree函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论