import Oql
import OqlParserBase
from OqlParserBase import SyntaxException
from OqlParserBase import InternalException
from OqlParserBase import PrintSyntaxException
from OqlParserBase import PrintInternalException
class OqlParseTreeTuple(OqlParserBase.OqlParserBase):
	def __init__(self):
		OqlParserBase.OqlParserBase.__init__(self)
	def queryProgram(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('QUERYPROGRAM')
		newNode.reverse()
		self.push(tuple(newNode))

	def declarationList(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('DECLARATIONLIST')
		newNode.reverse()
		self.push(tuple(newNode))

	def queryList(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('QUERYLIST')
		newNode.reverse()
		self.push(tuple(newNode))

	def declaration(self, arg0 = None):
		newNode = []
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('DECLARATION')
		newNode.reverse()
		self.push(tuple(newNode))

	def oql_import(self, arg0 = None, arg1 = None, arg2 = None, arg3 = None):
		newNode = []
		newNode.append((arg3 == '%%FT-NT%%' and self.pop()) or arg3)
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('OQL_IMPORT')
		newNode.reverse()
		self.push(tuple(newNode))

	def defineQuery(self, arg0 = None, arg1 = None, arg2 = None, arg3 = None, arg4 = None, arg5 = None, arg6 = None, arg7 = None):
		newNode = []
		newNode.append((arg7 == '%%FT-NT%%' and self.pop()) or arg7)
		newNode.append((arg6 == '%%FT-NT%%' and self.pop()) or arg6)
		newNode.append((arg5 == '%%FT-NT%%' and self.pop()) or arg5)
		newNode.append((arg4 == '%%FT-NT%%' and self.pop()) or arg4)
		newNode.append((arg3 == '%%FT-NT%%' and self.pop()) or arg3)
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('DEFINEQUERY')
		newNode.reverse()
		self.push(tuple(newNode))

	def parameterList(self, arg0 = None, arg1 = None, arg2 = None, arg3 = None):
		newNode = []
		newNode.append((arg3 == '%%FT-NT%%' and self.pop()) or arg3)
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('PARAMETERLIST')
		newNode.reverse()
		self.push(tuple(newNode))

	def undefineQuery(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('UNDEFINEQUERY')
		newNode.reverse()
		self.push(tuple(newNode))

	def qualifiedName(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('QUALIFIEDNAME')
		newNode.reverse()
		self.push(tuple(newNode))

	def query(self, arg0 = None):
		newNode = []
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('QUERY')
		newNode.reverse()
		self.push(tuple(newNode))

	def selectExpr(self, arg0 = None, arg1 = None, arg2 = None, arg3 = None, arg4 = None, arg5 = None, arg6 = None):
		newNode = []
		newNode.append((arg6 == '%%FT-NT%%' and self.pop()) or arg6)
		newNode.append((arg5 == '%%FT-NT%%' and self.pop()) or arg5)
		newNode.append((arg4 == '%%FT-NT%%' and self.pop()) or arg4)
		newNode.append((arg3 == '%%FT-NT%%' and self.pop()) or arg3)
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('SELECTEXPR')
		newNode.reverse()
		self.push(tuple(newNode))

	def projectionAttributes(self, arg0 = None):
		newNode = []
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('PROJECTIONATTRIBUTES')
		newNode.reverse()
		self.push(tuple(newNode))

	def projectionList(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('PROJECTIONLIST')
		newNode.reverse()
		self.push(tuple(newNode))

	def projection(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('PROJECTION')
		newNode.reverse()
		self.push(tuple(newNode))

	def fromClause(self, arg0 = None, arg1 = None):
		newNode = []
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('FROMCLAUSE')
		newNode.reverse()
		self.push(tuple(newNode))

	def iteratorDefList(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('ITERATORDEFLIST')
		newNode.reverse()
		self.push(tuple(newNode))

	def iteratorDef(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('ITERATORDEF')
		newNode.reverse()
		self.push(tuple(newNode))

	def whereClause(self, arg0 = None, arg1 = None):
		newNode = []
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('WHERECLAUSE')
		newNode.reverse()
		self.push(tuple(newNode))

	def groupClause(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('GROUPCLAUSE')
		newNode.reverse()
		self.push(tuple(newNode))

	def havingClauseList(self, arg0 = None, arg1 = None):
		newNode = []
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('HAVINGCLAUSELIST')
		newNode.reverse()
		self.push(tuple(newNode))

	def havingClause(self, arg0 = None, arg1 = None):
		newNode = []
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('HAVINGCLAUSE')
		newNode.reverse()
		self.push(tuple(newNode))

	def orderClause(self, arg0 = None, arg1 = None):
		newNode = []
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('ORDERCLAUSE')
		newNode.reverse()
		self.push(tuple(newNode))

	def sortCriterionList(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('SORTCRITERIONLIST')
		newNode.reverse()
		self.push(tuple(newNode))

	def sortCriterion(self, arg0 = None, arg1 = None):
		newNode = []
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('SORTCRITERION')
		newNode.reverse()
		self.push(tuple(newNode))

	def expr(self, arg0 = None):
		newNode = []
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('EXPR')
		newNode.reverse()
		self.push(tuple(newNode))

	def castExpr(self, arg0 = None, arg1 = None, arg2 = None, arg3 = None):
		newNode = []
		newNode.append((arg3 == '%%FT-NT%%' and self.pop()) or arg3)
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('CASTEXPR')
		newNode.reverse()
		self.push(tuple(newNode))

	def orExpr(self, arg0 = None, arg1 = None):
		newNode = []
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('OREXPR')
		newNode.reverse()
		self.push(tuple(newNode))

	def orelseExpr(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('ORELSEEXPR')
		newNode.reverse()
		self.push(tuple(newNode))

	def andExpr(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('ANDEXPR')
		newNode.reverse()
		self.push(tuple(newNode))

	def quantifierExpr(self, arg0 = None, arg1 = None, arg2 = None, arg3 = None):
		newNode = []
		newNode.append((arg3 == '%%FT-NT%%' and self.pop()) or arg3)
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('QUANTIFIEREXPR')
		newNode.reverse()
		self.push(tuple(newNode))

	def inClause(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('INCLAUSE')
		newNode.reverse()
		self.push(tuple(newNode))

	def andthenExpr(self, arg0 = None, arg1 = None):
		newNode = []
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('ANDTHENEXPR')
		newNode.reverse()
		self.push(tuple(newNode))

	def equalityExpr(self, arg0 = None, arg1 = None, arg2 = None, arg3 = None):
		newNode = []
		newNode.append((arg3 == '%%FT-NT%%' and self.pop()) or arg3)
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('EQUALITYEXPR')
		newNode.reverse()
		self.push(tuple(newNode))

	def relationalExpr(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('RELATIONALEXPR')
		newNode.reverse()
		self.push(tuple(newNode))

	def relationalOperand(self, arg0 = None):
		newNode = []
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('RELATIONALOPERAND')
		newNode.reverse()
		self.push(tuple(newNode))

	def compositePredicate(self, arg0 = None):
		newNode = []
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('COMPOSITEPREDICATE')
		newNode.reverse()
		self.push(tuple(newNode))

	def additiveExpr(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('ADDITIVEEXPR')
		newNode.reverse()
		self.push(tuple(newNode))

	def additiveOperand(self, arg0 = None):
		newNode = []
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('ADDITIVEOPERAND')
		newNode.reverse()
		self.push(tuple(newNode))

	def multiplicativeExpr(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('MULTIPLICATIVEEXPR')
		newNode.reverse()
		self.push(tuple(newNode))

	def multiplicativeOperand(self, arg0 = None):
		newNode = []
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('MULTIPLICATIVEOPERAND')
		newNode.reverse()
		self.push(tuple(newNode))

	def inExpr(self, arg0 = None, arg1 = None):
		newNode = []
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('INEXPR')
		newNode.reverse()
		self.push(tuple(newNode))

	def unaryExpr(self, arg0 = None, arg1 = None):
		newNode = []
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('UNARYEXPR')
		newNode.reverse()
		self.push(tuple(newNode))

	def unaryOperand(self, arg0 = None):
		newNode = []
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('UNARYOPERAND')
		newNode.reverse()
		self.push(tuple(newNode))

	def postfixExpr(self, arg0 = None, arg1 = None, arg2 = None, arg3 = None):
		newNode = []
		newNode.append((arg3 == '%%FT-NT%%' and self.pop()) or arg3)
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('POSTFIXEXPR')
		newNode.reverse()
		self.push(tuple(newNode))

	def postfixOperandList(self, arg0 = None, arg1 = None):
		newNode = []
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('POSTFIXOPERANDLIST')
		newNode.reverse()
		self.push(tuple(newNode))

	def postfixOperand(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('POSTFIXOPERAND')
		newNode.reverse()
		self.push(tuple(newNode))

	def index(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('INDEX')
		newNode.reverse()
		self.push(tuple(newNode))

	def exprList(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('EXPRLIST')
		newNode.reverse()
		self.push(tuple(newNode))

	def argList(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('ARGLIST')
		newNode.reverse()
		self.push(tuple(newNode))

	def primaryExpr(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('PRIMARYEXPR')
		newNode.reverse()
		self.push(tuple(newNode))

	def conversionExpr(self, arg0 = None, arg1 = None, arg2 = None, arg3 = None):
		newNode = []
		newNode.append((arg3 == '%%FT-NT%%' and self.pop()) or arg3)
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('CONVERSIONEXPR')
		newNode.reverse()
		self.push(tuple(newNode))

	def collectionExpr(self, arg0 = None, arg1 = None, arg2 = None, arg3 = None):
		newNode = []
		newNode.append((arg3 == '%%FT-NT%%' and self.pop()) or arg3)
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('COLLECTIONEXPR')
		newNode.reverse()
		self.push(tuple(newNode))

	def aggregateExpr(self, arg0 = None, arg1 = None, arg2 = None, arg3 = None):
		newNode = []
		newNode.append((arg3 == '%%FT-NT%%' and self.pop()) or arg3)
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('AGGREGATEEXPR')
		newNode.reverse()
		self.push(tuple(newNode))

	def undefinedExpr(self, arg0 = None, arg1 = None, arg2 = None, arg3 = None):
		newNode = []
		newNode.append((arg3 == '%%FT-NT%%' and self.pop()) or arg3)
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('UNDEFINEDEXPR')
		newNode.reverse()
		self.push(tuple(newNode))

	def objectConstruction(self, arg0 = None, arg1 = None, arg2 = None, arg3 = None):
		newNode = []
		newNode.append((arg3 == '%%FT-NT%%' and self.pop()) or arg3)
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('OBJECTCONSTRUCTION')
		newNode.reverse()
		self.push(tuple(newNode))

	def structConstruction(self, arg0 = None, arg1 = None, arg2 = None, arg3 = None):
		newNode = []
		newNode.append((arg3 == '%%FT-NT%%' and self.pop()) or arg3)
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('STRUCTCONSTRUCTION')
		newNode.reverse()
		self.push(tuple(newNode))

	def fieldList(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('FIELDLIST')
		newNode.reverse()
		self.push(tuple(newNode))

	def field(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('FIELD')
		newNode.reverse()
		self.push(tuple(newNode))

	def collectionConstruction(self, arg0 = None, arg1 = None, arg2 = None, arg3 = None):
		newNode = []
		newNode.append((arg3 == '%%FT-NT%%' and self.pop()) or arg3)
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('COLLECTIONCONSTRUCTION')
		newNode.reverse()
		self.push(tuple(newNode))

	def valueList(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('VALUELIST')
		newNode.reverse()
		self.push(tuple(newNode))

	def listRange(self, arg0 = None, arg1 = None, arg2 = None):
		newNode = []
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('LISTRANGE')
		newNode.reverse()
		self.push(tuple(newNode))

	def queryParam(self, arg0 = None, arg1 = None):
		newNode = []
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('QUERYPARAM')
		newNode.reverse()
		self.push(tuple(newNode))

	def type(self, arg0 = None, arg1 = None, arg2 = None, arg3 = None, arg4 = None, arg5 = None):
		newNode = []
		newNode.append((arg5 == '%%FT-NT%%' and self.pop()) or arg5)
		newNode.append((arg4 == '%%FT-NT%%' and self.pop()) or arg4)
		newNode.append((arg3 == '%%FT-NT%%' and self.pop()) or arg3)
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('TYPE')
		newNode.reverse()
		self.push(tuple(newNode))

	def literal(self, arg0 = None):
		newNode = []
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('LITERAL')
		newNode.reverse()
		self.push(tuple(newNode))

	def booleanLiteral(self, arg0 = None):
		newNode = []
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('BOOLEANLITERAL')
		newNode.reverse()
		self.push(tuple(newNode))

	def longLiteral(self, arg0 = None):
		newNode = []
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('LONGLITERAL')
		newNode.reverse()
		self.push(tuple(newNode))

	def doubleLiteral(self, arg0 = None):
		newNode = []
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('DOUBLELITERAL')
		newNode.reverse()
		self.push(tuple(newNode))

	def charLiteral(self, arg0 = None):
		newNode = []
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('CHARLITERAL')
		newNode.reverse()
		self.push(tuple(newNode))

	def stringLiteral(self, arg0 = None):
		newNode = []
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('STRINGLITERAL')
		newNode.reverse()
		self.push(tuple(newNode))

	def dateLiteral(self, arg0 = None, arg1 = None, arg2 = None, arg3 = None, arg4 = None, arg5 = None, arg6 = None, arg7 = None):
		newNode = []
		newNode.append((arg7 == '%%FT-NT%%' and self.pop()) or arg7)
		newNode.append((arg6 == '%%FT-NT%%' and self.pop()) or arg6)
		newNode.append((arg5 == '%%FT-NT%%' and self.pop()) or arg5)
		newNode.append((arg4 == '%%FT-NT%%' and self.pop()) or arg4)
		newNode.append((arg3 == '%%FT-NT%%' and self.pop()) or arg3)
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('DATELITERAL')
		newNode.reverse()
		self.push(tuple(newNode))

	def timeLiteral(self, arg0 = None, arg1 = None, arg2 = None, arg3 = None, arg4 = None, arg5 = None, arg6 = None, arg7 = None):
		newNode = []
		newNode.append((arg7 == '%%FT-NT%%' and self.pop()) or arg7)
		newNode.append((arg6 == '%%FT-NT%%' and self.pop()) or arg6)
		newNode.append((arg5 == '%%FT-NT%%' and self.pop()) or arg5)
		newNode.append((arg4 == '%%FT-NT%%' and self.pop()) or arg4)
		newNode.append((arg3 == '%%FT-NT%%' and self.pop()) or arg3)
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('TIMELITERAL')
		newNode.reverse()
		self.push(tuple(newNode))

	def timestampLiteral(self, arg0 = None, arg1 = None, arg2 = None, arg3 = None, arg4 = None, arg5 = None, arg6 = None, arg7 = None, arg8 = None, arg9 = None, arg10 = None, arg11 = None, arg12 = None):
		newNode = []
		newNode.append((arg12 == '%%FT-NT%%' and self.pop()) or arg12)
		newNode.append((arg11 == '%%FT-NT%%' and self.pop()) or arg11)
		newNode.append((arg10 == '%%FT-NT%%' and self.pop()) or arg10)
		newNode.append((arg9 == '%%FT-NT%%' and self.pop()) or arg9)
		newNode.append((arg8 == '%%FT-NT%%' and self.pop()) or arg8)
		newNode.append((arg7 == '%%FT-NT%%' and self.pop()) or arg7)
		newNode.append((arg6 == '%%FT-NT%%' and self.pop()) or arg6)
		newNode.append((arg5 == '%%FT-NT%%' and self.pop()) or arg5)
		newNode.append((arg4 == '%%FT-NT%%' and self.pop()) or arg4)
		newNode.append((arg3 == '%%FT-NT%%' and self.pop()) or arg3)
		newNode.append((arg2 == '%%FT-NT%%' and self.pop()) or arg2)
		newNode.append((arg1 == '%%FT-NT%%' and self.pop()) or arg1)
		newNode.append((arg0 == '%%FT-NT%%' and self.pop()) or arg0)
		newNode.append('TIMESTAMPLITERAL')
		newNode.reverse()
		self.push(tuple(newNode))


if __name__ == '__main__':
	from Ft.Lib import DumpBgTuple
	import sys
	rt = []
	p = OqlParseTreeTuple()
	if len(sys.argv)==2:
		l = open(sys.argv[1],'r').read()
	else:
		l = raw_input(">>>")
	try:
		rt = p.parse(l)
		DumpBgTuple.Dump(rt)
	except InternalException, e:
		PrintInternalException(e)
	except SyntaxException, e:
		PrintSyntaxException(e)
