+/* \} */
+
+/** \name Low-level interface to the converters */
+/* These produce some output text into a buffer. There are a few
+ * kinds of converters, each producing different type of output.
+ */
+/* \{ */
+
+/** \brief Create a string converter.
+ * \param n the nfa
+ * \param string the string to output
+ * \param length how many chars in the string
+ *
+ * This converter produces a constant string in the output
+ */
+yaz_nfa_converter *yaz_nfa_create_string_converter (
+ yaz_nfa *n,
+ yaz_nfa_char *string,
+ size_t length );
+
+/** \brief Create a backref converter
+ * \param n the nfa
+ * \param backref_no The backreference to reproduce
+ *
+ * This converter copies a backref into the output buffer
+ */
+yaz_nfa_converter *yaz_nfa_create_backref_converter (
+ yaz_nfa *n, int backref_no );
+
+
+/** \brief Create a charcater range converter
+ * \param n the nfa
+ * \param backref_no The backreference to reproduce
+ * \param from_char the first character of the original range
+ * \param to_char the first character of the target range
+ *
+ * This converter takes a backreference, and shifts the characters
+ * by a constant value. For example, translating a-z to A-Z.
+ * Note that backref 0 is always the last character that matched a
+ * range, even if no backrefs were defined in teh nfa. This makes
+ * it pretty useful with this converter.
+ *
+ */
+yaz_nfa_converter *yaz_nfa_create_range_converter (
+ yaz_nfa *n, int backref_no,
+ yaz_nfa_char from_char,
+ yaz_nfa_char to_char);
+
+
+/** \brief Connects converters in a chain.
+ * \param n the nfa (mostly for nmem access)
+ * \param startpoint the first converter in the chain
+ * \param newconverter
+ *
+ * Places the new converter at the end of the chain that starts from
+ * startpoint.
+ *
+ */
+void yaz_nfa_append_converter (
+ yaz_nfa *n,
+ yaz_nfa_converter *startpoint,
+ yaz_nfa_converter *newconverter);
+
+/** brief Runs the chain of converters.
+ * \param n the nfa (mostly for nmem access)
+ * \param c the first converter in a chain
+ * \param outbuff buffer to write the output in. Increments the ptr.
+ * \param outcharsleft how many may we write
+ *
+ * Runs the converters in the chain, placing output into outbuff
+ * (and incrementing the pointer).
+ *
+ * \retval YAZ_NFA_SUCCESS OK
+ * \retval YAZ_NFA_NOMATCH no match to get backrefs from
+ * \retval YAZ_NFA_NOSPACE no room in outbuf
+ * \retval YAZ_NFA_INTERNAL Should never happen
+ *
+ */
+int yaz_nfa_run_converters(
+ yaz_nfa *n,
+ yaz_nfa_converter *c,
+ yaz_nfa_char **outbuff,
+ size_t *outcharsleft);
+
+/** \} */
+
+/** \name High-level interface to the NFA */
+/* This interface combines the NFA and converters, for ease of
+ * access. There are a few calls to build a complete system, and a call
+ * to do the actual conversion.
+ */
+/* \{ */
+
+/** \brief Add a rule that converts one string to another ('IX' -> '9')
+ *
+ * \param n The nfa itself
+ * \param from_string the string to match
+ * \param from_length length of the from_string
+ * \param to_string the string to write in the output
+ * \param to_length length of the to_string
+ *
+ * Adds a matching rule and a string converter to the NFA.
+ * Can be used for converting strings into nothing, for example,
+ * to remove markup.
+ *
+ * \retval YAZ_NFA_SUCCESS OK
+ * \retval YAZ_NFA_ALREADY Conflict with some other rule
+ *
+ */
+int yaz_nfa_add_string_rule( yaz_nfa *n,
+ yaz_nfa_char *from_string,
+ size_t from_length,
+ yaz_nfa_char *to_string,
+ size_t to_length);
+
+/** brief Just like yaz_nfa_add_string_rule, but takes the strings in ascii
+ *
+ * \param n The nfa itself
+ * \param from_string the string to match
+ * \param to_string the string to write in the output
+ *
+ * Like yaz_nfa_add_string_rule, this adds a rule to translate a string
+ * into another. The only difference is that this one takes the strings as
+ * normal char *, which means that no high-valued unicodes can be handled,
+ * and that this one uses null-terminated strings. In short, this is a
+ * simplified version mostly intended for tests and other small uses.
+ *
+ * \retval YAZ_NFA_SUCCESS OK
+ * \retval YAZ_NFA_ALREADY Conflict with some other rule
+ */
+int yaz_nfa_add_ascii_string_rule( yaz_nfa *n,
+ char *from_string,
+ char *to_string);
+
+
+/** \brief Add a rule that converts a character range
+ *
+ * \param n The nfa itself
+ * \param range_start Where the matching range starts
+ * \param range_end Where the matching range ends
+ * \param output_range_start Where the resulting range starts
+ *
+ *
+ * Adds a character range rule to the NFA. The range to be converted
+ * is defined by the range_start and range_end parameters. The output
+ * range starts at output_range_start, and is automatically as long
+ * as the input range.
+ *
+ * Useful for alphabet normalizing [a-z] -> [A-Z]
+ *
+ * \retval YAZ_NFA_SUCCESS OK
+ * \retval YAZ_NFA_ALREADY Conflict with some other rule
+ */
+int yaz_nfa_add_char_range_rule (yaz_nfa *n,
+ yaz_nfa_char range_start,
+ yaz_nfa_char range_end,
+ yaz_nfa_char output_range_start);
+
+/** \brief Add a rule that converts a character range to a string
+ *
+ * \param n The nfa itself
+ * \param range_start Where the matching range starts
+ * \param range_end Where the matching range ends
+ * \param to_string the string to write in the output
+ * \param to_length length of the to_string
+ *
+ * \retval YAZ_NFA_SUCCESS OK
+ * \retval YAZ_NFA_ALREADY Conflict with some other rule
+ *
+ * Adds a character range match rule, and a string converter.
+ *
+ * Useful in converting a range of special characters into (short?)
+ * strings of whitespace, or even to nothing at all.
+ */
+int yaz_nfa_add_char_string_rule (yaz_nfa *n,
+ yaz_nfa_char range_start,
+ yaz_nfa_char range_end,
+ yaz_nfa_char* to_string,
+ size_t to_length);
+
+/** \brief Converts one 'slice' that is, the best matching rule.
+ *
+ * \param n the nfa itself
+ * \param inbuff buffer of input data. Will be incremented when match
+ * \param incharsleft max number of inchars to use from inbuff. decrements.
+ * \param outbuff buffer for output data. Will be incremented when match
+ * \param outcharsleft max number of chars to write to outbuff.
+ *
+ * \retval YAZ_NFA_SUCCESS OK
+ * \retval YAZ_NFA_OVERRUN No more input data, some pattern could match
+ * \retval YAZ_NFA_NOSPACE No room in the putput buffer
+ * \retval YAZ_NFA_NOSUCHBACKREF NFA refers to a non-existing backref
+ *
+ * Finds the best match at the beginning of inbuf, and fires its converter(s)
+ * to produce output in outbuff. Increments both inbuf and outbuf pointers and
+ * decrements the *charsleft values, so all is ready for calling again, until
+ * the buffer is exhausted. That loop is left to the caller, so he can load
+ * more data in the buffer in good time.
+ *
+ * If no match is found, converts one character into itself. If the matcher
+ * returns any sort of error, leaves the pointers where they were.
+ */
+int yaz_nfa_convert_slice (yaz_nfa *n,
+ yaz_nfa_char **inbuff,
+ size_t *incharsleft,
+ yaz_nfa_char **outbuff,
+ size_t *outcharsleft);
+
+
+/* \} */
+
+/** \name Debug routines */
+/* These provide a method for traversing all the states defined
+ * in the NFA, for example to release memory allocated in the results,
+ * and a simple debug routine to dump the NFA */
+/* \{ */
+
+