Esempio n. 1
0
        public override void ExitNotCondition(PrevailParser.NotConditionContext context)
        {
            base.ExitNotCondition(context);

            var condition = _conditionStack.Pop();

            var not = new NotCondition(condition);

            _conditionStack.Push(not);
        }
Esempio n. 2
0
        public override void ExitAndCondition(PrevailParser.AndConditionContext context)
        {
            base.ExitAndCondition(context);

            var right = _conditionStack.Pop();

            var left = _conditionStack.Pop();

            var and = new AndCondition(new Condition[] { left, right });

            _conditionStack.Push(and);
        }
Esempio n. 3
0
        public override void ExitExpression(PrevailParser.ExpressionContext context)
        {
            base.ExitExpression(context);

            if (_conditionStack.Count != 1)
            {
                throw new PrevailException(String.Format("Expect Result of Parse Expression. Expecting 1 Condition Found {0}.", _conditionStack.Count));
            }
            else
            {

                var result = _conditionStack.Pop();

                _condition = result;
            }
        }
Esempio n. 4
0
        public ExpressionLocator(String Name, int Order, Scope Scope, String Expression)
            : base(Name, Order, Scope)
        {
            _description = String.Format("Expression Locator: Order: {0} Scope: [{1}] Expression: [{2}]", Order, Scope, Expression);

            PrevailLexer lexer = new PrevailLexer(new AntlrInputStream(Expression));

            PrevailParser parser = new PrevailParser(new CommonTokenStream(lexer));

            IParseTree tree = parser.expression();

            ParseTreeWalker walker = new ParseTreeWalker();

            PrevailListener prevailListener = new PrevailListener();

            walker.Walk(prevailListener, tree);

            _condition = prevailListener.Result;
        }
Esempio n. 5
0
        public override void ExitOrCondition(PrevailParser.OrConditionContext context)
        {
            base.ExitOrCondition(context);

            var right = _conditionStack.Pop();

            var left = _conditionStack.Pop();

            var or = new OrCondition(new Condition[] { left, right });

            _conditionStack.Push(or);
        }
Esempio n. 6
0
        public override void ExitValue(PrevailParser.ValueContext context)
        {
            base.ExitValue(context);

            if (context.number() != null)
            {

                var floatingNumber = context.number().FLOAT();

                if (floatingNumber != null)
                {
                    _value = float.Parse(floatingNumber.GetText());

                    return;
                }

                var intNumber = context.number().INT();

                if (intNumber != null)
                {
                    _value = int.Parse(intNumber.GetText());

                    return;
                }

            }

            var stringLiteral = context.STRING();

            if (stringLiteral != null)
            {
                var value = stringLiteral.GetText();

                if (value.StartsWith("'"))
                {
                    if (value.EndsWith("'"))
                    {
                        value = value.Substring(1, value.Length - 2);
                    }
                }

                _value = value;

                return;
            }
        }
Esempio n. 7
0
        public override void ExitPropertyCondition(PrevailParser.PropertyConditionContext context)
        {
            base.ExitPropertyCondition(context);

            MetalMynds.FlatGlass.PrevailParser.PropertyContext propertyContext = (MetalMynds.FlatGlass.PrevailParser.PropertyContext)context.children[0];

            var propertyName = propertyContext.IDENTIFIER().GetText();

            Boolean equals = propertyContext.equals() != null;

            var property = AutomationHelper.GetProperty(propertyName);

            var propertyCondition = new PropertyCondition(property, _value);

            var condition = (Condition)propertyCondition;

            if (!equals)
            {
                condition = (Condition)new NotCondition(condition);
            }

            _conditionStack.Push(condition);
        }