diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2004-10-07 16:00:25 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2004-10-07 16:00:25 +0000 |
commit | b27976bda04ef7a2219c44dfc7150441b62b3a0a (patch) | |
tree | e003a51f0b829d1664358b6cc4dfac79ef67f7be /src | |
parent | 21ee0a3c2fc48d51b9a3e29a61a661afdaee4fc9 (diff) | |
download | ellinika-b27976bda04ef7a2219c44dfc7150441b62b3a0a.tar.gz ellinika-b27976bda04ef7a2219c44dfc7150441b62b3a0a.tar.bz2 |
Dictionary parser
git-svn-id: file:///home/puszcza/svnroot/ellinika/trunk@195 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, 38 insertions, 97 deletions
@@ -34,12 +34,7 @@ static int convert_pos(char *text, int *pos); %token NODE POS END MEANING ALIAS ANT TOPIC FORMS XREF %token <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 +%type <string> string %union { int num; @@ -54,146 +49,90 @@ 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 { - $$.type = item_node; - $$.v.node = create_node($1, $2); + printf("</NODE>\n\n"); } - | TOPIC string list end + | thead list END { - $$.type = item_list; - $$.v.list = $3; - list_iterate($3, _register_topic, - make_descr(descr_topic, $2)); + printf("</T>\n"); } ; +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 string pos forms - { - $$ = emalloc(sizeof(*$$)); - $$->key = $2; - $$->pos = $3; - $$->forms = $4; - } +nodehdr : node key pos forms ; -pos : /* empty */ - { - $$ = -1; +node : NODE + { + printf("<NODE>\n"); + } + ; + +key : string + { + printf(" <K>%s</K>\n", $1); } + ; + +pos : /* empty */ | POS string { - if (convert_pos($2, &$$)) - YYERROR; + printf(" <P>%s</P>\n", $2); } ; forms : /* empty */ - { - $$ = NULL; - } | FORMS string { - $$ = $2; + printf(" <F>%s</F>\n", $2); } ; aliases : alias - { - $$ = list_create(); - list_append($$, $1); - } | aliases alias - { - list_append($1, $2); - $$ = $1; - } ; -alias : ALIAS string pos forms - { - $$ = emalloc(sizeof(*$$)); - $$->key = $2; - $$->pos = $3; - $$->forms = $4; - } +alias : ALIAS key pos forms ; descrlist: descr - { - $$ = list_create(); - list_append($$, $1); - } | descrlist descr - { - list_append($1, $2); - $$ = $1; - } ; descr : TOPIC string { - $$ = make_descr(descr_topic, $2); + printf(" <T ID=\"%s\" />\n", $2); } | MEANING string { - $$ = make_descr(descr_meaning, $2); + printf(" <M>%s</M>\n", $2); } | ANT string { - $$ = make_descr(descr_antonym, $2); + printf(" <A>%s</A>\n", $2); } | XREF string { - $$ = make_descr(descr_xref, $2); + printf(" <X>%s</X>\n", $2); } ; diff --git a/src/input.l b/src/input.l index f05a6b5..02dd499 100644 --- a/src/input.l +++ b/src/input.l @@ -32,7 +32,9 @@ void set_location(); MWS [ \t]* WS [ \t]+ %% -#.*\n input_line++; +#.*\n { + printf("<!-- %*.*s -->\n",yyleng-2,yyleng-2,yytext+1); + 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 @@ main(int argc, char **argv) if (parse(argc, argv) || error_count) return 1; - if (compile_only) +// if (compile_only) return 0; if (cleanup_flag) @@ -369,7 +369,7 @@ main(int argc, char **argv) sql_query_n(&dict_index, "SELECT ident FROM dict ORDER BY ident DESC LIMIT 1"); - + list_iterate(node_list, emit_node, NULL); pending_fixup(); |