00001 // File: $Id$ 00002 // Author: John Wu <John.Wu at nersc.gov> 00003 // Lawrence Berkeley National Laboratory 00004 // Copyright 1998-2008 the Regents of the University of California 00005 #ifndef IBIS_PREDICATE_H 00006 #define IBIS_PREDICATE_H 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 #include "qExpr.h" 00021 00022 #include <stdio.h> // BUFSIZ 00023 #include <stack> 00024 #include <deque> 00025 #include <vector> 00026 00027 int yylex(); 00028 int yyparse(); 00029 void yyerror(const char *s); 00030 void yyparse_cleanup(); 00031 namespace ibis { 00033 qExpr* parseQuery(const char* str); 00034 } 00035 00036 extern std::vector<char*> parse_str_vec; 00037 extern char *parse_string; 00038 extern int parse_length, parse_offset; 00039 00040 #if defined(YYBISON) || defined(FLEX_SCANNER) 00041 // FLEX is instructed to use pointer instead of array 00042 extern char *yytext; 00043 #define YY_INPUT(buf,result,max_size) {\ 00044 if (parse_offset <= parse_length) {\ 00045 buf[0] = parse_string[parse_offset++];\ 00046 result = 1;}\ 00047 else {result = YY_NULL;}} 00048 00049 #else 00050 // on solaris machines, the lex/yacc uses array 00051 # define YYLMAX BUFSIZ 00052 extern char yytext[YYLMAX]; 00053 int yywrap(); 00054 00055 // Overwrite the default lex_input that reads from file. This version uses 00056 // the string stored in global variable parse_string. 00057 inline int lex_input() { 00058 if (parse_offset <= parse_length) { 00059 return parse_string[parse_offset++]; 00060 } 00061 else { 00062 yyerror("attempt to move beyond EOS"); 00063 return 0; 00064 } 00065 } 00066 00067 inline void unput(int){ 00068 if (parse_offset > 0) --parse_offset; 00069 else yyerror("attempt to move before BOS"); 00070 } 00071 #endif 00072 #endif // IBIS_PREDICATE_H
![]() |