FAUST compiler  0.9.9.6b8
Classes | Typedefs | Functions
patternmatcher.cpp File Reference
#include "tlib.hh"
#include "list.hh"
#include "boxes.hh"
#include "ppbox.hh"
#include "eval.hh"
#include "patternmatcher.hh"
#include <vector>
#include <list>
#include <set>
#include <utility>
Include dependency graph for patternmatcher.cpp:

Go to the source code of this file.

Classes

struct  Rule
 
struct  Trans
 
struct  State
 
struct  Automaton
 
struct  Assoc
 

Typedefs

typedef vector< int > Path
 
typedef list< AssocSubst
 

Functions

static bool isCons (Tree x, Tree &h, Tree &t)
 
static bool isBoxPatternOp (Tree box, Node &n, Tree &t1, Tree &t2)
 
static Tree subtree (Tree X, int i, const Path &p)
 
static Statemake_state (State *state, int r, Tree x, Path &p)
 
static Statemake_var_state (int n, State *state)
 
static void merge_state (State *state1, State *state2)
 
static void merge_rules (list< Rule > &rules1, list< Rule > &rules2)
 
static void merge_trans_var (list< Trans > &trans, State *state)
 
static void merge_trans_cst (list< Trans > &trans, Tree x, State *state)
 
static void merge_trans_op (list< Trans > &trans, const Node &op, int arity, State *state)
 
static void merge_trans (list< Trans > &trans1, list< Trans > &trans2)
 
Automatonmake_pattern_matcher (Tree R)
 
static void add_subst (vector< Subst > &subst, Automaton *A, int s)
 
static int apply_pattern_matcher_internal (Automaton *A, int s, Tree X, vector< Subst > &subst)
 
int apply_pattern_matcher (Automaton *A, int s, Tree X, Tree &C, vector< Tree > &E)
 

Typedef Documentation

typedef vector<int> Path

Definition at line 58 of file patternmatcher.cpp.

typedef list<Assoc> Subst

Definition at line 576 of file patternmatcher.cpp.

Function Documentation

static void add_subst ( vector< Subst > &  subst,
Automaton A,
int  s 
)
static

Definition at line 580 of file patternmatcher.cpp.

References Automaton::rules().

Referenced by apply_pattern_matcher_internal().

581 {
582  list<Rule> rules = A->rules(s);
583  list<Rule>::const_iterator r;
584  for (r = rules.begin(); r != rules.end(); r++)
585  if (r->id != NULL)
586  subst[r->r].push_back(Assoc(r->id, r->p));
587 }
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
const list< Rule > & rules(int s)

Here is the call graph for this function:

Here is the caller graph for this function:

int apply_pattern_matcher ( Automaton A,
int  s,
Tree  X,
Tree C,
vector< Tree > &  E 
)

Definition at line 660 of file patternmatcher.cpp.

References apply_pattern_matcher_internal(), boxError(), closure(), Automaton::final(), isBoxError(), Automaton::n_rules(), nil, pushValueDef(), Automaton::rhs, Automaton::rules(), searchIdDef(), subst(), and subtree().

Referenced by applyList(), and make_pattern_matcher().

665 {
666  int n = A->n_rules();
667  vector<Subst> subst(n, Subst());
668  /* perform matching, record variable substitutions */
669 #ifdef DEBUG
670  cerr << "automaton " << A << ", state " << s << ", start match on arg: " << *X << endl;
671 #endif
673  C = nil;
674  if (s < 0)
675  /* failed match */
676  return s;
677  /* process variable substitutions */
678  list<Rule>::const_iterator r;
679  for (r = A->rules(s).begin(); r != A->rules(s).end(); r++) {
680  // all rules still active in state s
681  if (!isBoxError(E[r->r])) { // and still viable
682  Subst::const_iterator assoc;
683  for (assoc = subst[r->r].begin(); assoc != subst[r->r].end(); assoc++) {
684  Tree Z, Z1 = subtree(X, 0, assoc->p);
685  if (searchIdDef(assoc->id, Z, E[r->r])) {
686  if (Z != Z1) {
687  /* failed nonlinearity, add to the set of nonviable rules */
688 #ifdef DEBUG
689  cerr << "state " << s << ", rule #" << r->r << ": " <<
690  *assoc->id << " := " << *Z1 << " *** failed *** old value: " <<
691  *Z << endl;
692 #endif
693  E[r->r] = boxError();
694  }
695  } else {
696  /* bind a variable for the current rule */
697 #ifdef DEBUG
698  cerr << "state " << s << ", rule #" << r->r << ": " <<
699  *assoc->id << " := " << *Z1 << endl;
700 #endif
701  E[r->r] = pushValueDef(assoc->id, Z1, E[r->r]);
702  }
703  }
704  }
705  }
706  if (A->final(s)) {
707  /* if in a final state then return the right-hand side together with the
708  corresponding variable environment */
709  for (r = A->rules(s).begin(); r != A->rules(s).end(); r++) // all rules matched in state s
710  if (!isBoxError(E[r->r])) { // and still viable
711  /* return the rhs of the matched rule */
712  C = closure(A->rhs[r->r], nil, nil, E[r->r]);
713 #ifdef DEBUG
714  cerr << "state " << s << ", complete match yields rhs #" << r->r <<
715  ": " << *A->rhs[r->r] << endl;
716 #endif
717  return s;
718  }
719  /* if none of the rules were matched then declare a failed match */
720 #ifdef DEBUG
721  cerr << "state " << s << ", *** match failed ***" << endl;
722 #endif
723  return -1;
724  }
725 #ifdef DEBUG
726  cerr << "state " << s << ", successful incomplete match" << endl;
727 #endif
728  return s;
729 }
Tree pushValueDef(Tree id, Tree def, Tree lenv)
Push a new layer and add a single definition.
Definition: environment.cpp:94
static Tree subtree(Tree X, int i, const Path &p)
bool searchIdDef(Tree id, Tree &def, Tree lenv)
Search the environment (until first barrier) for the definition of a symbol ID and return it...
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
bool final(int s)
list< Assoc > Subst
vector< Tree > rhs
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
static int apply_pattern_matcher_internal(Automaton *A, int s, Tree X, vector< Subst > &subst)
Tree boxError()
Definition: boxes.cpp:244
Tree closure(Tree abstr, Tree genv, Tree vis, Tree lenv)
Definition: boxes.cpp:234
Tree nil
Definition: list.cpp:116
const list< Rule > & rules(int s)
bool isBoxError(Tree t)
Definition: boxes.cpp:249

Here is the call graph for this function:

Here is the caller graph for this function:

static int apply_pattern_matcher_internal ( Automaton A,
int  s,
Tree  X,
vector< Subst > &  subst 
)
static

Definition at line 593 of file patternmatcher.cpp.

References add_subst(), isBoxPatternOp(), simplifyPattern(), Automaton::state, and Automaton::trans().

Referenced by apply_pattern_matcher().

595 {
596  /* FIXME: rewrite this non-recursively? */
597  if (s >= 0) {
598  list<Trans>::const_iterator t;
599  if (A->state[s]->match_num)
600  /* simplify possible numeric argument on the fly */
601  X = simplifyPattern(X);
602  /* first check for applicable non-variable transitions */
603  for (t = A->trans(s).begin(); t != A->trans(s).end(); t++) {
604  Tree x;
605  Node op(0), op1(0);
606  if (t->is_var_trans())
607  continue;
608  else if (t->is_cst_trans(x)) {
609  if (X==x) {
610  /* transition on constant */
611 #ifdef DEBUG
612  cerr << "state " << s << ", " << *x << ": goto state " << t->state->s << endl;
613 #endif
614  add_subst(subst, A, s);
615  s = t->state->s;
616  return s;
617  }
618  } else if (t->is_op_trans(op)) {
619  Tree x0, x1;
620  if (isBoxPatternOp(X, op1, x0, x1) && op == op1) {
621  /* transition on operation symbol */
622 #ifdef DEBUG
623  cerr << "state " << s << ", " << op << ": goto state " << t->state->s << endl;
624 #endif
625  add_subst(subst, A, s);
626  s = t->state->s;
627  if (s >= 0)
628  s = apply_pattern_matcher_internal(A, s, x0, subst);
629  if (s >= 0)
630  s = apply_pattern_matcher_internal(A, s, x1, subst);
631  return s;
632  }
633  }
634  }
635  /* check for variable transition (is always first in the list of
636  transitions) */
637  t = A->trans(s).begin();
638  if (t->is_var_trans()) {
639 #ifdef DEBUG
640  cerr << "state " << s << ", _: goto state " << t->state->s << endl;
641 #endif
642  add_subst(subst, A, s);
643  s = t->state->s;
644  } else {
645 #ifdef DEBUG
646  cerr << "state " << s << ", *** match failed ***" << endl;
647 #endif
648  s = -1;
649  }
650  }
651  return s;
652 }
static bool isBoxPatternOp(Tree box, Node &n, Tree &t1, Tree &t2)
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
static void add_subst(vector< Subst > &subst, Automaton *A, int s)
Tree simplifyPattern(Tree value)
Simplify a block-diagram pattern by computing its numerical sub-expressions.
Definition: eval.cpp:617
const list< Trans > & trans(int s)
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
vector< State * > state
static int apply_pattern_matcher_internal(Automaton *A, int s, Tree X, vector< Subst > &subst)

Here is the call graph for this function:

Here is the caller graph for this function:

static bool isBoxPatternOp ( Tree  box,
Node n,
Tree t1,
Tree t2 
)
inlinestatic

Definition at line 36 of file patternmatcher.cpp.

References isBoxHGroup(), isBoxMerge(), isBoxPar(), isBoxRec(), isBoxSeq(), isBoxSplit(), isBoxTGroup(), isBoxVGroup(), and CTree::node().

Referenced by apply_pattern_matcher_internal(), make_state(), and subtree().

37 {
38  if ( isBoxPar(box, t1, t2) ||
39  isBoxSeq(box, t1, t2) ||
40  isBoxSplit(box, t1, t2) ||
41  isBoxMerge(box, t1, t2) ||
42  isBoxHGroup(box, t1, t2) ||
43  isBoxVGroup(box, t1, t2) ||
44  isBoxTGroup(box, t1, t2) ||
45  isBoxRec(box, t1, t2) )
46  {
47  n = box->node();
48  return true;
49  } else {
50  return false;
51  }
52 }
bool isBoxSeq(Tree t, Tree &x, Tree &y)
Definition: boxes.cpp:136
bool isBoxSplit(Tree t, Tree &x, Tree &y)
Definition: boxes.cpp:148
const Node & node() const
return the content of the tree
Definition: tree.hh:143
bool isBoxHGroup(Tree s)
Definition: boxes.cpp:437
bool isBoxRec(Tree t, Tree &x, Tree &y)
Definition: boxes.cpp:144
bool isBoxTGroup(Tree s)
Definition: boxes.cpp:449
bool isBoxPar(Tree t, Tree &x, Tree &y)
Definition: boxes.cpp:140
bool isBoxVGroup(Tree s)
Definition: boxes.cpp:443
bool isBoxMerge(Tree t, Tree &x, Tree &y)
Definition: boxes.cpp:152

Here is the call graph for this function:

Here is the caller graph for this function:

static bool isCons ( Tree  x,
Tree h,
Tree t 
)
inlinestatic

Definition at line 25 of file patternmatcher.cpp.

References hd(), isList(), and tl().

Referenced by make_pattern_matcher().

26 {
27  if (isList(x)) {
28  h = hd(x); t = tl(x);
29  return true;
30  } else
31  return false;
32 }
Tree hd(Tree l)
Definition: list.hh:133
bool isList(Tree l)
Definition: list.hh:138
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

Here is the caller graph for this function:

Automaton* make_pattern_matcher ( Tree  R)

Definition at line 479 of file patternmatcher.cpp.

References apply_pattern_matcher(), Automaton::build(), Automaton::final(), isBoxError(), isCons(), len(), make_state(), merge_state(), nil, reverse(), Automaton::rhs, State::rules, and Automaton::rules().

Referenced by evalCase().

491 {
492  Automaton *A = new Automaton;
493  int n = len(R), r = n;
494  State *start = new State;
495  Tree rule, rest;
496  vector<Tree> rules(n, (Tree)NULL);
497  vector< vector<Tree> > testpats(n);
498  while (isCons(R, rule, rest)) {
499  rules[--r] = rule;
500  R = rest;
501  }
502  for (r = 0; r < n; r++) {
503  Tree lhs, rhs;
504  if (isCons(rules[r], lhs, rhs)) {
505  Tree pat, rest;
506  int m = len(lhs), i = m;
507  vector<Tree> pats(len(lhs), (Tree)NULL);
508  State *state0 = new State, *state = state0;
509  A->rhs.push_back(rhs);
510  while (isCons(lhs, pat, rest)) {
511  pats[--i] = pat;
512  lhs = rest;
513  }
514  testpats[r] = pats;
515  for (i = 0; i < m; i++) {
516  Path p;
517  state = make_state(state, r, pats[i], p);
518  }
519  Rule rule(r, NULL);
520  state->rules.push_back(rule);
521  merge_state(start, state0);
522  delete state0;
523  }
524  }
525  A->build(start);
526  /* Check for shadowed rules. Note that because of potential nonlinearities
527  it is *not* enough to just check the rule lists of final states and
528  determine whether they have multiple matched rules. */
529  for (r = 0; r < n; r++) {
530  int s = 0, m = (int)testpats[r].size();
531  Tree C;
532  vector<Tree> E(n, nil);
533  /* try to match the lhs of rule #r */
534  for (int i = 0; i < m; i++) {
535  s = apply_pattern_matcher(A, s, testpats[r][i], C, E);
536  if (s < 0) break;
537  }
538  if (A->final(s)) {
539  list<Rule>::const_iterator ru;
540  for (ru = A->rules(s).begin(); ru != A->rules(s).end(); ru++)
541  if (!isBoxError(E[ru->r]))
542  if (ru->r < r) {
543  /* Lhs of rule #r matched a higher-priority rule, so rule #r may
544  be shadowed. */
545  Tree lhs1, rhs1, lhs2, rhs2;
546  if (isCons(rules[ru->r], lhs1, rhs1) && isCons(rules[r], lhs2, rhs2)) {
547  cerr << "WARNING : shadowed pattern-matching rule: "
548  << boxpp(reverse(lhs2)) << " => " << boxpp(rhs2) << ";"
549  << " previous rule was: "
550  << boxpp(reverse(lhs1)) << " => " << boxpp(rhs1) << ";"
551  << endl;
552  } else {
553  cerr << "INTERNAL ERROR : " << __FILE__ << ":" << __LINE__ << endl;
554  exit(1);
555  }
556  } else if (ru->r >= r)
557  break;
558  }
559  }
560 #ifdef DEBUG
561  cerr << "automaton " << A << endl << *A << "end automaton" << endl;
562 #endif
563  return A;
564 }
Tree reverse(Tree l)
Definition: list.cpp:240
static State * make_state(State *state, int r, Tree x, Path &p)
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
list< Rule > rules
bool final(int s)
vector< Tree > rhs
static bool isCons(Tree x, Tree &h, Tree &t)
vector< int > Path
void build(State *st)
Definition: ppbox.hh:58
Tree nil
Definition: list.cpp:116
const list< Rule > & rules(int s)
static void merge_state(State *state1, State *state2)
bool isBoxError(Tree t)
Definition: boxes.cpp:249
int apply_pattern_matcher(Automaton *A, int s, Tree X, Tree &C, vector< Tree > &E)
int len(Tree l)
Definition: list.cpp:198

Here is the call graph for this function:

Here is the caller graph for this function:

static State* make_state ( State state,
int  r,
Tree  x,
Path p 
)
static

Definition at line 300 of file patternmatcher.cpp.

References isBoxPatternOp(), isBoxPatternVar(), State::rules, and State::trans.

Referenced by make_pattern_matcher().

301 {
302  Tree id, x0, x1;
303  Node op(0);
304  if (isBoxPatternVar(x, id)) {
305  /* variable */
306  Rule rule(r, id, p);
307  state->rules.push_back(rule);
308  Trans trans(NULL);
309  state->trans.push_back(trans);
310  return state->trans.begin()->state;
311  } else if (isBoxPatternOp(x, op, x0, x1)) {
312  /* composite pattern */
313  Rule rule(r, NULL);
314  state->rules.push_back(rule);
315  Trans trans(op, 2);
316  state->trans.push_back(trans);
317  State *next = state->trans.begin()->state;
318  p.push_back(0);
319  next = make_state(next, r, x0, p);
320  p.pop_back();
321  p.push_back(1);
322  next = make_state(next, r, x1, p);
323  p.pop_back();
324  return next;
325  } else {
326  /* constant */
327  Rule rule(r, NULL);
328  state->rules.push_back(rule);
329  Trans trans(x);
330  state->trans.push_back(trans);
331  return state->trans.begin()->state;
332  }
333 }
static bool isBoxPatternOp(Tree box, Node &n, Tree &t1, Tree &t2)
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
static State * make_state(State *state, int r, Tree x, Path &p)
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
list< Rule > rules
bool isBoxPatternVar(Tree s, Tree &id)
Definition: boxes.cpp:622
list< Trans > trans

Here is the call graph for this function:

Here is the caller graph for this function:

static State* make_var_state ( int  n,
State state 
)
static

Definition at line 337 of file patternmatcher.cpp.

References State::rules, and State::trans.

Referenced by merge_trans_op(), and merge_trans_var().

338 {
339  if (n <= 0)
340  return new State(*state);
341  list<Rule>rules = state->rules;
342  list<Rule>::iterator r;
343  for (r = rules.begin(); r != rules.end(); r++) {
344  r->id = NULL; r->p = Path();
345  }
346  State *prefix = new State, *current = prefix;
347  while (n-- > 0) {
348  current->rules = rules;
349  Trans trans(NULL);
350  current->trans.push_back(trans);
351  current = current->trans.begin()->state;
352  }
353  *current = *state;
354  return prefix;
355 }
list< Rule > rules
vector< int > Path
list< Trans > trans

Here is the caller graph for this function:

static void merge_rules ( list< Rule > &  rules1,
list< Rule > &  rules2 
)
inlinestatic

Definition at line 364 of file patternmatcher.cpp.

Referenced by merge_state().

365 {
366  list<Rule> cprules2 = rules2;
367  rules1.merge(cprules2);
368 }

Here is the caller graph for this function:

static void merge_state ( State state1,
State state2 
)
static

Definition at line 470 of file patternmatcher.cpp.

References merge_rules(), merge_trans(), State::rules, and State::trans.

Referenced by make_pattern_matcher(), merge_trans_cst(), merge_trans_op(), and merge_trans_var().

471 {
472  merge_rules(state1->rules, state2->rules);
473  merge_trans(state1->trans, state2->trans);
474 }
static void merge_trans(list< Trans > &trans1, list< Trans > &trans2)
list< Rule > rules
static void merge_rules(list< Rule > &rules1, list< Rule > &rules2)
list< Trans > trans

Here is the call graph for this function:

Here is the caller graph for this function:

static void merge_trans ( list< Trans > &  trans1,
list< Trans > &  trans2 
)
static

Definition at line 449 of file patternmatcher.cpp.

References merge_trans_cst(), merge_trans_op(), and merge_trans_var().

Referenced by merge_state().

450 {
451  Tree x;
452  Node op(0);
453  if (trans2.empty())
454  ;
455  else if (trans1.empty()) {
456  list<Trans> cptrans2 = trans2;
457  /* append a copy of trans2 to trans1 */
458  trans1.splice(trans1.end(), cptrans2);
459  } else if (trans2.begin()->is_var_trans())
460  /* merge a variable transition */
461  merge_trans_var(trans1, trans2.begin()->state);
462  else if (trans2.begin()->is_cst_trans(x))
463  /* merge a constant transition */
464  merge_trans_cst(trans1, x, trans2.begin()->state);
465  else if (trans2.begin()->is_op_trans(op))
466  /* merge a BDA op transition */
467  merge_trans_op(trans1, op, trans2.begin()->arity, trans2.begin()->state);
468 }
static void merge_trans_var(list< Trans > &trans, State *state)
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
static void merge_trans_op(list< Trans > &trans, const Node &op, int arity, State *state)
static void merge_trans_cst(list< Trans > &trans, Tree x, State *state)

Here is the call graph for this function:

Here is the caller graph for this function:

static void merge_trans_cst ( list< Trans > &  trans,
Tree  x,
State state 
)
static

Definition at line 396 of file patternmatcher.cpp.

References merge_state().

Referenced by merge_trans().

397 {
398  list<Trans>::iterator t0 = trans.begin(), t1 = t0, t;
399  Tree x1;
400  if (t0->is_var_trans()) t1++;
401  for (t = t1; t != trans.end(); t++) {
402  if (t->is_cst_trans(x1)) {
403  if (x == x1) {
404  merge_state(t->state, state);
405  return;
406  } else if (x < x1)
407  break;
408  }
409  }
410  /* no matching transition has been found; add a new one */
411  Trans tr(x);
412  trans.insert(t, tr); t--;
413  State *state1 = t->state;
414  *state1 = *state;
415  if (t1 != t0) {
416  /* if we have a variable transition in the current state, we also need to
417  merge its completion for the current symbol/constant */
418  merge_state(state1, t0->state);
419  }
420 }
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
static void merge_state(State *state1, State *state2)

Here is the call graph for this function:

Here is the caller graph for this function:

static void merge_trans_op ( list< Trans > &  trans,
const Node op,
int  arity,
State state 
)
static

Definition at line 422 of file patternmatcher.cpp.

References Node::getSym(), make_var_state(), and merge_state().

Referenced by merge_trans().

424 {
425  /* analogous to merge_trans_cst above, but handles the arity>0 case */
426  list<Trans>::iterator t0 = trans.begin(), t1 = t0, t;
427  Node op1(0);
428  if (t0->is_var_trans()) t1++;
429  for (t = t1; t != trans.end(); t++) {
430  if (t->is_op_trans(op1)) {
431  if (op == op1) {
432  merge_state(t->state, state);
433  return;
434  } else if (op.getSym() < op1.getSym())
435  break;
436  }
437  }
438  Trans tr(op, arity);
439  trans.insert(t, tr); t--;
440  State *state1 = t->state;
441  *state1 = *state;
442  if (t1 != t0) {
443  State *state2 = make_var_state(arity, t0->state);
444  merge_state(state1, state2);
445  delete state2;
446  }
447 }
Sym getSym() const
Definition: node.hh:106
static State * make_var_state(int n, State *state)
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
static void merge_state(State *state1, State *state2)

Here is the call graph for this function:

Here is the caller graph for this function:

static void merge_trans_var ( list< Trans > &  trans,
State state 
)
static

Definition at line 370 of file patternmatcher.cpp.

References make_var_state(), and merge_state().

Referenced by merge_trans().

371 {
372  if (!trans.begin()->is_var_trans()) {
373  /* If we don't have a variable transition in this state yet then create a
374  new one. */
375  Trans tr(NULL);
376  trans.push_front(tr);
377  }
378  list<Trans>::const_iterator t;
379  Tree x;
380  Node op(0);
381  for (t = trans.begin(); t != trans.end(); t++) {
382  if (t->is_var_trans())
383  merge_state(t->state, state);
384  else if (t->is_cst_trans(x)) {
385  /* add the completion of the given state for a constant */
386  merge_state(t->state, state);
387  } else if (t->is_op_trans(op)) {
388  /* add the completion of the given state for an arity>0 op */
389  State *state1 = make_var_state(t->arity, state);
390  merge_state(t->state, state1);
391  delete state1;
392  }
393  }
394 }
static State * make_var_state(int n, State *state)
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
static void merge_state(State *state1, State *state2)

Here is the call graph for this function:

Here is the caller graph for this function:

static Tree subtree ( Tree  X,
int  i,
const Path p 
)
static

Definition at line 62 of file patternmatcher.cpp.

References isBoxPatternOp().

Referenced by apply_pattern_matcher().

63 {
64  int n = (int)p.size();
65  Node op(0);
66  Tree x0, x1;
67  if (i < n && isBoxPatternOp(X, op, x0, x1))
68  return subtree((p[i]==0)?x0:x1, i+1, p);
69  else
70  return X;
71 }
static bool isBoxPatternOp(Tree box, Node &n, Tree &t1, Tree &t2)
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
static Tree subtree(Tree X, int i, const Path &p)
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109

Here is the call graph for this function:

Here is the caller graph for this function: