Exemplo n.º 1
0
        private void bLT_Click(object sender, EventArgs e)
        {
            if (scanner == null)
            {
                rtbLS.AppendText("Create scanner instance before testing!\r\n");
                return;
            }

            rtbLS.AppendText(" ----------- Start Lexing -----------\r\n");
            scanner.AllocateTarget(rtbLT.Text);

            try
            {
                while (scanner.Valid())
                {
                    var ss = scanner.Next();
                    if (scanner.Error())
                    {
                        rtbLS.AppendText("Error!\r\n");
                    }
                    rtbLS.AppendText($"{ss.Item1},".PadRight(10) + $" {ss.Item2} - line:{ss.Item3}, column:{ss.Item4}\r\n");
                }
            }
            catch (Exception ex)
            {
                rtbLS.AppendText("Error!\r\nCheck test case!\r\n");
            }
            rtbLS.AppendText(" ------------ End Lexing ------------\r\n");
        }
Exemplo n.º 2
0
        static void TestLexer()
        {
            var txt = File.ReadAllText("222.json");

            lexer.AllocateTarget(txt);

            while (lexer.Valid())
            {
                var pp = lexer.Next();
                Console.WriteLine(pp);
            }
        }