Ejemplo n.º 1
0
        public void Start()
        {
            var s = File.ReadAllText("in.txt");
            //var s = Console.ReadLine();
            LineNumberReader reader = new LineNumberReader(s);
            Lexer            l      = new Lexer(reader);
            BasicParser      bp     = new BasicParser();

            while (l.Peek(0) != Token.EOF)
            {
                ASTree ast = bp.Parse(l);
                Console.WriteLine("=> " + ast.ToString());
            }
        }
Ejemplo n.º 2
0
        public void Start()
        {
            BasicParser bp  = new BasicParser();
            BasicEnv    env = new BasicEnv();
            var         s   = File.ReadAllText("in.txt");
            //var s = Console.ReadLine();
            LineNumberReader reader = new LineNumberReader(s);
            Lexer            l      = new Lexer(reader);

            while (l.Peek(0) != Token.EOF)
            {
                ASTree ast = bp.Parse(l);
                if (!(ast is NullStmnt))
                {
                    Object r = ((ASTree)ast).eval(env);
                    //Console.WriteLine("=> " + ast.ToString());
                    Console.WriteLine("=> " + r.ToString());
                }
            }
        }