version 1.1.2.6, 2001/12/02 20:36:49
|
version 1.1.2.12, 2001/12/12 17:45:53
|
|
|
| |
/* A Bison parser, made from wql.y |
/* A Bison parser, made from wql.y with Bison version GNU Bison version 1.24 |
by GNU Bison version 1.28 */ |
*/ |
| |
#define YYBISON 1 /* Identify Bison output. */ | #define YYBISON 1 /* Identify Bison output. */ |
| |
|
|
#define yychar WQL_char | #define yychar WQL_char |
#define yydebug WQL_debug | #define yydebug WQL_debug |
#define yynerrs WQL_nerrs | #define yynerrs WQL_nerrs |
#define TOK_INTEGER 257 |
#define TOK_INTEGER 258 |
#define TOK_DOUBLE 258 |
#define TOK_DOUBLE 259 |
#define TOK_STRING 259 |
#define TOK_STRING 260 |
#define TOK_TRUE 260 |
#define TOK_TRUE 261 |
#define TOK_FALSE 261 |
#define TOK_FALSE 262 |
#define TOK_NULL 262 |
#define TOK_NULL 263 |
#define TOK_EQ 263 |
#define TOK_EQ 264 |
#define TOK_NE 264 |
#define TOK_NE 265 |
#define TOK_LT 265 |
#define TOK_LT 266 |
#define TOK_LE 266 |
#define TOK_LE 267 |
#define TOK_GT 267 |
#define TOK_GT 268 |
#define TOK_GE 268 |
#define TOK_GE 269 |
#define TOK_NOT 269 |
#define TOK_NOT 270 |
#define TOK_OR 270 |
#define TOK_OR 271 |
#define TOK_AND 271 |
#define TOK_AND 272 |
#define TOK_IS 272 |
#define TOK_IS 273 |
#define TOK_IDENTIFIER 273 |
#define TOK_IDENTIFIER 274 |
#define TOK_SELECT 274 |
#define TOK_SELECT 275 |
#define TOK_WHERE 275 |
#define TOK_WHERE 276 |
#define TOK_FROM 276 |
#define TOK_FROM 277 |
#define TOK_UNEXPECTED_CHAR 277 |
#define TOK_UNEXPECTED_CHAR 278 |
| |
#line 9 "wql.y" | #line 9 "wql.y" |
| |
|
|
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
#include <Pegasus/WQL/WQLOperation.h> | #include <Pegasus/WQL/WQLOperation.h> |
#include <Pegasus/WQL/WQLOperand.h> | #include <Pegasus/WQL/WQLOperand.h> |
|
#include <Pegasus/WQL/WQLParserState.h> |
#include <Pegasus/WQL/WQLSelectStatement.h> | #include <Pegasus/WQL/WQLSelectStatement.h> |
#include <string.h> | #include <string.h> |
#include <stdlib.h> | #include <stdlib.h> |
|
|
# include <alloca.h> | # include <alloca.h> |
#endif | #endif |
| |
#if 1 |
#if 0 |
# define WQL_TRACE(X) printf(X) |
# define WQL_TRACE(X) printf X |
#else | #else |
# define WQL_TRACE(X) | # define WQL_TRACE(X) |
#endif | #endif |
|
|
extern int WQL_lex(); | extern int WQL_lex(); |
extern int WQL_error(char*); | extern int WQL_error(char*); |
| |
|
// |
|
// Define the global parser state object: |
|
// |
|
|
|
PEGASUS_USING_PEGASUS; |
|
|
|
PEGASUS_NAMESPACE_BEGIN |
|
|
|
extern WQLParserState* globalParserState; |
|
|
|
PEGASUS_NAMESPACE_END |
|
|
| |
#line 45 "wql.y" |
#line 58 "wql.y" |
typedef union | typedef union |
{ | { |
int intValue; | int intValue; |
|
|
char* strValue; | char* strValue; |
void* nodeValue; | void* nodeValue; |
} YYSTYPE; | } YYSTYPE; |
|
|
|
#ifndef YYLTYPE |
|
typedef |
|
struct yyltype |
|
{ |
|
int timestamp; |
|
int first_line; |
|
int first_column; |
|
int last_line; |
|
int last_column; |
|
char *text; |
|
} |
|
yyltype; |
|
|
|
#define YYLTYPE yyltype |
|
#endif |
|
|
#include <stdio.h> | #include <stdio.h> |
| |
#ifndef __cplusplus | #ifndef __cplusplus |
|
|
#define YYFLAG -32768 | #define YYFLAG -32768 |
#define YYNTBASE 28 | #define YYNTBASE 28 |
| |
#define YYTRANSLATE(x) ((unsigned)(x) <= 277 ? yytranslate[x] : 43) |
#define YYTRANSLATE(x) ((unsigned)(x) <= 278 ? yytranslate[x] : 43) |
| |
static const char yytranslate[] = { 0, | static const char yytranslate[] = { 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, 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, 3, 4, 5, 6, |
2, 2, 2, 2, 2, 1, 2, 3, 4, 5, |
7, 8, 9, 10, 11, 12, 13, 14, 15, 16, |
6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
17, 18, 19, 20, 21, 22, 23 |
16, 17, 18, 19, 20, 21, 22, 23 |
}; | }; |
| |
#if YYDEBUG != 0 | #if YYDEBUG != 0 |
|
|
| |
#if YYDEBUG != 0 | #if YYDEBUG != 0 |
static const short yyrline[] = { 0, | static const short yyrline[] = { 0, |
116, 122, 128, 132, 138, 142, 148, 152, 158, 164, |
130, 136, 142, 146, 152, 156, 162, 166, 172, 179, |
170, 174, 178, 182, 186, 190, 194, 200, 204, 210, |
185, 190, 195, 201, 205, 209, 214, 223, 227, 233, |
214, 218, 222, 226, 230, 236, 240, 246, 250, 256, |
238, 243, 248, 253, 258, 265, 270, 277, 281, 287, |
261, 267, 271, 275, 279, 283 |
293, 300, 306, 311, 316, 321 |
}; | }; |
#endif |
|
|
|
|
|
#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) |
|
| |
static const char * const yytname[] = { "$","error","$undefined.","TOK_INTEGER", | static const char * const yytname[] = { "$","error","$undefined.","TOK_INTEGER", |
"TOK_DOUBLE","TOK_STRING","TOK_TRUE","TOK_FALSE","TOK_NULL","TOK_EQ","TOK_NE", | "TOK_DOUBLE","TOK_STRING","TOK_TRUE","TOK_FALSE","TOK_NULL","TOK_EQ","TOK_NE", |
|
|
"TOK_SELECT","TOK_WHERE","TOK_FROM","TOK_UNEXPECTED_CHAR","'*'","','","'('", | "TOK_SELECT","TOK_WHERE","TOK_FROM","TOK_UNEXPECTED_CHAR","'*'","','","'('", |
"')'","start","selectStatement","selectList","propertyList","selectExpression", | "')'","start","selectStatement","selectList","propertyList","selectExpression", |
"fromClause","whereClause","searchCondition","predicate","comparisonPredicate", | "fromClause","whereClause","searchCondition","predicate","comparisonPredicate", |
"nullPredicate","truthValue","propertyName","className","comparisonTerm", NULL |
"nullPredicate","truthValue","propertyName","className","comparisonTerm","" |
}; | }; |
#endif | #endif |
| |
|
|
switch (yyn) { | switch (yyn) { |
| |
case 1: | case 1: |
#line 117 "wql.y" |
#line 131 "wql.y" |
{ | { |
printf("YACC: start\n"); |
WQL_TRACE(("YACC: start\n")); |
; | ; |
break;} | break;} |
case 2: | case 2: |
#line 123 "wql.y" |
#line 137 "wql.y" |
{ | { |
| |
; | ; |
break;} | break;} |
case 3: | case 3: |
#line 129 "wql.y" |
#line 143 "wql.y" |
{ | { |
|
globalParserState->statement->appendSelectPropertyName("*"); |
; | ; |
break;} | break;} |
case 4: | case 4: |
#line 133 "wql.y" |
#line 147 "wql.y" |
{ | { |
| |
; | ; |
break;} | break;} |
case 5: | case 5: |
#line 139 "wql.y" |
#line 153 "wql.y" |
{ | { |
|
globalParserState->statement->appendSelectPropertyName(yyvsp[0].strValue); |
; | ; |
break;} | break;} |
case 6: | case 6: |
#line 143 "wql.y" |
#line 157 "wql.y" |
{ | { |
|
globalParserState->statement->appendSelectPropertyName(yyvsp[0].strValue); |
; | ; |
break;} | break;} |
case 7: | case 7: |
#line 149 "wql.y" |
#line 163 "wql.y" |
{ | { |
| |
; | ; |
break;} | break;} |
case 8: | case 8: |
#line 153 "wql.y" |
#line 167 "wql.y" |
{ | { |
| |
; | ; |
break;} | break;} |
case 9: | case 9: |
#line 159 "wql.y" |
#line 173 "wql.y" |
{ | { |
|
WQL_TRACE(("YACC: fromClause: TOK_FROM className(%s)\n", yyvsp[0].strValue)); |
|
globalParserState->statement->setClassName(yyvsp[0].strValue); |
; | ; |
break;} | break;} |
case 10: | case 10: |
#line 165 "wql.y" |
#line 180 "wql.y" |
{ | { |
| |
; | ; |
break;} | break;} |
case 11: | case 11: |
#line 171 "wql.y" |
#line 186 "wql.y" |
{ | { |
WQL_TRACE(("YACC: TOK_OR\n")); | WQL_TRACE(("YACC: TOK_OR\n")); |
|
globalParserState->statement->appendOperation(WQL_OR); |
; | ; |
break;} | break;} |
case 12: | case 12: |
#line 175 "wql.y" |
#line 191 "wql.y" |
{ | { |
WQL_TRACE(("YACC: TOK_AND\n")); | WQL_TRACE(("YACC: TOK_AND\n")); |
|
globalParserState->statement->appendOperation(WQL_AND); |
; | ; |
break;} | break;} |
case 13: | case 13: |
#line 179 "wql.y" |
#line 196 "wql.y" |
{ | { |
|
WQL_TRACE(("YACC: TOK_NOT\n")); |
| |
|
globalParserState->statement->appendOperation(WQL_NOT); |
; | ; |
break;} | break;} |
case 14: | case 14: |
#line 183 "wql.y" |
#line 202 "wql.y" |
{ | { |
| |
; | ; |
break;} | break;} |
case 15: | case 15: |
#line 187 "wql.y" |
#line 206 "wql.y" |
{ | { |
| |
; | ; |
break;} | break;} |
case 16: | case 16: |
#line 191 "wql.y" |
#line 210 "wql.y" |
{ | { |
|
WQLOperation op = yyvsp[0].intValue ? WQL_IS_TRUE : WQL_IS_FALSE; |
|
globalParserState->statement->appendOperation(op); |
; | ; |
break;} | break;} |
case 17: | case 17: |
#line 195 "wql.y" |
#line 215 "wql.y" |
{ | { |
|
WQLOperation op = yyvsp[0].intValue ? WQL_IS_NOT_TRUE : WQL_IS_NOT_FALSE; |
|
globalParserState->statement->appendOperation(op); |
; | ; |
break;} | break;} |
case 18: | case 18: |
#line 201 "wql.y" |
#line 224 "wql.y" |
{ | { |
| |
; | ; |
break;} | break;} |
case 19: | case 19: |
#line 205 "wql.y" |
#line 228 "wql.y" |
{ | { |
| |
; | ; |
break;} | break;} |
case 20: | case 20: |
#line 211 "wql.y" |
#line 234 "wql.y" |
{ | { |
WQL_TRACE(("YACC: TOK_LT\n")); | WQL_TRACE(("YACC: TOK_LT\n")); |
|
globalParserState->statement->appendOperation(WQL_LT); |
; | ; |
break;} | break;} |
case 21: | case 21: |
#line 215 "wql.y" |
#line 239 "wql.y" |
{ | { |
WQL_TRACE(("YACC: TOK_GT\n")); | WQL_TRACE(("YACC: TOK_GT\n")); |
|
globalParserState->statement->appendOperation(WQL_GT); |
; | ; |
break;} | break;} |
case 22: | case 22: |
#line 219 "wql.y" |
#line 244 "wql.y" |
{ | { |
WQL_TRACE(("YACC: TOK_LE\n")); | WQL_TRACE(("YACC: TOK_LE\n")); |
|
globalParserState->statement->appendOperation(WQL_LE); |
; | ; |
break;} | break;} |
case 23: | case 23: |
#line 223 "wql.y" |
#line 249 "wql.y" |
{ | { |
WQL_TRACE(("YACC: TOK_GE\n")); | WQL_TRACE(("YACC: TOK_GE\n")); |
|
globalParserState->statement->appendOperation(WQL_GE); |
; | ; |
break;} | break;} |
case 24: | case 24: |
#line 227 "wql.y" |
#line 254 "wql.y" |
{ | { |
WQL_TRACE(("YACC: TOK_EQ\n")); | WQL_TRACE(("YACC: TOK_EQ\n")); |
|
globalParserState->statement->appendOperation(WQL_EQ); |
; | ; |
break;} | break;} |
case 25: | case 25: |
#line 231 "wql.y" |
#line 259 "wql.y" |
{ | { |
WQL_TRACE(("YACC: TOK_NE\n")); | WQL_TRACE(("YACC: TOK_NE\n")); |
|
globalParserState->statement->appendOperation(WQL_NE); |
; | ; |
break;} | break;} |
case 26: | case 26: |
#line 237 "wql.y" |
#line 266 "wql.y" |
{ | { |
WQL_TRACE(("YACC: TOK_IS TOK_NULL\n")); |
WQL_TRACE(("YACC: nullPredicate : comparisonTerm IS NULL\n")); |
|
globalParserState->statement->appendOperation(WQL_IS_NULL); |
; | ; |
break;} | break;} |
case 27: | case 27: |
#line 241 "wql.y" |
#line 271 "wql.y" |
{ | { |
WQL_TRACE(("YACC: TOK_NOT TOK_NULL\n")); |
WQL_TRACE(("YACC: nullPredicate : comparisonTerm IS NOT NULL\n")); |
|
globalParserState->statement->appendOperation(WQL_IS_NOT_NULL); |
; | ; |
break;} | break;} |
case 28: | case 28: |
#line 247 "wql.y" |
#line 278 "wql.y" |
{ | { |
|
yyval.intValue = 1; |
; | ; |
break;} | break;} |
case 29: | case 29: |
#line 251 "wql.y" |
#line 282 "wql.y" |
{ | { |
|
yyval.intValue = 0; |
; | ; |
break;} | break;} |
case 30: | case 30: |
#line 257 "wql.y" |
#line 288 "wql.y" |
{ | { |
|
WQL_TRACE(("YACC: propertyName : TOK_IDENTIFIER(%s)\n", yyvsp[0].strValue)); |
|
yyval.strValue = yyvsp[0].strValue; |
; | ; |
break;} | break;} |
case 31: | case 31: |
#line 262 "wql.y" |
#line 294 "wql.y" |
{ | { |
|
WQL_TRACE(("YACC: TOK_IDENTIFIER %s\n", yyvsp[0].strValue)); |
|
yyval.strValue = yyvsp[0].strValue; |
; | ; |
break;} | break;} |
case 32: | case 32: |
#line 268 "wql.y" |
#line 301 "wql.y" |
{ | { |
|
globalParserState->statement->appendOperand( |
|
WQLOperand(yyvsp[0].strValue, WQL_PROPERTY_NAME_TAG)); |
|
globalParserState->statement->appendWherePropertyName(yyvsp[0].strValue); |
; | ; |
break;} | break;} |
case 33: | case 33: |
#line 272 "wql.y" |
#line 307 "wql.y" |
{ | { |
|
globalParserState->statement->appendOperand( |
|
WQLOperand(yyvsp[0].intValue, WQL_INTEGER_VALUE_TAG)); |
; | ; |
break;} | break;} |
case 34: | case 34: |
#line 276 "wql.y" |
#line 312 "wql.y" |
{ | { |
|
globalParserState->statement->appendOperand( |
|
WQLOperand(yyvsp[0].doubleValue, WQL_DOUBLE_VALUE_TAG)); |
; | ; |
break;} | break;} |
case 35: | case 35: |
#line 280 "wql.y" |
#line 317 "wql.y" |
{ | { |
|
globalParserState->statement->appendOperand( |
|
WQLOperand(yyvsp[0].strValue, WQL_STRING_VALUE_TAG)); |
; | ; |
break;} | break;} |
case 36: | case 36: |
#line 284 "wql.y" |
#line 322 "wql.y" |
{ | { |
|
globalParserState->statement->appendOperand( |
|
WQLOperand(yyvsp[0].intValue != 0, WQL_BOOLEAN_VALUE_TAG)); |
; | ; |
break;} | break;} |
} | } |
|
|
} | } |
return 1; | return 1; |
} | } |
#line 288 "wql.y" |
#line 327 "wql.y" |
|
|
| |
int WQL_error(char* errorMessage) |
|
{ |
|
fprintf(stderr, "WQL_error: %s\n", errorMessage); |
|
return -1; |
|
} |
|