YAZ
5.34.0
|
Implements CQL parser. More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <yaz/yaz-iconv.h>
#include <yaz/xmalloc.h>
#include <yaz/nmem.h>
#include <yaz/cql.h>
#include <limits.h>
Go to the source code of this file.
Data Structures | |
struct | token |
struct | cql_parser |
union | yyalloc |
Macros | |
#define | YYBISON 30802 |
#define | YYBISON_VERSION "3.8.2" |
#define | YYSKELETON_NAME "yacc.c" |
#define | YYPURE 1 |
#define | YYPUSH 0 |
#define | YYPULL 1 |
#define | yyparse cql_parse |
#define | yylex cql_lex |
#define | yyerror cql_error |
#define | yydebug cql_debug |
#define | yynerrs cql_nerrs |
#define | YYSTYPE token |
#define | YY_CAST(Type, Val) ((Type) (Val)) |
#define | YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) |
#define | YY_NULLPTR ((void*)0) |
#define | YYDEBUG 0 |
#define | YYTOKENTYPE |
#define | YYEMPTY -2 |
#define | YYEOF 0 |
#define | YYerror 256 |
#define | YYUNDEF 257 |
#define | PREFIX_NAME 258 |
#define | SIMPLE_STRING 259 |
#define | AND 260 |
#define | OR 261 |
#define | NOT 262 |
#define | PROX 263 |
#define | GE 264 |
#define | LE 265 |
#define | NE 266 |
#define | EXACT 267 |
#define | SORTBY 268 |
#define | YYPTRDIFF_T long |
#define | YYPTRDIFF_MAXIMUM LONG_MAX |
#define | YYSIZE_T unsigned |
#define | YYSIZE_MAXIMUM |
#define | YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) |
#define | YY_(Msgid) Msgid |
#define | YY_ATTRIBUTE_PURE |
#define | YY_ATTRIBUTE_UNUSED |
#define | YY_USE(E) ((void) (E)) |
#define | YY_INITIAL_VALUE(Value) Value |
#define | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
#define | YY_IGNORE_MAYBE_UNINITIALIZED_END |
#define | YY_IGNORE_USELESS_CAST_BEGIN |
#define | YY_IGNORE_USELESS_CAST_END |
#define | YY_ASSERT(E) ((void) (0 && (E))) |
#define | YYSTACK_ALLOC YYMALLOC |
#define | YYSTACK_FREE YYFREE |
#define | YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM |
#define | YYMALLOC malloc |
#define | YYFREE free |
#define | YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) |
#define | YYSTACK_BYTES(N) |
#define | YYCOPY_NEEDED 1 |
#define | YYSTACK_RELOCATE(Stack_alloc, Stack) |
#define | YYCOPY(Dst, Src, Count) |
#define | YYFINAL 3 |
#define | YYLAST 103 |
#define | YYNTOKENS 20 |
#define | YYNNTS 22 |
#define | YYNRULES 49 |
#define | YYNSTATES 66 |
#define | YYMAXUTOK 268 |
#define | YYTRANSLATE(YYX) |
#define | YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State]) |
#define | YYPACT_NINF (-34) |
#define | yypact_value_is_default(Yyn) ((Yyn) == YYPACT_NINF) |
#define | YYTABLE_NINF (-43) |
#define | yytable_value_is_error(Yyn) 0 |
#define | yyerrok (yyerrstatus = 0) |
#define | yyclearin (yychar = YYEMPTY) |
#define | YYACCEPT goto yyacceptlab |
#define | YYABORT goto yyabortlab |
#define | YYERROR goto yyerrorlab |
#define | YYNOMEM goto yyexhaustedlab |
#define | YYRECOVERING() (!!yyerrstatus) |
#define | YYBACKUP(Token, Value) |
#define | YYERRCODE YYUNDEF |
#define | YYDPRINTF(Args) ((void) 0) |
#define | YY_SYMBOL_PRINT(Title, Kind, Value, Location) |
#define | YY_STACK_PRINT(Bottom, Top) |
#define | YY_REDUCE_PRINT(Rule) |
#define | YYINITDEPTH 200 |
#define | YYMAXDEPTH 10000 |
#define | YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) |
Typedefs | |
typedef enum yytokentype | yytoken_kind_t |
typedef enum yysymbol_kind_t | yysymbol_kind_t |
typedef signed char | yytype_int8 |
typedef short | yytype_int16 |
typedef unsigned char | yytype_uint8 |
typedef unsigned short | yytype_uint16 |
typedef yytype_int8 | yy_state_t |
typedef int | yy_state_fast_t |
Functions | |
int | yylex (YYSTYPE *lval, void *vp) |
int | yyerror (void *lval, char *msg) |
int | cql_parse (void *parm) |
void * | malloc (YYSIZE_T) |
void | free (void *) |
static void | yydestruct (const char *yymsg, yysymbol_kind_t yykind, YYSTYPE *yyvaluep, void *parm) |
int | yyparse (void *parm) |
static void | putb (YYSTYPE *lval, CQL_parser cp, int c) |
int | cql_parser_stream (CQL_parser cp, int(*getbyte)(void *client_data), void(*ungetbyte)(int b, void *client_data), void *client_data) |
parses CQL query (query stream) More... | |
CQL_parser | cql_parser_create (void) |
creates a CQL parser. More... | |
void | cql_parser_destroy (CQL_parser cp) |
destroys a CQL parser. More... | |
struct cql_node * | cql_parser_result (CQL_parser cp) |
returns the parse tree of the most recently parsed CQL query. More... | |
void | cql_parser_strict (CQL_parser cp, int mode) |
configures strict mode More... | |
Variables | |
static const yytype_int8 | yytranslate [] |
static const yytype_int8 | yypact [] |
static const yytype_int8 | yydefact [] |
static const yytype_int8 | yypgoto [] |
static const yytype_int8 | yydefgoto [] |
static const yytype_int8 | yytable [] |
static const yytype_int8 | yycheck [] |
static const yytype_int8 | yystos [] |
static const yytype_int8 | yyr1 [] |
static const yytype_int8 | yyr2 [] |
Implements CQL parser.
This is a YACC parser, but since it must be reentrant, Bison is required. The original source file is cql.y.
Definition in file cql.c.
#define YY_ACCESSING_SYMBOL | ( | State | ) | YY_CAST (yysymbol_kind_t, yystos[State]) |
#define YYBACKUP | ( | Token, | |
Value | |||
) |
#define YYCOPY | ( | Dst, | |
Src, | |||
Count | |||
) |
#define yypact_value_is_default | ( | Yyn | ) | ((Yyn) == YYPACT_NINF) |
#define YYPOPSTACK | ( | N | ) | (yyvsp -= (N), yyssp -= (N)) |
#define YYSIZE_MAXIMUM |
#define YYSIZEOF | ( | X | ) | YY_CAST (YYPTRDIFF_T, sizeof (X)) |
#define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM |
#define YYSTACK_BYTES | ( | N | ) |
#define YYSTACK_RELOCATE | ( | Stack_alloc, | |
Stack | |||
) |
#define YYTRANSLATE | ( | YYX | ) |
typedef int yy_state_fast_t |
typedef yytype_int8 yy_state_t |
typedef enum yysymbol_kind_t yysymbol_kind_t |
typedef enum yytokentype yytoken_kind_t |
typedef short yytype_int16 |
typedef signed char yytype_int8 |
typedef unsigned short yytype_uint16 |
typedef unsigned char yytype_uint8 |
enum yysymbol_kind_t |
enum yytokentype |
int cql_parse | ( | void * | parm | ) |
Referenced by cql_parser_stream().
CQL_parser cql_parser_create | ( | void | ) |
creates a CQL parser.
Returns CQL parser or NULL if parser could not be created.
Definition at line 1880 of file cql.c.
References cql_parser::client_data, cql_parser::getbyte, cql_parser::last_error, cql_parser::last_pos, cql_parser::nmem, nmem_create(), cql_parser::strict, cql_parser::top, cql_parser::ungetbyte, and xmalloc.
Referenced by cql2pqf().
void cql_parser_destroy | ( | CQL_parser | cp | ) |
destroys a CQL parser.
cp | CQL parser |
This function does nothing if NULL if received.
Definition at line 1895 of file cql.c.
References cql_node_destroy(), cql_parser::nmem, nmem_destroy(), cql_parser::top, and xfree.
Referenced by cql2pqf().
struct cql_node* cql_parser_result | ( | CQL_parser | cp | ) |
returns the parse tree of the most recently parsed CQL query.
cp | CQL parser |
Definition at line 1902 of file cql.c.
References cql_parser::top.
Referenced by cql2pqf().
int cql_parser_stream | ( | CQL_parser | cp, |
int(*)(void *client_data) | getbyte, | ||
void(*)(int b, void *client_data) | ungetbyte, | ||
void * | client_data | ||
) |
parses CQL query (query stream)
cp | CQL parser |
getbyte | function which reads one character from stream |
ungetbyte | function which unreads one character from stream |
client_data | data to be passed to stream functions |
0 | success |
!=0 | failure |
This function is similar to cql_parser_string but takes a functions to read each query character from a stream.
The functions pointers getbytes, ungetbyte are similar to that known from stdios getc, ungetc.
Definition at line 1864 of file cql.c.
References cql_parser::client_data, cql_node_destroy(), cql_parse(), cql_parser::getbyte, cql_parser::nmem, nmem_reset(), cql_parser::top, and cql_parser::ungetbyte.
Referenced by cql_parser_stdio(), and cql_parser_string().
void cql_parser_strict | ( | CQL_parser | cp, |
int | mode | ||
) |
configures strict mode
cp | CQL parser |
mode | 1=enable strict mode, 0=disable strict mode |
This function is similar to cql_parser_string but reads from stdio FILE handle instead.
Definition at line 1907 of file cql.c.
References cql_parser::strict.
void free | ( | void * | ) |
void* malloc | ( | YYSIZE_T | ) |
Referenced by create_s(), define_module_bit(), sb_stemmer_new(), stem_file(), yaz_cond_create(), yaz_mutex_create(), and yaz_mutex_set_name().
|
static |
putb is a utility that puts one character to the string in current lexical token. This routine deallocates as necessary using NMEM.
Definition at line 1704 of file cql.c.
References cql_parser::nmem, and nmem_malloc().
Referenced by yylex().
|
static |
Definition at line 993 of file cql.c.
References YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN, YY_IGNORE_MAYBE_UNINITIALIZED_END, YY_SYMBOL_PRINT, and YY_USE.
Referenced by yyparse().
int yylex | ( | YYSTYPE * | lval, |
void * | vp | ||
) |
yylex returns next token for Bison to be read. In this case one of the CQL terminals are returned.
Definition at line 1723 of file cql.c.
References AND, cql_parser::client_data, cql_strcmp(), EXACT, GE, cql_parser::getbyte, LE, NE, cql_parser::nmem, nmem_malloc(), NOT, OR, PREFIX_NAME, PROX, putb(), SIMPLE_STRING, SORTBY, cql_parser::strict, cql_parser::ungetbyte, and yaz_isspace.
int yyparse | ( | void * | parm | ) |
Definition at line 1017 of file cql.c.
References cql_node::boolean, cql_apply_prefix(), cql_node_destroy(), cql_node_dup(), cql_node_mk_boolean(), cql_node_mk_sc(), cql_node_mk_sort(), nmem_strdup(), cql_node::st, cql_node::u, YY_, YY_ACCESSING_SYMBOL, YY_ASSERT, YY_CAST, YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN, YY_IGNORE_MAYBE_UNINITIALIZED_END, YY_IGNORE_USELESS_CAST_BEGIN, YY_IGNORE_USELESS_CAST_END, YY_INITIAL_VALUE, YY_REDUCE_PRINT, YY_STACK_PRINT, YY_SYMBOL_PRINT, YYABORT, YYACCEPT, yycheck, yydefact, yydefgoto, yydestruct(), YYDPRINTF, YYEMPTY, YYEOF, yyerror, YYerror, YYERROR, YYFINAL, YYINITDEPTH, YYLAST, yylex, YYMAXDEPTH, yynerrs, YYNOMEM, YYNSTATES, YYNTOKENS, yypact, yypact_value_is_default, yypgoto, YYPOPSTACK, YYPTRDIFF_T, yyr1, yyr2, YYSIZE_T, YYSIZEOF, yyalloc::yyss_alloc, YYSTACK_ALLOC, YYSTACK_BYTES, YYSTACK_FREE, YYSTACK_RELOCATE, YYSTYPE, YYSYMBOL_YYEMPTY, YYSYMBOL_YYEOF, YYSYMBOL_YYerror, yytable, yytable_value_is_error, YYTRANSLATE, YYUNDEF, and yyalloc::yyvs_alloc.
|
static |
Definition at line 755 of file cql.c.
Referenced by yyparse().
|
static |
Definition at line 710 of file cql.c.
Referenced by yyparse().
|
static |
|
static |
Definition at line 696 of file cql.c.
Referenced by yyparse().
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 740 of file cql.c.
Referenced by yyparse().
|
static |