Beispiel #1
0
        // Program
        public override object VisitProg([NotNull] GrammarParser.ProgContext context)
        {
            // 1. Visit and resolve left side (must return an AttributeValue)
            AttrValAndFeatureSelPair leftSideResult            = (AttrValAndFeatureSelPair)Visit(context.lefthandexpr());
            AttributeValue           leftSideAttributeValueBLO = leftSideResult.AttributeValue;


            // 2. Visit and resolve right side (value - single or multiple)
            object rightSideValue = Visit(context.righthandexpr());


            // 3. Validate and assign resulting value in right side to AttributeValue on the left side
            bool isDifferent = (leftSideAttributeValueBLO.Value != rightSideValue.ToString());

            if (rightSideValue.GetType() == typeof(int) && leftSideAttributeValueBLO.AttributeDataType == Core.BLOs.AttributeDataTypes.Integer)
            {
                leftSideAttributeValueBLO.Value = rightSideValue.ToString();
            }
            else if (rightSideValue.GetType() == typeof(bool))
            {
                leftSideAttributeValueBLO.Value = rightSideValue.ToString();
            }
            else
            {
                throw new Exception("Right side must evaluate to an int or bool");
            }


            // 4. Return the AttributeValue and it's parent FeatureSelection if any changes were done to it
            object returnValue = (isDifferent) ? leftSideResult.ParentFeatureSelection : null;

            return(returnValue);
        }
Beispiel #2
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="GrammarParser.prog"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitProg([NotNull] GrammarParser.ProgContext context)
 {
 }