public static void Init()
        {
            if (!Config.Instance.UseEmbeddedEngine && Config.Instance.CustomSyntaxerAsm.HasText())
            {
                syntaxer_asm  = Config.Instance.CustomSyntaxerAsm;
                syntaxer_port = Config.Instance.CustomSyntaxerPort;
            }
            else
            {
                syntaxer_asm  = dependenciesDirRoot.PathJoin("cs-syntaxer", "syntaxer.dll");
                syntaxer_port = 18001;

                if (!Directory.Exists(syntaxer_asm.GetDirName()))
                {
                    DeployDir(Bootstrapper.pluginDir.PathJoin("cs-syntaxer"),
                              syntaxer_asm.GetDirName());
                }
            }

            if (!Config.Instance.UseEmbeddedEngine && Config.Instance.CustomEngineAsm.HasText())
            {
                cscs_asm = Config.Instance.CustomEngineAsm;
            }
            else
            {
                cscs_asm = dependenciesDirRoot.PathJoin("cs-script", "cscs.dll");

                if (!Directory.Exists(cscs_asm.GetDirName()))
                {
                    DeployDir(Bootstrapper.pluginDir.PathJoin("cs-script"),
                              cscs_asm.GetDirName());
                }

                var oldServicesVersions = Directory.GetDirectories(Path.GetDirectoryName(dependenciesDirRoot))
                                          .Where(x => x != dependenciesDirRoot);
                foreach (var dir in oldServicesVersions)
                {
                    DeleteDir(dir);
                }
            }

            Syntaxer.cscs_asm      = () => Runtime.cscs_asm;
            Syntaxer.syntaxer_asm  = () => Runtime.syntaxer_asm;
            Syntaxer.syntaxer_port = () => Runtime.syntaxer_port;

            Syntaxer.StartServer(onlyIfNotRunning: true);
        }
Esempio n. 2
0
        public void MethodMembers()
        {
            string file = "";

            VSSolution vs = ef.GetVSSolution();
            List <MethodDeclarationSyntax> cs = new List <MethodDeclarationSyntax>();

            while (cs.Count <= 0)
            {
                file = RandomCompileItem();
                if (string.IsNullOrEmpty(file))
                {
                    continue;
                }
                OpenFile(file);
                //if (!CheckIfOpened(file))
                //    return;
                SyntaxTree syntaxTree = vs.GetSyntaxTree(file);
                cs = Syntaxer.MethodMembers(vs, syntaxTree);
            }
            MethodDeclarationSyntax s = cs[0];
            string name             = s.Identifier.Text;
            List <LocationSource> d = ef.Command_FindString("." + name, "", "", "", "", SearchDomain.solution);

            foreach (MethodDeclarationSyntax me in cs)
            {
                var       symbol = vs.GetSymbolAtLocation(me.Identifier.SpanStart, file);
                VSProject vp     = vs.GetProjectbyCompileItem(file);
                var       refs   = vs.GetAllSymbolReferences(symbol, file, vp).Result.ToList();
                MessageBox.Show("References - " + refs.Count);
                foreach (LocationSource c in d)
                {
                    foreach (ReferencedSymbol se in refs)
                    {
                        foreach (ReferenceLocation b in se.Locations)
                        {
                            if (c.textSpan.Start > b.Location.SourceSpan.Start && c.Source.FilePath == b.Location.SourceTree.FilePath)
                            {
                                MessageBox.Show("Location found " + b.Location.ToString());
                            }
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            var fileName = "";

            if (DEBUG)
            {
                fileName = "../../program.kxi";
            }
            else
            {
                fileName = args[0];
            }


            var done = false;

            while (!done)
            {
                if (File.Exists(fileName))
                {
                    var dt = File.GetLastWriteTime(fileName);
                    if (dt.ToString().Equals(lastModified))
                    {
                        System.Threading.Thread.Sleep(1000);
                        continue;
                    }
                    lastModified = dt.ToString();
                }

                var file = new System.IO.StreamReader(fileName);
                try
                {
                    var lexer = new Lexer(file);

                    var syntaxer    = new Syntaxer(lexer);
                    var symbolTable = syntaxer.SyntaxPass();
                    if (false)
                    {
                        Console.WriteLine("Syntax pass is done");
                        Console.ReadLine();

                        PrintSymbolTable(symbolTable);
                        Console.WriteLine("Symbol table is done");
                        Console.ReadLine();
                    }

                    var icodeList    = syntaxer.SemanticPass(symbolTable);
                    var symbolTable2 = Syntaxer._syntaxSymbolTable;
                    //Console.WriteLine("Semantics pass is done. Press enter to print final back-patched icode.");
                    //Console.ReadLine();

                    foreach (var q in icodeList)
                    {
                        if (q.Label.Length != 0)
                        {
                            Console.WriteLine();
                        }
                        Console.WriteLine(q.ToString());
                    }
                    Console.WriteLine("Finished with ICode generation\n");

                    var tarcoder  = new Tarcoder(symbolTable2, icodeList);
                    var tcodeList = tarcoder.Generate();
                    foreach (var t in tcodeList)
                    {
                        Console.WriteLine(t.ToString());
                    }
                    Console.WriteLine("Finished with TCode generation\n");
                    var tcodestring = Tarcoder.TCodeString(tcodeList);

                    VMShell.Execute(tcodestring);

                    done = true;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                file.Close();
            }
        }
Esempio n. 4
0
 public SyntaxerTests()
 {
     _lexical  = new Lexer();
     _syntaxer = new Syntaxer();
 }