Exemplo n.º 1
0
        BnfNonterminal Convert(EbnfNonterminal E)
        {
            BnfNonterminal B = null;

            if (nonterminalConversions.ContainsKey(E))
            {
                var footprint = nonterminalConversions [E];
                B = footprint.After;
            }
            else
            {
                B = Bnf.AddNonterminal(E.Name);
                var footprint = new NonterminalConversionFootprint(E, B);
                nonterminalConversions.Add(E, footprint);
            }
            return(B);
        }
Exemplo n.º 2
0
        public static EbnfGrammar Test2()
        {
            EbnfNonterminal S = new EbnfNonterminal(nameof(S));
            EbnfNonterminal A = new EbnfNonterminal(nameof(A));

            EbnfTerminal a = new EbnfTerminal(nameof(a));
            EbnfTerminal b = new EbnfTerminal(nameof(b));
            EbnfTerminal c = new EbnfTerminal(nameof(c));
            EbnfTerminal d = new EbnfTerminal(nameof(d));

            var rule1 = new EbnfRule(S, new EbnfEnumeration(new IEbnfEnumerationPart [] { c, A, d }));
            var rule2 = new EbnfRule(A, new EbnfEnumeration(new IEbnfEnumerationPart [] { a, b }));
            var rule3 = new EbnfRule(A, new EbnfEnumeration(new IEbnfEnumerationPart [] { a }));
            var G     = new EbnfGrammar();

            G.Add(rule1);
            G.Add(rule2);
            G.Add(rule3);
            return(G);
        }
Exemplo n.º 3
0
 public EbnfRule(EbnfNonterminal nt, IEbnfRuleRightPart rightPart)
 {
     nonterminal = nt;
     p           = rightPart;
 }