- for (i = 0; i<lookahead->len; i++)
- if (truncation_value == -1 && lookahead->name[i] == '?')
- {
- if (no == 0 && i == 0 && lookahead->len >= 1)
- left_trunc = 1;
- else if (!is_term_ok(lookahead->next->kind, term_list) &&
- i == lookahead->len-1 && i >= 1)
- right_trunc = 1;
- else
- mid_trunc = 1;
- }
- len += 1+lookahead->len;
- lookahead = lookahead->next;
- }
- /* len now holds the number of characters in the RPN term */
- /* no holds the number of CCL tokens (1 or more) */
-
- if (structure_value == -1 &&
- qual_val_type (qa, CCL_BIB1_STR, CCL_BIB1_STR_WP))
- { /* no structure attribute met. Apply either structure attribute
- WORD or PHRASE depending on number of CCL tokens */
- if (no == 1)
- add_attr (p, CCL_BIB1_STR, 2);
+ struct ccl_rpn_node *p;
+ size_t no, i;
+ int no_spaces = 0;
+ int left_trunc = 0;
+ int right_trunc = 0;
+ int mid_trunc = 0;
+ int relation_value = -1;
+ int position_value = -1;
+ int structure_value = -1;
+ int truncation_value = -1;
+ int completeness_value = -1;
+ int len = 0;
+ size_t max = 200;
+ if (and_list || or_list || !multi)
+ max = 1;
+
+ /* ignore commas when dealing with and-lists .. */
+ if (and_list && lookahead && lookahead->kind == CCL_TOK_COMMA)
+ {
+ lookahead = lookahead->next;
+ ADVANCE;
+ continue;
+ }
+ /* go through each TERM token. If no truncation attribute is yet
+ met, then look for left/right truncation markers (?) and
+ set left_trunc/right_trunc/mid_trunc accordingly */
+ for (no = 0; no < max && is_term_ok(lookahead->kind, term_list); no++)
+ {
+ for (i = 0; i<lookahead->len; i++)
+ if (lookahead->name[i] == ' ')
+ no_spaces++;
+ else if (strchr(truncation_aliases, lookahead->name[i]))
+ {
+ if (no == 0 && i == 0 && lookahead->len >= 1)
+ left_trunc = 1;
+ else if (!is_term_ok(lookahead->next->kind, term_list) &&
+ i == lookahead->len-1 && i >= 1)
+ right_trunc = 1;
+ else
+ mid_trunc = 1;
+ }
+ len += 1+lookahead->len;
+ lookahead = lookahead->next;
+ }
+
+ if (len == 0)
+ break; /* no more terms . stop . */
+
+
+ if (p_top)
+ {
+ if (or_list)
+ p = mk_node (CCL_RPN_OR);
+ else if (and_list)
+ p = mk_node (CCL_RPN_AND);
+ else
+ p = mk_node (CCL_RPN_AND);
+ p->u.p[0] = p_top;
+ p_top = p;
+ }
+
+ /* create the term node, but wait a moment before adding the term */
+ p = mk_node (CCL_RPN_TERM);
+ p->u.t.attr_list = NULL;
+ p->u.t.term = NULL;
+
+ /* make the top node point to us.. */
+ if (p_top)
+ p_top->u.p[1] = p;