Ejemplo n.º 1
0
        public SymbolTable Build(AstProgram node)
        {
            table = new SymbolTable();

            AddBuiltInSymbols();
            node.Accept(this);

            return table;
        }
Ejemplo n.º 2
0
        public bool Evaluate(AstProgram node)
        {
            var tableBuilder = new SymbolTableBuilder();

            result = true;
            isClassFieldDef = false;
            try
            {
                table = tableBuilder.Build(node);
            }
            catch (CallableSymbolAlreadyDefinedException e)
            {
                DispatchError(new SourcePosition(), "Function already defined: " + e.Message);
                return false;
            }
            catch (SymbolAlreadyDefinedException e)
            {
                DispatchError(new SourcePosition(), "Variable already defined: " + e.Message);
                return false;
            }
            catch (ArraySizeIncorrectException e)
            {
                DispatchError(new SourcePosition(), "Bad array size: " + e.Message);
                return false;
            }

            table.UseGlobalScope();
            resolver = new TypeResolver(table);
            currFunctionReturnType = null;
            currStateInsideExpr = false;

            try
            {
                node.Accept(this);
            }
            catch (SymbolNotFoundException e)
            {
                DispatchError(e.Expr.TextPosition, e.Message);
            }

            WarnUnusedSymbols();

            return result;
        }
Ejemplo n.º 3
0
 public TypeResolver(SymbolTable table)
 {
     this.table = table;
 }
Ejemplo n.º 4
0
 public void SetSymbolTable(SymbolTable table)
 {
     this.table = table;
 }