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)); }
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)); }
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); }
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(); }