Implements CQL parser. More...
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>#include <yaz/xmalloc.h>#include <yaz/nmem.h>#include <yaz/cql.h>Go to the source code of this file.
Data Structures | |
| struct | token |
| struct | cql_parser |
| union | yyalloc |
Defines | |
| #define | YYBISON 1 |
| #define | YYBISON_VERSION "2.4.1" |
| #define | YYSKELETON_NAME "yacc.c" |
| #define | YYPURE 1 |
| #define | YYPUSH 0 |
| #define | YYPULL 1 |
| #define | YYLSP_NEEDED 0 |
| #define | yyparse cql_parse |
| #define | yylex cql_lex |
| #define | yyerror cql_error |
| #define | yylval cql_lval |
| #define | yychar cql_char |
| #define | yydebug cql_debug |
| #define | yynerrs cql_nerrs |
| #define | YYSTYPE token |
| #define | YYPARSE_PARAM parm |
| #define | YYLEX_PARAM parm |
| #define | YYDEBUG 0 |
| #define | YYERROR_VERBOSE 0 |
| #define | YYTOKEN_TABLE 0 |
| #define | YYTOKENTYPE |
| #define | DOTTERM 258 |
| #define | TERM 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 | YYSIZE_T unsigned int |
| #define | YYSIZE_MAXIMUM ((YYSIZE_T) -1) |
| #define | YY_(msgid) msgid |
| #define | YYUSE(e) ((void) (e)) |
| #define | YYID(n) (n) |
| #define | YYSTACK_ALLOC YYMALLOC |
| #define | YYSTACK_FREE YYFREE |
| #define | YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM |
| #define | YYMALLOC malloc |
| #define | YYFREE free |
| #define | YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
| #define | YYSTACK_BYTES(N) |
| #define | YYCOPY(To, From, Count) |
| #define | YYSTACK_RELOCATE(Stack_alloc, Stack) |
| #define | YYFINAL 3 |
| #define | YYLAST 99 |
| #define | YYNTOKENS 20 |
| #define | YYNNTS 22 |
| #define | YYNRULES 55 |
| #define | YYNSTATES 71 |
| #define | YYUNDEFTOK 2 |
| #define | YYMAXUTOK 268 |
| #define | YYTRANSLATE(YYX) ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| #define | YYPACT_NINF -52 |
| #define | YYTABLE_NINF -49 |
| #define | yyerrok (yyerrstatus = 0) |
| #define | yyclearin (yychar = YYEMPTY) |
| #define | YYEMPTY (-2) |
| #define | YYEOF 0 |
| #define | YYACCEPT goto yyacceptlab |
| #define | YYABORT goto yyabortlab |
| #define | YYERROR goto yyerrorlab |
| #define | YYFAIL goto yyerrlab |
| #define | YYRECOVERING() (!!yyerrstatus) |
| #define | YYBACKUP(Token, Value) |
| #define | YYTERROR 1 |
| #define | YYERRCODE 256 |
| #define | YYRHSLOC(Rhs, K) ((Rhs)[K]) |
| #define | YYLLOC_DEFAULT(Current, Rhs, N) |
| #define | YY_LOCATION_PRINT(File, Loc) ((void) 0) |
| #define | YYLEX yylex (&yylval, YYLEX_PARAM) |
| #define | YYDPRINTF(Args) |
| #define | YY_SYMBOL_PRINT(Title, Type, 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 unsigned char | yytype_uint8 |
| typedef short int | yytype_int8 |
| typedef unsigned short int | yytype_uint16 |
| typedef short int | yytype_int16 |
Enumerations | |
| enum | yytokentype { DOTTERM = 258, TERM = 259, AND = 260, OR = 261, NOT = 262, PROX = 263, GE = 264, LE = 265, NE = 266, EXACT = 267, SORTBY = 268, DOTTERM = 258, TERM = 259, AND = 260, OR = 261, NOT = 262, PROX = 263, GE = 264, LE = 265, NE = 266, EXACT = 267, SORTBY = 268, GE = 258, LE = 259, NE = 260, AND = 261, OR = 262, NOT = 263, PROX = 264, CHARSTRING1 = 265, CHARSTRING2 = 266, SORTBY = 267 } |
Functions | |
| int | yylex (YYSTYPE *lval, void *vp) |
| int | yyerror (char *s) |
| static void | yydestruct (char *yymsg, int yytype, YYSTYPE *yyvaluep) const |
| int | yyparse () |
| int | yyparse (void *YYPARSE_PARAM) |
| 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) | |
| CQL_parser | cql_parser_create (void) |
| creates a CQL parser. | |
| void | cql_parser_destroy (CQL_parser cp) |
| destroys a CQL parser. | |
| struct cql_node * | cql_parser_result (CQL_parser cp) |
| returns the parse tree of the most recently parsed CQL query. | |
Variables | |
| static const yytype_uint8 | yytranslate [] |
| static const yytype_uint8 | yyr1 [] |
| static const yytype_uint8 | yyr2 [] |
| static const yytype_uint8 | yydefact [] |
| static const yytype_int8 | yydefgoto [] |
| static const yytype_int8 | yypact [] |
| static const yytype_int8 | yypgoto [] |
| static const yytype_int8 | yytable [] |
| static const yytype_int8 | yycheck [] |
| static const yytype_uint8 | yystos [] |
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_STACK_PRINT | ( | Bottom, | |||
| Top | ) |
| #define YY_SYMBOL_PRINT | ( | Title, | |||
| Type, | |||||
| Value, | |||||
| Location | ) |
Definition at line 894 of file cql.c.
Referenced by yydestruct(), and yyparse().
| #define YYBACKUP | ( | Token, | |||
| Value | ) |
| #define YYCOPY | ( | To, | |||
| From, | |||||
| Count | ) |
| #define YYLEX yylex (&yylval, YYLEX_PARAM) |
| #define YYLLOC_DEFAULT | ( | Current, | |||
| Rhs, | |||||
| N | ) |
do \ if (YYID (N)) \ { \ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ } \ else \ { \ (Current).first_line = (Current).last_line = \ YYRHSLOC (Rhs, 0).last_line; \ (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ } \ while (YYID (0))
| #define YYPOPSTACK | ( | N | ) | (yyvsp -= (N), yyssp -= (N)) |
Referenced by yyparse().
| #define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM |
| #define YYSTACK_BYTES | ( | N | ) |
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM)
Definition at line 370 of file cql.c.
Referenced by yyparse().
| #define YYSTACK_RELOCATE | ( | Stack_alloc, | |||
| Stack | ) |
do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (YYID (0))
Definition at line 397 of file cql.c.
Referenced by yyparse().
| #define YYTRANSLATE | ( | YYX | ) | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| #define YYUSE | ( | e | ) | ((void) (e)) |
Definition at line 261 of file cql.c.
Referenced by yydestruct().
| typedef short int yytype_int16 |
| typedef short int yytype_int8 |
| typedef unsigned short int yytype_uint16 |
| typedef unsigned char yytype_uint8 |
| enum yytokentype |
| CQL_parser cql_parser_create | ( | void | ) |
| void cql_parser_destroy | ( | CQL_parser | cp | ) |
| struct cql_node* cql_parser_result | ( | CQL_parser | cp | ) | [read] |
| 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 2037 of file cql.c.
Referenced by cql_parser_stdio(), and cql_parser_string().
| static void putb | ( | YYSTYPE * | lval, | |
| CQL_parser | cp, | |||
| int | c | |||
| ) | [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 1881 of file cql.c.
References cql_parser::nmem, and nmem_malloc().
Referenced by yylex().
| static void yydestruct | ( | char * | yymsg, | |
| int | yytype, | |||
| YYSTYPE * | yyvaluep | |||
| ) | const [static] |
Definition at line 1140 of file cql.c.
References YY_SYMBOL_PRINT, and YYUSE.
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 1900 of file cql.c.
References AND, cql_parser::client_data, cql_strcmp(), DOTTERM, EXACT, GE, cql_parser::getbyte, LE, NE, cql_parser::nmem, nmem_malloc(), NOT, OR, PROX, putb(), SORTBY, TERM, and cql_parser::ungetbyte.
| int yyparse | ( | void * | YYPARSE_PARAM | ) |
Definition at line 1190 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(), nmem_strdup(), cql_node::st, cql_node::u, YY_, YY_REDUCE_PRINT, YY_STACK_PRINT, YY_SYMBOL_PRINT, YYABORT, YYACCEPT, yydestruct(), YYDPRINTF, YYEMPTY, YYEOF, yyerror, YYFINAL, YYID, YYINITDEPTH, YYLAST, YYLEX, yylval, YYMAXDEPTH, yynerrs, YYNTOKENS, YYPACT_NINF, YYPOPSTACK, YYSIZE_T, yyalloc::yyss_alloc, YYSTACK_ALLOC, YYSTACK_ALLOC_MAXIMUM, YYSTACK_BYTES, YYSTACK_FREE, YYSTACK_RELOCATE, YYSTYPE, YYTABLE_NINF, YYTERROR, YYTRANSLATE, and yyalloc::yyvs_alloc.
| int yyparse | ( | ) |
Definition at line 1179 of file cql.tab.c.
References cql_node::boolean, cql_apply_prefix(), cql_node_destroy(), cql_node_dup(), cql_node_mk_boolean(), cql_node_mk_sc(), nmem_strdup(), cql_node::st, cql_node::u, YY_, YY_REDUCE_PRINT, YY_STACK_PRINT, YY_SYMBOL_PRINT, YYABORT, YYACCEPT, yydestruct(), YYDPRINTF, YYEMPTY, YYEOF, yyerror, YYFINAL, YYID, YYINITDEPTH, YYLAST, YYLEX, yylval, YYMAXDEPTH, yynerrs, YYNTOKENS, YYPACT_NINF, YYPOPSTACK, YYSIZE_T, yyalloc::yyss_alloc, YYSTACK_ALLOC, YYSTACK_ALLOC_MAXIMUM, YYSTACK_BYTES, YYSTACK_FREE, YYSTACK_RELOCATE, YYSTYPE, YYTABLE_NINF, YYTERROR, YYTRANSLATE, and yyalloc::yyvs_alloc.
const yytype_int8 yycheck[] [static] |
{
11, 20, 37, 21, 55, 56, 3, 0, 1, 44,
21, 0, 9, 10, 11, 12, 15, 14, 15, 13,
13, 40, 19, 4, 42, 17, 42, 18, 39, -1,
-1, 42, -1, 3, 5, 6, 7, 8, 57, 9,
10, 11, 12, 54, 14, 15, -1, -1, -1, 19,
3, 4, 5, 6, 7, 8, -1, -1, 69, -1,
13, 14, -1, 16, 3, 4, 5, 6, 7, 8,
-1, -1, -1, -1, 13, -1, -1, 16, 3, 4,
5, 6, 7, 8, -1, -1, -1, -1, 13, 9,
10, 11, 12, -1, 14, 15, -1, -1, -1, 19
}
const yytype_uint8 yydefact[] [static] |
{
2, 0, 0, 1, 50, 49, 51, 52, 53, 54,
55, 0, 19, 4, 0, 11, 16, 0, 25, 14,
0, 0, 3, 10, 26, 27, 28, 29, 32, 47,
43, 44, 45, 46, 41, 40, 42, 32, 21, 0,
0, 0, 5, 7, 32, 48, 17, 22, 24, 12,
15, 20, 6, 8, 0, 0, 0, 0, 30, 18,
23, 13, 36, 37, 38, 39, 34, 33, 35, 0,
31
}
const yytype_int8 yydefgoto[] [static] |
const yytype_int8 yypact[] [static] |
{
-52, 11, 47, -52, -52, -52, -52, -52, -52, -52,
-52, 75, -52, 6, 7, 29, -52, 3, 30, 1,
47, 75, -52, -52, -52, -52, -52, -52, -52, -52,
-52, -52, -52, -52, -52, -52, -52, -52, 19, 75,
47, 8, 75, -52, -52, -52, 9, 9, -52, -52,
-52, -52, -52, 9, 75, 61, 61, 47, 80, -52,
-52, -52, -52, -52, -52, -52, -52, -52, -52, 75,
-52
}
const yytype_int8 yypgoto[] [static] |
const yytype_uint8 yyr1[] [static] |
const yytype_uint8 yyr2[] [static] |
const yytype_uint8 yystos[] [static] |
{
0, 21, 22, 0, 3, 4, 5, 6, 7, 8,
13, 14, 16, 26, 27, 30, 32, 40, 41, 41,
33, 13, 23, 1, 5, 6, 7, 8, 36, 3,
9, 10, 11, 12, 14, 15, 19, 39, 35, 15,
29, 27, 24, 25, 40, 41, 37, 37, 4, 41,
27, 17, 25, 37, 18, 31, 34, 28, 41, 32,
32, 27, 9, 10, 11, 12, 14, 15, 19, 38,
41
}
const yytype_int8 yytable[] [static] |
{
19, 41, 47, 44, 59, 60, 29, -9, 23, 53,
45, 3, 30, 31, 32, 33, 39, 34, 35, 21,
-9, 50, 36, 48, 44, 51, 52, 54, 49, 0,
0, 45, 0, -48, 24, 25, 26, 27, 61, -48,
-48, -48, -48, 58, -48, -48, 0, 0, 0, -48,
4, 5, 6, 7, 8, 9, 0, 0, 70, 0,
10, 11, 0, 12, 4, 5, 6, 7, 8, 9,
0, 0, 0, 0, 10, 0, 0, 12, 4, 5,
6, 7, 8, 9, 0, 0, 0, 0, 10, 62,
63, 64, 65, 0, 66, 67, 0, 0, 0, 68
}
const yytype_uint8 yytranslate[] [static] |
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
16, 17, 2, 2, 2, 2, 2, 18, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
19, 15, 14, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13
}
1.6.3