Beispiel #1
0
        private PdlLexerRuleTerm VisitLexerRuleTermNode(IInternalTreeNode node)
        {
            PdlLexerRuleFactor factor = null;
            PdlLexerRuleTerm   term   = null;

            for (int c = 0; c < node.Children.Count; c++)
            {
                var child = node.Children[c];
                if (child.NodeType != TreeNodeType.Internal)
                {
                    continue;
                }
                var internalNode = child as IInternalTreeNode;
                var symbolValue  = internalNode.Symbol.Value;
                if (PdlGrammar.LexerRuleFactor == symbolValue)
                {
                    factor = VisitLexerRuleFactorNode(internalNode);
                }
                if (PdlGrammar.LexerRuleTerm == symbolValue)
                {
                    term = VisitLexerRuleTermNode(internalNode);
                }
            }

            if (term is null)
            {
                return(new PdlLexerRuleTerm(factor));
            }

            return(new PdlLexerRuleTermConcatenation(factor, term));
        }
Beispiel #2
0
        private PdlLexerRuleExpression VisitLexerRuleExpressionNode(IInternalTreeNode node)
        {
            PdlLexerRuleTerm       term       = null;
            PdlLexerRuleExpression expression = null;

            for (int c = 0; c < node.Children.Count; c++)
            {
                var child = node.Children[c];
                if (child.NodeType != TreeNodeType.Internal)
                {
                    continue;
                }
                var internalNode = child as IInternalTreeNode;
                var symbolValue  = internalNode.Symbol.Value;
                if (PdlGrammar.LexerRuleTerm == symbolValue)
                {
                    term = VisitLexerRuleTermNode(internalNode);
                }
                if (PdlGrammar.LexerRuleExpression == symbolValue)
                {
                    expression = VisitLexerRuleExpressionNode(internalNode);
                }
            }

            if (expression is null)
            {
                return(new PdlLexerRuleExpression(term));
            }
            return(new PdlLexerRuleExpressionAlteration(term, expression));
        }
        INfa LexerRuleTerm(PdlLexerRuleTerm term)
        {
            var nfa = LexerRuleFactor(term.Factor);

            if (term.NodeType == PdlNodeType.PdlLexerRuleTermConcatenation)
            {
                var concatenation = term as PdlLexerRuleTermConcatenation;
                var concatNfa     = LexerRuleTerm(concatenation.Term);
                nfa = nfa.Concatenation(concatNfa);
            }
            return(nfa);
        }
Beispiel #4
0
 public PdlLexerRuleTermConcatenation(PdlLexerRuleFactor factor, PdlLexerRuleTerm term)
     : base(factor)
 {
     Term      = term;
     _hashCode = ComputeHashCode();
 }
 public PdlLexerRuleExpressionAlteration(PdlLexerRuleTerm term, PdlLexerRuleExpression expression)
     : base(term)
 {
     Expression = expression;
     _hashCode  = ComputeHashCode();
 }
 public PdlLexerRuleExpression(PdlLexerRuleTerm term)
 {
     Term      = term;
     _hashCode = ComputeHashCode();
 }