Example #1
0
        public CompilationUnit Parse(byte[] data)
        {
            var compilationUnit = new CompilationUnit();

            _br = new BinaryReader(new MemoryStream(data));
            while (_br.BaseStream.Position < _br.BaseStream.Length)
            {
                _opCode = _br.ReadByte();
                try
                {
                    var statement = ExecuteOpCode();
                    compilationUnit.AddStatement(statement);
                }
                catch (Exception e)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(e);
                    Console.ResetColor();
                    return(compilationUnit);
                }
            }

            return(compilationUnit);
        }
Example #2
0
 public override string Visit(CompilationUnit node)
 {
     return(node.Statement.Accept(this));
 }
Example #3
0
        public CompilationUnit Replace(CompilationUnit cu)
        {
            var visitor = new PushAstVisitor();

            return(cu.Accept(visitor) as CompilationUnit);
        }
Example #4
0
        public CompilationUnit Replace(CompilationUnit cu)
        {
            var newCu = cu.Accept(visitor);

            return((CompilationUnit)newCu);
        }
Example #5
0
 public override IAstNode Visit(CompilationUnit node)
 {
     return(new CompilationUnit((BlockStatement)node.Statement.Accept(this)));
 }