コード例 #1
0
        //-----< Semiexpression from souce code file >------------------------
        static bool testSemiExpression(string path)
        {
            //Toker toker = new Toker();
            SemiExp semiExp = new SemiExp();


            string fqf = System.IO.Path.GetFullPath(path);

            if (!semiExp.open(fqf))
            {
                Console.Write("\n can't open {0}\n", fqf);
                return(false);
            }
            else
            {
                Console.Write("\n  SemiExpressions:");
                Console.Write("\n  ================");
            }
            while (!semiExp.isDone())
            {
                List <String> sec = semiExp.get();
                if (sec.Count != 0)
                {
                    Console.Write("\n  - line{0, 3} : {1}", semiExp.lineCount, semiExp.DisplayStr(sec));
                }
            }
            Console.Write("\n");
            semiExp.close();
            return(true);
        }
コード例 #2
0
        //----< test for each semi express case by index>---
        static private bool testSemiExpression(int testIndex)
        {
            // generate semi expression
            SemiExp test = new SemiExp();

            test.returnNewLines  = true;
            test.displayNewLines = true;

            // open testfile
            string testFile = "../../" + testCaseFileName + +testIndex + ".cs";

            if (!test.open(testFile))
            {
                Console.Write(format: "\n  Can't open file {0}", arg0: testFile);
            }

            // open output file
            StreamWriter file = new StreamWriter("../../" + testCaseResult + testIndex + ".txt");

            // loop untill output all of the semiexpression
            while (test.getSemi())
            {
                if (test.gotCollection() != "")
                {
                    file.WriteLine(test.gotCollection());
                }
            }

            file.Close();

            // compare with the standard
            return(compareTwoFiles("../../" + testCaseResult + testIndex + ".txt", "../../" + testCaseResultStandard + testIndex + ".txt"));
        }
コード例 #3
0
ファイル: Autotest.cs プロジェクト: yxing999/Lexical-Scanner
        static bool Requirement8(string file)
        {
            Console.Write("\n\n  Demonstrate requirement 8: ");
            Console.Write("\n ============================\n");

            Console.Write(" The file content: \n\n");
            fs_ = new System.IO.StreamReader("../../" + file, true);
            int ch;

            while (!fs_.EndOfStream)
            {
                ch = fs_.Read();
                Console.Write("{0}", (char)ch);
            }
            fs_.Close();
            Console.Write("\n ============================\n");
            Console.Write("The output: \n");

            SemiExp test = new SemiExp();

            test.returnNewLines  = true;
            test.displayNewLines = true;
            string path = "../../" + file;

            if (!test.open(path))
            {
                Console.Write("\n  Can't open file {0}", path);
            }
            while (test.GetSemi())
            {
                test.display();
            }
            test.close();
            return(true);
        }
        public bool testSemi(string path)
        {
            SemiExp test     = new SemiExp();
            string  testFile = path;

            if (!test.open(testFile))
            {
                Console.Write("\n  Can't open file {0}", testFile);
            }
            while (test.getSemi())
            {
                test.display();
            }
            return(true);
        }
コード例 #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter path of file to be processed :");
            string  input = Console.ReadLine();
            SemiExp test  = new SemiExp();

            string testFile = "../../testSemi.txt";

            if (!test.open(testFile))
            {
                Console.Write("\n  Can't open file {0}", testFile);
            }

            test.CallSemiExpression();
            Console.ReadLine();
        }
    static bool testSemiExp(string path)
    {
        SemiExp test = new SemiExp();
        string  fqf  = System.IO.Path.GetFullPath(path);

        if (!test.open(fqf))
        {
            Console.Write("\n can't open {0}\n", fqf);
            return(false);
        }
        else
        {
            Console.Write("\n  processing file: {0}", fqf);
        }
        while (test.getSemi())
        {
            test.returnNewLines  = true;
            test.displayNewLines = true;

            // while (test.getSemi())
            //   test.display();

            test.initialize();
            test.insert(0, "this");
            test.insert(1, "is");
            test.insert(2, "a");
            test.insert(3, "test");
            test.display();

            Console.Write("\n  2nd token = \"{0}\"\n", test[1]);

            Console.Write("\n  removing first token:");
            test.remove(0);
            test.display();
            Console.Write("\n");

            Console.Write("\n  removing token \"test\":");
            test.remove("test");
            test.display();
            Console.Write("\n");
            //Console.Write("\n -- line#{0, 4} : {1}", toker.lineCount(), tok);
        }
        test.close();
        return(true);
    }
        public static void Main(string[] args)
        {
            String path     = "../../../Test.txt";
            string fullpath = System.IO.Path.GetFullPath(path);

            Console.WriteLine("\n*****************DEMONSTRATION OF LEXICAL SCANNER*******************");
            Console.WriteLine("\n********************REQUIREMENTS***************************************\n\n\n");

            ITokCollect semiExp = new SemiExp();

            requirement1();
            requirement3(fullpath, semiExp);
            requirement4(fullpath, semiExp);
            requirement6(fullpath, semiExp);
            //  requirement9(fullpath, semiExp);
            requirement10(fullpath, semiExp);
            Console.ReadLine();
        }