Exemplo n.º 1
0
 public static void Check(ExpressoAst ast, Parser parser)
 {
     if(parser.Symbols != null){
         FlowChecker fc = new FlowChecker(parser, ast);
         ast.AcceptWalker(fc);
     }
 }
Exemplo n.º 2
0
        public void VisitAst(ExpressoAst ast)
        {
            Debug.Assert(symbol_table.Parent == null);
            scope_counter = 0;

            ast.Imports.AcceptWalker(this);
            ast.Declarations.AcceptWalker(this);
            Debug.Assert(symbol_table.Parent == null);
        }
Exemplo n.º 3
0
        void Bind(ExpressoAst unboundAst)
        {
            Debug.Assert(unboundAst != null);

            // Find all scopes and variables
            unboundAst.AcceptWalker(this);

            TypeChecker.Check(unboundAst, parser);
            // Run flow checker
            //FlowChecker.Check(unboundAst);
        }
Exemplo n.º 4
0
 /// <summary>
 /// The public surface of post-parse processing.
 /// In this method, we are binding names, checking type validity and doing some flow analisys.
 /// Note that we are NOT doing any AST-wide optimizations here.
 /// </summary>
 internal static void BindAst(ExpressoAst ast, Parser parser)
 {
     ExpressoNameBinder binder = new ExpressoNameBinder(parser);
     binder.Bind(ast);
     #if DEBUG
     Console.WriteLine("We have given ids on total of {0} identifiers.", UniqueIdGenerator.CurrentId - 1);
     #endif
 }
Exemplo n.º 5
0
        public void VisitAst(ExpressoAst ast)
        {
            foreach(var import in ast.Imports)
                import.AcceptWalker(this);

            foreach(var decl in ast.Declarations)
                decl.AcceptWalker(this);
        }
Exemplo n.º 6
0
 FlowChecker(Parser parser, ExpressoAst decl)
 {
     bits = new BitArray(symbols.NumberOfSymbols * 2);
     this.parser = parser;
 }
Exemplo n.º 7
0
        void ModuleBody(out ExpressoAst ast)
        {
            var decls = new List<EntityDeclaration>();
            string module_name; Modifiers modifiers = ExpressoModifiers.None;
            List<ImportDeclaration> prog_defs = null; EntityDeclaration decl = null;

            ModuleNameDefinition(out module_name);
            if (la.kind == 31) {
            ProgramDefinition(out prog_defs);
            }
            if (la.kind == 29) {
            Get();
            modifiers = ExpressoModifiers.Export;
            }
            if (la.kind == 38) {
            FuncDecl(out decl, modifiers);
            } else if (la.kind == 33) {
            ClassDecl(out decl, modifiers);
            } else SynErr(102);
            decls.Add(decl);
            modifiers = ExpressoModifiers.None;

            while (la.kind == 29 || la.kind == 33 || la.kind == 38) {
            if (la.kind == 29) {
                Get();
                modifiers = ExpressoModifiers.Export;
            }
            if (la.kind == 38) {
                FuncDecl(out decl, modifiers);
            } else if (la.kind == 33) {
                ClassDecl(out decl, modifiers);
            } else SynErr(103);
            decls.Add(decl);
            modifiers = ExpressoModifiers.None;

            }
            ast = AstNode.MakeModuleDef(module_name, decls, prog_defs);
        }