Exemple #1
0
        private PdlBlockRule VisitRuleNode(IInternalTreeNode node)
        {
            PdlQualifiedIdentifier qualifiedIdentifier = null;
            PdlExpression          expression          = null;

            for (int c = 0; c < node.Children.Count; c++)
            {
                var child = node.Children[c];
                switch (child.NodeType)
                {
                case TreeNodeType.Internal:
                    var internalNode = child as IInternalTreeNode;
                    var symbolValue  = internalNode.Symbol.Value;

                    if (PdlGrammar.QualifiedIdentifier == symbolValue)
                    {
                        qualifiedIdentifier = VisitQualifiedIdentifierNode(internalNode);
                    }
                    else if (PdlGrammar.Expression == symbolValue)
                    {
                        expression = VisitExpressionNode(internalNode);
                    }
                    break;

                case TreeNodeType.Token:
                    break;
                }
            }
            return(new PdlBlockRule(
                       new PdlRule(qualifiedIdentifier, expression)));
        }
Exemple #2
0
        private PdlExpression VisitExpressionNode(IInternalTreeNode node)
        {
            PdlTerm       term       = null;
            PdlExpression expression = null;

            for (int c = 0; c < node.Children.Count; c++)
            {
                var child = node.Children[c];
                switch (child.NodeType)
                {
                case TreeNodeType.Internal:
                    var internalNode = child as IInternalTreeNode;
                    var symbolValue  = internalNode.Symbol.Value;
                    if (PdlGrammar.Term == symbolValue)
                    {
                        term = VisitTermNode(internalNode);
                    }
                    else if (PdlGrammar.Expression == symbolValue)
                    {
                        expression = VisitExpressionNode(internalNode);
                    }
                    break;

                case TreeNodeType.Token:
                    break;
                }
            }
            if (expression is null)
            {
                return(new PdlExpression(term));
            }
            return(new PdlExpressionAlteration(term, expression));
        }
Exemple #3
0
 public PdlExpressionAlteration(
     PdlTerm term,
     PdlExpression expression)
     : base(term)
 {
     Expression = expression;
     _hashCode  = ComputeHashCode();
 }
        IEnumerable <ProductionModel> Expression(PdlExpression expression, ProductionModel currentProduction)
        {
            foreach (var production in Term(expression.Term, currentProduction))
            {
                yield return(production);
            }

            if (expression.NodeType != PdlNodeType.PdlExpressionAlteration)
            {
                yield break;
            }

            var expressionAlteration = expression as PdlExpressionAlteration;

            currentProduction.Lambda();

            foreach (var production in Expression(expressionAlteration.Expression, currentProduction))
            {
                yield return(production);
            }
        }
Exemple #5
0
 public PdlFactorGrouping(PdlExpression expression)
 {
     Expression = expression;
     _hashCode  = ComputeHashCode();
 }
Exemple #6
0
 public PdlFactorOptional(PdlExpression expression)
 {
     Expression = expression;
     _hashCode  = ComputeHashCode();
 }
Exemple #7
0
 public PdlFactorRepetition(PdlExpression expression)
 {
     Expression = expression;
     _hashCode  = ComputeHashCode();
 }
Exemple #8
0
 public PdlRule(PdlQualifiedIdentifier qualifiedIdentifier, PdlExpression expression)
 {
     QualifiedIdentifier = qualifiedIdentifier;
     Expression          = expression;
     _hashCode           = ComputeHashCode();
 }