CWB
Functions
tree.c File Reference
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "../cl/macros.h"
#include "../cl/attributes.h"
#include "cqp.h"
#include "eval.h"
#include "treemacros.h"
#include "tree.h"
#include "options.h"
#include "symtab.h"
#include "builtins.h"
#include "matchlist.h"

Functions

void print_pattern (int envidx, int index, int indent)
 Pretty-prints {what??}. More...
 
void print_rep_factor (int i)
 Translates the symbolic value for the repetition arguments. More...
 
void print_evaltree (int envidx, Evaltree etptr, int indent)
 Pretty-prints an evaluation tree. More...
 
void free_booltree (Constrainttree ctptr)
 Deletes a boolean evaluation tree (recursive with depth-first). More...
 
void free_evaltree (Evaltree *etptr)
 Deletes an evaluation tree with the depth-first method. More...
 
void init_booltree (Constrainttree *ctptr)
 Initialises a boolean evaluation tree. More...
 
void print_booltree (Constrainttree ctptr, int indent)
 Prints a boolean evaluation tree. More...
 
void show_patternlist (int eidx)
 Shows the contents of the patternlist. More...
 
char * evaltree2searchstr (Evaltree etptr, int *length)
 Converts an evaluation tree to a string. More...
 
Constrainttry_optimization (Constraint *tree)
 

Function Documentation

char* evaltree2searchstr ( Evaltree  etptr,
int *  length 
)

Converts an evaluation tree to a string.

This is done by traversing the tree in infix order.

Parameters
etptrThe evaluation tree to convert.
lengthSize of the returned string is placed here.
Returns
The resulting string.

References cl_free, cl_malloc(), cl_strdup(), evaltree2searchstr(), leaf, e_tree::leaf, e_tree::left, left, e_tree::max, e_tree::min, node, e_tree::node, e_tree::op_id, e_tree::patindex, re_disj, re_od_concat, re_oi_concat, re_repeat, repeat_inf, repeat_none, e_tree::right, right, and e_tree::type.

Referenced by do_SearchPattern(), and evaltree2searchstr().

void free_booltree ( Constrainttree  ctptr)
void free_evaltree ( Evaltree etptr)

Deletes an evaluation tree with the depth-first method.

Parameters
etptrThe evaluation tree to delete.

References DELETE_NODE, free_evaltree(), leaf, meet_union, node, re_disj, re_od_concat, re_oi_concat, re_repeat, and tabular.

Referenced by free_environment(), and free_evaltree().

void init_booltree ( Constrainttree ctptr)

Initialises a boolean evaluation tree.

At the moment, this involved simply setting the Constrainttree to NULL.

Parameters
ctptrPointer to the constrainttree to initialise. Note the Constrainttree type is itself a pointer, so this is underlyingly a pointer-to-pointer.
void print_booltree ( Constrainttree  ctptr,
int  indent 
)

Prints a boolean evaluation tree.

This function is a pretty-printer for the Constrainttree data type. It traverses a boolean evaluation tree and prints its contents. An indentation level must be specified.

(The indentation is needed because this function calls itself recursively for sub-branches.)

Parameters
ctptrConstrainttree to print.
indentNumber of indent levels at which to start printing. Each indent level is realised as two spaces.

References _Attribute::any, c_tree::args, c_tree::attr, b_and, b_implies, b_not, b_or, bnode, builtin_function, CID, cmp_eq, cmp_ex, cmp_get, cmp_gt, cmp_let, cmp_lt, cmp_neq, cnode, c_tree::constnode, c_tree::ctype, c_tree::dynattr, float_leaf, func, c_tree::func, id_list, c_tree::idlist, int_leaf, c_tree::items, c_tree::label, c_tree::leaf, c_tree::left, _builtinf::name, _label_entry::name, c_tree::negated, _ActualParamList::next, c_tree::node, NORMAL, c_tree::nr_items, c_tree::op_id, pa_ref, c_tree::pa_ref, _ActualParamList::param, c_tree::pat_type, c_tree::predef, print_booltree(), REGEXP, c_tree::right, sa_ref, sbound, string_leaf, tree_debug, c_tree::type, c_tree::val, var_ref, c_tree::varName, and c_tree::varref.

Referenced by print_booltree(), print_pattern(), and show_environment().

void print_evaltree ( int  envidx,
Evaltree  etptr,
int  indent 
)

Pretty-prints an evaluation tree.

This function traverses the evaluation tree in infix order and prints it appropriately indented.

Parameters
envidxIndex into the Environment global array.
etptrThe evaluation tree to print.
indentThe indent level to start printing at.

References _Attribute::any, e_tree::cooc, cooc_meet, cooc_union, Environment, leaf, e_tree::leaf, e_tree::left, e_tree::lw, e_tree::max, e_tree::max_dist, evalenv::MaxPatIndex, meet_union, e_tree::min, e_tree::min_dist, e_tree::next, node, e_tree::node, e_tree::op_id, e_tree::patindex, print_evaltree(), print_pattern(), print_rep_factor(), re_disj, re_od_concat, re_oi_concat, re_repeat, repeat_none, e_tree::right, e_tree::rw, e_tree::struc, e_tree::tab_el, tabular, and e_tree::type.

Referenced by do_SearchPattern(), print_evaltree(), and show_environment().

void print_pattern ( int  envidx,
int  index,
int  indent 
)

Pretty-prints {what??}.

Parameters
envidxIndex into the Environment global array.
indexIndex into the patternlist element of that element of environment.
indentThe indent level to start printing at.

References Environment, IGNORE_CASE, IGNORE_DIAC, IGNORE_REGEX, MatchAll, Pattern, evalenv::patternlist, print_booltree(), and Tag.

Referenced by print_evaltree(), and show_patternlist().

void print_rep_factor ( int  i)

Translates the symbolic value for the repetition arguments.

(The translated value is printed as a string to STDOUT.)

Parameters
iThe repetition argument symbol to translate.

References repeat_inf, and repeat_none.

Referenced by print_evaltree().

void show_patternlist ( int  eidx)

Shows the contents of the patternlist.

(Prints to STDOUT.)

Parameters
eidxIndex into the global Environment array, identifying the element whose patternlist is to be printed.

References Environment, evalenv::MaxPatIndex, and print_pattern().

Referenced by show_environment().

Constraint* try_optimization ( Constraint tree)