dev/c/tex_parser/tex_table.c

106 lines
1.5 KiB
C
Raw Normal View History

#include "tex_table.h"
#include <string.h>
2011-06-10 19:03:50 +04:00
#include <ctype.h>
#include "tex_table_tags.h"
#include "zalloc_ext.h"
#include "zalloc.h"
2011-06-17 19:03:06 +04:00
#define MAX_TEX_STACK_LEVEL 128
int parse_table(const char *table_source, size_t len, struct table_s *table, struct xerror_s *error)
{
if (!len)
len = strlen(table_source);
2011-06-10 19:03:50 +04:00
char *tag = NULL;
size_t i = 0;
enum where_e
{
2011-06-17 19:03:06 +04:00
IN_GLOBAL = 0,
IN_COMMENT,
2011-06-10 19:03:50 +04:00
IN_TAG,
2011-06-17 19:03:06 +04:00
IN_TAG_CRLBRACEPAR,
IN_TAG_SQRBRACEPAR,
IN_TAG_SQUAREBRACE_COMMA,
IN_TAGCLOSE,
//~ IN_TAG,
2011-06-10 19:03:50 +04:00
IN_TAG_END,
IN_TAG_BEGIN_END,
IN_TAG_PARAM,
IN_TAG_BEGIN_PARAM
2011-06-17 19:03:06 +04:00
} where_stack[MAX_TEX_STACK_LEVEL] = {IN_GLOBAL};
int tex_level = 0;
//~ where_e where_stack[32] = ;
2011-06-10 19:03:50 +04:00
/* Ищем первое вхождение
* \begin{longtable}
*/
2011-06-17 19:03:06 +04:00
/* for (i = 0; i < len; i++) {
char c = table_source[i];
2011-06-10 19:03:50 +04:00
switch (where) {
case IN_GLOBAL:
if (c == '\\') {
zfree(&tag);
where = IN_TAG;
}
break;
case IN_TAG:
if (!isalpha(c)) {
//~ size_t len = zmalloc_getlen(tag);
//~ zrealloc(&tag, len + 1);
//~ tag[len] = c;
2011-06-10 19:03:50 +04:00
} else {
if (!strcmp(tag, TEX_TAG_BEGIN))
where = IN_TAG_BEGIN_END;
else
where = IN_TAG_END;
}
break;
case IN_TAG_PARAM:
//~ if ()
2011-06-10 19:03:50 +04:00
if (!isspace(c) || c == '{') {
2011-06-10 19:03:50 +04:00
} else if (isspace(c)) {
2011-06-10 19:03:50 +04:00
} else {
}
break;
case IN_TAG_BEGIN_PARAM:
if (isalpha(c)) {
} else if (isspace(c)) {
} else {
}
break;
case IN_TAG_END:
break;
case IN_TAG_BEGIN_END:
break;
2011-06-10 19:03:50 +04:00
}
2011-06-17 19:03:06 +04:00
}*/
table->id = "Drossel1.Table1";
error->message = NULL;
return 0;
}