public void Emit(CompilationContext context) { var grammar = System.Reflection.Assembly.GetExecutingAssembly().GetTypes() .Where(c => c.Namespace == "CmC.Compiler.Syntax.Assembly" || c.Namespace == "CmC.Compiler.Syntax.Common") .Where(c => typeof(ILanguageToken).IsAssignableFrom(c)) .Select(t => (ILanguageToken)Activator.CreateInstance(t, null)).ToList(); var generator = new ParserGenerator(grammar); LanguageParser parser = generator.GetParser(); var tokens = parser.Parse(AssemblySource, "ASM_INSTRUCTION"); foreach (var token in tokens) { ((ICodeEmitter)token).Emit(context); } }
private static void ProcessSourceText(string text, CompilationContext context) { var grammar = Assembly.GetExecutingAssembly().GetTypes() .Where(c => c.Namespace == "CmC.Compiler.Syntax" || c.Namespace == "CmC.Compiler.Syntax.Common") .Where(c => typeof(ILanguageToken).IsAssignableFrom(c)) .Select(t => (ILanguageToken)Activator.CreateInstance(t, null)); var generator = new ParserGenerator(grammar.ToList()); LanguageParser parser = generator.GetParser(); var tokens = parser.Parse(text); foreach (var token in tokens) { ((ICodeEmitter)token).Emit(context); } }