public override ConditionalNode VisitConditionalBlock(ConditionalBlockContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("Context can't be null");
            }

            // Process the statements and add them to the conditionalBlock.
            var logicalExpressionVisitor = new LogicalExpressionVisitor();
            var expression = logicalExpressionVisitor.VisitLogicalExpression(context.logicalExpression());

            //Create a conditionalBlock wherein we can store the results.
            var conditionalNode = new ConditionalNode(Location.FromContext(context), expression);

            // Get the sections and process them.
            var sectionContexts = context.section();
            var sectionVisitor  = new SectionVisitor();

            foreach (var sectionContext in sectionContexts)
            {
                conditionalNode.AddNode(sectionVisitor.VisitSection(sectionContext));
            }

            return(conditionalNode);
        }
Пример #2
0
        public override FormNode VisitForm(FormContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("Context can't be null");
            }

            if (context.children.Any(x => x.GetType() == typeof(ErrorNodeImpl)))
            {
                return(null);
            }

            // Construct FormNode object to store the results in.
            var      name = context.formName().GetText();
            FormNode node = new FormNode(Location.FromContext(context), name);

            // Get the sections
            SectionContext[] sectionContexts = context.section();
            SectionVisitor   visitor         = new SectionVisitor();

            foreach (SectionContext sectionContext in sectionContexts)
            {
                node.AddNode(visitor.VisitSection(sectionContext));
            }

            return(node);
        }