Beispiel #1
0
        public Hashtable MakeObjectListing(string code, CProject.File filedecl, Hashtable ht)
        {
            // Construct listing of objects and their functions
            Regex rx = new Regex(@"(^(\s*///\s*(.*?)\n){0,5})?^\s*\bfunction\b\s*(\b[A-Z_][A-Z0-9_]*\b)::(\b[A-Z][A-Z0-9]*\b)\s*\((.*?)\)", RegexOptions.IgnoreCase | RegexOptions.Multiline);

            //Hashtable ht = new Hashtable();

            foreach (Match mt in rx.Matches(code))
            {
                CProject.TokenObject tokobj;
                if (ht.ContainsKey(mt.Groups[4].Value.ToLower()))
                {
                    tokobj = (CProject.TokenObject)ht[mt.Groups[4].Value.ToLower()];
                }
                else
                {
                    tokobj            = new CProject.TokenObject();
                    tokobj.ObjectName = mt.Groups[4].Value;
                    tokobj.isInternal = false;
                    ht.Add(mt.Groups[4].Value.ToLower(), tokobj);
                }

                if (!tokobj.ObjectFunctions.ContainsKey(mt.Groups[5].Value.ToLower()))
                {
                    // Create a function definition if none exists already
                    CProject.TokenObject.ObjectDescr objdescr = new CProject.TokenObject.ObjectDescr();
                    objdescr.FuncName   = mt.Groups[5].Value;
                    objdescr.FuncOffset = mt.Groups[5].Index;
                    objdescr.FuncFile   = filedecl;

                    // Set description
                    string descr = mt.Groups[1].Value.Replace("///", "").Replace("\t", "").Replace("\r", "").TrimStart('\n');
                    foreach (string line in descr.Split('\n'))
                    {
                        if (line.Trim() == "")
                        {
                            continue;
                        }

                        objdescr.FuncDescr += line.Trim() + "<br />";
                    }

                    // Grab all the function parameters by splitting it at the comma
                    // and stick them in the appropriate array
                    if (mt.Groups[4].Value != "")
                    {
                        objdescr.FuncParams = mt.Groups[6].Value.Replace(" ", "").Split(',');
                    }
                    else
                    {
                        objdescr.FuncParams = null;
                    }

                    // Add it to the hashtable
                    tokobj.ObjectFunctions.Add(mt.Groups[5].Value.ToLower(), objdescr);
                }
            }

            return(MakeObjectDeclarations(code, filedecl, ht));;
        }
Beispiel #2
0
        public int FindToken(string word, string prevtok, out CProject.File out_file)
        {
            out_file = null;

            // Find it in the file listing first
            foreach (CProject.File file in g.Project.FileList)
            {
                if (file.TokenList.ContainsKey(word.ToLower()))
                {
                    // Got it!
                    out_file = file;
                    return(((CProject.TokenKey)file.TokenList[word.ToLower()]).LineNumber);
                }
            }

            // Now search active objects, seeing if this is an object
            // we can jump to.
            if (g.Project.TokenObjList.ContainsKey(word.ToLower()))
            {
                // Yes, it appears this is a valid object...
                CProject.TokenObject tokobj = (CProject.TokenObject)g.Project.TokenObjList[word.ToLower()];
                if (tokobj.ObjectFileDecl != null)
                {
                    out_file = tokobj.ObjectFileDecl;
                    return(tokobj.ObjectDeclOffset);
                }
                else
                {
                    return(-1);
                }
            }


            // Check to see if the *previous* token wasn't an object...
            // ... which would mean that the *current* token is a function
            // definition inside an object
            if (g.Project.TokenObjList.ContainsKey(prevtok.ToLower()))
            {
                // Yes, it appears this is so... see if the thingy is a valid function
                CProject.TokenObject tokobj = (CProject.TokenObject)g.Project.TokenObjList[prevtok.ToLower()];

                if (!tokobj.ObjectFunctions.ContainsKey(word.ToLower()))
                {
                    return(-1);
                }

                // Retrieve the function file information
                CProject.TokenObject.ObjectDescr func = (CProject.TokenObject.ObjectDescr)tokobj.ObjectFunctions[word.ToLower()];
                out_file = func.FuncFile;
                return(func.FuncOffset);
            }

            return(-1);
        }
Beispiel #3
0
        public Hashtable MakeObjectListing(string code, CProject.File filedecl, Hashtable ht)
        {
            // Construct listing of objects and their functions
            Regex rx = new Regex(@"(^(\s*///\s*(.*?)\n){0,5})?^\s*\bfunction\b\s*(\b[A-Z_][A-Z0-9_]*\b)::(\b[A-Z][A-Z0-9]*\b)\s*\((.*?)\)", RegexOptions.IgnoreCase | RegexOptions.Multiline);

            //Hashtable ht = new Hashtable();

            foreach(Match mt in rx.Matches(code)) {
                CProject.TokenObject tokobj;
                if (ht.ContainsKey(mt.Groups[4].Value.ToLower()))
                    tokobj = (CProject.TokenObject)ht[mt.Groups[4].Value.ToLower()];
                else {
                    tokobj = new CProject.TokenObject();
                    tokobj.ObjectName = mt.Groups[4].Value;
                    tokobj.isInternal = false;
                    ht.Add(mt.Groups[4].Value.ToLower(), tokobj);
                }

                if (!tokobj.ObjectFunctions.ContainsKey(mt.Groups[5].Value.ToLower())) {
                    // Create a function definition if none exists already
                    CProject.TokenObject.ObjectDescr objdescr = new CProject.TokenObject.ObjectDescr();
                    objdescr.FuncName = mt.Groups[5].Value;
                    objdescr.FuncOffset = mt.Groups[5].Index;
                    objdescr.FuncFile = filedecl;

                    // Set description
                    string descr = mt.Groups[1].Value.Replace("///", "").Replace("\t", "").Replace("\r", "").TrimStart('\n');
                    foreach(string line in descr.Split('\n')) {
                        if (line.Trim() == "")
                            continue;

                        objdescr.FuncDescr += line.Trim() + "<br />";
                    }

                    // Grab all the function parameters by splitting it at the comma
                    // and stick them in the appropriate array
                    if (mt.Groups[4].Value != "")
                        objdescr.FuncParams = mt.Groups[6].Value.Replace(" ", "").Split(',');
                    else
                        objdescr.FuncParams = null;

                    // Add it to the hashtable
                    tokobj.ObjectFunctions.Add(mt.Groups[5].Value.ToLower(), objdescr);
                }
            }

            return MakeObjectDeclarations(code, filedecl, ht);;
        }