• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ NEW2函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中NEW2函数的典型用法代码示例。如果您正苦于以下问题:C++ NEW2函数的具体用法?C++ NEW2怎么用?C++ NEW2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NEW2函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: output_actions

void output_actions()
{
    nvectors = 3*nstates + nvars;

    froms = NEW2(nvectors, Yshort *);
    tos = NEW2(nvectors, Yshort *);
    tally = NEW2(nvectors, Yshort);
    width = NEW2(nvectors, Yshort);
    if (SRtotal+RRtotal)
	conflicts = NEW2(4*(SRtotal+RRtotal), Yshort);
    else
	conflicts = 0;
    nconflicts = 0;

    token_actions();
    FREE(lookaheads);
    FREE(LA);
    FREE(LAruleno);

    goto_actions();
    FREE(goto_map + ntokens);
    FREE(from_state);
    FREE(to_state);

    sort_actions();
    pack_table();
    output_base();
    output_table();
    output_check();
    output_ctable();
    output_astable();
    FREE(accessing_symbol);
}
开发者ID:sunfirefox,项目名称:btyacc,代码行数:33,代码来源:output.c


示例2: allocate_storage

static void allocate_storage (void)
{
    allocate_itemsets ();
    shiftset  = NEW2 (nsyms, Value_t);
    redset    = NEW2 (nrules + 1, Value_t);
    state_set = NEW2 (nitems, core *);
}
开发者ID:JX7P,项目名称:JXWebGen,代码行数:7,代码来源:lr0.c


示例3: output_actions

static void
output_actions(void)
{
    nvectors = 2 * nstates + nvars;

    froms = NEW2(nvectors, Value_t *);
    tos = NEW2(nvectors, Value_t *);
    tally = NEW2(nvectors, Value_t);
    width = NEW2(nvectors, Value_t);

    token_actions();
    FREE(lookaheads);
    FREE(LA);
    FREE(LAruleno);
    FREE(accessing_symbol);

    goto_actions();
    FREE(goto_map + ntokens);
    FREE(from_state);
    FREE(to_state);

    sort_actions();
    pack_table();
    output_base();
    output_table();
    output_check();
}
开发者ID:Der-Jan,项目名称:freebsd-crypto,代码行数:27,代码来源:output.c


示例4: verbose

void verbose(void)
{
    register int i;

    if (!vflag) return;

    null_rules = (Yshort *) NEW2(nrules, null_rules[0]);
    if (null_rules == 0) no_space();

    BtYacc_puts("\f\n", verbose_file);

    for (i = 0; i < nstates; ++i)
        print_state(i);
    FREE(null_rules);

    if (nunused)
        log_unused();
    if (SRtotal || RRtotal)
        log_conflicts();

    print_tokens();

    BtYacc_printf(verbose_file, "\n\n%d terminals, %d nonterminals\n%d grammar rules, %d states\n",
                  ntokens, nvars, nrules - 2, nstates);
}
开发者ID:GerHobbelt,项目名称:BtYacc,代码行数:25,代码来源:verbose.c


示例5: set_derives

static void
set_derives(void)
{
    Value_t i, k;
    int lhs;

    derives = NEW2(nsyms, Value_t *);
    rules = NEW2(nvars + nrules, Value_t);

    k = 0;
    for (lhs = start_symbol; lhs < nsyms; lhs++)
    {
	derives[lhs] = rules + k;
	for (i = 0; i < nrules; i++)
	{
	    if (rlhs[i] == lhs)
	    {
		rules[k] = i;
		k++;
	    }
	}
	rules[k] = -1;
	k++;
    }

#ifdef	DEBUG
    print_derives();
#endif
}
开发者ID:0xffffffRabbit,项目名称:NextBSD-1,代码行数:29,代码来源:lr0.c


示例6: sort_actions

void sort_actions()
{
  register int i;
  register int j;
  register int k;
  register int t;
  register int w;

  order = NEW2(nvectors, Yshort);
  nentries = 0;

  for (i = 0; i < nvectors; i++)
    {
      if (tally[i] > 0)
	{
	  t = tally[i];
	  w = width[i];
	  j = nentries - 1;

	  while (j >= 0 && (width[order[j]] < w))
	    j--;

	  while (j >= 0 && (width[order[j]] == w) && (tally[order[j]] < t))
	    j--;

	  for (k = nentries - 1; k > j; k--)
	    order[k + 1] = order[k];

	  order[j + 1] = i;
	  nentries++;
	}
    }
}
开发者ID:sunfirefox,项目名称:btyacc,代码行数:33,代码来源:output.c


示例7: goto_actions

static void
goto_actions(void)
{
    int i, j, k;

    state_count = NEW2(nstates, Value_t);

    k = default_goto(start_symbol + 1);
    start_int_table("dgoto", k);
    save_column(start_symbol + 1, k);

    j = 10;
    for (i = start_symbol + 2; i < nsyms; i++)
    {
	if (j >= 10)
	{
	    output_newline();
	    j = 1;
	}
	else
	    ++j;

	k = default_goto(i);
	output_int(k);
	save_column(i, k);
    }

    end_table();
    FREE(state_count);
}
开发者ID:Der-Jan,项目名称:freebsd-crypto,代码行数:30,代码来源:output.c


示例8: goto_actions

void goto_actions()
{
    register int i, j, k;

    state_count = NEW2(nstates, Yshort);

    k = default_goto(start_symbol + 1);
    if (!rflag)
	fprintf(output_file, "static ");
    fprintf(output_file, "int yydgoto[] = {%40d,", k);
    save_column(start_symbol + 1, k);

    j = 10;
    for (i = start_symbol + 2; i < nsyms; i++)
    {
	if (j >= 10)
	{
	    if (!rflag) ++outline;
	    putc('\n', output_file);
	    j = 1;
	}
	else
	    ++j;

	k = default_goto(i);
	fprintf(output_file, "%5d,", k);
	save_column(i, k);
    }

    if (!rflag) outline += 2;
    fprintf(output_file, "\n};\n");
    FREE(state_count);
}
开发者ID:sunfirefox,项目名称:btyacc,代码行数:33,代码来源:output.c


示例9: sort_actions

static void
sort_actions(void)
{
    Value_t i;
    int j;
    int k;
    int t;
    int w;

    order = NEW2(nvectors, Value_t);
    nentries = 0;

    for (i = 0; i < nvectors; i++)
    {
	if (tally[i] > 0)
	{
	    t = tally[i];
	    w = width[i];
	    j = nentries - 1;

	    while (j >= 0 && (width[order[j]] < w))
		j--;

	    while (j >= 0 && (width[order[j]] == w) && (tally[order[j]] < t))
		j--;

	    for (k = nentries - 1; k > j; k--)
		order[k + 1] = order[k];

	    order[j + 1] = i;
	    nentries++;
	}
    }
}
开发者ID:Der-Jan,项目名称:freebsd-crypto,代码行数:34,代码来源:output.c


示例10: set_EFF

static void set_EFF(void)
{
    register unsigned *row;
    register Yshort symbol;
    register Yshort *sp;
    register int rowsize;
    register int i;
    register int rule;

    rowsize = WORDSIZE(nvars);
    EFF = NEW2(nvars * rowsize, EFF[0]);

    row = EFF;

    for (i = start_symbol; i < nsyms; ++i)
    {
        sp = derives[i];
        for (rule = *sp; rule > 0; rule = *++sp)
        {
            symbol = ritem[rrhs[rule]];
            if (ISVAR(symbol))
            {
                symbol -= start_symbol;
                SETBIT(row, symbol);
            }
        }
        row += rowsize;
    }

    reflexive_transitive_closure(EFF, nvars);

    if (tflag > 1)
        print_EFF();
}
开发者ID:GerHobbelt,项目名称:BtYacc,代码行数:34,代码来源:closure.c


示例11: pack_table

void pack_table()
{
    register int i;
    register int place;
    register int state;

    base = NEW2(nvectors, Yshort);
    pos = NEW2(nentries, Yshort);

    maxtable = 1000;
    table = NEW2(maxtable, Yshort);
    check = NEW2(maxtable, Yshort);

    lowzero = 0;
    high = 0;

    for (i = 0; i < maxtable; i++)
	check[i] = -1;

    for (i = 0; i < nentries; i++)
    {
	state = matching_vector(i);

	if (state < 0)
	    place = pack_vector(i);
	else
	    place = base[state];

	pos[i] = place;
	base[order[i]] = place;
    }

    for (i = 0; i < nvectors; i++)
    {
	if (froms[i])
	    FREE(froms[i]);
	if (tos[i])
	    FREE(tos[i]);
    }

    FREE(froms);
    FREE(tos);
    FREE(tally);
    FREE(width);
    FREE(pos);
}
开发者ID:sunfirefox,项目名称:btyacc,代码行数:46,代码来源:output.c


示例12: pack_table

static void
pack_table(void)
{
    int i;
    Value_t place;
    int state;

    base = NEW2(nvectors, Value_t);
    pos = NEW2(nentries, Value_t);

    maxtable = 1000;
    table = NEW2(maxtable, Value_t);
    check = NEW2(maxtable, Value_t);

    lowzero = 0;
    high = 0;

    for (i = 0; i < maxtable; i++)
	check[i] = -1;

    for (i = 0; i < nentries; i++)
    {
	state = matching_vector(i);

	if (state < 0)
	    place = (Value_t) pack_vector(i);
	else
	    place = base[state];

	pos[i] = place;
	base[order[i]] = place;
    }

    for (i = 0; i < nvectors; i++)
    {
	if (froms[i])
	    FREE(froms[i]);
	if (tos[i])
	    FREE(tos[i]);
    }

    FREE(froms);
    FREE(tos);
    FREE(pos);
}
开发者ID:Der-Jan,项目名称:freebsd-crypto,代码行数:45,代码来源:output.c


示例13: set_accessing_symbol

static void
set_accessing_symbol(void)
{
    core *sp;

    accessing_symbol = NEW2(nstates, Value_t);
    for (sp = first_state; sp; sp = sp->next)
	accessing_symbol[sp->number] = sp->accessing_symbol;
}
开发者ID:0mp,项目名称:freebsd,代码行数:9,代码来源:lalr.c


示例14: defreds

static void
defreds(void)
{
    int i;

    defred = NEW2(nstates, Value_t);
    for (i = 0; i < nstates; i++)
	defred[i] = (Value_t) sole_reduction(i);
}
开发者ID:tizenorg,项目名称:external.byacc,代码行数:9,代码来源:mkpar.c


示例15: set_first_derives

void set_first_derives(void)
{
  register unsigned *rrow;
  register unsigned *vrow;
  register int j;
  register unsigned mask;
  register unsigned cword;
  register Yshort *rp;

  int rule;
  int i;
  int rulesetsize;
  int varsetsize;

  rulesetsize = WORDSIZE(nrules);
  varsetsize = WORDSIZE(nvars);
  first_derives = NEW2(nvars * rulesetsize, first_derives[0]);
  first_derives -= ntokens * rulesetsize;

  set_EFF();

  rrow = first_derives + ntokens * rulesetsize;

  for (i = start_symbol; i < nsyms; ++i)
    {
      vrow = EFF + ((i - ntokens) * varsetsize);
      cword = *vrow++;
      mask = 1;

      for (j = start_symbol; j < nsyms; ++j)
        {
          if (cword & mask)
            {
              rp = derives[j];
              while ((rule = *rp++) >= 0)
                {
                  SETBIT(rrow, rule);
                }
            }

          mask <<= 1;
          if (mask == 0)
            {
              cword = *vrow++;
              mask = 1;
            }
        }

      vrow += varsetsize;
      rrow += rulesetsize;
    }

    if (tflag > 1)
        print_first_derives();

  FREE(EFF);
}
开发者ID:GerHobbelt,项目名称:BtYacc,代码行数:57,代码来源:closure.c


示例16: save_column

static void
save_column(int symbol, int default_state)
{
    int i;
    int m;
    int n;
    Value_t *sp;
    Value_t *sp1;
    Value_t *sp2;
    Value_t count;
    int symno;

    m = goto_map[symbol];
    n = goto_map[symbol + 1];

    count = 0;
    for (i = m; i < n; i++)
    {
	if (to_state[i] != default_state)
	    ++count;
    }
    if (count == 0)
	return;

    symno = symbol_value[symbol] + 2 * nstates;

    froms[symno] = sp1 = sp = NEW2(count, Value_t);
    tos[symno] = sp2 = NEW2(count, Value_t);

    for (i = m; i < n; i++)
    {
	if (to_state[i] != default_state)
	{
	    *sp1++ = from_state[i];
	    *sp2++ = to_state[i];
	}
    }

    tally[symno] = count;
    width[symno] = (Value_t) (sp1[-1] - sp[0] + 1);
}
开发者ID:Der-Jan,项目名称:freebsd-crypto,代码行数:41,代码来源:output.c


示例17: allocate_itemsets

static void
allocate_itemsets(void)
{
    Value_t *itemp;
    Value_t *item_end;
    int symbol;
    int i;
    int count;
    int max;
    Value_t *symbol_count;

    count = 0;
    symbol_count = NEW2(nsyms, Value_t);

    item_end = ritem + nitems;
    for (itemp = ritem; itemp < item_end; itemp++)
    {
	symbol = *itemp;
	if (symbol >= 0)
	{
	    count++;
	    symbol_count[symbol]++;
	}
    }

    kernel_base = NEW2(nsyms, Value_t *);
    kernel_items = NEW2(count, Value_t);

    count = 0;
    max = 0;
    for (i = 0; i < nsyms; i++)
    {
	kernel_base[i] = kernel_items + count;
	count += symbol_count[i];
	if (max < symbol_count[i])
	    max = symbol_count[i];
    }

    shift_symbol = symbol_count;
    kernel_end = NEW2(nsyms, Value_t *);
}
开发者ID:0xffffffRabbit,项目名称:NextBSD-1,代码行数:41,代码来源:lr0.c


示例18: save_column

void save_column(int symbol, int default_state)
{
    register int i;
    register int m;
    register int n;
    register Yshort *sp;
    register Yshort *sp1;
    register Yshort *sp2;
    register int count;
    register int symno;

    m = goto_map[symbol];
    n = goto_map[symbol + 1];

    count = 0;
    for (i = m; i < n; i++)
    {
	if (to_state[i] != default_state)
	    ++count;
    }
    if (count == 0) return;

    symno = symbol_value[symbol] + 3*nstates;

    froms[symno] = sp1 = sp = NEW2(count, Yshort);
    tos[symno] = sp2 = NEW2(count, Yshort);

    for (i = m; i < n; i++)
    {
	if (to_state[i] != default_state)
	{
	    *sp1++ = from_state[i];
	    *sp2++ = to_state[i];
	}
    }

    tally[symno] = count;
    width[symno] = sp1[-1] - sp[0] + 1;
}
开发者ID:sunfirefox,项目名称:btyacc,代码行数:39,代码来源:output.c


示例19: initialize_LA

static void
initialize_LA(void)
{
    int i, j, k;
    reductions *rp;

    lookaheads = NEW2(nstates + 1, Value_t);

    k = 0;
    for (i = 0; i < nstates; i++)
    {
	lookaheads[i] = (Value_t)k;
	rp = reduction_table[i];
	if (rp)
	    k += rp->nreds;
    }
    lookaheads[nstates] = (Value_t)k;

    LA = NEW2(k * tokensetsize, unsigned);
    LAruleno = NEW2(k, Value_t);
    lookback = NEW2(k, shorts *);

    k = 0;
    for (i = 0; i < nstates; i++)
    {
	rp = reduction_table[i];
	if (rp)
	{
	    for (j = 0; j < rp->nreds; j++)
	    {
		LAruleno[k] = rp->rules[j];
		k++;
	    }
	}
    }
}
开发者ID:0mp,项目名称:freebsd,代码行数:36,代码来源:lalr.c


示例20: digraph

static void
digraph(Value_t **relation)
{
    int i;

    infinity = (Value_t)(ngotos + 2);
    INDEX = NEW2(ngotos + 1, Value_t);
    VERTICES = NEW2(ngotos + 1, Value_t);
    top = 0;

    R = relation;

    for (i = 0; i < ngotos; i++)
	INDEX[i] = 0;

    for (i = 0; i < ngotos; i++)
    {
	if (INDEX[i] == 0 && R[i])
	    traverse(i);
    }

    FREE(INDEX);
    FREE(VERTICES);
}
开发者ID:0mp,项目名称:freebsd,代码行数:24,代码来源:lalr.c



注:本文中的NEW2函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ NEWERROR函数代码示例发布时间:2022-05-30
下一篇:
C++ NEVER函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap