コード例 #1
0
        // ExprAndOr:
        private void MatchExprAndOr(out IExpr result)
        {
            TokenTypes t;                               // remember the type

            IExpr lhs;

            MatchExprNot(out lhs);
            result = lhs;                               // in case we get no matches
            while ((t = curToken.Type) == TokenTypes.AND || t == TokenTypes.OR)
            {
                curToken = tokens.Extract();
                IExpr rhs;
                MatchExprNot(out rhs);
                bool bBool = (rhs.GetTypeCode() == TypeCode.Boolean &&
                              lhs.GetTypeCode() == TypeCode.Boolean);
                if (!bBool)
                {
                    throw new ParserException("AND/OR operations require both sides to be boolean expressions." + "  At column " + Convert.ToString(curToken.StartCol));
                }

                switch (t)
                {
                case TokenTypes.AND:
                    result = new FunctionAnd(lhs, rhs);
                    break;

                case TokenTypes.OR:
                    result = new FunctionOr(lhs, rhs);
                    break;
                }
                lhs = result;                           // in case we have more AND/OR s
            }
        }
コード例 #2
0
ファイル: Parser.cs プロジェクト: hardsoft/My-FyiReporting
		// ExprAndOr: 
		private void MatchExprAndOr(out IExpr result)
		{
			TokenTypes t;			// remember the type

			IExpr lhs;
			MatchExprNot(out lhs);
			result = lhs;			// in case we get no matches
			while ((t = curToken.Type) == TokenTypes.AND || t == TokenTypes.OR)
			{
				curToken = tokens.Extract();
				IExpr rhs;
				MatchExprNot(out rhs);
				bool bBool = (rhs.GetTypeCode() == TypeCode.Boolean &&
					lhs.GetTypeCode() == TypeCode.Boolean);
				if (!bBool)
					throw new ParserException("AND/OR operations require both sides to be boolean expressions." + "  At column " + Convert.ToString(curToken.StartCol));

				switch(t)
				{
					case TokenTypes.AND:
						result = new FunctionAnd(lhs, rhs);
						break;
					case TokenTypes.OR:
						result = new FunctionOr(lhs, rhs);
						break;
				}
				lhs = result;		// in case we have more AND/OR s
			}
		}
コード例 #3
0
ファイル: Parser.cs プロジェクト: Elboodo/My-FyiReporting
		// ExprAndOr: 
		private void MatchExprAndOr(out IExpr result)
		{
			TokenTypes t;			// remember the type

			IExpr lhs;
			MatchExprNot(out lhs);
			result = lhs;			// in case we get no matches
			while ((t = curToken.Type) == TokenTypes.AND || t == TokenTypes.OR)
			{
				curToken = tokens.Extract();
				IExpr rhs;
				MatchExprNot(out rhs);
				bool bBool = (rhs.GetTypeCode() == TypeCode.Boolean &&
					lhs.GetTypeCode() == TypeCode.Boolean);
				if (!bBool)
					throw new ParserException(Strings.Parser_ErrorP_AND_OR_RequiresBoolean + GetLocationInfo(curToken));

				switch(t)
				{
					case TokenTypes.AND:
						result = new FunctionAnd(lhs, rhs);
						break;
					case TokenTypes.OR:
						result = new FunctionOr(lhs, rhs);
						break;
				}
				lhs = result;		// in case we have more AND/OR s
			}
		}