Пример #1
0
        private Expression matchSTROPERATOR(Expression litr1)
        {
            int operator_indx = match((int)TokenTags.STROPERATOR);

            Expression litr2 = expression();

            if (litr2.Type == ExpressionTypes.Number)
            {
                litr2 = new StrExpr(Convert.ToString(litr2.Value()));
            }
            Expression oprtr;

            switch (((Word)TokenList[operator_indx]).lexeme)
            {
            case "$+":
                oprtr = new Pluss(ExpressionTypes.String, litr1, litr2);
                break;

            case "$==":
                oprtr = new Equal(ExpressionTypes.String, litr1, litr2);
                break;

            case "$!=":
                oprtr = new NotEqual(ExpressionTypes.String, litr1, litr2);
                break;

            default: throw new Exception("Fatal error: wrong operator");
            }
            return(oprtr);
        }
Пример #2
0
        private Expression matchBOPERATOR(Expression eNumb1)
        {
            int operator_indx = match((int)TokenTags.BOPERATOR);

            Expression eNumb2 = expression();

            if (eNumb2.Type == ExpressionTypes.String)
            {
                string err1 = "Syntax Error : must be Number";
                throw new Exception(err1);
            }
            Expression oprtr;

            switch (((Word)TokenList[operator_indx]).lexeme)
            {
            case "+":
                oprtr = new Pluss(ExpressionTypes.Number, eNumb1, eNumb2);
                break;

            case "-":
                oprtr = new Minus(eNumb1, eNumb2);
                break;

            case "*":
                oprtr = new Mult(eNumb1, eNumb2);
                break;

            case "/":
                oprtr = new Div(eNumb1, eNumb2);
                break;

            case ">":
                oprtr = new Bigger(eNumb1, eNumb2);
                break;

            case "<":
                oprtr = new Less(eNumb1, eNumb2);
                break;

            case ">=":
                oprtr = new BiggerEqual(eNumb1, eNumb2);
                break;

            case "<=":
                oprtr = new LessEqual(eNumb1, eNumb2);
                break;

            case "==":
                oprtr = new Equal(ExpressionTypes.Number, eNumb1, eNumb2);
                break;

            case "!=":
                oprtr = new NotEqual(ExpressionTypes.Number, eNumb1, eNumb2);
                break;

            default: throw new Exception("Fatal error: wrong operator");
            }
            return(oprtr);
        }