Esempio n. 1
0
        static void Main(string[] args)
        {
            string    testCase = "@ \"ttt\" #ab 1.2 2. 51555.6 2.5548 1555.5848 .336 f#f'' '999' \" 999 #123abc 3456   Tuwaiq_BootCamp3 #abc123 123 1.1 22 . 55.6 Hi_hdfj; /*  1.1 22 */ ' //Tuwaiq_BootCamp3 ";
            Tokenizer t        = new Tokenizer(testCase);

            Tokenizable[] handlers = new Tokenizable[] { /*new NumberTokenizer(),*/
                new NumberTokenizer(),
                new SingleQuotTokenizer(),
                new StringTokenizer(),
                new ILCommentTokenizer(),
                new MuitLinesCommentTokenizer(),
                new WhiteSpaceTokenizer(),
                new IdTokenizer(),
                new HexColorTokenizer(),
                new PunctuationTokenizer()
            };
            Token token = null;

            while (t.currentPostion + 1 < t.input.Length)
            {
                token = t.tokenizer(handlers);
                if (token != null)
                {
                    Console.WriteLine($"{token.value} [{token.type}]");
                }

                else
                {
                    t.next();
                }
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("===============");
            string    testCase = "78 true _PORT ! . 45.67 78.88888888 4566 /*fff*/ ++ = TEA tea //hhhh  5 ";
            Tokenizer t        = new Tokenizer(testCase);

            Tokenizable[] handlers = new Tokenizable[] {
                new OneLineCommentTokenizer()
                , new WhiteSpaceTokenizer()
                , new OperatorTokenizer()
                , new NumberTokenizer()
                , new IdTokenizer()
                , new MultiLineCommentTokenizer()
                , new PunctuationTokenizer()
                , new UpperCasesTokenizer()
                , new LowerCasesTokenizer()
            };
            Token token = t.tokenize(handlers);

            while (token != null)
            {
                Console.WriteLine(token.value + " : " + token.type);
                token = t.tokenize(handlers);
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Tokenizer t = new Tokenizer("#vjdnkd 20 20.12f hhh aaaf 19 if  _jdc_nkjd  20f @Abdulrahman <to> hhh  </to> jjj ");

            Tokenizable[] handers = new Tokenizable[] { new xmlTokenizable(), new IntOrfloatTokenizer(), new WhiteSpace(), new idTokenizer(), new hachTokenizable(), new userTokenizable() };
            Token         token   = t.tokenize(handers);

            while (token != null)
            {
                Console.WriteLine(token.value + " | " + token.type);
                token = t.tokenize(handers);
            }
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            // Tokenizer t = new Tokenizer("234 ! && &&& | || ||| hello /***this\n is\n multi\n line\n comments/ //helo this is commnets\n this ");
            Tokenizer t = new Tokenizer("234  && && 335<5 <= == >= || ||| hello /***this\n is\n multi\n line\n comments/ //helo this is commnets\n this ");

            Tokenizable [] handlers = new Tokenizable []
            {
                // new NumberTokenizer(),
                // new IdTokenizer(),
                // new WhiteSpace(),
                // new OneLineComments(),
                // new MultiLineComments(),
                // new LogicalOperator(),
                // new BitWiseOperator(),
            };

            Token tkn = t.tokenize(handlers);

            while (tkn != null)
            {
                Console.WriteLine("(" + tkn.type + ", " + tkn.value + ")");
                tkn = t.tokenize(handlers);
            }
        }