\\ symbol now interpreted as tag

This commit is contained in:
Kolan Sh 2011-06-21 12:01:53 +04:00
parent c1638e027d
commit 7e29364c79
3 changed files with 45 additions and 36 deletions

View File

@ -1,5 +1,6 @@
%% LyX 1.6.8 created this file. For more info, see http://www.lyx.org/. %% LyX 1.6.8 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing. %% Do not edit unless you really know what you are doing.
\\
\documentclass[english,russian]{article} \documentclass[english,russian]{article}
\usepackage[T1]{fontenc} \usepackage[T1]{fontenc}
\usepackage[latin9,koi8-r]{inputenc} \usepackage[latin9,koi8-r]{inputenc}

View File

@ -6,6 +6,9 @@
#include "zalloc_ext.h" #include "zalloc_ext.h"
#include "zalloc.h" #include "zalloc.h"
/* unnecessary includes */
#include <stdio.h>
#define MAX_TEX_STACK_LEVEL 128 #define MAX_TEX_STACK_LEVEL 128
char * const PARSING_ERROR = "Error parsing"; char * const PARSING_ERROR = "Error parsing";
@ -44,9 +47,10 @@ int parse_table(const char *table_source, size_t len, struct table_s *table, str
return -1; return -1;
} }
/* read one charecter from input stream */ /* read one character from input stream */
char c = table_source[i]; char c = table_source[i];
/* looking at where_stack and encountered character */
switch (where_stack[tex_level]) { switch (where_stack[tex_level]) {
case IN_UNDEF: case IN_UNDEF:
if (c == '\\') { if (c == '\\') {
@ -71,11 +75,14 @@ int parse_table(const char *table_source, size_t len, struct table_s *table, str
break; break;
case IN_TAG: case IN_TAG:
if (islower(c) || isdigit(c)) { if (islower(c) || isdigit(c) || !tag && c == '\\') {
zalloc_append8_str(tag, c); tag = zalloc_append8_str(tag, c);
} else { } else {
if (!tag) { if (!tag) {
error->code = -1;
error->message = PARSING_ERROR;
return -1;
} else if (!strcmp(tag, TEX_TAG_BEGIN)) { } else if (!strcmp(tag, TEX_TAG_BEGIN)) {
where_stack[tex_level++] = IN_TAG_BEGIN; where_stack[tex_level++] = IN_TAG_BEGIN;
@ -104,34 +111,34 @@ int parse_table(const char *table_source, size_t len, struct table_s *table, str
} }
break; break;
case IN_TAG_BEGIN: //~ case IN_TAG_BEGIN:
if (c == '{') { //~ if (c == '{') {
where_stack[++tex_level] = IN_TAGPARM; //~ where_stack[++tex_level] = IN_TAGPARM;
//~
//~ } else if (isspace(c)) {
//~
//~ } else {
//~ error->code = -1;
//~ error->message = PARSING_ERROR;
//~ return -1;
//~ }
//~ break;
} else if (isspace(c)) { //~ case IN_TAGPARM:
//~ if (c == '}') {
} else { //~ where_stack[tex_level--] = IN_UNDEF;
error->code = -1; //~
error->message = PARSING_ERROR; //~ } else if (isgraph(c)) {
return -1; //~ brpar = zalloc_append8_str(brpar, c);
} //~
break; //~ } else if (isspace(c)) {
//~
case IN_TAGPARM: //~ } else {
if (c == '}') { //~ error->code = -1;
where_stack[tex_level--] = IN_UNDEF; //~ error->message = PARSING_ERROR;
//~ return -1;
} else if (isgraph(c)) { //~ }
zalloc_append8_str(brpar, c); //~ break;
} else if (isspace(c)) {
} else {
error->code = -1;
error->message = PARSING_ERROR;
return -1;
}
break;
default: default:
error->code = -1; error->code = -1;

View File

@ -17,11 +17,12 @@ long_line_column=72
[files] [files]
current_page=1 current_page=1
FILE_NAME_0=216;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table_test.c;0 FILE_NAME_0=709;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table_test.c;0
FILE_NAME_1=480;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table.c;0 FILE_NAME_1=2380;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table.c;0
FILE_NAME_2=549;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table.h;0 FILE_NAME_2=1762;C;0;16;1;1;1;/home/kolan/projects/include/zalloc_ext.h;0
FILE_NAME_3=612;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table_tags.h;0 FILE_NAME_3=2350;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table.h;0
FILE_NAME_4=1740;Make;0;16;1;1;1;/home/kolan/dev/c/tex_parser/Makefile;0 FILE_NAME_4=634;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table_tags.h;0
FILE_NAME_5=1488;Make;0;16;1;1;1;/home/kolan/dev/c/tex_parser/Makefile;0
[build-menu] [build-menu]
NF_00_LB=_Сделать NF_00_LB=_Сделать
@ -44,5 +45,5 @@ CFT_02_CM=
CFT_02_WD=%p CFT_02_WD=%p
filetypes=C; filetypes=C;
EX_00_LB=_Выполнить EX_00_LB=_Выполнить
EX_00_CM="./%e" tables4.tex EX_00_CM=./tex_table_test tables4.tex
EX_00_WD=%p EX_00_WD=%p