Exemple #1
0
        private static string DeleteBlank(string code)
        {
            ScriptAnalyser sa = new ScriptAnalyser(code);

            for (int index = 0; index < sa.Tokens.Count; index++)
            {
                if (sa.Tokens[index].Kind == ScriptAnalyser.Token.Kind_e.BLANK)
                {
                    string ptn = sa.Tokens[index].Pattern;
                    int    ndx = ptn.LastIndexOf('\n');

                    if (ndx != -1)
                    {
                        bool mltLf = 2 <= ptn.Where(v => v == '\n').Count();

                        ptn = ptn.Substring(ndx);

                        if (mltLf)
                        {
                            ptn = "\n" + ptn;
                        }

                        sa.Tokens[index].Pattern = ptn;
                    }
                    else if (StringTools.LiteValidate(ptn, " ", 2))
                    {
                        ptn = " ";
                        sa.Tokens[index].Pattern = ptn;
                    }
                }
            }
            return(sa.GetString());
        }
Exemple #2
0
        private static string DeleteComment(string code)
        {
            ScriptAnalyser sa = new ScriptAnalyser(code);

            for (int index = 0; index < sa.Tokens.Count; index++)
            {
                if (sa.Tokens[index].Kind == ScriptAnalyser.Token.Kind_e.COMMENT)
                {
                    sa.Tokens[index].Kind    = ScriptAnalyser.Token.Kind_e.BLANK;
                    sa.Tokens[index].Pattern = "";
                }
            }
            return(sa.GetString());
        }
        public void Delete()
        {
            this.Sa = new ScriptAnalyser(this.Code);
            this.CollectVariable();

            foreach (VariableInfo variable in this.Variables)
            {
                if (this.IsUsingVariable(variable) == false)
                {
                    this.DeleteFunction(variable);
                    this.DeleteCount++;
                }
            }
            this.Code = this.Sa.GetString();
        }
        public void Delete()
        {
            this.Sa = new ScriptAnalyser(this.Code);
            this.CollectFunction();

            foreach (FunctionInfo function in this.Functions)
            {
                if (this.IsUsingFunction(function) == false)
                {
                    this.DeleteFunction(function);
                    this.DeleteCount++;
                }
            }
            this.Code = this.Sa.GetString();
        }