void init_shortref()

- initalizes this module

Bool is_shortref(delimiter)

- checks whether delimiter is a short reference delimiter Delimiter delimiter;

These functions are straight forward.

P_Map new_map(name)

- creates a new map String name;

void define_mapping(map, literal, entity_name)

- defines a short reference P_Map map; String literal; String entity_name;

Bool map_equal(map1, map2)

- checks whether map1 and map2 have the same name P_Map map1; P_Map map2;

These functions create new short reference maps, new_map() creates a new map. It checks, using map_equal(), that the name of the new map is not used for another map. A map must be created before a short reference delimiter can be added to it. Define_mapping() adds the short reference delimiter literal, that is mapped to entity_name, to the short reference map map. If the literal is not a correct short reference delimiter or if a short reference is defined twice, an error report is given. See the Standard figure 4, page 33 for a list of all allowed short reference delimiters.

void push_map(map, gi)

- pushes map, when it becomes current map P_Map map; int gi;

void pop_map(map, gi)

- pops map, when it is ended P_Map map; int gi;

Short reference maps are used in a stack-like manner. Whenever a new map becomes active, the previous map is stored. When the new map becomes inactive the old one is re-installed. A stack is used to keep all open maps. push_map() and pop_map() work on this stack. The top of the stack is always the current map. The argument gi for pop_map() and push_map() is the symbolic name of the generic identifier to which the map belongs. If the map was activated by a USEMAP declaration, gi equals TOK_NOD. A map is deactivated, when the element in which it was activated is closed. The gi parameter is needed to find which maps must be deactivated.

void usemap(elems, map)

- usemap declaration P_Group elems; String map;

This function is called to store the result of a usemap declaration. The group elems contains the names of the elements, map is the name of the short reference map. A usemap declaration with elements is an error if it occurs in a document.

Bool in_current_map(shortref)

- checks whether shortref is in the current map int shortref;

String current_mapping(shortref)

- returns current mapping of shortref Delimiter shortref;

The function in_current_map() checks whether the short reference delimiter shortref is defined in the current map. The function current_mapping() returns the name of the entity to which short reference delimiter shortref is mapped in the currently active short reference map.. It returns 0 if shortref is not mapped in the current map.

Bool is_current_shortref_char(ch)

- checks if ch can be short reference int ch;

void add_first_chars(set, ch)

- puts ch in set P_Set set; int ch;

is_current_shortref_char() checks whether ch can be the start of a short reference in the current map. This is used to speed up the lexical analyser. Using this function, it only has to try to match a short reference delimiter if the first character is the start of one. add_first_chars() is used to put the first characters of all defined short reference delimiters in a set, which is used by the previous function.

P_Map lookup_map(map_name)

- finds map with name map_name String map_name;

String element_map_var(elem_name)

- returns the variable name of the map belonging to elem_name String elem;

void generate_map(src, ext)

- generates map for document parser FILE *src; FILE *ext;

The function generate_map() generates C code that will be included in the document parser. This is needed to make the short reference maps, defined in the DTD, known to the document parser. element_map_var() returns the variable name of the map that corresponds to elem. Lookup_map() takes a string and finds the short reference map with that name. It returns ILL_MAP if no such map exists. These functions are only used in the generator.

Bool maps_ok()

- checks whether the maps are correct

String element_map(elem)

- returns the name of the map belonging to elem String elem;

The function maps_ok() checks whether each map that occurs in a usemap declaration is defined. It also checks whether an element name does not occur in more then one usemap declaration. element_map() returns the name of the map that corresponds to elem. These functions are only used in the generator.

Mapstack new_mapstack(null_elem)

- creates a new stack for maps P_Stackelem null_elem;

void push_mapstack(s, e)

- push element e on stack s Mapstack s; P_Stackelem e;

P_Stackelem pop_mapstack(s)

- pops the top element of stack s Mapstack s;

P_Stackelem top_mapstack(s)

- returns top element of stack s Mapstack s;

For the description of these functions see ``stack.gen''.

void debug_shortref(b)

- turns debugging flag ON/OFF Bool b;

void print_map(file, map)

- prints map on file FILE *file; P_Map map;

These functions are used for debugging purposes only.

shortref.c shortref.h