Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public PdlLexerRuleTermConcatenation(PdlLexerRuleFactor factor, PdlLexerRuleTerm term)
     : base(factor)
 {
     Term      = term;
     _hashCode = ComputeHashCode();
 }
Exemplo n.º 5
0
 public PdlLexerRuleExpressionAlteration(PdlLexerRuleTerm term, PdlLexerRuleExpression expression)
     : base(term)
 {
     Expression = expression;
     _hashCode  = ComputeHashCode();
 }
Exemplo n.º 6
0
 public PdlLexerRuleExpression(PdlLexerRuleTerm term)
 {
     Term      = term;
     _hashCode = ComputeHashCode();
 }