示例#1
0
        private EbnfLexerRuleExpression VisitLexerRuleExpressionNode(IInternalTreeNode node)
        {
            EbnfLexerRuleTerm       term       = null;
            EbnfLexerRuleExpression 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 (EbnfGrammar.LexerRuleTerm == symbolValue)
                {
                    term = VisitLexerRuleTermNode(internalNode);
                }
                if (EbnfGrammar.LexerRuleExpression == symbolValue)
                {
                    expression = VisitLexerRuleExpressionNode(internalNode);
                }
            }

            if (expression == null)
            {
                return(new EbnfLexerRuleExpression(term));
            }
            return(new EbnfLexerRuleExpressionAlteration(term, expression));
        }
示例#2
0
        private EbnfLexerRuleTerm VisitLexerRuleTermNode(IInternalTreeNode node)
        {
            EbnfLexerRuleFactor factor = null;
            EbnfLexerRuleTerm   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 (EbnfGrammar.LexerRuleFactor == symbolValue)
                {
                    factor = VisitLexerRuleFactorNode(internalNode);
                }
                if (EbnfGrammar.LexerRuleTerm == symbolValue)
                {
                    term = VisitLexerRuleTermNode(internalNode);
                }
            }

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

            return(new EbnfLexerRuleTermConcatenation(factor, term));
        }
示例#3
0
        INfa LexerRuleTerm(EbnfLexerRuleTerm term)
        {
            var nfa = LexerRuleFactor(term.Factor);

            if (term.NodeType == EbnfNodeType.EbnfLexerRuleTermConcatenation)
            {
                var concatenation = term as EbnfLexerRuleTermConcatenation;
                var concatNfa     = LexerRuleTerm(concatenation.Term);
                nfa = nfa.Concatenation(concatNfa);
            }
            return(nfa);
        }
示例#4
0
 public EbnfLexerRuleTermConcatenation(EbnfLexerRuleFactor factor, EbnfLexerRuleTerm term)
     : base(factor)
 {
     Term      = term;
     _hashCode = ComputeHashCode();
 }
 public EbnfLexerRuleExpressionAlteration(EbnfLexerRuleTerm term, EbnfLexerRuleExpression expression)
     : base(term)
 {
     Expression = expression;
     _hashCode = ComputeHashCode();
 }
 public EbnfLexerRuleExpression(EbnfLexerRuleTerm term)
 {
     Term = term;
     _hashCode = ComputeHashCode();
 }
示例#7
0
 public EbnfLexerRuleExpressionAlteration(EbnfLexerRuleTerm term, EbnfLexerRuleExpression expression)
     : base(term)
 {
     Expression = expression;
     _hashCode  = ComputeHashCode();
 }
示例#8
0
 public EbnfLexerRuleExpression(EbnfLexerRuleTerm term)
 {
     Term      = term;
     _hashCode = ComputeHashCode();
 }
示例#9
0
 public EbnfLexerRuleTermConcatenation(EbnfLexerRuleFactor factor, EbnfLexerRuleTerm term)
     : base(factor)
 {
     Term = term;
     _hashCode = ComputeHashCode();
 }