Ejemplo n.º 1
0
        private Expression Expr()
        {
            Expression expr = new Expression ("expr", currentToken.Row, currentToken.Column);
            if ((Token.Types)currentToken.Type == Token.Types.LeftParenthesis ||
                (Token.Types)currentToken.Type == Token.Types.IntLiteral ||
                (Token.Types)currentToken.Type == Token.Types.StringLiteral ||
                (Token.Types)currentToken.Type == Token.Types.Identifier ||
                (Token.Types)currentToken.Type == Token.Types.BoolLiteral) {

                Expression left = Conjuct ();
                Expression right = ExprLogical ();

                if (right.Name != null) {
                    right.AddChild (left);
                    expr.AddChild (right);
                    return expr;
                } else {
                    expr.AddChild (left);
                    return expr;
                }
            } else if ((Token.Types)currentToken.Type == Token.Types.Not) {
                NotExpr notExpr = new NotExpr ("!", currentToken.Row, currentToken.Column);
                Match (Token.Types.Not);
                notExpr.AddChild (Expr ());
                return notExpr;
            }

            throw new SyntaxError ("invalid token to start expression " + currentToken.Type,
            currentToken.Row, currentToken.Column);
        }
Ejemplo n.º 2
0
        private Expression GetNextExpression(List<string> Parts, Expression FirstExpression)
        {
            if (Parts.Count < 2)
            {
                return FirstExpression;
            }

            Expression secondExpression = new ValueExpression(Parts[1]);
            string part = Parts[0];
            Parts.RemoveAt(0);
            Parts.RemoveAt(0);
            if (part.ToUpper().Equals("OR"))
            {
                return new OrExpression(FirstExpression, GetNextExpression(Parts, secondExpression));
            }
            else
            {
                return new AndExpression(FirstExpression, GetNextExpression(Parts, secondExpression));
            }
        }
 public void Visit(Expression node)
 {
     VisitChildren (node);
 }
Ejemplo n.º 4
0
 public AndExpression(Expression expression1, Expression expression2)
 {
     this.Expression1 = expression1;
     this.Expression2 = expression2;
 }