Ejemplo n.º 1
0
        private Nfa LexerRuleTerm(IEbnfLexerRuleTerm term)
        {
            var nfa = LexerRuleFactor(term.Factor);

            if (term is EbnfLexerRuleTermConcatenation concatenation)
            {
                var concatNfa = LexerRuleTerm(concatenation.Term);
                nfa = nfa.Concatenation(concatNfa);
            }

            return(nfa);
        }
Ejemplo n.º 2
0
        private IEbnfLexerRuleTerm VisitLexerRuleTermNode(IInternalTreeNode node)
        {
            IEbnfLexerRuleFactor factor = null;
            IEbnfLexerRuleTerm   term   = null;

            foreach (var internalNode in node.Children.OfType <IInternalTreeNode>())
            {
                if (internalNode.Is(EbnfGrammar.LexerRuleFactor))
                {
                    factor = VisitLexerRuleFactorNode(internalNode);
                }
                else if (internalNode.Is(EbnfGrammar.LexerRuleTerm))
                {
                    term = VisitLexerRuleTermNode(internalNode);
                }
            }

            if (term == null)
            {
                return(new EbnfLexerRuleTermSimple(factor));
            }

            return(new EbnfLexerRuleTermConcatenation(factor, term));
        }
Ejemplo n.º 3
0
        private IEbnfLexerRuleExpression VisitLexerRuleExpressionNode(IInternalTreeNode node)
        {
            IEbnfLexerRuleTerm       term       = null;
            IEbnfLexerRuleExpression expression = null;

            foreach (var internalNode in node.Children.OfType <IInternalTreeNode>())
            {
                if (internalNode.Is(EbnfGrammar.LexerRuleTerm))
                {
                    term = VisitLexerRuleTermNode(internalNode);
                }
                else if (internalNode.Is(EbnfGrammar.LexerRuleExpression))
                {
                    expression = VisitLexerRuleExpressionNode(internalNode);
                }
            }

            if (expression == null)
            {
                return(new EbnfLexerRuleExpressionSimple(term));
            }

            return(new EbnfLexerRuleExpressionAlteration(term, expression));
        }
Ejemplo n.º 4
0
 public EbnfLexerRuleExpressionAlteration(IEbnfLexerRuleTerm term, IEbnfLexerRuleExpression expression)
 {
     Term       = term;
     Expression = expression;
 }
Ejemplo n.º 5
0
 public EbnfLexerRuleExpressionSimple(IEbnfLexerRuleTerm term)
 {
     Term = term;
 }
Ejemplo n.º 6
0
 public EbnfLexerRuleTermConcatenation(IEbnfLexerRuleFactor factor, IEbnfLexerRuleTerm term)
 {
     Factor = factor;
     Term   = term;
 }