Пример #1
0
        // ExprRelop:
        private void MatchExprRelop(out IExpr result)
        {
            TokenTypes t;                               // remember the type

            IExpr lhs;

            MatchExprAddSub(out lhs);
            result = lhs;                               // in case we get no matches
            while ((t = curToken.Type) == TokenTypes.EQUAL ||
                   t == TokenTypes.NOTEQUAL ||
                   t == TokenTypes.GREATERTHAN ||
                   t == TokenTypes.GREATERTHANOREQUAL ||
                   t == TokenTypes.LESSTHAN ||
                   t == TokenTypes.LESSTHANOREQUAL)
            {
                curToken = tokens.Extract();
                IExpr rhs;
                MatchExprAddSub(out rhs);

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

                case TokenTypes.NOTEQUAL:
                    result = new FunctionRelopNE(lhs, rhs);
                    break;

                case TokenTypes.GREATERTHAN:
                    result = new FunctionRelopGT(lhs, rhs);
                    break;

                case TokenTypes.GREATERTHANOREQUAL:
                    result = new FunctionRelopGTE(lhs, rhs);
                    break;

                case TokenTypes.LESSTHAN:
                    result = new FunctionRelopLT(lhs, rhs);
                    break;

                case TokenTypes.LESSTHANOREQUAL:
                    result = new FunctionRelopLTE(lhs, rhs);
                    break;
                }
                lhs = result;                           // in case we continue the loop
            }
        }
Пример #2
0
		// ExprRelop: 
		private void MatchExprRelop(out IExpr result)
		{
			TokenTypes t;			// remember the type

			IExpr lhs;
			MatchExprAddSub(out lhs);
			result = lhs;			// in case we get no matches
			while ((t = curToken.Type) == TokenTypes.EQUAL ||
				t == TokenTypes.NOTEQUAL ||
				t == TokenTypes.GREATERTHAN ||
				t == TokenTypes.GREATERTHANOREQUAL ||
				t == TokenTypes.LESSTHAN ||
				t == TokenTypes.LESSTHANOREQUAL)
			{
				curToken = tokens.Extract();
				IExpr rhs;
				MatchExprAddSub(out rhs);

				switch(t)
				{
					case TokenTypes.EQUAL:
						result = new FunctionRelopEQ(lhs, rhs);
						break;
					case TokenTypes.NOTEQUAL:
						result = new FunctionRelopNE(lhs, rhs);
						break;
					case TokenTypes.GREATERTHAN:
						result = new FunctionRelopGT(lhs, rhs);
						break;
					case TokenTypes.GREATERTHANOREQUAL:
						result = new FunctionRelopGTE(lhs, rhs);
						break;
					case TokenTypes.LESSTHAN:
						result = new FunctionRelopLT(lhs, rhs);
						break;
					case TokenTypes.LESSTHANOREQUAL:
						result = new FunctionRelopLTE(lhs, rhs);
						break;
				}
				lhs = result;		// in case we continue the loop
			}
		}