dev/c/tex_parser/tex_parser.h

125 lines
2.9 KiB
C

#ifndef _TEX_PARSER_H
#define _TEX_PARSER_H
#include <sys/types.h>
#include "tex_parser_table.h"
#include "tex_parser_graphics.h"
#include "zerror.h"
#define TEX_PARSER_DOMAIN 0
/**
* enum tex_parser_error - the LaTeX parser error code
*
* @TEX_PARSER_NOERROR: Default state indicates no error.
* @TEX_PARSER_ERROR_UNKNOWN:
* @TEX_PARSER_ERROR_STACK:
* @TEX_PARSER_ERROR_PLACE_UNKNOWN:
* @TEX_PARSER_ERROR_UNEXPECTED_SYMBOL:
*
* Need some description here...
*/
enum tex_parser_error {
TEX_PARSER_NOERROR = 0,
TEX_PARSER_ERROR_UNKNOWN,
TEX_PARSER_ERROR_STACK,
TEX_PARSER_ERROR_PLACE_UNKNOWN,
TEX_PARSER_ERROR_UNEXPECTED_SYMBOL,
};
/**
* struct tex_table_row_s - LaTeX table row
*
*
*/
struct tex_table_row_s {
char **cells;
char *after; // \hline, \cline{4-5} etc.
};
/**
* struct tex_table_s - LaTeX table
*
*
*
*/
struct tex_table_s {
size_t document_offset; // offset (in sybmols) in the LaTeX document
size_t document_size; // size (in symbols) in the LaTeX document
char *id; // "Drossel1.Table1"
char **col_props; // divided by >
struct tex_table_row_s *head_table; // divided by &
struct tex_table_row_s *foot_table; // divided by & and \tabularnewline
struct tex_table_row_s *main_table; // divided by & and \tabularnewline
};
/**
*
*
*/
struct tex_graphics {
void *something;
};
/**
* enum tex_element_type - Type of LaTeX element
*
* TEX_ELEM_TEXT: Text containing non-arable code
* TEX_ELEM_TABLE: LaTeX table or longtable
* TEX_ELEM_GRAPHICS: LaTeX graphics (images, plots)
*
* Need some description here...
*/
enum tex_elem_type {
TEX_ELEM_TEXT,
TEX_ELEM_TABLE,
TEX_ELEM_GRAPHICS
};
/**
* struct tex_elem_s - Element of LaTeX code
*
* @type: LaTeX element type
* @data: Element data structure
*
* Need some description here...
*/
struct tex_elem_s {
enum tex_elem_type type;
union {
char *text;
struct tex_table_s *table;
struct tex_graphics_s *graphics;
} data;
};
/**
* struct tex_struct_s - LaTeX code structure
*
* @elems: List of LaTeX elements
*
* Need some description here...
*/
struct tex_struct_s {
struct tex_elem_s *elems;
};
/**
* tex_parse() - Parse the LaTeX code
*
* @source: LaTeX code string
* @len: Length of LaTeX string
* @tex_struct: A return location for a #tex_struct_s
* @error: A return location for a #zerror_s
*
* Parses LaTeX text string @source of length len to *@tex_struct.
* If some error occurs, parser returns immediatly with error info in *@error.
* @tex_struct or @error can't be %NULL,
*/
void tex_parse(const char *source, size_t len, struct tex_struct_s **tex_struct, struct zerror_s **error);
#endif