Inheritance: Node
 public SymbolTable Analyze(Ast ast)
 {
     var symbols = new SymbolTable();
     ast.Accept(new ModAnalyzer(log, symbols));
     // TODO(kai): Check that variABLES ACTUALLY EXIST
     return symbols;
 }
Beispiel #2
0
 public void Visit(Ast node)
 {
     node.children.ForEach(child =>
     {
         WriteTabs();
         child.Accept(this);
         WriteLine();
     });
 }
        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;
        }
Beispiel #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);
        }
Beispiel #5
0
 public void Resolve(Ast ast, SymbolTable symbols)
 {
     walker = new SymbolTableWalker(symbols);
     
     do
     {
         walker.Reset();
         hasResolved = true;
         ast.Accept(this);
     }
     while (!hasResolved);
 }
Beispiel #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;
        }
Beispiel #7
0
 public void Visit(Ast node) =>
     node.children.ForEach(child => child.Accept(this));