00001 /* This file is part of the YAZ toolkit. 00002 * Copyright (C) 1995-2010 Index Data. 00003 * All rights reserved. 00004 * Redistribution and use in source and binary forms, with or without 00005 * modification, are permitted provided that the following conditions are met: 00006 * 00007 * * Redistributions of source code must retain the above copyright 00008 * notice, this list of conditions and the following disclaimer. 00009 * * Redistributions in binary form must reproduce the above copyright 00010 * notice, this list of conditions and the following disclaimer in the 00011 * documentation and/or other materials provided with the distribution. 00012 * * Neither the name of Index Data nor the names of its contributors 00013 * may be used to endorse or promote products derived from this 00014 * software without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY 00017 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00018 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00019 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY 00020 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00021 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00022 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00023 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00024 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00025 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 */ 00027 00032 #include <yaz/ccl.h> 00033 00034 #define CCL_TOK_EOL 0 00035 #define CCL_TOK_TERM 1 00036 #define CCL_TOK_REL 2 00037 #define CCL_TOK_EQ 3 00038 #define CCL_TOK_PROX 4 00039 #define CCL_TOK_LP 5 00040 #define CCL_TOK_RP 6 00041 #define CCL_TOK_COMMA 7 00042 #define CCL_TOK_AND 8 00043 #define CCL_TOK_OR 9 00044 #define CCL_TOK_NOT 10 00045 #define CCL_TOK_SET 11 00046 00047 typedef struct ccl_qualifier *ccl_qualifier_t; 00048 00050 struct ccl_token { 00051 char kind; 00052 size_t len; /* length of name below */ 00053 const char *name; /* string / name of token */ 00054 struct ccl_token *next; 00055 struct ccl_token *prev; 00056 const char *ws_prefix_buf; /* leading white space buf */ 00057 size_t ws_prefix_len; /* leading white space len */ 00058 int left_trunc; /* left truncated */ 00059 int right_trunc; /* right truncated */ 00060 }; 00061 00063 struct ccl_parser { 00065 struct ccl_token *look_token; 00066 00068 int error_code; 00070 const char *start_pos; 00072 const char *error_pos; 00073 00075 CCL_bibset bibset; 00076 00078 const char **ccl_token_and; 00080 const char **ccl_token_or; 00082 const char **ccl_token_not; 00084 const char **ccl_token_set; 00086 int ccl_case_sensitive; 00087 }; 00088 00093 YAZ_EXPORT 00094 struct ccl_token *ccl_parser_tokenize (CCL_parser cclp, const char *command); 00095 00099 YAZ_EXPORT 00100 void ccl_token_del (struct ccl_token *list); 00101 00105 YAZ_EXPORT 00106 struct ccl_token *ccl_token_add (struct ccl_token *at); 00107 00108 00109 YAZ_EXPORT 00110 struct ccl_rpn_node *ccl_parser_find_token(CCL_parser cclp, 00111 struct ccl_token *list); 00112 00113 00114 YAZ_EXPORT 00115 ccl_qualifier_t ccl_qual_search(CCL_parser cclp, const char *name, 00116 size_t name_len, int seq); 00117 00118 YAZ_EXPORT 00119 struct ccl_rpn_attr *ccl_qual_get_attr(ccl_qualifier_t q); 00120 00121 YAZ_EXPORT 00122 const char *ccl_qual_get_name(ccl_qualifier_t q); 00123 00124 /* 00125 * Local variables: 00126 * c-basic-offset: 4 00127 * c-file-style: "Stroustrup" 00128 * indent-tabs-mode: nil 00129 * End: 00130 * vim: shiftwidth=4 tabstop=8 expandtab 00131 */ 00132
1.6.3