version 1.1.2.1, 2001/11/30 02:53:56
|
version 1.1.2.4, 2001/12/02 07:52:38
|
|
|
# include <alloca.h> | # include <alloca.h> |
#endif | #endif |
| |
|
#if 0 |
|
# define WQL_TRACE(X) printf(X) |
|
#else |
|
# define WQL_TRACE(X) |
|
#endif |
|
|
extern int WQL_lex(); | extern int WQL_lex(); |
extern int WQL_error(char*); | extern int WQL_error(char*); |
| |
|
|
| |
%token <intValue> TOK_INTEGER | %token <intValue> TOK_INTEGER |
%token <doubleValue> TOK_DOUBLE | %token <doubleValue> TOK_DOUBLE |
%token <strValue> STRING_LITERAL |
%token <strValue> TOK_STRING |
%token <intValue> EQ |
%token <intValue> TOK_TRUE |
%token <intValue> NE |
%token <intValue> TOK_FALSE |
%token <intValue> LT |
%token <intValue> TOK_NULL |
%token <intValue> LE |
|
%token <intValue> GT |
%token <intValue> TOK_EQ |
%token <intValue> GE |
%token <intValue> TOK_NE |
%token <intValue> TOK_SELECT |
%token <intValue> TOK_LT |
%token <intValue> WHERE |
%token <intValue> TOK_LE |
%token <intValue> FROM |
%token <intValue> TOK_GT |
|
%token <intValue> TOK_GE |
|
|
|
%token <intValue> TOK_NOT |
|
%token <intValue> TOK_OR |
|
%token <intValue> TOK_AND |
|
%token <intValue> TOK_IS |
|
|
%token <strValue> TOK_IDENTIFIER | %token <strValue> TOK_IDENTIFIER |
%token <intValue> NOT |
%token <intValue> TOK_SELECT |
%token <intValue> OR |
%token <intValue> TOK_WHERE |
%token <intValue> AND |
%token <intValue> TOK_FROM |
%token <intValue> ISA |
|
%token <intValue> WQL_TRUE |
%token <strValue> TOK_UNEXPECTED_CHAR |
%token <intValue> WQL_FALSE |
|
|
%type <nodeValue> propertyName |
%type <nodeValue> constant |
|
%type <nodeValue> property |
|
%type <nodeValue> propertyListOrStar |
|
%type <nodeValue> propertyList | %type <nodeValue> propertyList |
%type <nodeValue> expressionTerm |
%type <nodeValue> predicate |
%type <nodeValue> expression |
%type <nodeValue> comparisonPredicate |
|
%type <nodeValue> comparisonTerm |
|
%type <nodeValue> nullPredicate |
|
%type <nodeValue> searchCondition |
|
%type <nodeValue> fromClause |
%type <nodeValue> whereClause | %type <nodeValue> whereClause |
%type <strValue> fromClass |
|
%type <nodeValue> selectStatement | %type <nodeValue> selectStatement |
|
%type <nodeValue> selectList |
|
%type <nodeValue> selectExpression |
%type <strValue> className | %type <strValue> className |
%type <nodeValue> function |
|
%type <nodeValue> functionParameterList |
|
%type <nodeValue> functionParameter |
|
|
|
%left OR |
|
%left AND |
|
%nonassoc NOT |
|
| |
/* |
%left TOK_OR |
**============================================================================== |
%left TOK_AND |
** |
%nonassoc TOK_NOT |
** The grammar itself. |
|
** |
|
**============================================================================== |
|
*/ |
|
| |
%% | %% |
| |
/* | /* |
**------------------------------------------------------------------------------ |
**============================================================================== |
** | ** |
** start rule: |
** The grammar itself. |
** | ** |
**------------------------------------------------------------------------------ |
**============================================================================== |
*/ | */ |
| |
start | start |
: selectStatement | : selectStatement |
{ | { |
|
printf("YACC: start\n"); |
} | } |
| |
/* BOOKMARK */ |
|
|
|
/* |
|
**------------------------------------------------------------------------------ |
|
** |
|
** Select Statement |
|
** |
|
**------------------------------------------------------------------------------ |
|
*/ |
|
|
|
selectStatement | selectStatement |
: TOK_SELECT propertyListOrStar fromClass |
: TOK_SELECT selectList selectExpression |
{ |
|
|
|
} |
|
| TOK_SELECT propertyListOrStar fromClass whereClause |
|
{ |
|
|
|
} |
|
|
|
fromClass : FROM className |
|
{ |
|
$$ = $2; |
|
} |
|
|
|
className : TOK_IDENTIFIER |
|
{ |
|
$$ = $1 |
|
} |
|
|
|
whereClause : WHERE expression |
|
{ | { |
| |
} | } |
| |
propertyListOrStar |
selectList |
: propertyList |
: '*' |
{ | { |
| |
} | } |
| '*' |
| propertyList |
{ | { |
| |
} | } |
| |
propertyList : property |
propertyList |
|
: propertyName |
{ | { |
| |
} | } |
| propertyList ',' property |
| propertyList ',' propertyName |
{ | { |
| |
} | } |
| |
property |
selectExpression |
: TOK_IDENTIFIER |
: fromClause whereClause |
{ | { |
| |
} | } |
| TOK_IDENTIFIER '.' TOK_IDENTIFIER |
| fromClause |
{ | { |
| |
} | } |
| |
expression |
fromClause |
: expression OR expression |
: TOK_FROM className |
{ | { |
| |
} | } |
| expression AND expression |
|
{ |
|
| |
} |
whereClause |
| NOT expression |
: TOK_WHERE searchCondition |
{ | { |
| |
} | } |
| '(' expression ')' |
|
{ |
|
| |
} |
searchCondition |
| expressionTerm |
: searchCondition TOK_OR searchCondition |
{ | { |
| |
} | } |
|
| searchCondition TOK_AND searchCondition |
expressionTerm |
|
: property LT constant |
|
{ | { |
| |
} | } |
| property GT constant |
| TOK_NOT searchCondition |
{ | { |
| |
} | } |
| property LE constant |
| '(' searchCondition ')' |
{ | { |
| |
} | } |
| property GE constant |
| predicate |
{ | { |
| |
} | } |
| property EQ constant |
| predicate TOK_IS truthValue |
{ | { |
| |
} | } |
| property NE constant |
| predicate TOK_IS TOK_NOT truthValue |
{ | { |
| |
} | } |
| constant LT property |
|
{ |
|
| |
} |
predicate |
| constant GT property |
: comparisonPredicate |
{ | { |
| |
} | } |
| constant LE property |
| nullPredicate |
{ | { |
| |
} | } |
| constant GE property |
|
{ |
|
| |
} |
comparisonPredicate |
| constant EQ property |
: comparisonTerm TOK_LT comparisonTerm |
{ | { |
| |
} | } |
| constant NE property |
| comparisonTerm TOK_GT comparisonTerm |
{ | { |
| |
} | } |
| function LT constant |
| comparisonTerm TOK_LE comparisonTerm |
{ | { |
| |
} | } |
| function GT constant |
| comparisonTerm TOK_GE comparisonTerm |
{ | { |
| |
} | } |
| function LE constant |
| comparisonTerm TOK_EQ comparisonTerm |
{ | { |
| |
} | } |
| function GE constant |
| comparisonTerm TOK_NE comparisonTerm |
{ | { |
| |
} | } |
| function EQ constant |
|
{ |
|
| |
} |
nullPredicate |
| function NE constant |
: comparisonTerm TOK_IS TOK_NULL |
{ | { |
| |
} | } |
| constant LT function |
| comparisonTerm TOK_IS TOK_NOT TOK_NULL |
{ | { |
| |
} | } |
| constant GT function |
|
{ |
|
| |
} |
truthValue |
| constant LE function |
: TOK_TRUE |
{ |
|
|
|
} |
|
| constant GE function |
|
{ | { |
| |
} | } |
| constant EQ function |
| TOK_FALSE |
{ | { |
| |
} | } |
| constant NE function |
|
{ |
|
| |
} |
propertyName |
| className ISA className |
: TOK_IDENTIFIER |
{ | { |
| |
} | } |
| |
function |
className : TOK_IDENTIFIER |
: TOK_IDENTIFIER '(' ')' |
|
{ |
|
|
|
} |
|
| TOK_IDENTIFIER '(' functionParameterList ')' |
|
{ | { |
| |
} | } |
| |
functionParameterList |
comparisonTerm |
: functionParameter |
: propertyName |
{ | { |
| |
} | } |
| functionParameterList ',' functionParameter |
| TOK_INTEGER |
{ | { |
| |
} | } |
|
| TOK_DOUBLE |
functionParameter |
|
: property |
|
| constant |
|
| function |
|
; |
|
|
|
constant |
|
: TOK_INTEGER |
|
{ | { |
| |
} | } |
| TOK_DOUBLE |
| TOK_STRING |
{ | { |
| |
} | } |
| STRING_LITERAL |
| truthValue |
{ | { |
|
|
} | } |
| |
%% | %% |