diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2004-10-07 16:10:05 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2004-10-07 16:10:05 +0000 |
commit | 72d789af56bad636cfc1a8d6e55fee928118b22b (patch) | |
tree | 5f01043e1f6bc8bcb4b67bcd72f761eade238b9c /src | |
parent | 3609d7741bd60450bb2577b7af075b09c37c56b0 (diff) | |
download | ellinika-72d789af56bad636cfc1a8d6e55fee928118b22b.tar.gz ellinika-72d789af56bad636cfc1a8d6e55fee928118b22b.tar.bz2 |
Reverted accidentally applied changes
git-svn-id: file:///home/puszcza/svnroot/ellinika/trunk@197 941c8c0f-9102-463b-b60b-cd22ce0e6858
Diffstat (limited to 'src')
-rw-r--r-- | src/gram.y | 123 | ||||
-rw-r--r-- | src/input.l | 4 | ||||
-rw-r--r-- | src/main.c | 8 |
3 files changed, 97 insertions, 38 deletions
@@ -34,7 +34,12 @@ static int convert_pos(char *text, int *pos); %token NODE POS END MEANING ALIAS ANT TOPIC FORMS XREF %token <string> STRING -%type <string> string +%type <num> pos +%type <string> string forms +%type <header> nodehdr alias +%type <descr> descr +%type <list> list aliases descrlist header +%type <item> item %union { int num; @@ -49,90 +54,146 @@ static int convert_pos(char *text, int *pos); %% input : list + { + node_list = $1; + } ; list : item + { + $$ = list_create(); + switch ($1.type) { + case item_node: + list_append($$, $1.v.node); + break; + + case item_list: + list_concat($$, $1.v.list); + list_destroy(&$1.v.list, NULL, NULL); + } + } | list item + { + switch ($2.type) { + case item_node: + list_append($1, $2.v.node); + break; + + case item_list: + list_concat($1, $2.v.list); + list_destroy(&$2.v.list, NULL, NULL); + } + $$ = $1; + } ; -item : header descrlist END +item : header descrlist end { - printf("</NODE>\n\n"); + $$.type = item_node; + $$.v.node = create_node($1, $2); } - | thead list END + | TOPIC string list end { - printf("</T>\n"); + $$.type = item_list; + $$.v.list = $3; + list_iterate($3, _register_topic, + make_descr(descr_topic, $2)); } ; -thead : TOPIC string - { - printf("<T ID=\"%s\">\n", $2); - } - ; - end : END ; header : nodehdr + { + $$ = list_create(); + list_append($$, $1); + } | nodehdr aliases + { + list_prepend($2, $1); + $$ = $2; + } ; -nodehdr : node key pos forms - ; - -node : NODE - { - printf("<NODE>\n"); - } - ; - -key : string - { - printf(" <K>%s</K>\n", $1); +nodehdr : NODE string pos forms + { + $$ = emalloc(sizeof(*$$)); + $$->key = $2; + $$->pos = $3; + $$->forms = $4; } ; - + pos : /* empty */ + { + $$ = -1; + } | POS string { - printf(" <P>%s</P>\n", $2); + if (convert_pos($2, &$$)) + YYERROR; } ; forms : /* empty */ + { + $$ = NULL; + } | FORMS string { - printf(" <F>%s</F>\n", $2); + $$ = $2; } ; aliases : alias + { + $$ = list_create(); + list_append($$, $1); + } | aliases alias + { + list_append($1, $2); + $$ = $1; + } ; -alias : ALIAS key pos forms +alias : ALIAS string pos forms + { + $$ = emalloc(sizeof(*$$)); + $$->key = $2; + $$->pos = $3; + $$->forms = $4; + } ; descrlist: descr + { + $$ = list_create(); + list_append($$, $1); + } | descrlist descr + { + list_append($1, $2); + $$ = $1; + } ; descr : TOPIC string { - printf(" <T ID=\"%s\" />\n", $2); + $$ = make_descr(descr_topic, $2); } | MEANING string { - printf(" <M>%s</M>\n", $2); + $$ = make_descr(descr_meaning, $2); } | ANT string { - printf(" <A>%s</A>\n", $2); + $$ = make_descr(descr_antonym, $2); } | XREF string { - printf(" <X>%s</X>\n", $2); + $$ = make_descr(descr_xref, $2); } ; diff --git a/src/input.l b/src/input.l index 02dd499..f05a6b5 100644 --- a/src/input.l +++ b/src/input.l @@ -32,9 +32,7 @@ void set_location(); MWS [ \t]* WS [ \t]+ %% -#.*\n { - printf("<!-- %*.*s -->\n",yyleng-2,yyleng-2,yytext+1); - input_line++; } +#.*\n input_line++; ^[nN][oO][dD][eE] return NODE; ^[pP][oO][sS] return POS; ^[eE][nN][dD]{MWS} return END; @@ -347,12 +347,12 @@ main(int argc, char **argv) case ARG_VERSION: printf("trans (%s)\n", PACKAGE_STRING); exit(0); -x } + } } make_m4_args (m4_bin, include_list); -// sql_connect(); + sql_connect(); node_list = list_create(); @@ -361,7 +361,7 @@ x } if (parse(argc, argv) || error_count) return 1; -// if (compile_only) + if (compile_only) return 0; if (cleanup_flag) @@ -369,7 +369,7 @@ x } sql_query_n(&dict_index, "SELECT ident FROM dict ORDER BY ident DESC LIMIT 1"); - + list_iterate(node_list, emit_node, NULL); pending_fixup(); |