コード例 #1
0
ファイル: EbnfVisitor.cs プロジェクト: ArsenShnurkov/Pliant
        private EbnfTerm VisitTermNode(IInternalTreeNode node)
        {
            EbnfFactor factor = null;
            EbnfTerm   term   = 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 (EbnfGrammar.Factor == symbolValue)
                    {
                        factor = VisitFactorNode(internalNode);
                    }
                    else if (EbnfGrammar.Term == symbolValue)
                    {
                        term = VisitTermNode(internalNode);
                    }
                    break;

                case TreeNodeType.Token:
                    break;
                }
            }
            if (term == null)
            {
                return(new EbnfTerm(factor));
            }
            return(new EbnfTermConcatenation(factor, term));
        }
コード例 #2
0
ファイル: EbnfVisitor.cs プロジェクト: ArsenShnurkov/Pliant
        private EbnfExpression VisitExpressionNode(IInternalTreeNode node)
        {
            EbnfTerm       term       = null;
            EbnfExpression 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 (EbnfGrammar.Term == symbolValue)
                    {
                        term = VisitTermNode(internalNode);
                    }
                    else if (EbnfGrammar.Expression == symbolValue)
                    {
                        expression = VisitExpressionNode(internalNode);
                    }
                    break;

                case TreeNodeType.Token:
                    break;
                }
            }
            if (expression == null)
            {
                return(new EbnfExpression(term));
            }
            return(new EbnfExpressionAlteration(term, expression));
        }
コード例 #3
0
ファイル: EbnfExpression.cs プロジェクト: DinkDev/Pliant
 public EbnfExpressionAlteration(
     EbnfTerm term,
     EbnfExpression expression)
     : base(term)
 {
     Expression = expression;
     _hashCode  = ComputeHashCode();
 }
コード例 #4
0
        IEnumerable <ProductionModel> Term(EbnfTerm term, ProductionModel currentProduction)
        {
            foreach (var production in Factor(term.Factor, currentProduction))
            {
                yield return(production);
            }

            if (term.NodeType != EbnfNodeType.EbnfTermConcatenation)
            {
                yield break;
            }

            var concatenation = term as EbnfTermConcatenation;

            foreach (var production in Term(concatenation.Term, currentProduction))
            {
                yield return(production);
            }
        }
コード例 #5
0
ファイル: EbnfExpression.cs プロジェクト: DinkDev/Pliant
 public EbnfExpression(EbnfTerm term)
 {
     Term      = term;
     _hashCode = ComputeHashCode();
 }
コード例 #6
0
ファイル: EbnfTerm.cs プロジェクト: DinkDev/Pliant
 public EbnfTermConcatenation(EbnfFactor factor, EbnfTerm term)
     : base(factor)
 {
     Term      = term;
     _hashCode = ComputeHashCode();
 }
コード例 #7
0
        IEnumerable<ProductionModel> Term(EbnfTerm term, ProductionModel currentProduction)
        {
            foreach (var production in Factor(term.Factor, currentProduction))
                yield return production;

            if (term.NodeType != EbnfNodeType.EbnfTermConcatenation)
                yield break;

            var concatenation = term as EbnfTermConcatenation;
            foreach(var production in Term(concatenation.Term, currentProduction))
                yield return production;
        }
コード例 #8
0
ファイル: EbnfTerm.cs プロジェクト: bilsaboob/Pliant
 public EbnfTermConcatenation(EbnfFactor factor, EbnfTerm term)
     : base(factor)
 {
     Term = term;
     _hashCode = ComputeHashCode();
 }