示例#1
0
 void ClearTree()
 {
     funcs     = new List <ASTFunction>();
     tokens    = new List <IASTtoken>();
     variables = new List <ASTvariable>();
     MISC.ClearStack();
     GlobalVars = new CommandOrder();
 }
示例#2
0
 public override void Trace(int depth)
 {
     Console.Write(MISC.tabs(depth));
     MISC.ConsoleWriteLine("DEFINE [" + defineType.ToString() + "]", ConsoleColor.DarkGreen);
     a.Trace(depth + 1);
     MISC.finish = true;
     b.Trace(depth + 1);
 }
示例#3
0
 public override void Trace(int depth)
 {
     Console.Write(MISC.tabs(depth)); MISC.ConsoleWrite(operationString, ConsoleColor.Green); MISC.ConsoleWriteLine(" " + returnType.ToString().Substring(1), ConsoleColor.DarkGreen);
     if (a != null) //if (returnType == VT.Cadress)
     {
         MISC.finish = true;
         a.Trace(depth + 1);
     }
 }
示例#4
0
        ASTTree ReadFileToTree(string codeFolder, string command)
        {
            //while (true)
            //{
            //    Console.WriteLine("a");
            //    Thread.Sleep(1000);
            //}

            string code = "";

            string[] lines = System.IO.File.ReadAllLines(@"" + codeFolder + "/" + command + ".txt");
            //linesOut = lines;
            //
            //string filename = "";
            //Thread thread = new Thread(() => ReadFile(codeFolder, command));
            //thread.Start();
            //
            foreach (string line in lines)
            {
                // if an included module
                if (line.IndexOf("#include") >= 0)
                {
                    try
                    {
                        string moduleName = line.Substring(line.IndexOf("<") + 1, line.IndexOf(">") - line.IndexOf("<") - 1);
                        MISC.ConsoleWriteLine("Included: " + moduleName, ConsoleColor.Green);
                        try
                        {
                            string[] modulelines = System.IO.File.ReadAllLines(@"" + moduleFolder + "/" + moduleName);
                            foreach (string moduleline in modulelines)
                            {
                                code += moduleline + "\n";
                                MISC.ConsoleWriteLine(moduleline, ConsoleColor.Yellow);
                            }
                        }
                        catch
                        {
                            MISC.ConsoleWriteLine("Invalid include adress: " + moduleFolder + "/" + moduleName, ConsoleColor.Red);
                        }
                    }
                    catch
                    {
                        MISC.ConsoleWriteLine("Invalid include: " + line, ConsoleColor.Red);
                    }
                }
                else
                {
                    code += line + "\n";
                    Console.WriteLine(line);
                }
            }

            ASTTree t = new ASTTree(code);

            return(t);
        }