상속: Node
예제 #1
0
 public SymbolTable Analyze(Ast ast)
 {
     var symbols = new SymbolTable();
     ast.Accept(new ModAnalyzer(log, symbols));
     // TODO(kai): Check that variABLES ACTUALLY EXIST
     return symbols;
 }
예제 #2
0
 public void Visit(Ast node)
 {
     node.children.ForEach(child =>
     {
         WriteTabs();
         child.Accept(this);
         WriteLine();
     });
 }
예제 #3
0
        public LLVMModuleRef Compile(string name, Ast ast, SymbolTable symbols)
        {
            var context = ContextCreate();
            var module = ModuleCreateWithNameInContext(name, context);
            var builder = CreateBuilderInContext(context);

            var compiler = new ModCompiler(log, new SymbolTableWalker(symbols), context, module, builder);
            ast.Accept(compiler);

            return module;
        }
예제 #4
0
        public void Check(Ast ast, SymbolTable symbols)
        {
            var resolver = new TyResolver(log);
            resolver.Resolve(ast, symbols);

            if (log.HasErrors)
                return;

            var checker = new TyChecker(log, new SymbolTableWalker(symbols));
            ast.Accept(checker);
        }
예제 #5
0
 public void Resolve(Ast ast, SymbolTable symbols)
 {
     walker = new SymbolTableWalker(symbols);
     
     do
     {
         walker.Reset();
         hasResolved = true;
         ast.Accept(this);
     }
     while (!hasResolved);
 }
예제 #6
0
        public Ast Parse(DetailLogger log, TokenList tokens, string fileName)
        {
            var state = new ParserState(log, tokens, fileName);

            var ast = new Ast();
            // TODO(kai): actually run a parser loop.
            while (true)
            {
                //Console.WriteLine("Attempting to parse");
                var node = state.ParseTopLevel();
                if (node == null)
                    break;
                ast.children.Add(node);
            }

            return ast;
        }
예제 #7
0
 public void Visit(Ast node) =>
     node.children.ForEach(child => child.Accept(this));