/* This file is part of the Zebra server.
- Copyright (C) 1994-2011 Index Data
+ Copyright (C) 2004-2013 Index Data
Zebra is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <stdio.h>
#include <assert.h>
BSet charset);
static void term_Tnode (struct DFA_parse *parse_info);
-static void
- del_followpos (struct DFA_parse *parse_info),
- init_pos (struct DFA_parse *parse_info),
+static void
+ del_followpos (struct DFA_parse *parse_info),
+ init_pos (struct DFA_parse *parse_info),
del_pos (struct DFA_parse *parse_info),
mk_dfa_tran (struct DFA_parse *parse_info, struct DFA_states *dfas),
add_follow (struct DFA_parse *parse_info, DFASet lastpos, DFASet firstpos),
nextchar (struct DFA_parse *parse_info, int *esc),
read_charset (struct DFA_parse *parse_info);
-static const char
+static const char
*str_char (unsigned c);
#define L_LP 1
*expr_4 (struct DFA_parse *parse_info);
static struct Tnode *expr_1 (struct DFA_parse *parse_info)
-{
+{
struct Tnode *t1, *t2, *tn;
if (!(t1 = expr_2 (parse_info)))
lex (parse_info);
if (!(t2 = expr_2 (parse_info)))
return t2;
-
+
tn = mk_Tnode (parse_info);
tn->pos = OR;
tn->u.p[0] = t1;
static struct Tnode *expr_2 (struct DFA_parse *parse_info)
{
struct Tnode *t1, *t2, *tn;
-
+
if (!(t1 = expr_3 (parse_info)))
return t1;
while (parse_info->lookahead == L_WILD ||
{
if (!(t2 = expr_3 (parse_info)))
return t2;
-
+
tn = mk_Tnode (parse_info);
tn->pos = CAT;
tn->u.p[0] = t1;
t2 = mk_Tnode (parse_info);
t2->pos = ++parse_info->position;
t2->u.ch[1] = t2->u.ch[0] = '\n';
-
+
tn = mk_Tnode (parse_info);
tn->pos = CAT;
tn->u.p[0] = t1;
tn->u.p[1] = t2;
t1 = tn;
-
+
lex (parse_info);
}
}
t2->pos = ++parse_info->position;
t2->u.ch[0] = -(++parse_info->rule);
t2->u.ch[1] = start_anchor_flag ? 0 : -(parse_info->rule);
-
+
*tnp = mk_Tnode(parse_info);
(*tnp)->pos = CAT;
(*tnp)->u.p[0] = t1;
ch0 = nextchar_set (parse_info, &esc0);
}
/**
- ch0 is last met character
- ch1 is "next" char
+ ch0 is last met character
+ ch1 is "next" char
*/
while (ch0 != 0)
{
mapto = (*parse_info->cmap) (parse_info->cmap_data, &cp0, len);
assert (mapto);
-
+
parse_info->expr_ptr = (const unsigned char *) cp0;
parse_info->look_ch = ((unsigned char **) mapto)[i][0];
yaz_log (YLOG_DEBUG, "map from %c to %d", parse_info->expr_ptr[-1], parse_info->look_ch);
return map_l_char (parse_info);
else if (parse_info->look_ch == '[')
return read_charset(parse_info);
- else
+ else
{
const int *cc;
for (cc = parse_info->charMap; *cc; cc += 2)
static void init_pos (struct DFA_parse *parse_info)
{
- parse_info->posar = (struct Tnode **) imalloc (sizeof(struct Tnode*)
+ parse_info->posar = (struct Tnode **) imalloc (sizeof(struct Tnode*)
* (1+parse_info->position));
}
{
while (lastpos)
{
- parse_info->followpos[lastpos->value] =
+ parse_info->followpos[lastpos->value] =
union_DFASet (parse_info->poset,
parse_info->followpos[lastpos->value], firstpos);
lastpos = lastpos->next;
- }
+ }
}
static void dfa_trav (struct DFA_parse *parse_info, struct Tnode *n)
{
struct Tnode **posar = parse_info->posar;
DFASetType poset = parse_info->poset;
-
+
switch (n->pos)
{
case CAT:
pos_i = pos;
j = i = 0;
for (tran_set = dfa_from->set; tran_set; tran_set = tran_set->next)
- if ((c = posar[tran_set->value]->u.ch[0]) >= 0 && c <= max_char)
+ if ((c = posar[tran_set->value]->u.ch[0]) >= 0 && c <= max_char)
*pos_i++ = tran_set->value;
else if (c < 0)
{
{
char_0 = max_char+1;
for (pos_i = pos; (i = *pos_i) != -1; ++pos_i)
- if (posar[i]->u.ch[1] >= char_1
+ if (posar[i]->u.ch[1] >= char_1
&& (c=posar[i]->u.ch[0]) < char_0)
{
if (c < char_1)
break;
char_1 = max_char;
-
+
tran_set = mk_DFASet (poset);
for (pos_i = pos; (i = *pos_i) != -1; ++pos_i)
{
{
while ((cc[0] = cc[2]))
{
- cc[1] = cc[3];
+ cc[1] = cc[3];
cc += 2;
}
break;
static struct DFA_parse *dfa_parse_init (void)
{
- struct DFA_parse *parse_info =
+ struct DFA_parse *parse_info =
(struct DFA_parse *) imalloc (sizeof (struct DFA_parse));
parse_info->charset = mk_BSetHandle (255, 20);