@
@	Cego language definition
@	--------------------
@	by Bjoern Lemke
@
@	(C)opyright 2003-2009 by Bjoern Lemke
@
@	This language defintion can be used with Dragon(c) 
@	for parser code generation

HEADER
IGNORE	STRINGVAL
SEPIGNORE '\t'
SEPIGNORE ' '
SEPIGNORE '\n'
SEPSIGN ';'
SEPSIGN ','
SEPSIGN '='
SEPSIGN '<'
SEPSIGN '>'
SEPSIGN ')'
SEPSIGN '('
SEPSIGN '['
SEPSIGN ']'
SEPSIGN '/'
SEPSIGN '+'
SEPSIGN '-'
SEPSIGN '|'
END

TOKENSET
add			:	ADD
and			:	AND
all			:	ALL
alter			:	ALTER
append			:	APPEND
as			:	AS
asc			:	ASC
authorize		:	AUTHORIZE
autocommit		:	AUTOCOMMIT
avg			:	AVG
begin			:	BEGIN
bigint			:	BIGINT
blob			:	BLOB
bool			:	BOOL
by			:	BY
call			:	CALL
case			:	CASE
check			:	CHECK
close			:	CLOSE
commit			:	COMMIT
column			:	COLUMN
constraint		:	CONSTRAINT
count			:	COUNT
counter			:	COUNTER
create			:	CREATE
cursor			:	CURSOR
date			:	DATE
date2str		:	DATE2STR
datetime		:	DATETIME
decimal			:	DECIMAL
default			:	DEFAULT
delete			:	DELETETOK
desc			:	DESC
distinct		:	DISTINCT
double			:	DOUBLE
drop			:	DROP
else			:	ELSE
elsif			:	ELSIF
end			:	END_TOKEN
exception		:	EXCEPTION
exists			:	EXISTS
false			:	FALSEVAL
fetch			:	FETCH
fixed			:	FIXED
float			:	FLOAT
for			:	FOR
foreign			:	FOREIGN
from			:	FROM
getpos			:	GETPOS
group			:	GROUP
having			:	HAVING
identified		:	IDENTIFIED
if			:	IF
in			:	INTOK
index			:	INDEX
inner			:	INNER
int			:	INT
into			:	INTO
insert			:	INSERT
is			:	IS
isolation		:	ISOLATION
jdbc			:	JDBC
join			:	JOIN
key			:	KEY
left			:	LEFT
length			:	LENGTH
like			:	LIKE
list			:	LIST
load			:	LOAD
locks			:	LOCKS
long			:	LONG
lower			:	LOWER
min			:	MIN
max			:	MAX
modify			:	MODIFY
noop			:	NOOP
not			:	NOT
null			:	NULLTOKEN
off			:	OFF
on			:	ON
out			:	OUTTOK
outer			:	OUTER
or			:	OR
order			:	ORDER
orderspace		:	ORDERSPACE
plan			:	PLAN
pool			:	POOL
primary			:	PRIMARY
print			:	PRINT
procedure		:	PROCEDURE
quit			:	QUIT
randstr			:	RANDSTR
randint			:	RANDINT
rbseg			:	RBSEG
references		:	REFERENCES
rename			:	RENAME
reorganize		:	REORGANIZE
return			:	RETURNTOKEN
remove			:	REMOVE
replace			:	REPLACE
right			:	RIGHT
rollback		:	ROLLBACK
rowlimit		:	ROWLIMIT
select			:	SELECT
set			:	SET
show			:	SHOW
smallint		:	SMALLINT
start			:	START_TOKEN
string			:	STRING
substr			:	SUBSTR
sum			:	SUM
sync			:	SYNC
sysdate			:	SYSDATE
systemspace		:	SYSTEMSPACE
tableinfo		:	TABLEINFO
table			:	TABLE
tableset		:	TABLESET
then			:	THEN
tinyint			:	TINYINT
transaction		:	TRANSACTION
str2int			:	STR2INT
str2long		:	STR2LONG
to			:	TO
trim			:	TRIM
true			:	TRUEVAL
trunc			:	TRUNC
union			:	UNION
unique			:	UNIQUE
update			:	UPDATE
upper			:	UPPER
var			:	VAR
values			:	VALUES
view			:	VIEW
when			:	WHEN
where			: 	WHERE
while			:	WHILE
'|'			:	CONCAT
'='			:	EQU
','			:	KSEP
'('			:	LB
'<'			:	LT
'>'			:	MT
'!'			:	NEGATION
')'			:	RB
'['			:	LAB
']'			:	RAB
';'			: 	SEMICOLON
'*'			:	STAR
'/'			:	DIV
'-'			:	MINUS
'+'			:	PLUS
(0|[1-9]*[0-9])		:	INTVAL
(0|[1-9]*[0-9])'.'*[0-9]	:	FLOATVAL
[a-zA-Z]*[a-zA-Z0-9_]		:	IDENTIFIER
':'[a-zA-Z]*[a-zA-Z0-9_]	:	VARREF
[a-zA-Z]*[a-zA-Z0-9_]'.*'	:	QUALIFIEDSTAR
[a-zA-Z]*[a-zA-Z0-9_]'.'[a-zA-Z]*[a-zA-Z0-9_]	:	QUALIFIEDOBJ1
[a-zA-Z]*[a-zA-Z0-9_]'@'[a-zA-Z]*[a-zA-Z0-9_]	:	QUALIFIEDOBJ2
'#'[a-zA-Z]*[a-zA-Z0-9_]			:	COUNTERID
END

PRODUCTIONSET
Start			: 	Statement SEMICOLON
Statement		:	SYNC ; execSync
Statement		:	LIST TABLESET ; execListTableSet
Statement		:	LIST TABLE TableSetOpt ; execListTable
Statement		:	LIST PROCEDURE  TableSetOpt ; execListProc
Statement		:	LIST VIEW TableSetOpt ; execListView
Statement		:	LIST INDEX TableSetOpt ; execListIndex
Statement		:	LIST KEY TableSetOpt ; execListKey
Statement		:	LIST COUNTER TableSetOpt ; execListCounter
TableSetOpt		:	FOR IDENTIFIER ; setTableSetOpt 
TableSetOpt		:	
Statement		:	TABLEINFO ObjSpec ; execTableInfo
Statement		:	SHOW POOL ; execShowPool
Statement		:	SHOW SYSTEMSPACE ; execShowSystemSpace
Statement		:	DESC TABLE ObjSpec ; execTableDesc
Statement		:	DESC INDEX ObjSpec ; execIndexDesc
Statement		:	DESC VIEW ObjSpec ; execViewDesc
Statement		:	DESC KEY ObjSpec ; execKeyDesc
Statement		:	DESC PROCEDURE ObjSpec ; execProcDesc
Statement		:	SET TABLESET IDENTIFIER ; execSetTableSet
Statement		:	AUTHORIZE IDENTIFIER IDENTIFIED BY STRINGVAL FOR IDENTIFIER ; execAuthUser
Statement		:	StartStatement ; execQuery
Statement		:	CommitStatement ; execQuery
Statement		:	RollbackStatement ; execQuery
Statement		:	SET APPEND ON ; execEnableAppendMode
Statement		:	SET APPEND OFF ; execDisableAppendMode
Statement		:	SET AUTOCOMMIT ON ; execEnableAutoCommit
Statement		:	SET AUTOCOMMIT OFF ; execDisableAutoCommit
Statement		:	SET ISOLATION IDENTIFIER ; execSetIsolation
Statement		:	REORGANIZE TABLE ObjSpec ; execTableReorganize
Statement		:	REORGANIZE INDEX ObjSpec ; execIndexReorganize
Statement		:	SelectStatement ; execSelect
Statement		:	PLAN SelectStatement ; execSelectPlan
Statement		:	InsertStatement ; execQuery
Statement		:	DeleteStatement ; execQuery
Statement		:	UpdateStatement ; execQuery
Statement		:	AlterStatement ; execQuery
Statement		:	RenameStatement ; execQuery

# view execs
Statement		:	CREATE VIEW ObjSpec AS SelectStatement ; execViewCreate
Statement		:	LOAD VIEW ObjSpec AS SelectStatement ; execViewLoad
Statement		:	DROP VIEW ObjSpec ; execViewDrop
# procedure execs
Statement		:	CREATE ProcDef ; execProcCreate
Statement		:	LOAD ProcDef ; execProcLoad
Statement		:    	CALL ObjSpec LB ProcValueListOpt RB ; execProcCall
Statement		:    	VARREF EQU CALL ObjSpec LB ProcValueListOpt RB ; execFuncCall
# create execs
Statement		:	CREATE TABLE ObjSpec LB ColumnList RB  ; execUserTableCreate
Statement		:	CREATE PRIMARY INDEX ON ObjSpec LB SimpleAttrList RB ; execPrimaryIndexCreate
Statement		:	CREATE IndexOption INDEX IDENTIFIER ON ObjSpec LB SimpleAttrList RB ; execIndexCreate
Statement		:	DROP TABLE ObjSpec ; execTableDrop
Statement		:	DROP INDEX ObjSpec ; execIndexDrop
Statement		:	DROP PROCEDURE ObjSpec ; execProcDrop
Statement		:	DROP FOREIGN KEY ObjSpec ; execFKeyDrop
Statement		:	ALTER TABLE ObjSpec ADD FOREIGN KEY IDENTIFIER LB SimpleAttrList RB  REFERENCES IDENTIFIER LB SimpleAttrList RB ; execForeignKeyCreate
Statement		:	SET IDENTIFIER EQU Expr ; execAssignStatement
Statement		:	PRINT Expr ; execPrint
Statement		:	CHECK INDEX IDENTIFIER ; execIndexCheck
Statement		:	CREATE COUNTER IDENTIFIER ; execCreateCounter
Statement		:	DROP COUNTER IDENTIFIER ; execDropCounter
# JDBC info calls
Statement		:	JDBC JdbcArgList ; jdbcInfo
JdbcArgList		:	JdbcArgList IDENTIFIER ; jdbcArg1
JdbcArgList		:	IDENTIFIER ; jdbcArg2

#
# Union All
#
UnionAllOpt		:	UNION ALL SelectStatement ; unionAllStore 
UnionAllOpt		:	

#
# Procedures
#
ProcHead		:	PROCEDURE ObjSpec LB ProcArgOpt RB ReturnOpt ; procHead
ProcDef			:    	ProcHead  BEGIN ProcStmtBlock END_TOKEN ; procStore
ReturnOpt		:	RETURNTOKEN DataTypeProd ; procReturnOpt
ReturnOpt		:	
ProcArgOpt		:	ProcArgList
ProcArgOpt		:
ProcArgList		:	ProcArgList KSEP ProcArg
ProcArgList		:	ProcArg 
ProcArg			:	IDENTIFIER INTOK DataTypeProd ; procArg1
ProcArg			:	IDENTIFIER OUTTOK DataTypeProd ; procArg2
ProcStmtBlock		:	ProcStatementList ProcExceptionList 
ProcStatementList	:	ProcStatementList ProcStatement SEMICOLON
ProcStatementList	:	ProcStatement SEMICOLON ; procStoreBlock
ProcStatement		:	VAR IDENTIFIER DataTypeProd  ; procVarStatement
ProcStatement		:	CURSOR IDENTIFIER AS SelectStatement ; procCursorCreateStatement
ProcStatement		:	CLOSE IDENTIFIER ; procCursorCloseStatement
ProcStatement		:	VARREF EQU Expr ; procAssignStatement
ProcStatement		:	NOOP ; procNoopStatement
# procedure queries
ProcStatement		:	InsertStatement ; procQueryStatement
ProcStatement		:	DeleteStatement ; procQueryStatement
ProcStatement		:	UpdateStatement ; procQueryStatement
ProcStatement		:	StartStatement ; procQueryStatement
ProcStatement		:	CommitStatement ; procQueryStatement
ProcStatement		:	RollbackStatement ; procQueryStatement
#
# Procedure return statement
#
ProcStatement		:	RETURNTOKEN ; procReturnStatement1
ProcStatement		:	RETURNTOKEN Expr ; procReturnStatement2
#
# Procedure nested block
#
ProcStatement		:	ProcBlockStart ProcStmtBlock END_TOKEN ; procBlockStatement
ProcBlockStart		:	BEGIN ; procBlockStart
#
# Procedure exception handling
#
ProcExceptionList	:	ProcExceptionList ProcExceptionStmt
ProcExceptionList	:	
ProcExceptionStmt	:	EXCEPTION WHEN ProcExceptionType THEN ProcStatementList ; procExceptionStatement
ProcValueListOpt	: 	ProcValueList ; procValueSpec
ProcValueListOpt	:
ProcValueList		:	ProcValueList KSEP Expr ; procExprValue
ProcValueList		:	Expr ; procExprValue
ProcExceptionType	:	IDENTIFIER ; procExceptionCondition
#
# Procedure if condition
#
ProcStatement		:	ProcIfPart ProcElsIfList ProcElseOpt END_TOKEN ; procIfStatement
ProcIfPart		:	IF ProcIfCondition THEN ProcStmtBlock ; procStoreIfBlock
ProcElsIfList		:	ProcElsIfOpt ProcElsIfList
ProcElsIfList		:	
ProcElsIfOpt		:	ELSIF ProcElsIfCondition THEN ProcStmtBlock ; procStoreIfBlock
ProcElseOpt		:	ProcElsePart ProcStmtBlock ; procStoreElseBlock
ProcElseOpt		:
ProcElsePart		:	ELSE ; procElsePart
ProcIfCondition		:	ProcCondition ; procIfCondition
ProcElsIfCondition	:	ProcCondition ; procElsIfCondition
#
# Procedure while loop
#
ProcStatement		:	WHILE ProcWhileCondition BEGIN ProcStmtBlock END_TOKEN ; procWhileStatement
ProcWhileCondition	:	ProcCondition ; procWhileCondition
#
# Procedure condition and predicate
#
ProcCondition		: 	ProcCondition OR ProcPredicate  ; procCondition1
ProcCondition		: 	ProcCondition AND ProcPredicate  ; procCondition2
ProcCondition		:	ProcPredicate ; procCondition3
ProcPredicate		:	LB ProcCondition RB ; procPredicate1
ProcPredicate		:	Expr Comparison Expr ; procPredicate2
ProcPredicate		:	Expr IS NULLTOKEN ; procPredicate3
ProcPredicate		:	Expr IS NOT NULLTOKEN ; procPredicate4
#
# Procedure expr, term and factor
#
Expr			:	Expr PLUS Term ; procExpr1
Expr			:	Expr MINUS Term ; procExpr2
Expr			:	Term ; procExpr3
Expr			:	Expr CONCAT Term ; procExpr4
Term			:	Term STAR Factor ; procTerm1
Term			:	Term DIV Factor ; procTerm2
Term			:	Factor ; procTerm3
Factor			:	VARREF ; procFactor1
Factor			:	Constant ; procFactor2
Factor			:	FETCH IDENTIFIER INTO LB FetchArgList RB ; procFactor3
Factor			:	Attribute ; procFactor4
Factor			:	Function ; procFactor5
Factor			:	LB Expr RB ; procFactor6
Factor			:	LB SelectStatement RB ; procFactor7
Factor			:	CaseClause ; procFactor8
CaseClause		:	CasePrepare CaseConditionList ELSE Expr END_TOKEN ; caseClause
CaseConditionList	:	CaseConditionList CaseCondition ; caseConditionList1
CaseConditionList	:	CaseCondition ; caseConditionList2
CaseCondition		:	WHEN QueryCondition THEN Expr ; caseCondition
CasePrepare		:   	CASE ; casePrepare
#
FetchArgList		:       FetchArgList KSEP VARREF ; procStoreFetchArg1
FetchArgList		:       VARREF  ; procStoreFetchArg2

#
# Object Creation
#
ColumnList		:	ColumnList KSEP KeyColumn
ColumnList		:	KeyColumn
KeyColumn		:	PRIMARY ColumnDesc ; createSetPrimary
KeyColumn		:	ColumnDesc ; createSetOrdinary
ColumnDesc		:	IDENTIFIER DataTypeProd DefaultOpt NullOpt ConstraintOpt ; createFieldName
NullOpt			:	NULLTOKEN ; createNullOpt
NullOpt			:	NOT NULLTOKEN ; createNotNullOpt
NullOpt			:       DefaultNullOpt ;  createNullOpt
DefaultNullOpt		:		
DefaultOpt		:	DEFAULT Constant ; defaultOpt
DefaultOpt		:	DefaultDefOpt ; defaultNullOpt
DefaultDefOpt		:
ConstraintOpt		:	ConstraintList
ConstraintOpt		:
ConstraintList		:	ConstraintList Constraint
ConstraintList		:	Constraint
Constraint		:	CONSTRAINT IDENTIFIER CHECK QueryPredicate
# 
SimpleAttrList		:	SimpleAttr  KSEP SimpleAttrList
SimpleAttrList		:	SimpleAttr ; createSimpleAttrList
SimpleAttr		:	IDENTIFIER ; createSimpleAttr
IndexOption		:	UNIQUE ; createUniqueIndex
IndexOption		:
#
# TA Statement
# 
StartStatement		:	START_TOKEN TRANSACTION ; startStore
CommitStatement		:	COMMIT ; commitStore
RollbackStatement	:	ROLLBACK ; rollbackStore
#
# Insert Statement
# 
InsertStatement		:	INSERT INTO ObjSpec InsertArgSpec VALUES InsertValueSpec ; insertStore
InsertStatement		:	INSERT INTO ObjSpec InsertArgSpec SelectStatement ; insertBySelectStore
InsertArgSpec		:	LB InsertArgList RB
InsertArgSpec		:	
InsertValueSpec		:	LB InsertValueList RB ; insertValueSpec 
InsertArgList		:	InsertArgList KSEP IDENTIFIER ; insertArg 
InsertArgList		:	IDENTIFIER ; insertArg 
InsertValueList		:	InsertValueList KSEP Expr ; insertExprValue 
InsertValueList		:	Expr ; insertExprValue 
#
# Select Statement
#
SelectStatement		:	SELECT Selection FROM TableSource WhereClause GroupClause OrderingClause LimitOpt UnionAllOpt ; selectStore
Selection		:	DistinctOpt SelectionList ; selectSelectionStore1
Selection		:	STAR ; selectSelectionStore2
SelectionList		:	SelectionList KSEP SelectItem ; selectionList1 
SelectionList		:	SelectItem ; selectionList2
SelectItem		:	Expr AliasOpt ; selectItem
SelectItem		:	Aggregation AliasOpt ; selectItem
Aggregation		:	COUNT LB STAR RB ; selectAggregation1
Aggregation		:	SUM LB Expr RB ; selectAggregation2
Aggregation		:	AVG LB Expr RB ; selectAggregation3
Aggregation		:	COUNT LB Expr RB ; selectAggregation4
Aggregation		:	MIN LB Expr RB ; selectAggregation5
Aggregation		:	MAX LB Expr RB ; selectAggregation6

TableSource		:	TableList ; selectTableListStore
TableSource		:	JoinSpecList ; selectJoinSpecStore
JoinSpecList		:	JoinSpecList JoinSpec 
JoinSpecList		:	Table JoinSpec 
JoinSpec		:	INNER JOIN Table ON QueryPredicate ; selectInnerJoinStore 
JoinSpec		:	LEFT OUTER JOIN Table ON QueryPredicate ; selectLeftOuterJoinStore 
JoinSpec		:	RIGHT OUTER JOIN Table ON QueryPredicate ; selectRightOuterJoinStore 

TableList		:	Table KSEP TableList
TableList		:	Table 
Table			:	ObjSpec ; selectTable1
Table			:	ObjSpec IDENTIFIER ; selectTable2

AliasOpt		:	AS IDENTIFIER ; aliasOpt
AliasOpt		:	

GroupClause		:	GROUP BY GroupList HavingClause ; selectGroupClause
GroupClause		:	NoGroup ; selectEmptyGroupClause
NoGroup			:	
GroupList		:	GroupList KSEP Attribute  ; selectGroupList1
GroupList		:	Attribute ; selectGroupList2

HavingClause		:	HAVING Aggregation Comparison Expr ; selectHavingClause
HavingClause		:	NoHaving ; selectEmptyHavingClause
NoHaving		:

OrderingClause		:	ORDER BY OrderingList OrderingOpt ; selectOrderingClause
OrderingClause		:	NoOrdering ; selectEmptyOrderingClause
NoOrdering		:
# OrderingList		:       OrderingList KSEP Attribute ; selectOrderingList1
# OrderingList		:	Attribute ; selectOrderingList2
OrderingList		:       OrderingList KSEP Expr ; selectOrderingList1
OrderingList		:	Expr ; selectOrderingList2
OrderingOpt		:	DefaultOrderOpt ; selectOrderingAsc
OrderingOpt		:	DESC ; selectOrderingDesc
DefaultOrderOpt 	:	ASC
DefaultOrderOpt 	:	
DistinctOpt		:	DISTINCT ; selectDistinctOpt
DistinctOpt		:	

LimitOpt		:	ROWLIMIT INTVAL ; selectLimitOpt1
LimitOpt		:	NoLimit ; selectLimitOpt2
NoLimit			:

#
# Update Statement
# 

UpdateStatement		:	UPDATE ObjSpec SET UpdateList WhereClause UpdReturnOpt ; updateStore
UpdateList		:	UpdateList KSEP Assignment
UpdateList		:	Assignment
Assignment		:	IDENTIFIER EQU Expr ; updateAssignment
UpdReturnOpt		:	RETURNTOKEN ReturnVarList
UpdReturnOpt		:
ReturnVarList		:	ReturnVarList KSEP ReturnVar
ReturnVarList		:	ReturnVar
ReturnVar		:	VARREF EQU Expr ; returnVarAssignment

#
# Delete Statement
# 

DeleteStatement		:	DELETETOK FROM ObjSpec WhereClause ; deleteStore

#
# Alter Statement
# 

AlterStatement		:	ALTER TABLE ObjSpec AlterList ; alterStore
AlterList		:       AlterOption KSEP AlterList
AlterList		:       AlterOption
AlterOption		:	DROP COLUMN IDENTIFIER ; alterDropCol
AlterOption		:	ADD COLUMN ColumnDesc ; alterAddCol
AlterOption		:	MODIFY COLUMN ColumnDesc ; alterModCol
AlterOption		:	RENAME COLUMN IDENTIFIER TO IDENTIFIER ; alterRenameCol

#
# Rename Statement
# 

RenameStatement		:	RENAME TABLE ObjSpec TO IDENTIFIER ; renameTable
RenameStatement		:	RENAME INDEX ObjSpec TO IDENTIFIER ; renameIndex
RenameStatement		:	RENAME KEY ObjSpec TO IDENTIFIER ; renameKey
RenameStatement		:	RENAME PROCEDURE ObjSpec TO IDENTIFIER ; renameProcedure
RenameStatement		:	RENAME VIEW ObjSpec TO IDENTIFIER ; renameView

#
# Functions
#

Function		:	TRIM LB Expr KSEP Expr RB ; functionTrim
Function		:	DATE2STR LB Attribute KSEP Expr RB ; functionDate
Function		:	LOWER LB Expr RB ; functionLower
Function		:	UPPER LB Expr RB ; functionUpper
Function		:	LEFT LB Expr KSEP Expr RB ; functionLeft
Function		:	RIGHT LB Expr KSEP Expr RB ; functionRight
Function		:	GETPOS LB Expr KSEP Expr RB ; functionGetPos1
Function		:	GETPOS LB Expr KSEP Expr KSEP Expr RB ; functionGetPos2
Function		:	GETPOS LB Expr KSEP Expr KSEP Expr KSEP Expr RB ; functionGetPos3
Function		:	SUBSTR LB Expr KSEP Expr  RB ; functionSubstr1
Function		:	SUBSTR LB Expr KSEP Expr KSEP Expr RB ; functionSubstr2
Function		:	REPLACE LB Expr KSEP Expr KSEP Expr RB ; functionReplace
Function		:	LENGTH LB Expr  RB ; functionLength
Function		:	TRUNC LB Expr RB ; functionTrunc
Function		:	STR2INT LB Expr RB ; functionStr2Int
Function		:	STR2LONG LB Expr RB ; functionStr2Long
Function		:	RANDSTR LB Expr RB ; functionRandStr
Function		:	RANDINT LB Expr RB ; functionRandInt
Function		:	ObjSpec LB ExpressionList RB ; functionUserDef
ExpressionList		:	ExpressionList KSEP Expr ; functionExprList1
ExpressionList		:	Expr ; functionExprList2

#
# Where Clause
#

WhereClause		:	WHERE QueryCondition ; wcWhereClause
WhereClause		:       NoWhere ; wcEmptyClause
NoWhere			:
QueryCondition		: 	QueryCondition AND QueryPredicate  ; wcConditionAnd
QueryCondition		: 	QueryCondition OR QueryPredicate  ; wcConditionOr
QueryCondition		:	QueryPredicate ; wcConditionPredicate
QueryCondition		:	NOT QueryPredicate ; wcConditionNotPredicate
QueryPredicate		: 	EXISTS LB SelectStatement RB ; wcPredicateQueryExists
# QueryPredicate		: 	NOT EXISTS LB SelectStatement RB ;  wcPredicateQueryNotExists
# QueryPredicate		:	Expr Comparison LB SelectStatement RB ; wcPredicateQueryComp
QueryPredicate		:	Expr INTOK LB SelectStatement RB ; wcPredicateQueryIn
QueryPredicate		:	Expr NOT INTOK LB SelectStatement RB ; wcPredicateQueryNotIn 
QueryPredicate		:	Expr Comparison Expr ; wcPredicateExprComp
QueryPredicate		:	Expr IS NULLTOKEN ; wcPredicateNullComp
QueryPredicate		:	Expr IS NOT NULLTOKEN ; wcPredicateNotNullComp
QueryPredicate		:	Expr LIKE STRINGVAL ; wcPredicateLikeComp
QueryPredicate		:	Expr NOT LIKE STRINGVAL ; wcPredicateNotLikeComp
QueryPredicate		:	LB QueryCondition RB ; wcPredicateCondition

#
# Other
#

DataTypeProd		:	INT ; miscIntType
DataTypeProd		:	LONG ; miscLongType
DataTypeProd		:	STRING LB INTVAL RB ; miscStringType
DataTypeProd		:	DATETIME ; miscDateTimeType
DataTypeProd		:	BOOL ; miscBoolType
DataTypeProd		:	BIGINT LB INTVAL RB ; miscBigIntType
DataTypeProd		:	FLOAT ; miscFloatType
DataTypeProd		:	DOUBLE ; miscDoubleType
DataTypeProd		:	SMALLINT ; miscSmallIntType
DataTypeProd		:	TINYINT ; miscTinyIntType
DataTypeProd		:	DECIMAL LB INTVAL RB ; miscDecimalType
DataTypeProd		:	FIXED LB INTVAL RB ; miscFixedType
DataTypeProd		:	BLOB ; miscBlobType
Comparison		:	EQU ; miscEqualComp
Comparison		:	NEGATION EQU ; miscNotEqualComp
Comparison		:	LT ; miscLessComp
Comparison		:	MT ; miscMoreComp
Comparison		:	LT EQU ; miscLessEqualComp
Comparison		:	MT EQU ; miscMoreEqualComp
Attribute		:	IDENTIFIER ; miscAttribute1
Attribute		:	QUALIFIEDOBJ1 ; miscAttribute2
Attribute		:	QUALIFIEDSTAR ; miscAttribute3
SignedInt		:	INTVAL ; miscIntString
SignedInt		:	MINUS INTVAL ; miscNegatedIntString
SignedFloat		:	FLOATVAL ; miscFloatString
SignedFloat		:	MINUS FLOATVAL ; miscNegatedFloatString
Constant		:	SignedInt ; miscIntValue
Constant		:	LB LONG RB SignedInt ; miscLongValue
Constant		:	LB BIGINT RB SignedInt ; miscBigIntValue
Constant		:	LB SMALLINT RB SignedInt ; miscSmallIntValue
Constant		:	LB TINYINT RB SignedInt ; miscTinyIntValue
Constant		:	STRINGVAL ; miscStringValue
Constant		:	SignedFloat ; miscFloatValue 
Constant		:	LB DOUBLE RB SignedFloat ; miscDoubleValue
Constant		:	LB DECIMAL RB SignedFloat ; miscDecimalValue
Constant		:	LB FIXED RB SignedFloat ; miscFixedValue
Constant		:	DATE LB DateFormat KSEP DateValue RB ; miscFormatDate
Constant		:	SYSDATE ; miscSysDate
Constant		:	NULLTOKEN ; miscNull
Constant		:	TRUEVAL ; miscTrueValue
Constant		:	FALSEVAL ; miscFalseValue
Constant		:	LAB INTVAL KSEP INTVAL RAB ; miscBlobRef
Constant		:	COUNTERID ; miscCounter
DateFormat		:	STRINGVAL ; miscDateFormat
DateValue		:	STRINGVAL ; miscDateValue
ObjSpec			:	IDENTIFIER ; setObject1
ObjSpec			:	QUALIFIEDOBJ1 ; setObject2
ObjSpec			:	QUALIFIEDOBJ2 ; setObject3
END






