コード例 #1
0
        private async void Compile_Click(object sender, RoutedEventArgs e)
        {
            string code = Code.Text;

            var lexicalAnalyser = new LexicalAnalyser();

            var tokens = await lexicalAnalyser.ExecuteAsync(code);

            var syntaticAnalyser = new SyntacticAnalyser(tokens.ToList());

            var result = await syntaticAnalyser.ExecuteAsync();

            foreach (var token in tokens)
            {
                var tokenName = $"TokenType: {token.TokenType}";

                var tokenValue = $"Lexema: {token.TokenValue}";

                Console.WriteLine(string.Format("{0,-40} {1,5}\n", tokenName, tokenValue));
            }

            var assemblyGenerator = new AssemblyGenerator(result);

            await assemblyGenerator.GenerateAsync();

            Console.ReadLine();
        }