до \cyrtext допарсил
This commit is contained in:
parent
e48a755e0c
commit
4f1cde3f8f
|
@ -89,16 +89,22 @@ int parse_table(const char *table_source, size_t len, struct table_s *table, str
|
|||
break;
|
||||
|
||||
case IN_TAG:
|
||||
if (islower(c) || isdigit(c) || (!tag && c == '\\')) { // test for char, digit and newline tag "\\"
|
||||
if (isalpha(c) || isdigit(c) || (!tag && c == '\\')) { // test for char, digit and newline tag "\\"
|
||||
tag = zalloc_append8_str(tag, c);
|
||||
} else if (isspace(c)) {
|
||||
|
||||
} else if (c == '{' || c == '[') {
|
||||
where_stack[++tex_level] = IN_TAGPARM;
|
||||
|
||||
} else if (c == '%') {
|
||||
where_stack[++tex_level] = IN_COMMENT;
|
||||
|
||||
} else if (!tag) {
|
||||
error->code = TEX_PARSING_ERROR_UNDEF;
|
||||
error->message = TEX_PARSING_ERROR_UNDEF_STR;
|
||||
return error->code;
|
||||
} else {
|
||||
if (!tag) {
|
||||
error->code = TEX_PARSING_ERROR_UNDEF;
|
||||
error->message = TEX_PARSING_ERROR_UNDEF_STR;
|
||||
return error->code;
|
||||
|
||||
} else if (!strcmp(tag, TEX_TAG_BEGIN)) {
|
||||
if (!strcmp(tag, TEX_TAG_BEGIN)) {
|
||||
where_stack[tex_level] = IN_TAG_BEGIN;
|
||||
|
||||
} else if (!strcmp(tag, TEX_TAG_CLINE)) {
|
||||
|
@ -131,18 +137,24 @@ int parse_table(const char *table_source, size_t len, struct table_s *table, str
|
|||
} else if (!strcmp(tag, TEX_TAG_SLASH)) {
|
||||
where_stack[tex_level] = IN_TAG_SLASH;
|
||||
|
||||
} else { // unknown tag
|
||||
|
||||
}
|
||||
printf("\\%s\n", tag);
|
||||
tag = zfree_null(tag);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case IN_TAGPARM:
|
||||
if (c == '{') { // tag params
|
||||
if (c == '{' || c == '[') { // tag params
|
||||
where_stack[++tex_level] = IN_TAGPARM;
|
||||
|
||||
} else if (c == '}') { // end tag params
|
||||
} else if (c == '}' || c == ']') { // end tag params
|
||||
where_stack[tex_level--] = IN_UNDEF;
|
||||
|
||||
} else if (c == '\\') { // new tag
|
||||
tag = zfree_null(tag);
|
||||
where_stack[++tex_level] = IN_TAG;
|
||||
|
||||
} else if (isprint(c)) {
|
||||
|
@ -156,10 +168,11 @@ int parse_table(const char *table_source, size_t len, struct table_s *table, str
|
|||
break;
|
||||
|
||||
case IN_TAG_BEGIN:
|
||||
if (c == '{') { // tag params
|
||||
if (c == '{' || c == '[') { // tag params
|
||||
where_stack[++tex_level] = IN_TAGPARM;
|
||||
|
||||
} else if (c == '\\') { // new tag
|
||||
tag = zfree_null(tag);
|
||||
where_stack[tex_level] = IN_TAG;
|
||||
|
||||
if (FALSE) { // longtable
|
||||
|
|
|
@ -18,7 +18,7 @@ long_line_column=72
|
|||
[files]
|
||||
current_page=1
|
||||
FILE_NAME_0=709;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table_test.c;0
|
||||
FILE_NAME_1=4204;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table.c;0
|
||||
FILE_NAME_1=4568;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table.c;0
|
||||
FILE_NAME_2=119;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table.h;0
|
||||
FILE_NAME_3=1762;C;0;16;1;1;1;/home/kolan/projects/include/zalloc_ext.h;0
|
||||
FILE_NAME_4=634;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table_tags.h;0
|
||||
|
|
|
@ -32,7 +32,10 @@ int main(int argc, char *argv[])
|
|||
struct table_s table;
|
||||
memset(&table, 0, sizeof(struct table_s));
|
||||
/* Коммент по-русски */
|
||||
parse_table(tex_buf, (size_t)stat_buf.st_size, &table, &error);
|
||||
int result = parse_table(tex_buf, (size_t)stat_buf.st_size, &table, &error);
|
||||
if (result) {
|
||||
printf("Parsing error: %s\n", error.message);
|
||||
}
|
||||
|
||||
tex_buf = xfree_null(tex_buf);
|
||||
|
||||
|
|
Loading…
Reference in New Issue