CWB
|
#define LAB_DEFINED 1 |
whether label has been defined or is defined by this call
Referenced by check_labels(), do_NamedWfPattern(), do_XMLTag(), and simulate().
#define LAB_RDAT 8 |
name space #2 used for s-attribute region boundaries by query engine
Referenced by do_XMLTag(), findlabel(), labellookup(), simulate(), and symbol_table_new_iterator().
#define LAB_SPECIAL 4 |
special labels must not be set/modified by user; defined/used consistency isn't checked for special labels
Referenced by check_labels(), do_IDReference(), do_LabelReference(), do_NamedWfPattern(), and labellookup().
#define LAB_USED 2 |
whether label has been used (i.e.
read out) or is used by this call
Referenced by check_labels(), do_IDReference(), do_LabelReference(), do_NamedWfPattern(), do_XMLTag(), and simulate().
typedef struct _label_entry * LabelEntry |
LabelEntry: the symbol tables are made up of two linked lists of these objects.
typedef struct _symbol_table * SymbolTable |
The SymbolTable object.
cqp-2.2+ uses a global symbol table to store label references which gives erroneous results for queries that contain optional elements. A proper treatment of labels requires each of the simulations traversing the NFA in parallel to have its own symbol table. Since the actual symbols are the same for all states, it is more efficient to split the symbol tables into symbol lookup and the actual data. Each simulation has its own data array (which stores corpus positions), but symbol lookup is shared between all simulations and returns an _index_ into the data array. If a simulation branches -- which happens at the left edge of alternatives or optional elements -- the symbol data array must be duplicated.
A symbol table now contains multiple namespaces (accessed by flags such as LAB_RDAT)
int check_labels | ( | SymbolTable | st | ) |
Checks whether all used labels are defined (and vice versa).
[only non-special labels in the user namespace will be checked]
References cqpmessage(), _label_entry::flags, LAB_DEFINED, LAB_SPECIAL, LAB_USED, _label_entry::name, _label_entry::next, _symbol_table::user, and Warning.
Referenced by do_SearchPattern().
void delete_reftab | ( | RefTab | rt | ) |
Deletes (and frees) a reference table.
References _RefTab::data.
Referenced by check_alignment_constraints(), and simulate_dfa().
void delete_symbol_table | ( | SymbolTable | st | ) |
delete symbol table (free all entries)
References free_labellist(), _symbol_table::rdat, and _symbol_table::user.
Referenced by free_environment().
void droplabel | ( | SymbolTable | st, |
LabelEntry | l | ||
) |
Drops a label from the symbol table (NB: its reference index can't be re-used).
WARNING: this function is not implemented (doesn't seem to be useful at the moment)
Copies rt1 to rt2; doesn't allocate new reftab for efficiency reasons.
References _RefTab::data, and _RefTab::size.
Referenced by eval_constraint(), and simulate().
LabelEntry findlabel | ( | SymbolTable | st, |
char * | s, | ||
int | flags | ||
) |
Returns label entry, or NULL if undefined (flags are used _only_ to determine namespace)
References LAB_RDAT, _label_entry::name, _label_entry::next, _symbol_table::rdat, and _symbol_table::user.
Referenced by do_XMLTag(), and labellookup().
int get_reftab | ( | RefTab | rt, |
int | index, | ||
int | cpos | ||
) |
read references (cpos value in get_reftab is returned for 'this' label (_), set to -1 if n/a)
References _RefTab::data, and _RefTab::size.
Referenced by eval_constraint(), get_label_referenced_position(), print_label_values(), and simulate().
LabelEntry labellookup | ( | SymbolTable | st, |
char * | s, | ||
int | flags, | ||
int | create | ||
) |
Look up a label, add flags, and return label entry (NULL if undefined).
if create is set and label does not exist, it is added to the symbol table
References cl_malloc(), cl_strdup(), field_name_to_type(), findlabel(), _label_entry::flags, LAB_RDAT, LAB_SPECIAL, _label_entry::name, _label_entry::next, _symbol_table::next_index, NoField, _symbol_table::rdat, _label_entry::ref, and _symbol_table::user.
Referenced by do_IDReference(), do_LabelReference(), do_NamedWfPattern(), and do_XMLTag().
RefTab new_reftab | ( | SymbolTable | st | ) |
Create new reference table of required size for the given symbol table.
NB If further labels are added to st, you must reallocate the reference table to make room for the new reference indices
References cl_malloc(), _RefTab::data, _symbol_table::next_index, and _RefTab::size.
Referenced by check_alignment_constraints(), and simulate_dfa().
SymbolTable new_symbol_table | ( | ) |
create new symbol table
References cl_malloc(), _symbol_table::next_index, _symbol_table::rdat, and _symbol_table::user.
Referenced by next_environment().
void print_label_values | ( | SymbolTable | st, |
RefTab | rt, | ||
int | cpos | ||
) |
Prints the current label values (for debugging).
st | The SymbolTable |
rt | |
cpos | The corpus position |
References get_reftab(), _label_entry::name, _label_entry::next, _symbol_table::next_index, _symbol_table::rdat, _label_entry::ref, _RefTab::size, and _symbol_table::user.
Referenced by simulate().
void print_symbol_table | ( | SymbolTable | st | ) |
print symbol table contents (for debugging purposes)
References _label_entry::flags, _label_entry::name, _label_entry::next, _symbol_table::rdat, _label_entry::ref, and _symbol_table::user.
Referenced by simulate_dfa().
void reset_reftab | ( | RefTab | rt | ) |
resets all referenced corpus position to -1 -> undefine all references
References _RefTab::data, and _RefTab::size.
Referenced by simulate(), and simulate_dfa().
void set_reftab | ( | RefTab | rt, |
int | index, | ||
int | value | ||
) |
set references (cpos value in get_reftab is returned for 'this' label (_), set to -1 if n/a)
References cqpmessage(), _RefTab::data, Error, and _RefTab::size.
Referenced by eval_bool(), eval_constraint(), get_leaf_value(), and simulate().
LabelEntry symbol_table_iterator | ( | LabelEntry | prev, |
int | flags | ||
) |
References _label_entry::flags, and _label_entry::next.
Referenced by simulate(), and symbol_table_new_iterator().
LabelEntry symbol_table_new_iterator | ( | SymbolTable | st, |
int | flags | ||
) |
References _label_entry::flags, LAB_RDAT, _symbol_table::rdat, symbol_table_iterator(), and _symbol_table::user.
Referenced by simulate().