Esempio n. 1
0
        private IEnumerable <ProductionModel> Term(IEbnfTerm term, ProductionModel currentProduction)
        {
            foreach (var production in Factor(term.Factor, currentProduction))
            {
                yield return(production);
            }

            if (term is EbnfTermConcatenation concatenation)
            {
                foreach (var production in Term(concatenation.Term, currentProduction))
                {
                    yield return(production);
                }
            }
        }
Esempio n. 2
0
        private IEbnfTerm VisitTermNode(IInternalTreeNode node)
        {
            IEbnfFactor factor = null;
            IEbnfTerm   term   = null;

            foreach (var internalNode in node.Children.OfType <IInternalTreeNode>())
            {
                if (internalNode.Is(EbnfGrammar.Factor))
                {
                    factor = VisitFactorNode(internalNode);
                }
                else if (internalNode.Is(EbnfGrammar.Term))
                {
                    term = VisitTermNode(internalNode);
                }
            }

            if (term == null)
            {
                return(new EbnfTermSimple(factor));
            }

            return(new EbnfTermConcatenation(factor, term));
        }
Esempio n. 3
0
        private IEbnfExpression VisitExpressionNode(IInternalTreeNode node)
        {
            IEbnfTerm       term       = null;
            IEbnfExpression expression = null;

            foreach (var internalNode in node.Children.OfType <IInternalTreeNode>())
            {
                if (internalNode.Is(EbnfGrammar.Term))
                {
                    term = VisitTermNode(internalNode);
                }
                else if (internalNode.Is(EbnfGrammar.Expression))
                {
                    expression = VisitExpressionNode(internalNode);
                }
            }

            if (expression == null)
            {
                return(new EbnfExpressionSimple(term));
            }

            return(new EbnfExpressionAlteration(term, expression));
        }
Esempio n. 4
0
 public EbnfTermConcatenation(IEbnfFactor factor, IEbnfTerm term)
 {
     Factor = factor;
     Term   = term;
 }
Esempio n. 5
0
 public EbnfExpressionAlteration(IEbnfTerm term, IEbnfExpression expression)
 {
     Term       = term;
     Expression = expression;
 }
Esempio n. 6
0
 public EbnfExpressionSimple(IEbnfTerm term)
 {
     Term = term;
 }