public override bool Visit(AstProgram node)
        {
            ErrorIfIsNull(node);
            ErrorIfIsNull(node.Class);

            return true;
        }
예제 #2
0
        public bool Check(AstProgram rootNode)
        {
            result = true;
            rootNode.Accept(this);

            return result;
        }
예제 #3
0
 public override bool Visit(AstProgram node)
 {
     table.UseGlobalScope();
     SaveStringConstants();
     CreateLLVMBuiltIn();
     return true;
 }
        public SymbolTable Build(AstProgram node)
        {
            table = new SymbolTable();

            AddBuiltInSymbols();
            node.Accept(this);

            return table;
        }
 public bool TestTree(AstProgram node)
 {
     try
     {
         node.Accept(this);
     }
     catch (InvalidAstException)
     {
         return false;
     }
     return true;
 }
예제 #6
0
        public override bool Generate(AstProgram astRootNode, Stream outStream)
        {
            stringLiteralCounter = 0;
            var findStringsVisitor = new FindAllStringConstantsVisitor();
            stringConstants = findStringsVisitor.FindAll(astRootNode);

            codeStream = new StreamWriter(outStream);
            codeStream.AutoFlush = true;
            astRootNode.Accept(this);
            codeStream.Flush();
            return true;
        }
예제 #7
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;
        }
 public override bool Visit(AstProgram node)
 {
     table.UseGlobalScope();
     return true;
 }
예제 #9
0
        // #PS_PROGRAM #CLASS_DEF EOF
        private void ConstructPsProgram()
        {
            var astClass = nodes.Pop() as AstClass;
            var program = new AstProgram(astClass);
            rootNode = program;

            if (nodes.Count > 0)
            {
                throw new Exception("bad code detected.");
            }
        }
예제 #10
0
 // http://en.wikipedia.org/wiki/Shunting-yard_algorithm
 public AstBuilder()
 {
     rootNode = null;
     nodes = new Stack<AstNode>();
 }
 public List<string> FindAll(AstProgram root)
 {
     result = new List<string>();
     root.Accept(this);
     return result;
 }
 public override bool Visit(AstProgram node)
 {
     return true;
 }
예제 #13
0
 public abstract bool Generate(AstProgram astRootNode, Stream outStream);
예제 #14
0
 public abstract bool Visit(AstProgram node);