Exemple #1
0
        public static void PrintTree(ADTree tree, string fileName)
        {
            string tab = "\t";

            Console.WriteLine("**********************************************");
            Console.WriteLine($"************** {fileName} *****************");
            Console.WriteLine("**********************************************");

            Console.WriteLine("+ Root");

            foreach (var node in tree.Nodes)
            {
                PrintNode(node, tab);
            }
        }
 private Task BuildADTree()
 {
     return(Task.Factory.StartNew(() =>
     {
         object locker = new object();
         Parallel.ForEach(RootOU.Children.Cast <DirectoryEntry>().AsEnumerable(), child =>
         {
             if (child.SchemaClassname.Equals("organizationalUnit"))
             {
                 ADTree ChildTree = new ADTree(child);
                 lock (locker)
                 {
                     ChildOUs.Add(ChildTree);
                 }
             }
         });
     }));
 }
Exemple #3
0
        static void Main(string[] args)
        {
            PrecedenceSyntaxAnalysis.LoadPrecTable();

            string input      = string.Empty;
            string sourceCode = string.Empty;

            while ((input = Console.ReadLine()) != null)
            {
                sourceCode += input + Environment.NewLine;
            }

            MainFSM.SourceCode = sourceCode;
            MainFSM.Index      = 0;
            MainFSM.RowCounter = 0;

            var adTree = new ADTree();

            ParserFunctions.prog(adTree);

            AssemblyCompiler.Compile(adTree);
        }
Exemple #4
0
        public static void Compile(ADTree tree)
        {
            Console.WriteLine("#################################################################");
            Console.WriteLine("############### HeroC compiler by Zdenek Vidensky ###############");
            Console.WriteLine("#################################################################");

            Console.WriteLine();
            Console.WriteLine();

            foreach (var node in tree.Nodes)
            {
                if (node is ADFunctionDeclaration)
                {
                    Console.WriteLine($".global {(node as ADFunctionDeclaration).Name}");
                    Console.WriteLine();
                    Console.WriteLine();
                }
            }

            string globalAssigns = string.Empty;

            Console.WriteLine(".data");
            foreach (var node in tree.Nodes)
            {
                if (node is ADDeclaration)
                {
                    globalAssigns = DeclareGlobalVariables(node as ADDeclaration);
                }
            }

            Console.WriteLine(".text");

            foreach (var node in tree.Nodes)
            {
                PrintNode(node, "", "", "", null, globalAssigns);
            }
        }
        public static void prog(ADTree tree)
        {
            STablesStack.Push(new STable());
            var printLongFunction = new ADFunctionDeclaration()
            {
                Name = "print_long"
            };

            printLongFunction.Arguments.Add(new ADVariable());

            var printNlFunction = new ADFunctionDeclaration()
            {
                Name = "print_nl"
            };

            var printCharFunction = new ADFunctionDeclaration()
            {
                Name = "print_char"
            };

            printCharFunction.Arguments.Add(new ADVariable());

            FunctionsST.Records.Add(new STRecord()
            {
                Access = STAccess.global, Function = printLongFunction, Name = "print_long", Type = STType.function
            });
            FunctionsST.Records.Add(new STRecord()
            {
                Access = STAccess.global, Function = printNlFunction, Name = "print_nl", Type = STType.function
            });
            FunctionsST.Records.Add(new STRecord()
            {
                Access = STAccess.global, Function = printCharFunction, Name = "print_char", Type = STType.function
            });


            if (MainFSM.PeekNextToken().Type == TokenType.longType)
            {
                var global_declarations = global_decl_list();

                tree.Nodes.Add(global_declarations);
            }

            if (MainFSM.PeekNextToken().Type == TokenType.idType)
            {
                var statements_list = st_main_list();
                foreach (var item in statements_list)
                {
                    tree.Nodes.Add(item);
                }
            }

            if (MainFSM.PeekNextToken().Type == TokenType.eofType)
            {
                return;
            }
            else
            {
                SyntaxError("Byla ocekavana deklarace globalni promenne nebo funkce.");
            }
        }