Example #1
0
        /// <summary>
        /// Is a RuleReturnScope node candidate for the left-hand-side of an in expression?
        /// </summary>
        /// <param name="lhs">The RuleReturnScope node</param>
        /// <param name="cached">The cached result of a former call to this method</param>
        /// <returns>True if so, false otherwise</returns>
        public bool IsLeftHandSideIn(RuleReturnScope lhs, ref bool? cached)
        {
            if (cached.HasValue)
            {
                return cached.Value;
            }

            bool result = IsLeftHandSideExpression(lhs) && (input.LA(1) == IN);

            cached = result;
            return result;
        }
Example #2
0
        /// <summary>
        /// Is a RuleReturnScope node candidate for the left-hand-side of an assignment expression?
        /// </summary>
        /// <param name="lhs">The RuleReturnScope node</param>
        /// <param name="cached">The cached result of a former call to this method</param>
        /// <returns>True if so, false otherwise</returns>
        public bool IsLeftHandSideAssign(RuleReturnScope lhs, ref bool? cached)
        {
            if (cached.HasValue)
            {
                return cached.Value;
            }

            bool result;
            if (IsLeftHandSideExpression(lhs))
            {
                switch (input.LA(1))
                {
                    case ASSIGN:
                    case MULASS:
                    case DIVASS:
                    case MODASS:
                    case ADDASS:
                    case SUBASS:
                    case SHLASS:
                    case SHRASS:
                    case SHUASS:
                    case ANDASS:
                    case XORASS:
                    case ORASS:
                        result = true;
                        break;

                    default:
                        result = false;
                        break;
                }
            }
            else
            {
                result = false;
            }

            cached = result;
            return result;
        }
		/// <summary>
		/// Is a RuleReturnScope node candidate a left-hand-side expression?
		/// </summary>
		/// <param name="lhs">The RuleReturnScope node</param>
		/// <returns>True if so, false otherwise</returns>
		private bool IsLeftHandSideExpression(RuleReturnScope lhs)
		{
			if (lhs.Tree == null) // e.g. during backtracking
			{
				return true;
			}
			else
			{
				switch (((ITree)lhs.Tree).Type)
				{
					// primaryExpression
					case THIS:
					case Identifier:
					case NULL:
					case TRUE:
					case FALSE:
					case DecimalLiteral:
					case OctalIntegerLiteral:
					case HexIntegerLiteral:
					case StringLiteral:
					case RegularExpressionLiteral:
					case ARRAY:
					case OBJECT:
					case PAREXPR:
					// functionExpression
					case FUNCTION:
					// newExpression
					case NEW:
					// leftHandSideExpression
					case CALL:
					case BYFIELD:
					case BYINDEX:
						return true;

					default:
						return false;
				}
			}
		}
Example #4
0
 private bool isLeftHandSideIn(RuleReturnScope lhs, Object[] cached)
 {
 	if (cached[0] != null)
 	{
 		return (bool)cached[0];
 	}
 	
 	bool result = isLeftHandSideExpression(lhs) && (input.LA(1) == IN);
 	cached[0] = result;
 	return result;
 }
Example #5
0
 private bool isLeftHandSideAssign(RuleReturnScope lhs, Object[] cached)
 {
 	if (cached[0] != null)
 	{
 		return (bool)cached[0];
 	}
 	
 	bool result;
 	if (isLeftHandSideExpression(lhs))
 	{
 		switch (input.LA(1))
 		{
 			case ASSIGN:
 			case MULASS:
 			case DIVASS:
 			case MODASS:
 			case ADDASS:
 			case SUBASS:
 			case SHLASS:
 			case SHRASS:
 			case SHUASS:
 			case ANDASS:
 			case XORASS:
 			case ORASS:
 				result = true;
 				break;
 			default:
 				result = false;
 				break;
 		}
 	}
 	else
 	{
 		result = false;
 	}
 	
 	cached[0] = result;
 	return result;
 }