示例#1
0
        BnfGrammar Convert(EbnfGrammar EG)
        {
            Bnf       = new BnfGrammar();
            Footprint = new GrammarConversionFootprint(EG, Bnf);
            foreach (var er in EG.Rules)
            {
                BnfRule br = Convert(er);
            }
            List <IOperationFootprint> ops = new List <IOperationFootprint> ();

            ops.AddRange(nonterminalConversions.Values);
            ops.AddRange(ruleConversions.Values);
            Footprint.Parts = ops.ToArray();
            return(Bnf);
        }
示例#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);
        }
示例#3
0
 public FromEbnfToBnf_ByCopying(EbnfGrammar EG)
 {
     Convert(EG);
 }