public static T Create() { ForeignGrammarFactory <T> factory = new ForeignGrammarFactory <T>(); T result = proxyGenerator.CreateClassProxy <T>(factory); int nonterminalIndex = 0; // Now initialize the grammar foreach (MethodInfo method in typeof(T).GetMethods()) { if (method.ReturnType == typeof(Expression) && method.GetParameters().Length == 0 && !method.IsSpecialName) { ForeignNonterminal rule = new ForeignNonterminal(); rule.Name = method.Name; factory.rules[rule.Name] = rule; } } T tokenizerGrammar = GrammarFactory <T> .Create(); result.SetTokenizer(tokenizerGrammar, tokenizerGrammar.Tokenizer); return(result); }