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); }
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); }
public FromEbnfToBnf_ByCopying(EbnfGrammar EG) { Convert(EG); }