1 /* $Id: lexer.c,v 1.1 2003-01-06 08:20:27 adam Exp $
2 Copyright (C) 2002-2003
5 This file is part of the YAZ toolkit.
10 * bison lexer for CQL.
13 int yylex(YYSTYPE *lval, void *vp)
15 CQL_parser cp = (CQL_parser) vp;
19 c = cp->getbyte(cp->client_data);
27 if (strchr("()=></", c))
30 lval->buf[lval->len++] = c;
33 c1 = cp->getbyte(cp->client_data);
36 lval->buf[lval->len++] = c1;
37 lval->buf[lval->len] = 0;
41 cp->ungetbyte(c1, cp->client_data);
45 c1 = cp->getbyte(cp->client_data);
48 lval->buf[lval->len++] = c1;
49 lval->buf[lval->len] = 0;
54 lval->buf[lval->len++] = c1;
55 lval->buf[lval->len] = 0;
59 cp->ungetbyte(c1, cp->client_data);
61 lval->buf[lval->len] = 0;
66 while ((c = cp->getbyte(cp->client_data)) != EOF && c != '"')
69 c = cp->getbyte(cp->client_data);
70 lval->buf[lval->len++] = c;
72 lval->buf[lval->len] = 0;
76 lval->buf[lval->len++] = c;
77 while ((c = cp->getbyte(cp->client_data)) != 0 &&
78 !strchr(" \n()=<>/", c))
81 c = cp->getbyte(cp->client_data);
82 lval->buf[lval->len++] = c;
84 lval->buf[lval->len] = 0;
86 printf ("got %s\n", lval->buf);
89 cp->ungetbyte(c, cp->client_data);
90 if (!strcmp(lval->buf, "and"))
92 if (!strcmp(lval->buf, "or"))
94 if (!strcmp(lval->buf, "not"))
96 if (!strcmp(lval->buf, "exact"))
98 if (!strcmp(lval->buf, "all"))
100 if (!strncmp(lval->buf, "prox", 4))
102 if (!strcmp(lval->buf, "any"))
104 if (!strcmp(lval->buf, "scr"))