aboutsummaryrefslogtreecommitdiff
path: root/src/gram.y
diff options
context:
space:
mode:
Diffstat (limited to 'src/gram.y')
-rw-r--r--src/gram.y31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/gram.y b/src/gram.y
index 597d566..c8ee0d7 100644
--- a/src/gram.y
+++ b/src/gram.y
@@ -9,19 +9,22 @@ struct obstack stk;
struct descr *make_descr(enum descr_type type, u_char *value);
static int _register_topic(void *item, void *data);
+static int convert_pos(char *text, int *pos);
%}
%token NODE POS END MEANING ALIAS ANT TOPIC FORMS XREF
%token <string> STRING
-%type <string> string pos forms
+%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;
u_char *string;
struct header *header;
struct descr *descr;
@@ -106,11 +109,12 @@ nodehdr : NODE string pos forms
pos : /* empty */
{
- $$ = NULL;
+ $$ = -1;
}
| POS string
{
- $$ = $2;
+ if (convert_pos($2, &$$))
+ YYERROR;
}
;
@@ -226,3 +230,24 @@ _register_topic(void *item, void *data)
list_append(node->descr, data);
return 0;
}
+
+
+static int
+convert_pos(char *text, int *pos)
+{
+ unsigned long n;
+ if (sql_query_n(&n,
+ "SELECT id FROM pos WHERE abbr=\"%s\"",
+ text)
+ && sql_query_n(&n,
+ "SELECT id FROM pos WHERE abbr_lat=\"%s\"",
+ text)
+ && sql_query_n(&n,
+ "SELECT id FROM pos WHERE name=\"%s\"",
+ text)) {
+ yyerror("unknown or misspelled part of speech");
+ return 1;
+ }
+ *pos = n;
+ return 0;
+}

Return to:

Send suggestions and report system problems to the System administrator.