home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / freeWAIS-sf-1.1 / ir / query_y.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-08  |  34.0 KB  |  1,306 lines

  1.  
  2. /*  A Bison parser, made from query_y.y with Bison version GNU Bison version 1.22
  3.   */
  4.  
  5. #define YYBISON 1  /* Identify Bison output.  */
  6.  
  7. #define    WORD    258
  8. #define    PHONIX    259
  9. #define    SOUNDEX    260
  10. #define    OR    261
  11. #define    AND    262
  12. #define    NOT    263
  13.  
  14. #line 12 "query_y.y"
  15.  
  16. #include "cutil.h"
  17. #include <stdio.h>
  18. /* #include <string.h> */
  19. #include <ctype.h>
  20. /*
  21. extern char *malloc();
  22. extern char *calloc();
  23. */
  24. #define YYSTYPE yystype
  25. #define strcatXC(A,B)  strcatCC((A),(B)),free(A)
  26. #define strcatCX(A,B)  strcatCC((A),(B)),free(B)
  27. #define strcatXX(A,B)  strcatCC((A),(B)),free(A),free(B)
  28. #define strcatXXC(A,B,C) strcatCCC((A),(B),(C)),free(A),free(B)
  29. #define strcatCCX(A,B,C) strcatCCC((A),(B),(C)),free(C)
  30. #define strcatXXX(A,B,C) strcatCCC((A),(B),(C)),free(A),free(B),free(C)
  31. #define strcatXCX(A,B,C) strcatCCC((A),(B),(C)),free(A),free(C)
  32. #define strcatCCXX(A,B,C,D) strcatCCCC((A),(B),(C),(D)),free(C),free(D)
  33. #define strcatXCXX(A,B,C,D) strcatCCCC((A),(B),(C),(D)),free(A),free(C),free(D)
  34.  
  35. extern int yylineno;
  36. extern char yytext[];
  37. #ifdef YYBISON
  38. int yydebug;
  39. #else
  40. extern int yydebug;
  41. #endif
  42. static int yyverbose = 0;
  43. static int yyboolean = 0;
  44. static int numeric_field = 0;
  45. static int global_dct_exists = 0;
  46. char *current_field;
  47. char *yybuf;
  48. char *yyresultstring;
  49. #define MAX_NUM_FIELDS 100
  50. char *field_name_array[MAX_NUM_FIELDS];
  51. static long fields_found_this_query = 0;
  52.  
  53. extern long number_of_operands; /* defined in field_search.c */
  54. /* char** field_name_array = NULL; */
  55.  
  56. static char * strcatCC _AP((char *w, char *wl));
  57. static char * strcatCCC _AP((char *w, char *wl, char *op));
  58. static char * strcatCCCC _AP((char *w, char *wl, char *op1, char *op2));
  59.  
  60. #line 63 "query_y.y"
  61. typedef union {
  62.    int  ival;
  63.    char *sval;
  64.    } YYSTYPE;
  65.  
  66. #ifndef YYLTYPE
  67. typedef
  68.   struct yyltype
  69.     {
  70.       int timestamp;
  71.       int first_line;
  72.       int first_column;
  73.       int last_line;
  74.       int last_column;
  75.       char *text;
  76.    }
  77.   yyltype;
  78.  
  79. #define YYLTYPE yyltype
  80. #endif
  81.  
  82. #include <stdio.h>
  83.  
  84. #ifndef __cplusplus
  85. #ifndef __STDC__
  86. #define const
  87. #endif
  88. #endif
  89.  
  90.  
  91.  
  92. #define    YYFINAL        49
  93. #define    YYFLAG        -32768
  94. #define    YYNTBASE    14
  95.  
  96. #define YYTRANSLATE(x) ((unsigned)(x) <= 263 ? yytranslate[x] : 29)
  97.  
  98. static const char yytranslate[] = {     0,
  99.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  100.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  101.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  102.      2,     2,     2,     2,     2,     2,     2,     2,     2,     9,
  103.     10,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  104.      2,     2,     2,     2,     2,     2,     2,     2,     2,    12,
  105.     11,    13,     2,     2,     2,     2,     2,     2,     2,     2,
  106.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  107.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  108.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  109.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  110.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  111.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  112.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  113.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  114.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  115.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  116.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  117.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  118.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  119.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  120.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  121.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  122.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  123.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  124.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  125.      6,     7,     8
  126. };
  127.  
  128. #if YYDEBUG != 0
  129. static const short yyprhs[] = {     0,
  130.      0,     2,     3,     5,     7,     9,    11,    15,    17,    21,
  131.     23,    26,    30,    31,    38,    39,    44,    45,    51,    52,
  132.     57,    60,    62,    64,    66,    68,    70,    74,    76,    80,
  133.     82,    85
  134. };
  135.  
  136. static const short yyrhs[] = {    17,
  137.      0,     0,     6,     0,     7,     0,     8,     0,    18,     0,
  138.     17,    15,    18,     0,    19,     0,    18,    16,    19,     0,
  139.      3,     0,    25,     3,     0,     9,    17,    10,     0,     0,
  140.      3,    11,    20,     9,    26,    10,     0,     0,     3,    11,
  141.     21,     3,     0,     0,     3,    11,    22,    25,     3,     0,
  142.      0,     3,    24,    23,     3,     0,    11,    11,     0,    12,
  143.      0,    13,     0,     4,     0,     5,     0,    27,     0,    26,
  144.     15,    27,     0,    28,     0,    27,    16,    28,     0,     3,
  145.      0,    25,     3,     0,     9,    26,    10,     0
  146. };
  147.  
  148. #endif
  149.  
  150. #if YYDEBUG != 0
  151. static const short yyrline[] = { 0,
  152.     68,    77,    78,    81,    82,    85,    89,   100,   104,   111,
  153.    120,   128,   132,   133,   139,   140,   149,   149,   159,   160,
  154.    189,   190,   191,   193,   194,   196,   200,   211,   215,   222,
  155.    232,   238
  156. };
  157.  
  158. static const char * const yytname[] = {   "$","error","$illegal.","WORD","PHONIX",
  159. "SOUNDEX","OR","AND","NOT","'('","')'","'='","'<'","'>'","query","or","and",
  160. "expression","term","factor","@1","@2","@3","@4","relop","phonsound","s_expression",
  161. "s_term","s_factor",""
  162. };
  163. #endif
  164.  
  165. static const short yyr1[] = {     0,
  166.     14,    15,    15,    16,    16,    17,    17,    18,    18,    19,
  167.     19,    19,    20,    19,    21,    19,    22,    19,    23,    19,
  168.     24,    24,    24,    25,    25,    26,    26,    27,    27,    28,
  169.     28,    28
  170. };
  171.  
  172. static const short yyr2[] = {     0,
  173.      1,     0,     1,     1,     1,     1,     3,     1,     3,     1,
  174.      2,     3,     0,     6,     0,     4,     0,     5,     0,     4,
  175.      2,     1,     1,     1,     1,     1,     3,     1,     3,     1,
  176.      2,     3
  177. };
  178.  
  179. static const short yydefact[] = {     0,
  180.     10,    24,    25,     0,     2,     6,     8,     0,    17,    22,
  181.     23,    19,     2,     3,     0,     4,     5,     0,    11,    21,
  182.      0,     0,     0,     0,    12,     7,     9,     0,    16,     0,
  183.     20,    30,     0,     0,     2,    26,    28,    18,     2,    31,
  184.     14,     0,     0,    32,    27,    29,     0,     0,     0
  185. };
  186.  
  187. static const short yydefgoto[] = {    47,
  188.     15,    18,     5,     6,     7,    21,    22,    23,    24,    12,
  189.      8,    35,    36,    37
  190. };
  191.  
  192. static const short yypact[] = {     9,
  193.     21,-32768,-32768,     9,    22,    28,-32768,     0,    -2,-32768,
  194. -32768,-32768,    17,-32768,     9,-32768,-32768,     9,-32768,-32768,
  195.     -3,    36,    33,    37,-32768,    28,-32768,    12,-32768,    38,
  196. -32768,-32768,    12,    39,    19,    28,-32768,-32768,    20,-32768,
  197. -32768,    12,    12,-32768,    28,-32768,    24,    31,-32768
  198. };
  199.  
  200. static const short yypgoto[] = {-32768,
  201.    -31,   -34,    40,    30,    25,-32768,-32768,-32768,-32768,-32768,
  202.    -23,    13,     5,     6
  203. };
  204.  
  205.  
  206. #define    YYLAST        49
  207.  
  208.  
  209. static const short yytable[] = {    30,
  210.    -15,    43,    19,    42,    34,    28,   -13,    42,    20,    34,
  211.     43,     1,     2,     3,    32,     2,     3,     4,    34,    34,
  212.     33,    -1,    14,    48,    14,    14,    25,    14,    41,    44,
  213.     49,     9,    10,    11,    16,    17,     2,     3,    29,    31,
  214.     38,    40,    27,    13,    26,    39,    45,     0,    46
  215. };
  216.  
  217. static const short yycheck[] = {    23,
  218.      3,    36,     3,    35,    28,     9,     9,    39,    11,    33,
  219.     45,     3,     4,     5,     3,     4,     5,     9,    42,    43,
  220.      9,     0,     6,     0,     6,     6,    10,     6,    10,    10,
  221.      0,    11,    12,    13,     7,     8,     4,     5,     3,     3,
  222.      3,     3,    18,     4,    15,    33,    42,    -1,    43
  223. };
  224. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  225. #line 3 "/usr/local/gnulang-94a/lib/bison.simple"
  226.  
  227. /* Skeleton output parser for bison,
  228.    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  229.  
  230.    This program is free software; you can redistribute it and/or modify
  231.    it under the terms of the GNU General Public License as published by
  232.    the Free Software Foundation; either version 1, or (at your option)
  233.    any later version.
  234.  
  235.    This program is distributed in the hope that it will be useful,
  236.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  237.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  238.    GNU General Public License for more details.
  239.  
  240.    You should have received a copy of the GNU General Public License
  241.    along with this program; if not, write to the Free Software
  242.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  243.  
  244.  
  245. #ifndef alloca
  246. #ifdef __GNUC__
  247. #define alloca __builtin_alloca
  248. #else /* not GNU C.  */
  249. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
  250. #include <alloca.h>
  251. #else /* not sparc */
  252. #if defined (MSDOS) && !defined (__TURBOC__)
  253. #include <malloc.h>
  254. #else /* not MSDOS, or __TURBOC__ */
  255. #if defined(_AIX)
  256. #include <malloc.h>
  257.  #pragma alloca
  258. #else /* not MSDOS, __TURBOC__, or _AIX */
  259. #ifdef __hpux
  260. #ifdef __cplusplus
  261. extern "C" {
  262. void *alloca (unsigned int);
  263. };
  264. #else /* not __cplusplus */
  265. void *alloca ();
  266. #endif /* not __cplusplus */
  267. #endif /* __hpux */
  268. #endif /* not _AIX */
  269. #endif /* not MSDOS, or __TURBOC__ */
  270. #endif /* not sparc.  */
  271. #endif /* not GNU C.  */
  272. #endif /* alloca not defined.  */
  273.  
  274. /* This is the parser code that is written into each bison parser
  275.   when the %semantic_parser declaration is not specified in the grammar.
  276.   It was written by Richard Stallman by simplifying the hairy parser
  277.   used when %semantic_parser is specified.  */
  278.  
  279. /* Note: there must be only one dollar sign in this file.
  280.    It is replaced by the list of actions, each action
  281.    as one case of the switch.  */
  282.  
  283. #define yyerrok        (yyerrstatus = 0)
  284. #define yyclearin    (yychar = YYEMPTY)
  285. #define YYEMPTY        -2
  286. #define YYEOF        0
  287. #define YYACCEPT    return(0)
  288. #define YYABORT     return(1)
  289. #define YYERROR        goto yyerrlab1
  290. /* Like YYERROR except do call yyerror.
  291.    This remains here temporarily to ease the
  292.    transition to the new meaning of YYERROR, for GCC.
  293.    Once GCC version 2 has supplanted version 1, this can go.  */
  294. #define YYFAIL        goto yyerrlab
  295. #define YYRECOVERING()  (!!yyerrstatus)
  296. #define YYBACKUP(token, value) \
  297. do                                \
  298.   if (yychar == YYEMPTY && yylen == 1)                \
  299.     { yychar = (token), yylval = (value);            \
  300.       yychar1 = YYTRANSLATE (yychar);                \
  301.       YYPOPSTACK;                        \
  302.       goto yybackup;                        \
  303.     }                                \
  304.   else                                \
  305.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  306. while (0)
  307.  
  308. #define YYTERROR    1
  309. #define YYERRCODE    256
  310.  
  311. #ifndef YYPURE
  312. #define YYLEX        yylex()
  313. #endif
  314.  
  315. #ifdef YYPURE
  316. #ifdef YYLSP_NEEDED
  317. #define YYLEX        yylex(&yylval, &yylloc)
  318. #else
  319. #define YYLEX        yylex(&yylval)
  320. #endif
  321. #endif
  322.  
  323. /* If nonreentrant, generate the variables here */
  324.  
  325. #ifndef YYPURE
  326.  
  327. int    yychar;            /*  the lookahead symbol        */
  328. YYSTYPE    yylval;            /*  the semantic value of the        */
  329.                 /*  lookahead symbol            */
  330.  
  331. #ifdef YYLSP_NEEDED
  332. YYLTYPE yylloc;            /*  location data for the lookahead    */
  333.                 /*  symbol                */
  334. #endif
  335.  
  336. int yynerrs;            /*  number of parse errors so far       */
  337. #endif  /* not YYPURE */
  338.  
  339. #if YYDEBUG != 0
  340. int yydebug;            /*  nonzero means print parse trace    */
  341. /* Since this is uninitialized, it does not stop multiple parsers
  342.    from coexisting.  */
  343. #endif
  344.  
  345. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  346.  
  347. #ifndef    YYINITDEPTH
  348. #define YYINITDEPTH 200
  349. #endif
  350.  
  351. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  352.     (effective only if the built-in stack extension method is used).  */
  353.  
  354. #if YYMAXDEPTH == 0
  355. #undef YYMAXDEPTH
  356. #endif
  357.  
  358. #ifndef YYMAXDEPTH
  359. #define YYMAXDEPTH 10000
  360. #endif
  361.  
  362. /* Prevent warning if -Wstrict-prototypes.  */
  363. #ifdef __GNUC__
  364. int yyparse (void);
  365. #endif
  366.  
  367. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  368. #define __yy_bcopy(FROM,TO,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  369. #else                /* not GNU C or C++ */
  370. #ifndef __cplusplus
  371.  
  372. /* This is the most reliable way to avoid incompatibilities
  373.    in available built-in functions on various systems.  */
  374. static void
  375. __yy_bcopy (from, to, count)
  376.      char *from;
  377.      char *to;
  378.      int count;
  379. {
  380.   register char *f = from;
  381.   register char *t = to;
  382.   register int i = count;
  383.  
  384.   while (i-- > 0)
  385.     *t++ = *f++;
  386. }
  387.  
  388. #else /* __cplusplus */
  389.  
  390. /* This is the most reliable way to avoid incompatibilities
  391.    in available built-in functions on various systems.  */
  392. static void
  393. __yy_bcopy (char *from, char *to, int count)
  394. {
  395.   register char *f = from;
  396.   register char *t = to;
  397.   register int i = count;
  398.  
  399.   while (i-- > 0)
  400.     *t++ = *f++;
  401. }
  402.  
  403. #endif
  404. #endif
  405.  
  406. #line 184 "/usr/local/gnulang-94a/lib/bison.simple"
  407. int
  408. yyparse()
  409. {
  410.   register int yystate;
  411.   register int yyn;
  412.   register short *yyssp;
  413.   register YYSTYPE *yyvsp;
  414.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  415.   int yychar1 = 0;        /*  lookahead token as an internal (translated) token number */
  416.  
  417.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  418.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  419.  
  420.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  421.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  422.  
  423. #ifdef YYLSP_NEEDED
  424.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  425.   YYLTYPE *yyls = yylsa;
  426.   YYLTYPE *yylsp;
  427.  
  428. #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  429. #else
  430. #define YYPOPSTACK   (yyvsp--, yyssp--)
  431. #endif
  432.  
  433.   int yystacksize = YYINITDEPTH;
  434.  
  435. #ifdef YYPURE
  436.   int yychar;
  437.   YYSTYPE yylval;
  438.   int yynerrs;
  439. #ifdef YYLSP_NEEDED
  440.   YYLTYPE yylloc;
  441. #endif
  442. #endif
  443.  
  444.   YYSTYPE yyval;        /*  the variable used to return        */
  445.                 /*  semantic values from the action    */
  446.                 /*  routines                */
  447.  
  448.   int yylen;
  449.  
  450. #if YYDEBUG != 0
  451.   if (yydebug)
  452.     fprintf(stderr, "Starting parse\n");
  453. #endif
  454.  
  455.   yystate = 0;
  456.   yyerrstatus = 0;
  457.   yynerrs = 0;
  458.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  459.  
  460.   /* Initialize stack pointers.
  461.      Waste one element of value and location stack
  462.      so that they stay on the same level as the state stack.
  463.      The wasted elements are never initialized.  */
  464.  
  465.   yyssp = yyss - 1;
  466.   yyvsp = yyvs;
  467. #ifdef YYLSP_NEEDED
  468.   yylsp = yyls;
  469. #endif
  470.  
  471. /* Push a new state, which is found in  yystate  .  */
  472. /* In all cases, when you get here, the value and location stacks
  473.    have just been pushed. so pushing a state here evens the stacks.  */
  474. yynewstate:
  475.  
  476.   *++yyssp = yystate;
  477.  
  478.   if (yyssp >= yyss + yystacksize - 1)
  479.     {
  480.       /* Give user a chance to reallocate the stack */
  481.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  482.       YYSTYPE *yyvs1 = yyvs;
  483.       short *yyss1 = yyss;
  484. #ifdef YYLSP_NEEDED
  485.       YYLTYPE *yyls1 = yyls;
  486. #endif
  487.  
  488.       /* Get the current used size of the three stacks, in elements.  */
  489.       int size = yyssp - yyss + 1;
  490.  
  491. #ifdef yyoverflow
  492.       /* Each stack pointer address is followed by the size of
  493.      the data in use in that stack, in bytes.  */
  494. #ifdef YYLSP_NEEDED
  495.       /* This used to be a conditional around just the two extra args,
  496.      but that might be undefined if yyoverflow is a macro.  */
  497.       yyoverflow("parser stack overflow",
  498.          &yyss1, size * sizeof (*yyssp),
  499.          &yyvs1, size * sizeof (*yyvsp),
  500.          &yyls1, size * sizeof (*yylsp),
  501.          &yystacksize);
  502. #else
  503.       yyoverflow("parser stack overflow",
  504.          &yyss1, size * sizeof (*yyssp),
  505.          &yyvs1, size * sizeof (*yyvsp),
  506.          &yystacksize);
  507. #endif
  508.  
  509.       yyss = yyss1; yyvs = yyvs1;
  510. #ifdef YYLSP_NEEDED
  511.       yyls = yyls1;
  512. #endif
  513. #else /* no yyoverflow */
  514.       /* Extend the stack our own way.  */
  515.       if (yystacksize >= YYMAXDEPTH)
  516.     {
  517.       yyerror("parser stack overflow");
  518.       return 2;
  519.     }
  520.       yystacksize *= 2;
  521.       if (yystacksize > YYMAXDEPTH)
  522.     yystacksize = YYMAXDEPTH;
  523.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  524.       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  525.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  526.       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  527. #ifdef YYLSP_NEEDED
  528.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  529.       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  530. #endif
  531. #endif /* no yyoverflow */
  532.  
  533.       yyssp = yyss + size - 1;
  534.       yyvsp = yyvs + size - 1;
  535. #ifdef YYLSP_NEEDED
  536.       yylsp = yyls + size - 1;
  537. #endif
  538.  
  539. #if YYDEBUG != 0
  540.       if (yydebug)
  541.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  542. #endif
  543.  
  544.       if (yyssp >= yyss + yystacksize - 1)
  545.     YYABORT;
  546.     }
  547.  
  548. #if YYDEBUG != 0
  549.   if (yydebug)
  550.     fprintf(stderr, "Entering state %d\n", yystate);
  551. #endif
  552.  
  553.   goto yybackup;
  554.  yybackup:
  555.  
  556. /* Do appropriate processing given the current state.  */
  557. /* Read a lookahead token if we need one and don't already have one.  */
  558. /* yyresume: */
  559.  
  560.   /* First try to decide what to do without reference to lookahead token.  */
  561.  
  562.   yyn = yypact[yystate];
  563.   if (yyn == YYFLAG)
  564.     goto yydefault;
  565.  
  566.   /* Not known => get a lookahead token if don't already have one.  */
  567.  
  568.   /* yychar is either YYEMPTY or YYEOF
  569.      or a valid token in external form.  */
  570.  
  571.   if (yychar == YYEMPTY)
  572.     {
  573. #if YYDEBUG != 0
  574.       if (yydebug)
  575.     fprintf(stderr, "Reading a token: ");
  576. #endif
  577.       yychar = YYLEX;
  578.     }
  579.  
  580.   /* Convert token to internal form (in yychar1) for indexing tables with */
  581.  
  582.   if (yychar <= 0)        /* This means end of input. */
  583.     {
  584.       yychar1 = 0;
  585.       yychar = YYEOF;        /* Don't call YYLEX any more */
  586.  
  587. #if YYDEBUG != 0
  588.       if (yydebug)
  589.     fprintf(stderr, "Now at end of input.\n");
  590. #endif
  591.     }
  592.   else
  593.     {
  594.       yychar1 = YYTRANSLATE(yychar);
  595.  
  596. #if YYDEBUG != 0
  597.       if (yydebug)
  598.     {
  599.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  600.       /* Give the individual parser a way to print the precise meaning
  601.          of a token, for further debugging info.  */
  602. #ifdef YYPRINT
  603.       YYPRINT (stderr, yychar, yylval);
  604. #endif
  605.       fprintf (stderr, ")\n");
  606.     }
  607. #endif
  608.     }
  609.  
  610.   yyn += yychar1;
  611.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  612.     goto yydefault;
  613.  
  614.   yyn = yytable[yyn];
  615.  
  616.   /* yyn is what to do for this token type in this state.
  617.      Negative => reduce, -yyn is rule number.
  618.      Positive => shift, yyn is new state.
  619.        New state is final state => don't bother to shift,
  620.        just return success.
  621.      0, or most negative number => error.  */
  622.  
  623.   if (yyn < 0)
  624.     {
  625.       if (yyn == YYFLAG)
  626.     goto yyerrlab;
  627.       yyn = -yyn;
  628.       goto yyreduce;
  629.     }
  630.   else if (yyn == 0)
  631.     goto yyerrlab;
  632.  
  633.   if (yyn == YYFINAL)
  634.     YYACCEPT;
  635.  
  636.   /* Shift the lookahead token.  */
  637.  
  638. #if YYDEBUG != 0
  639.   if (yydebug)
  640.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  641. #endif
  642.  
  643.   /* Discard the token being shifted unless it is eof.  */
  644.   if (yychar != YYEOF)
  645.     yychar = YYEMPTY;
  646.  
  647.   *++yyvsp = yylval;
  648. #ifdef YYLSP_NEEDED
  649.   *++yylsp = yylloc;
  650. #endif
  651.  
  652.   /* count tokens shifted since error; after three, turn off error status.  */
  653.   if (yyerrstatus) yyerrstatus--;
  654.  
  655.   yystate = yyn;
  656.   goto yynewstate;
  657.  
  658. /* Do the default action for the current state.  */
  659. yydefault:
  660.  
  661.   yyn = yydefact[yystate];
  662.   if (yyn == 0)
  663.     goto yyerrlab;
  664.  
  665. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  666. yyreduce:
  667.   yylen = yyr2[yyn];
  668.   if (yylen > 0)
  669.     yyval = yyvsp[1-yylen]; /* implement default value of the action */
  670.  
  671. #if YYDEBUG != 0
  672.   if (yydebug)
  673.     {
  674.       int i;
  675.  
  676.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  677.            yyn, yyrline[yyn]);
  678.  
  679.       /* Print the symbols being reduced, and their result.  */
  680.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  681.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  682.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  683.     }
  684. #endif
  685.  
  686.  
  687.   switch (yyn) {
  688.  
  689. case 1:
  690. #line 69 "query_y.y"
  691. {
  692.   yyresultstring = yyvsp[0].sval;    /* who calls free ? (up) */
  693. #ifdef YYDEBUG
  694.   if (yydebug) fprintf(stderr,"query->%s<-\n",yyresultstring);
  695. #endif
  696. ;
  697.     break;}
  698. case 4:
  699. #line 81 "query_y.y"
  700. { yyval.sval = "and"; ;
  701.     break;}
  702. case 5:
  703. #line 82 "query_y.y"
  704. { yyval.sval = "not"; ;
  705.     break;}
  706. case 6:
  707. #line 86 "query_y.y"
  708. {
  709.                   yyval.sval = yyvsp[0].sval;
  710.                 ;
  711.     break;}
  712. case 7:
  713. #line 90 "query_y.y"
  714. {
  715.                   if (yyboolean) {
  716.                     ++number_of_operands;
  717.                     yyval.sval = strcatXXC(yyvsp[-2].sval, yyvsp[0].sval, "or");
  718.                   } else {
  719.                     yyval.sval = strcatXX(yyvsp[-2].sval, yyvsp[0].sval);
  720.                   }
  721.                 ;
  722.     break;}
  723. case 8:
  724. #line 101 "query_y.y"
  725. {
  726.                   yyval.sval = yyvsp[0].sval;
  727.                 ;
  728.     break;}
  729. case 9:
  730. #line 105 "query_y.y"
  731. {
  732.                   ++number_of_operands;
  733.                   yyval.sval = strcatXXC(yyvsp[-2].sval, yyvsp[0].sval, yyvsp[-1].sval);
  734.                 ;
  735.     break;}
  736. case 10:
  737. #line 112 "query_y.y"
  738. {
  739.                   if (yyverbose) {
  740.                     yyval.sval = strcatCCX("text", "=", yyvsp[0].sval);
  741.                     global_dct_exists = 1;
  742.                   } else {
  743.                     yyval.sval = yyvsp[0].sval;
  744.                   }
  745.                 ;
  746.     break;}
  747. case 11:
  748. #line 121 "query_y.y"
  749. {
  750.           if (yyverbose) {
  751.                     yyval.sval = strcatXCXX("text", "=", yyvsp[-1].sval, yyvsp[0].sval);
  752.           } else {
  753.             yyval.sval = strcatXX(yyvsp[-1].sval, yyvsp[0].sval);
  754.           }
  755.         ;
  756.     break;}
  757. case 12:
  758. #line 129 "query_y.y"
  759. {
  760.                   yyval.sval = yyvsp[-1].sval;
  761.                 ;
  762.     break;}
  763. case 13:
  764. #line 132 "query_y.y"
  765. {current_field = yyvsp[-1].sval;numeric_field = 0;;
  766.     break;}
  767. case 14:
  768. #line 134 "query_y.y"
  769. {
  770.                   insert_field(current_field);
  771.                   yyval.sval = yyvsp[-1].sval;
  772.                   free(current_field);
  773.                 ;
  774.     break;}
  775. case 15:
  776. #line 139 "query_y.y"
  777. {current_field = yyvsp[-1].sval;numeric_field = 0;;
  778.     break;}
  779. case 16:
  780. #line 140 "query_y.y"
  781. {
  782.                   if (yyverbose) {
  783.                     insert_field(current_field);
  784.                     yyval.sval = strcatXCX(current_field, "=", yyvsp[0].sval);
  785.                   } else {
  786.                     yyval.sval = yyvsp[0].sval;
  787.                     free(current_field);
  788.                   }
  789.                 ;
  790.     break;}
  791. case 17:
  792. #line 149 "query_y.y"
  793. {current_field = yyvsp[-1].sval;numeric_field = 0;;
  794.     break;}
  795. case 18:
  796. #line 150 "query_y.y"
  797. {
  798.                   if (yyverbose) {
  799.                     insert_field(current_field);
  800.                     yyval.sval = strcatXCXX(current_field, "=", yyvsp[-1].sval, yyvsp[0].sval);
  801.                   }else {
  802.                     yyval.sval = strcatXX(yyvsp[-1].sval, yyvsp[0].sval);
  803.                     free(current_field);
  804.                   }
  805.                 ;
  806.     break;}
  807. case 19:
  808. #line 159 "query_y.y"
  809. {current_field = yyvsp[-1].sval;numeric_field = 1;;
  810.     break;}
  811. case 20:
  812. #line 160 "query_y.y"
  813. {
  814.                   if (yyverbose) {
  815.                     /* was soll hier eigentlich passieren ?
  816.                        "py == 1990" => "py=" in die feldliste
  817.                                        "py == 1990"
  818.                        "py < 1990"  => "py" in die feldliste
  819.                                        "py < 1990"
  820.                        "py > 1990"  => "py" in die feldliste
  821.                                        "py > 1990"
  822.                     */
  823.                     if(!strcmp(yyvsp[-2].sval, ">")) {
  824.                       insert_field_p(current_field, ">");
  825.                     }
  826.                     else if(!strcmp(yyvsp[-2].sval, "<")) {
  827.                       insert_field_p(current_field, "<");
  828.                     }
  829.                     else if(!strcmp(yyvsp[-2].sval, "==")) {
  830.                       insert_field_p(current_field, "=");
  831.                     }
  832.                     else insert_field(current_field);
  833.                     /* up: relop is static, so do not free it !! */
  834.                     yyval.sval = strcatXCX(current_field, yyvsp[-2].sval, yyvsp[0].sval);
  835.                   } else {
  836.                     yyval.sval = yyvsp[0].sval;
  837.                     free(current_field);
  838.                   }
  839.                   /* up do no free current_field twice */
  840.                 ;
  841.     break;}
  842. case 21:
  843. #line 189 "query_y.y"
  844. { yyval.sval = "=="; ;
  845.     break;}
  846. case 22:
  847. #line 190 "query_y.y"
  848. { yyval.sval = "<"; ;
  849.     break;}
  850. case 23:
  851. #line 191 "query_y.y"
  852. { yyval.sval = ">"; ;
  853.     break;}
  854. case 26:
  855. #line 197 "query_y.y"
  856. {
  857.                   yyval.sval = yyvsp[0].sval   ;
  858.                 ;
  859.     break;}
  860. case 27:
  861. #line 201 "query_y.y"
  862. {
  863.                   if (yyboolean) {
  864.                     ++number_of_operands;
  865.                     yyval.sval = strcatXXC(yyvsp[-2].sval, yyvsp[0].sval, "or");
  866.                   } else {
  867.                     yyval.sval = strcatXX(yyvsp[-2].sval, yyvsp[0].sval);
  868.                   }
  869.                 ;
  870.     break;}
  871. case 28:
  872. #line 212 "query_y.y"
  873. {
  874.                   yyval.sval = yyvsp[0].sval;
  875.                 ;
  876.     break;}
  877. case 29:
  878. #line 216 "query_y.y"
  879. {
  880.                   ++number_of_operands;
  881.                   yyval.sval = strcatXXC(yyvsp[-2].sval, yyvsp[0].sval, yyvsp[-1].sval);
  882.                 ;
  883.     break;}
  884. case 30:
  885. #line 223 "query_y.y"
  886. {
  887.                   if (yyverbose) {
  888.                     if(numeric_field) 
  889.                       yyval.sval = strcatCCX(current_field, "==", yyvsp[0].sval);
  890.                     else yyval.sval = strcatCCX(current_field, "=", yyvsp[0].sval);
  891.                   } else {
  892.                     yyval.sval = yyvsp[0].sval;
  893.                   }
  894.                 ;
  895.     break;}
  896. case 31:
  897. #line 233 "query_y.y"
  898. {
  899.                   if (yyverbose) 
  900.                     yyval.sval = strcatCCXX(current_field, "=", yyvsp[-1].sval, yyvsp[0].sval);
  901.                   else yyval.sval = strcatXX(yyvsp[-1].sval, yyvsp[0].sval);
  902.                 ;
  903.     break;}
  904. case 32:
  905. #line 239 "query_y.y"
  906. {
  907.                   yyval.sval = yyvsp[-1].sval;
  908.                 ;
  909.     break;}
  910. }
  911.    /* the action file gets copied in in place of this dollarsign */
  912. #line 465 "/usr/local/gnulang-94a/lib/bison.simple"
  913.  
  914.   yyvsp -= yylen;
  915.   yyssp -= yylen;
  916. #ifdef YYLSP_NEEDED
  917.   yylsp -= yylen;
  918. #endif
  919.  
  920. #if YYDEBUG != 0
  921.   if (yydebug)
  922.     {
  923.       short *ssp1 = yyss - 1;
  924.       fprintf (stderr, "state stack now");
  925.       while (ssp1 != yyssp)
  926.     fprintf (stderr, " %d", *++ssp1);
  927.       fprintf (stderr, "\n");
  928.     }
  929. #endif
  930.  
  931.   *++yyvsp = yyval;
  932.  
  933. #ifdef YYLSP_NEEDED
  934.   yylsp++;
  935.   if (yylen == 0)
  936.     {
  937.       yylsp->first_line = yylloc.first_line;
  938.       yylsp->first_column = yylloc.first_column;
  939.       yylsp->last_line = (yylsp-1)->last_line;
  940.       yylsp->last_column = (yylsp-1)->last_column;
  941.       yylsp->text = 0;
  942.     }
  943.   else
  944.     {
  945.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  946.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  947.     }
  948. #endif
  949.  
  950.   /* Now "shift" the result of the reduction.
  951.      Determine what state that goes to,
  952.      based on the state we popped back to
  953.      and the rule number reduced by.  */
  954.  
  955.   yyn = yyr1[yyn];
  956.  
  957.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  958.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  959.     yystate = yytable[yystate];
  960.   else
  961.     yystate = yydefgoto[yyn - YYNTBASE];
  962.  
  963.   goto yynewstate;
  964.  
  965. yyerrlab:   /* here on detecting error */
  966.  
  967.   if (! yyerrstatus)
  968.     /* If not already recovering from an error, report this error.  */
  969.     {
  970.       ++yynerrs;
  971.  
  972. #ifdef YYERROR_VERBOSE
  973.       yyn = yypact[yystate];
  974.  
  975.       if (yyn > YYFLAG && yyn < YYLAST)
  976.     {
  977.       int size = 0;
  978.       char *msg;
  979.       int x, count;
  980.  
  981.       count = 0;
  982.       /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
  983.       for (x = (yyn < 0 ? -yyn : 0);
  984.            x < (sizeof(yytname) / sizeof(char *)); x++)
  985.         if (yycheck[x + yyn] == x)
  986.           size += strlen(yytname[x]) + 15, count++;
  987.       msg = (char *) malloc(size + 15);
  988.       if (msg != 0)
  989.         {
  990.           strcpy(msg, "parse error");
  991.  
  992.           if (count < 5)
  993.         {
  994.           count = 0;
  995.           for (x = (yyn < 0 ? -yyn : 0);
  996.                x < (sizeof(yytname) / sizeof(char *)); x++)
  997.             if (yycheck[x + yyn] == x)
  998.               {
  999.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  1000.             strcat(msg, yytname[x]);
  1001.             strcat(msg, "'");
  1002.             count++;
  1003.               }
  1004.         }
  1005.           yyerror(msg);
  1006.           free(msg);
  1007.         }
  1008.       else
  1009.         yyerror ("parse error; also virtual memory exceeded");
  1010.     }
  1011.       else
  1012. #endif /* YYERROR_VERBOSE */
  1013.     yyerror("parse error");
  1014.     }
  1015.  
  1016.   goto yyerrlab1;
  1017. yyerrlab1:   /* here on error raised explicitly by an action */
  1018.  
  1019.   if (yyerrstatus == 3)
  1020.     {
  1021.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  1022.  
  1023.       /* return failure if at end of input */
  1024.       if (yychar == YYEOF)
  1025.     YYABORT;
  1026.  
  1027. #if YYDEBUG != 0
  1028.       if (yydebug)
  1029.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  1030. #endif
  1031.  
  1032.       yychar = YYEMPTY;
  1033.     }
  1034.  
  1035.   /* Else will try to reuse lookahead token
  1036.      after shifting the error token.  */
  1037.  
  1038.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  1039.  
  1040.   goto yyerrhandle;
  1041.  
  1042. yyerrdefault:  /* current state does not do anything special for the error token. */
  1043.  
  1044. #if 0
  1045.   /* This is wrong; only states that explicitly want error tokens
  1046.      should shift them.  */
  1047.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  1048.   if (yyn) goto yydefault;
  1049. #endif
  1050.  
  1051. yyerrpop:   /* pop the current state because it cannot handle the error token */
  1052.  
  1053.   if (yyssp == yyss) YYABORT;
  1054.   yyvsp--;
  1055.   yystate = *--yyssp;
  1056. #ifdef YYLSP_NEEDED
  1057.   yylsp--;
  1058. #endif
  1059.  
  1060. #if YYDEBUG != 0
  1061.   if (yydebug)
  1062.     {
  1063.       short *ssp1 = yyss - 1;
  1064.       fprintf (stderr, "Error: state stack now");
  1065.       while (ssp1 != yyssp)
  1066.     fprintf (stderr, " %d", *++ssp1);
  1067.       fprintf (stderr, "\n");
  1068.     }
  1069. #endif
  1070.  
  1071. yyerrhandle:
  1072.  
  1073.   yyn = yypact[yystate];
  1074.   if (yyn == YYFLAG)
  1075.     goto yyerrdefault;
  1076.  
  1077.   yyn += YYTERROR;
  1078.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1079.     goto yyerrdefault;
  1080.  
  1081.   yyn = yytable[yyn];
  1082.   if (yyn < 0)
  1083.     {
  1084.       if (yyn == YYFLAG)
  1085.     goto yyerrpop;
  1086.       yyn = -yyn;
  1087.       goto yyreduce;
  1088.     }
  1089.   else if (yyn == 0)
  1090.     goto yyerrpop;
  1091.  
  1092.   if (yyn == YYFINAL)
  1093.     YYACCEPT;
  1094.  
  1095. #if YYDEBUG != 0
  1096.   if (yydebug)
  1097.     fprintf(stderr, "Shifting error token, ");
  1098. #endif
  1099.  
  1100.   *++yyvsp = yylval;
  1101. #ifdef YYLSP_NEEDED
  1102.   *++yylsp = yylloc;
  1103. #endif
  1104.  
  1105.   yystate = yyn;
  1106.   goto yynewstate;
  1107. }
  1108. #line 243 "query_y.y"
  1109.  
  1110.  
  1111. yyerror(s)
  1112. char *s;
  1113. {
  1114.    fprintf(stderr,"line %d: syntax error at or near string \"%s\"\n",
  1115.            yylineno, yytext);
  1116.    fprintf(stderr,"%s\n", s);
  1117. }
  1118.  
  1119. yywrap()
  1120. {
  1121.    return(1);
  1122. }
  1123.  
  1124. static char *strcatCC(w, wl)
  1125. char *w, *wl;
  1126. {
  1127.    char *wln;
  1128.    int len;
  1129.  
  1130.    len = strlen(w) + strlen(wl) + 2;
  1131.    wln = (char *)malloc(len);
  1132.  
  1133.    wln = strcpy(wln, w);
  1134.    wln = strcat(wln, " ");
  1135.    wln = strcat(wln, wl);
  1136.  
  1137.    return(wln);
  1138. }
  1139.  
  1140. static char *strcatCCC(w, wl, op)
  1141. char *w, *wl, *op;
  1142. {
  1143.    char *wln;
  1144.    int len;
  1145.  
  1146.    len = strlen(w) + strlen(wl) + strlen(op) + 3;
  1147.    wln = (char *)malloc(len);
  1148.  
  1149.    wln = strcpy(wln, w);
  1150.    if ((*wl == '=') || (*wl == '<') || (*wl == '>')) {
  1151.      /* no blank */
  1152.    } else {
  1153.      wln = strcat(wln, " ");
  1154.    }
  1155.    wln = strcat(wln, wl);
  1156.    wln = strcat(wln, " ");      
  1157.    wln = strcat(wln, op);
  1158.  
  1159.    return(wln);
  1160. }
  1161.  
  1162. static char *strcatCCCC(w, wl, op1, op2)
  1163. char *w, *wl, *op1, *op2;
  1164. {
  1165.    char *wln;
  1166.    int len;
  1167.  
  1168.    len = strlen(w) + strlen(wl) + strlen(op1) + strlen(op2) + 3;
  1169.    wln = (char *)malloc(len);
  1170.  
  1171.    wln = strcpy(wln, w);
  1172.    if ((*wl == '=') || (*wl == '<') || (*wl == '>')) {
  1173.      /* no blank */
  1174.    } else {
  1175.      wln = strcat(wln, " ");
  1176.    }
  1177.    wln = strcat(wln, wl);
  1178.    wln = strcat(wln, " ");      
  1179.    wln = strcat(wln, op1);
  1180.    wln = strcat(wln, " ");
  1181.    wln = strcat(wln, op2);
  1182.  
  1183.    return(wln);
  1184. }
  1185.  
  1186. int is_duplicate_field(field_name)
  1187.      char* field_name;
  1188. {
  1189.   long i = 0;
  1190.   long len = strlen(field_name);
  1191.  
  1192.   for (i=0;i<fields_found_this_query;i++)
  1193.     if (!strncmp(field_name, field_name_array[i], len))
  1194.       return(1); /* it is duplicate */
  1195.  
  1196.   return(0); /* not duplicate and field_name can inserted. */
  1197. }
  1198.  
  1199. #define MAX_WORD_LENGTH 20
  1200. int insert_field_p(field_name,c)
  1201.      char* field_name;
  1202.      char* c;
  1203. {
  1204.   char field_name_p[MAX_WORD_LENGTH];
  1205.   strncpy(field_name_p,field_name,MAX_WORD_LENGTH);
  1206.   strncat(field_name_p,c,MAX_WORD_LENGTH);
  1207.   return(insert_field(field_name_p));
  1208. }
  1209.  
  1210. int insert_field(field_name)
  1211.      char* field_name;
  1212. {
  1213.   long i = 0;
  1214.   long len = strlen(field_name);
  1215.  
  1216.   if (fields_found_this_query > MAX_NUM_FIELDS) {
  1217.     /* overflow: should be handled with realloc ? */
  1218.     return(-1);
  1219.   }
  1220.   if (!is_duplicate_field(field_name)) {
  1221.       /* dont know why not use strdup (up)?
  1222.          field_name_array[fields_found_this_query] = strdup(field_name); 
  1223.          */
  1224.     field_name_array[fields_found_this_query] =
  1225.       (char*)malloc((size_t)((MAX_WORD_LENGTH + 1) * sizeof(char)));
  1226.     /* warn if malloc failed !! (up)*/
  1227.     strncpy(field_name_array[fields_found_this_query],field_name,MAX_WORD_LENGTH);
  1228.     fields_found_this_query++;
  1229.   }
  1230.   return(0);
  1231. }
  1232.  
  1233.  
  1234. char* analyse_string(string, number_of_fields, global_dictionary_exists)
  1235.      char* string;
  1236.      long* number_of_fields;
  1237.      int* global_dictionary_exists;
  1238. {
  1239.   int result;
  1240.  
  1241.   fields_found_this_query = 0;
  1242.   yyverbose = 0;
  1243.   numeric_field = 0;
  1244.   yydebug = 0;
  1245.   yybuf   = string;
  1246.  
  1247.   if (strchr(string,'=')) 
  1248.     yyverbose++;
  1249.   else  if (strchr(string,'>')) 
  1250.     yyverbose++;
  1251.   else if (strchr(string,'<')) yyverbose++;
  1252.  
  1253.   yyboolean = yyverbose || (strstr(string," and ") || strstr(string," AND ")||
  1254.         strstr(string," not ") || strstr(string," NOT "));
  1255.  
  1256.   if (!yyparse()) {
  1257.     field_name_array[fields_found_this_query] = NULL;
  1258. #ifdef YYDEBUG
  1259.     if (yydebug) {
  1260.       int i;
  1261.       fprintf(stderr,"Found %d fields\n", fields_found_this_query);
  1262.       for (i=0;i<fields_found_this_query;i++) {
  1263.         fprintf(stderr,"feld %d %s\n", i, 
  1264.                 (field_name_array[i]==NULL)?"(nil)":field_name_array[i]);
  1265.       }
  1266.       sleep(2);
  1267.     }
  1268. #endif
  1269.     *number_of_fields = fields_found_this_query;
  1270.     *global_dictionary_exists = global_dct_exists;
  1271.     global_dct_exists = 0;
  1272.     return(yyresultstring);
  1273.   } else {
  1274.     *number_of_fields = 0;
  1275.     field_name_array[0] = NULL;
  1276.     return(NULL);
  1277.   }
  1278. }
  1279.  
  1280.  
  1281. #ifdef TEST_QUERY
  1282. long number_of_operands = 0;
  1283.  
  1284. int main _AP((int argc, char *argv[]));
  1285.  
  1286. main(argc,argv)
  1287. int argc;
  1288. char *argv[];
  1289. {
  1290.   long dummy;
  1291.   if (argc ==1) {
  1292.     char s[80];
  1293.     fprintf(stderr, ">");
  1294.     fgets(s,79,stdin);
  1295.     printf("%s -> %s\n", s, analyse_string(s, &dummy, &dummy));
  1296.   } else {
  1297.     if (argc != 2) {
  1298.       fprintf(stderr, "USAGE: %s <query>\n", argv[0]);
  1299.       exit(1);
  1300.     }
  1301.     printf("%s -> %s\n", argv[1], analyse_string(argv[1], &dummy, &dummy));
  1302.   }
  1303.   exit(0);
  1304. }
  1305. #endif
  1306.