Пример #1
0
        static void Main(string[] args)
        {
            // string text = System.IO.File.ReadAllText("Program.cs"); // ye file eski program ki .cs file hai yo ye program bana huwa hai usi ko tokenized kr k dikha rhi hai
            string          text     = System.IO.File.ReadAllText("python1.txt"); // Ye python k code ko tokenize kr rhi hain jo b textfile mein code hai
            LexicalAnalysis analyzer = new LexicalAnalysis();

            analyzer.Parse(text);

            while (text != null)
            {
                text = text.Trim(' ', '\t');
                string token = analyzer.GetNextLexicalAtom(ref text);
                System.Console.Write(token);
            }
            System.Console.Read();
        }
Пример #2
0
        static void Main(string[] args)
        {
            string text = System.IO.File.ReadAllText("Program.cs");
            //string[] elements = text.Split(new char[] { ' ', '\r', '\n' },StringSplitOptions.RemoveEmptyEntries);
            LexicalAnalysis analyzer = new LexicalAnalysis();

            // analyzer.Parse(text);

            while (text != null)
            {
                text = text.Trim(' ', '\t');
                string token = analyzer.GetNextLexicalAtom(ref text);
                System.Console.Write(token);
            }
            //foreach (string item in elements)
            //{
            //    analyzer.Parse(item);
            //}
            //System.Console.WriteLine(text);
            System.Console.Read();
        }