⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sqlgrammar.jj

📁 derby database source code.good for you.
💻 JJ
📖 第 1 页 / 共 5 页
字号:
		  	retval = true;			break;		  case CURRENT:			if (isDATETIME(getToken(2).kind)) 		  		retval = true;			break;			  case CAST:		  case LEFT_PAREN:		  	retval = false;			break;		  default:		    if (getToken(2).kind == LEFT_PAREN)				retval = true;			break;		}		return retval;	}	/**	 * Determine whether the next sequence of tokens can be the beginning	 * of a subquery. A subquery can begin with an arbitrary number of	 * left parentheses, followed by either SELECT or VALUES.	 *	 * @return	TRUE iff the next set of tokens is the beginning of a	 *			subquery.	 */	private boolean subqueryFollows()	{		int tokKind;		boolean retval = false;		for (int i = 1; true; i++)		{			tokKind = getToken(i).kind;			if (tokKind == LEFT_PAREN)			{				// A subquery can start with an arbitrary number of left				// parentheses.				continue;			}			else if (tokKind == SELECT || tokKind == VALUES)			{				// If the first token we find after all the left parentheses				// is SELECT or VALUES, it's a subquery.				retval = true;				break;			}			else			{				// If the first token we find after all the left parentheses				// is neither SELECT nor VALUES, it's not a subquery.				break;			}		}		return retval;	}	/**	 * Determine whether the next sequence of tokens can be the beginning	 * of a rowValueConstructorList. A rowValueConstructorList is a comma-	 * separated list of expressions enclosed in parentheses. This presents	 * special problems, because an expression be nested within an	 * arbitrary number of parentheses. To determine whether a left	 * parenthesis introduces a rowValueConstructorList or an expression,	 * we need to find the closing parenthesis, and determine whether	 * the next token is a comma.	 *	 * For example, the following is a rowValueConstructorList:	 *	 *		(((1)), 2)	 *	 * and the following is just an expression:	 *	 *		(((1)))	 *	 * @return	TRUE iff the next set of tokens is the beginning of a	 *			subquery.	 */	private boolean rowValueConstructorListFollows()	{		int nesting;		boolean retval = false;		// A rowValueConstructorList starts with a left parenthesis		if (getToken(1).kind == LEFT_PAREN)		{			// Keep track of the nesting of parens while looking ahead			nesting = 1;			for (int i = 2; true; i++)			{				int tokKind = getToken(i).kind;				// Special case for NULL/DEFAULT because they are not allowed in				// a parenthesized expression, so (null)/(default) must be seen				// as a rowValueConstructorList with one element.				if (i == 2 && (tokKind == NULL || tokKind == _DEFAULT))				{					retval = true;					break;				}				// There must be a COMMA at nesting level 1 (i.e. outside of				// the first expression) for it to be a rowValueConstructorList				if (nesting == 1 && tokKind == COMMA)				{					retval = true;					break;				}				// If we run out of tokens before finding the last closing				// parenthesis, it's not a rowValueConstructorList (it's				// probably a syntax error, in fact)				if (tokKind == EOF)				{					break;				}				// Increase the nesting for each (, and decrease it for each )				if (tokKind == LEFT_PAREN)				{					nesting++;				}				else if (tokKind == RIGHT_PAREN)				{					nesting--;				}				// Don't look any farther than the last closing parenthesis				if (nesting == 0)				{					break;				}			}		}		return retval;	}	/**	 * Determine whether the next sequence of tokens can be the beginning	 * of a propertyList(). A properties list is the word "properties"	 * followed by a dot-separated list, followed by an =,	 * followed by a value. This means that the first token must be the word	 * "properties", and the third must be a period (from the dot-separated	 * list) or an =.	 *	 * @return	TRUE iff the next set of tokens is the beginning of a	 *			propertyList().	 */	private boolean propertyListFollows()	{		int tokKind;		return 			getToken(1).kind == PROPERTIES &&				((tokKind = getToken(3).kind) == PERIOD ||					tokKind == EQUALS_OPERATOR				);	}	/**	 * Determine whether the next sequence of tokens can be the beginning	 * of a newInvocation(). A newInvocation() begins with the word "new"	 * followed by a dot-separated list of identifiers, followed	 * by a left parenthesis.	 *	 * @param startToken	Token to look for new at	 *	 * @return	TRUE iff the next set of tokens is the beginning of a	 *			newInvocation().	 */	private boolean newInvocationFollows(int startToken)	{		boolean retval = false;		// newInvocation() starts with the word "new"		if (getToken(startToken).kind == NEW)		{			// Look at every other token. Ignore the identifiers, because			// they are hard to test for.			for (int i = 2 + startToken; true; i += 2)			{				int tokKind = getToken(i).kind;				// If we find a left parenthesis without any intervening				// cruft, we have found a newInvocation()				if (tokKind == LEFT_PAREN)				{					retval = true;					break;				}				else if (tokKind != PERIOD)				{					// Anything other than a PERIOD is "cruft"					break;				}			}		}		return retval;	}	/**	 * Determine whether the next sequence of tokens is a class name	 *	 * @param startToken	Token to look for class name at	 *	 * @return	TRUE iff the next set of tokens is the java class name	 */	boolean javaClassFollows()	{		boolean retval = false;		// Look at every other token. Ignore the identifiers, because		// they are hard to test for.		for (int i = 2; true; i += 2)		{			int tokKind = getToken(i).kind;			// If we find a '::' without any intervening			// cruft, we have found a javaClass			if (tokKind == DOUBLE_COLON)			{				retval = true;				break;			}			else if (tokKind != PERIOD)			{				// Anything other than a PERIOD is "cruft"				break;			}		}		return retval;	}	/**	 * Determine whether the next sequence of tokens can be the beginning	 * of a FROM newInvocation(). A FROM newInvocation() begins with the words "from new"	 * followed by a dot-separated list of identifiers, followed	 * by a left parenthesis.	 *	 * @return	TRUE iff the next set of tokens is the beginning of a	 *			FROM newInvocation().	 */	private boolean fromNewInvocationFollows()	{		boolean retval = false;		// FROM newInvocation() starts with the words "from new"		return (getToken(1).kind == FROM && newInvocationFollows(2));	}	/**	 * Determine whether the next sequence of tokens can be the beginning	 * of a joinedTableExpression(). A joinedTableExpression() begins	 * with one of:	 *	 *	JOIN	 *	INNER JOIN	 *	LEFT OUTER JOIN	 *	RIGHT OUTER JOIN	 *	 * @return	TRUE iff the next set of tokens is the beginning of a	 *			joinedTableExpression().	 */	private boolean joinedTableExpressionFollows()	{		boolean retval = false;		int tokKind1 = getToken(1).kind;		int tokKind2 = getToken(2).kind;		if (tokKind1 == JOIN)		{			retval = true;		}		else if (tokKind1 == INNER && tokKind2 == JOIN)		{			retval = true;		}		else if ((tokKind1 == LEFT || tokKind1 == RIGHT) && tokKind2 == OUTER)		{			if (getToken(3).kind == JOIN)			{				retval = true;			}		}		else if ((tokKind1 == LEFT || tokKind1 == RIGHT) && tokKind2 == JOIN)		{			retval = true;		}		return retval;	}	/**	 * Translate a token for the name of a built-in aggregate to a String	 * containing an aggregate name.	 */	private static String aggName(Token token)	{		String	retval = null;		switch (token.kind)		{		  case MAX:		  	retval = "MAX";			break;		  case AVG:		    retval = "AVG";			break;		  case MIN:		    retval = "MIN";			break;		  case SUM:		    retval = "SUM";			break;		  case COUNT:		    retval = "COUNT";			break;		  default:		  	if (SanityManager.DEBUG)			{				SanityManager.THROWASSERT("Unexpected token type in aggName: " +											token.kind);			}			break;		}		return retval;	}	/**	 * Translate a token for the name of a built-in aggregate to an	 * aggregate definition class.	 */	private static Class aggClass(Token token)	{		Class	retval = null;		switch (token.kind)		{		  case MAX:		  case MIN:		  	retval = MaxMinAggregateDefinition.class;			break;		  case AVG:		  case SUM:		  	retval = SumAvgAggregateDefinition.class;			break;		  case COUNT:		    retval = CountAggregateDefinition.class;			break;		  default:		  	if (SanityManager.DEBUG)			{				SanityManager.THROWASSERT("Unexpected token type in aggClass: "											+ token.kind);			}			break;		}		return retval;	}	/**	 * Determine whether the next sequence of tokens can be the beginning	 * of another element in a PROPERTY list. These elements are of the	 * form:	 *	 *		COMMA dot.separated.list = ...	 *	 * Look for the COMMA, the dots in the dot-separated list, and the =	 *	 * @return	TRUE iff the next set of tokens is the beginning of a	 *			another element in a PROPERTY list.	 */	private boolean anotherPropertyFollows()	{		boolean retval = false;		// Element must start with COMMA		if (getToken(1).kind == COMMA)		{			// Rest of element is dot-separated list with = at end			int i = 3;			int tokKind;			do			{				tokKind = getToken(i).kind;				// If we've found nothing but PERIODs until the EQUALS_OPERATOR				// it is the beginning of another property list element.				if (tokKind == EQUALS_OPERATOR)				{					retval = true;					break;				}				i += 2;			} while (tokKind == PERIOD);		}		return retval;	}	/**	 * Get one of the several types of create alias nodes.	 *	 * @param aliasName	The name of the alias	 * @param fullStaticMethodName	The full path/method name	 * @param aliasSpecificInfo	 Information specific to the type of alias being created.	 * @param aliasType	The type of alias to create	 * @param delimitedIdentifier	Whether or not to treat the class name	 *								as a delimited identifier if trying to	 *								resolve it as a class alias.	 *	 * @return	A CreateAliasNode matching the given parameters	 *	 * @exception StandardException		Thrown on error	 */	QueryTreeNode	getCreateAliasNode(		Object aliasName,		String fullStaticMethodName,		Object aliasSpecificInfo,		char aliasType,		Boolean delimitedIdentifier)		throws StandardException	{		StatementNode aliasNode = (StatementNode) getNodeFactory().getCreateAliasNode			(				aliasName,				fullStaticMethodName,				aliasSpecificInfo,				aliasType,				delimitedIdentifier,				getContextManager()			);		return aliasNode;	}	/**		Create a node for the drop alias/procedure call.	*/	QueryTreeNode	dropAliasNode(Object aliasName, char type) throws StandardException	{		StatementNode stmt = (StatementNode) nodeFactory.getNode(								C_NodeTypes.DROP_ALIAS_NODE,								aliasName,								new Character(type),								getContextManager());		return stmt;	}    /**     * Get a substring node from     *      - the string     *      - the start position     *      - the length     *      - a boolean values for specifying the kind of substring function     * @exception StandardException  Thrown on error     */    ValueNode getSubstringNode( ValueNode stringValue, ValueNode startPosition,                          ValueNode length, Boolean boolVal ) throws StandardException    {        return (ValueNode) nodeFactory.getNode(	    					C_NodeTypes.SUBSTRING_OPERATOR_NODE,		    				stringValue,			    			startPosition,				    		length,				    		ReuseFactory.getInteger(TernaryOperatorNode.SUBSTRING),					    	null,						    getContextManager());    }    final public TableName    qualifiedName(int id_length_limit) throws ParseException, StandardException    {	return qualifiedName( C_NodeTypes.TABLE_NAME, id_length_limit);    }    private void initStatement( String statementSQLText, Object[] paramDefaults)        throws StandardException    {        /* Do per-statement initialization here */        parameterNumber = 0;        stringSlicer = null;        this.statementSQLText = statementSQLText;        this.paramDefaults = paramDefaults;        nodeFactory = getNodeFactory();        initUnnamedParameterList();    } // End of initStatement    private void checkIdentifierLengthLimit( String identifier, int identifier_length_limit)         throws StandardException    {	if (identifier.length() > identifier_length_limit)		throw StandardException.newException(SQLState.LANG_IDENTIFIER_TOO_LONG, identifier, String.valueOf(identifier_length_limit));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -