Ejemplo n.º 1
0
        /*
         * Will execute the compiler or the interpreter.
         */
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private static boolean excuteCompiler(com.juliar.parser.JuliarParser parser) throws java.io.IOException
        private static bool excuteCompiler(JuliarParser parser)
        {
            // Calls the parse CompileUnit method
            // to parse a complete program
            // then calls the code generator.

            JuliarParser.CompileUnitContext context = parser.compileUnit();
//JAVA TO C# CONVERTER TODO TASK: Java lambdas satisfy functional interfaces, while .NET lambdas satisfy delegates - change the appropriate interface to a delegate:
            Visitor visitor = new Visitor((imports, linesToSkip) =>
            {
            }, true);

            visitor.visit(context);

            if (errors.errorList().Count > 0 || visitor.ErrorList.Count > 0)
            {
                foreach (string error in errors.errorList())
                {
                    JuliarLogger.logerr(error);
                }

                foreach (string error in visitor.ErrorList)
                {
                    JuliarLogger.logerr(error);
                }

                return(true);
            }
            new Interpreter(visitor.instructions());
            return(false);
        }
Ejemplo n.º 2
0
        public override Node visitCompileUnit(JuliarParser.CompileUnitContext ctx)
        {
            CompliationUnitNode node = new CompliationUnitNode();

            try
            {
                string nodeName = node.ToString();
                callStack.Push(nodeName);
                symbolTable.addLevel(nodeName);

                new IterateOverContext(this, ctx, this, node);

                instructionList.Add(node);

                popScope(node.Type);
                //cfa.walkGraph();
                //symbolTable.dumpSymbolTable();
            }
            catch (Exception ex)
            {
                JuliarLogger.log(ex.Message);
            }
            return(node);
        }