Esempio n. 1
0
linktodefs ()
{
  register int rule, alt, afx;
  newtop ();
  alt = SON (root);
  afx = AFFIXDEF (alt);
  if ((afx == nil) || (NODENAME (afx) != derived) || (BROTHER (afx) != nil))
  {
    error = true;
    if (input_from_partlist)
      fprintf (stderr, "In %s:\n", PART (root));
    fprintf (stderr, "line %ld: start rule should have at most ONE derived affix\n", LINE (root));
  }

  for (rule = root; rule != laststdpred; rule = BROTHER (rule))
  {
    int alt = SON (rule);
    check_affix_def (rule);
    multiple_defined (rule);
    for (; alt != nil; alt = BROTHER (alt))
    {
      lhs_affixes_defined (alt, rule);
      rhs_members_affixes_defined (alt, rule);
    }
  }
  delete_multiple_defined_hyperrules ();
  if (error)
    if (!tree_flag)
      exit (10);
}
Esempio n. 2
0
tail_recursion_elimination ()
{
  int alt;
  int tre = 0;

  if (no_recursion_elm_flag)
    return false;

  for (alt = SON (ulhs); alt != nil; alt = BROTHER (alt))
  {
    int mem = SON (alt);
    if (mem == nil)
      continue;
    if (FLAG_MARKED (alt, no_tail_recursion_opt_f))
      continue;
    mem = get_last_but_cut_mem (mem);
    if (DEF (mem) == ulhs)
    {
      FLAG_SET (alt, tail_recursion_opt_f);
      FLAG_SET (mem, tail_recursion_opt_f);
      tre = 1;
    }
  }
  return tre;
}
Esempio n. 3
0
det_rule_tail ()
{
  int last_alt;

  for (last_alt = SON (ulhs); BROTHER (last_alt) != nil; last_alt = BROTHER (last_alt));
  if (SON (last_alt) == nil)
  {
    fprintf (output, "  \n}\n");
    return;
  }

  if (trace_flag)
  {
    if (errormsg_flag)
      fprintf (output, "  set_errmsg(ntname);\n");
    fprintf (output, "  endtrace(parsecount,pntnamesv,ntname); level=ltr;");
  }
  else if (errormsg_flag)
  {
    fprintf (output, "  set_errmsg(ntname);\n");
    fprintf (output, " level = lsave;\n");
  }

/*   
 */
  if (stat_flag)
    fprintf (output, "  stat_tab[%ld] += stat_count - s1;\n", COUNT (ulhs));


  fprintf (output, "  return false;\n}\n");

}
Esempio n. 4
0
builtin_used ()
{
  int rule, alt, mem;
  for (rule = root; rule != laststdpred; rule = BROTHER (rule))
    for (alt = SON (rule); alt != nil; alt = BROTHER (alt))
      for (mem = SON (alt); mem != nil; mem = BROTHER (mem))
        if ((builtin == DEF (mem)) && !(TERMINAL (mem)))
          return true;
  return false;
}
Esempio n. 5
0
void dump_operation(struct operation *op)
{
	if (!op) {
		printf("OP: NULL\n");
		return;
	}

	printf("COND: \"%s\"\nOP: \"%s\"\nARGS: \"%s\", \"%s\", \"%s\"\n\n",
               SON(op->cond), SON(op->cmd), SON(op->arg0),
               SON(op->arg1), SON(op->arg2));
}
Esempio n. 6
0
alias_used_builtins ()
{
  int rule, one_builtin_used = false;
  brother = laststdpred;
  for (builtin = laststdpred; builtin != nil; builtin = BROTHER (builtin))
    if ((builtin != cut) && (builtin != nestarset) &&
        (!mystrcmp (REPR (builtin), "select")) &&
        (builtin != tltraditionalterm) &&
        (builtin != transformlatticeterm) &&
        (builtin != tltraditional) &&
        (builtin != transformlattice) &&
        (builtin != skip) &&
        (builtin != explintersect) &&
        (builtin != getip) &&
        (builtin != falseip) &&
        (builtin != restoreip) &&
        (builtin != evalmeta) &&
        (builtin != initmeta) &&
        (builtin != evalmeta) && (builtin != resetinputptr) && (builtin != nestaralt) && (builtin != where))
    {
      int mem, alt;
      char *n, *m = REPR (builtin);
      if (!builtin_used ())
        continue;
      one_builtin_used = true;
      if (det_flag)
        if ((builtin == tltraditional) || (builtin == tltraditionalterm)
            || (mystrcmp (REPR (builtin), "select")) || (mystrcmp (REPR (builtin), "delete")))
          continue;
      make_new_rule (brother);
      new_rule = brother;

      n = (char *) malloc (strlen (m) + 7);
      if (n == NULL)
        fprintf (stderr, "glammar: Out of memory.\n"), exit (-1);
      strcpy (n, "built_"), strcpy (n + 6, m);
      REPR (new_rule) = n;
      SET (new_rule, external);
      PART (new_rule) = PART (root);
      for (rule = root; rule != laststdpred; rule = BROTHER (rule))
        for (alt = SON (rule); alt != nil; alt = BROTHER (alt))
          for (mem = SON (alt); mem != nil; mem = BROTHER (mem))
            if ((builtin == DEF (mem)) && !(TERMINAL (mem)))
            {
              DEF (mem) = new_rule;
              REPR (mem) = n;
            }
    }
  if (!one_builtin_used)
    return;
  for (rule = root; BROTHER (rule) != laststdpred; rule = BROTHER (rule));
  BROTHER (rule) = new_rule;
}
Esempio n. 7
0
newtop ()
{
  if (AFFIXDEF (SON (root)) == nil)
  {
    int root_mem = nil;

    if (root != laststdpred)
    {
      newdefnode (ntnode, nil, nil, root, REPR (root));
      root_mem = brother;
    }

    newnode (affixtm, nil, nil, "");
    newnode (derived, nil, brother, "(nil)");
    newnode (brother, nil, root_mem, "(nil)");
    newrulenode (NODENAME (root), root, brother, 0, PART (root), "newroot");
    OLDSUM (brother) = OLDSUM (root);
    root = brother;
  }
}
Esempio n. 8
0
det_rule_head ()
{
  fprintf (output, "\n\n/*  %s   */\n", FREPR (ulhs));
  if (MARKED (ulhs, external))
    fprintf (output, "int D%s(", REPR (ulhs));
  else
    fprintf (output, "static int D_%d(", ulhs);
  det_get_affixes (AFFIXDEF (SON (ulhs)));

  if (fprintf (output, " {\n register AFFIX raf = af;\n") == EOF)
  {
    fprintf (stderr, "glammar: Write failed (try again later)\n");
    exit (12);
  }
  if (BROTHER (SON (ulhs)) != nil)
  {
    fprintf (output, "  char *rc = c,  *rip = ip;\n");
  }
  if (lookahead_in_alt (SON (ulhs)))
    fprintf (output, "  char *lkh;\n");
  if (BROTHER (SON (ulhs)) != nil)
    fprintf (output, "  int cut_set = 0;\n");
  fprintf (output, "  int ltr=level++;\n");
  if (trace_flag)
    fprintf (output, " char *pntnamesv = pntname; char *ntname = \"%s\";\n", FREPR (ulhs));
  else if (errormsg_flag)
  {
    int mem = SON (SON (ulhs));
    if (mem != nil && DEF (mem) == equal)
      fprintf (output, "  char *pntnamesv = pntname; char *ntname = \"%s\"; int lsave = level+10;\n", FREPR (ulhs));
    else
      fprintf (output, "  char *pntnamesv = pntname; char *ntname = \"%s\"; int lsave = level++;\n", FREPR (ulhs));
  }

  if (stat_flag)
  {
    fprintf (output, "  int s1 = stat_count++;\n");
  }
  save_lattice_afx ();
  if (tail_recursion_elimination ())
    fprintf (output, " label_%d:\n\n", ulhs);

}
Esempio n. 9
0
ProxyItemSelectionWidget::ProxyItemSelectionWidget(QWidget* parent, Qt::WindowFlags f)
  : QWidget(parent, f)
{
  QSplitter *splitter = new QSplitter(this);
  QHBoxLayout *layout = new QHBoxLayout(this);
  layout->addWidget(splitter);

  DynamicTreeModel *rootModel = new DynamicTreeModel(this);

  DynamicTreeWidget *dynamicTreeWidget = new DynamicTreeWidget(rootModel, splitter);

  dynamicTreeWidget->setInitialTree(
    "- 1"
    "- 2"
    "- - 3"
    "- - - 4"
    "- 5"
    "- 6"
    "- 7"
  );

  QSplitter *vSplitter = new QSplitter(Qt::Vertical, splitter);
  QSplitter *hSplitter1 = new QSplitter(vSplitter);
  QSplitter *hSplitter2 = new QSplitter(vSplitter);

  QSortFilterProxyModel *proxy1 = new QSortFilterProxyModel(this);
  SON(proxy1);
  QSortFilterProxyModel *proxy2 = new QSortFilterProxyModel(this);
  SON(proxy2);
  QSortFilterProxyModel *proxy3 = new QSortFilterProxyModel(this);
  SON(proxy3);
  QSortFilterProxyModel *proxy4 = new QSortFilterProxyModel(this);
  SON(proxy4);
  QSortFilterProxyModel *proxy5 = new QSortFilterProxyModel(this);
  SON(proxy5);

  QTreeView *view1 = new QTreeView(hSplitter1);
  QTreeView *view2 = new QTreeView(hSplitter1);
  QTreeView *view3 = new QTreeView(hSplitter2);
  QTreeView *view4 = new QTreeView(hSplitter2);

  proxy1->setSourceModel( rootModel );
  proxy2->setSourceModel( proxy1 );
  proxy3->setSourceModel( proxy2 );

  proxy4->setSourceModel( rootModel );
  proxy5->setSourceModel( proxy4 );

  view1->setModel( proxy3 );
  view2->setModel( proxy5 );
  view3->setModel( proxy2 );
  view4->setModel( proxy1 );

  QItemSelectionModel *rootSelectionModel = dynamicTreeWidget->treeView()->selectionModel();

  KLinkItemSelectionModel *view1SelectionModel = new KLinkItemSelectionModel(view1->model(), rootSelectionModel, this );
  view1->setSelectionModel( view1SelectionModel );

  KLinkItemSelectionModel *view2SelectionModel = new KLinkItemSelectionModel(view2->model(), view1->selectionModel(), this );
  view2->setSelectionModel( view2SelectionModel );

  KLinkItemSelectionModel *view3SelectionModel = new KLinkItemSelectionModel(view3->model(), view4->selectionModel(), this );
  view3->setSelectionModel( view3SelectionModel );

  view1->expandAll();
  view2->expandAll();
  view3->expandAll();
  view4->expandAll();
}