コード例 #1
0
        static void Compile(string programText)
        {
            Tokenizer          tknizer    = new Tokenizer();
            TokenStreamCleaner tknCleaner = new TokenStreamCleaner();

            tknCleaner.StripLineComments  = true;
            tknCleaner.StripBlockComments = true;

            var tkns = tknizer.Tokenize(programText);

            for (int i = 0; i < TokenStreamCleaner.CleanupPassCount; i++)
            {
                tkns = tknCleaner.Cleanup(tkns, i);
            }

            for (int i = 0; i < tkns.Length; i++)
            {
                Console.WriteLine(tkns[i]);
            }

            //Build the syntax tree
            SyntaxNode rNode = SyntaxTree.Build(tkns);

            //Print the syntax tree
            Console.WriteLine("\n");
            PrintSyntaxNode(rNode);
        }