Exemplo n.º 1
0
        public static StringBuilder test5to(string path)
        {
            StringBuilder s     = new StringBuilder();
            Toker         toker = new Toker();
            string        fqf   = System.IO.Path.GetFullPath(path);

            if (!toker.open(fqf))
            {
                return(null);
            }
            int count = 0;

            while (!toker.isDone())
            {
                Token tok = toker.getTok();
                ++count;

                if (toker.lineCount() != 1)
                {
                    continue;
                }
                if (tok.ToString() != "\n")
                {
                    s.Append("\n   - " + toker.lineCount() + "      | ").Append(tok);
                    s.Append(' ', (50 - tok.Length)).Append("|" + count);
                }
            }
            return(s);
        }
Exemplo n.º 2
0
        static bool testTokenizer(string path)
        {
            Toker toker = new Toker();

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

            if (!toker.Open(fileName))
            {
                Console.WriteLine("\n Can't open file {0}\n", fileName);
                return(false);
            }
            else
            {
                Console.WriteLine("\n Processing file: {0}", fileName);
            }

            while (!toker.IsDone())
            {
                Token singleToken = toker.GetToken();
                Console.Write("\n --Line{0, 4} : {1}", toker.LineCount(), singleToken);
            }
            toker.Close();
            return(true);
        }
Exemplo n.º 3
0
        public static StringBuilder testTokera(string path, int t)
        {
            StringBuilder s     = new StringBuilder();
            Toker         toker = new Toker();
            string        fqf   = System.IO.Path.GetFullPath(path);

            if (!toker.open(fqf))
            {
                return(null);
            }
            if (t == 1)
            {
                toker.setspecialchar(new List <char> {
                });
                toker.setdspecialchar(new List <string> {
                });
            }
            while (!toker.isDone())
            {
                Token tok = toker.getTok();
                if (!new List <int> {
                    19, 16, 18, 11, 12, 13, 14, 15
                }.Contains(toker.lineCount()))
                {
                    continue;
                }
                if (tok.ToString() != "\n")
                {
                    s.Append("\n   - " + toker.lineCount() + "      | ").Append(tok);
                    if (Char.IsLetterOrDigit(tok[0]))
                    {
                        s.Append(' ', (50 - tok.Length)).Append("|AlphaNumeric Tokens");
                    }
                    else if (tok.ToString().Contains("\'"))
                    {
                        s.Append(' ', (50 - tok.Length)).Append("|Single Quoted Tokens");
                    }
                    else if (tok.ToString().Contains("\""))
                    {
                        s.Append(' ', (50 - tok.Length)).Append("|Double Quoted Tokens");
                    }
                    else if (tok.ToString().Contains("//"))
                    {
                        s.Append(' ', (50 - tok.Length)).Append("|Single Line Comment Token");
                    }
                    else if (tok.ToString().Contains("/*"))
                    {
                        s.Append(' ', (50 - tok.Length)).Append("|Multi Line Comment Token");
                    }
                    else if (toker.getdspecialchar().Contains(tok.ToString()))
                    {
                        s.Append(' ', (50 - tok.Length)).Append("|Double Special Char Token");
                    }
                    else if (toker.getspecialchar().Intersect(tok.ToString().ToList()).Any())
                    {
                        s.Append(' ', (50 - tok.Length)).Append("|Single Special Char Token");
                    }
                    else
                    {
                        s.Append(' ', (50 - tok.Length)).Append("|Punctuator Token");
                    }
                }
            }
            //toker.close();
            return(s);
        }