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); } } }
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)); }
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)); }
public EbnfTermConcatenation(IEbnfFactor factor, IEbnfTerm term) { Factor = factor; Term = term; }
public EbnfExpressionAlteration(IEbnfTerm term, IEbnfExpression expression) { Term = term; Expression = expression; }
public EbnfExpressionSimple(IEbnfTerm term) { Term = term; }