Example #1
0
        public string struc(long indent)
        {
            string ret = new string(' ', Math.Max(0, (int)indent));

            if (this != root)
            {
                ret += def + ctn.before(1, "<");
            }
            string lastType = "";

            foreach (Tag t in _tags)
            {
                if ((t.type.len == 0) && ((t.def + t.ctn.before(1, "<")).len > 0))
                {
                    ret += t.def + t.ctn.before(1, "<");
                }
                else if (t.type.text.ToLower().Equals("/" + lastType))
                {
                    ret += t.def;
                }
                else
                {
                    ret += "\n".Substring(0, Math.Min(1, ret.Length)) + t.struc(indent + 1);
                }
                lastType = t.type.text.ToLower();
            }
            if (closingTag != null)
            {
                if (closingTag != this)
                {
                    ret += closingTag.def;
                }
                else if (!type.Equals("") && !type.Equals("!") && !type.startsWith("/"))
                {
                    if (!def.at(-2).equals("/"))
                    {
                        ret += "</" + type + ">";
                    }
                }
            }
            return(ret);
        }
Example #2
0
 public bool matches(Tag t)
 {
     for (int i = 1; i <= symbs.Len; i++)
     {
         Reach  value = t.val(symbs[i]);
         string comp  = comps[i];
         string ptn   = patts[i];
         bool   neg   = comp.StartsWith("!");
         if (neg)
         {
             comp = comp.Substring(1);
         }
         if (comp.Equals("=="))
         {
             if (neg ^ value.equals(ptn))
             {
                 return(true);
             }
         }
         else if (comp.Equals("°="))
         {
             if (neg ^ value.Equals(ptn))
             {
                 return(true);
             }
         }
         else if (comp.Equals("~~"))
         {
             if (neg ^ new Regex(ptn).IsMatch(value.text))
             {
                 return(true);
             }
         }
         else if (comp.Equals("°~"))
         {
             if (neg ^ new Regex(ptn.ToUpper()).IsMatch(value.uText))
             {
                 return(true);
             }
         }
         else
         {
             throw new Exception("Invalid Compare Operator for Tag Filter! Use one of these: == °= ~~ °~ !== !°= !~~ !°~");
         }
     }
     return(false);
 }
Example #3
0
        private void splitparts()
        {
            Pile <Reach> res = new Pile <Reach>();

            Reach s = parts[1].Trim();

            while (s.len > 0)
            {
                Reach first = s.At(1, false, ops.array());
                if (first.len == 0)
                {
                    res.Push(s); s = "";
                }
                else
                {
                    if (s.startsWith(first))
                    {
                        if (first.Equals("\""))
                        {
                            res.Push("`dsF`"); res.Push(Zone.quotation.on(s)); res.Push(s.after(res[-1]).Trim()); s = "";
                        }
                        if (first.Equals("'"))
                        {
                            res.Push("`dsF`"); res.Push(Zone.charray.on(s)); res.Push(s.after(res[-1]).Trim()); s = "";
                        }
                        if (first.Equals("("))
                        {
                            res.Push(Zone.bracelet.on(s)); res.Push(s.after(res[-1]).Trim()); s = "";
                        }
                        if (first.Equals("["))
                        {
                            res.Push(Zone.bracket.on(s)); res.Push(s.after(res[-1]).Trim()); s = "";
                        }
                        if (first.Equals("{"))
                        {
                            res.Push(Zone.curlybrack.on(s)); res.Push(s.after(res[-1]).Trim()); s = "";
                        }

                        if (first.Equals("+"))
                        {
                            res.Push("`cct`"); res.Push(Zone.curlybrack.on(s)); res.Push(s.after(res[-1]).Trim()); s = "";
                        }
                        if (first.Equals("||"))
                        {
                            res.Push("`cct`"); res.Push(Zone.curlybrack.on(s)); res.Push(s.after(res[-1]).Trim()); s = "";
                        }

                        if (first.Equals("ltrim("))
                        {
                            res.Push("`ltr`"); res.Push(Zone.bracelet.on(s)); res.Push(s.after(res[-1]).Trim()); s = "";
                        }
                        if (first.Equals("rtrim("))
                        {
                            res.Push("`rtr`"); res.Push(Zone.bracelet.on(s)); res.Push(s.after(res[-1]).Trim()); s = "";
                        }
                    }
                    else
                    {
                        res.Push("`dF`");
                        res.Push(s.before(first).Trim());
                        res.Push(s.from(first).Trim());
                        s = "";
                    }
                }
            }
            parts = res;
        }
Example #4
0
        private void splitparts()
        {
            if (operators == null)
            {
                operators = ops.Clone(); foreach (string key in Dtv.Keys)
                {
                    operators.Push(new Reach(Dtv[key]).before(1, "``"));
                }
            }
            int inx = 1;

            while (inx <= Len)
            {
                Reach  rest = null;
                object lOp  = null;
                object rOp  = null;
                object tOp  = null;
                //if (this[inx].GetType() ==  typeof(string)) rest = new Reach((string)this[inx]).Trim();   //AttGeTr SEVERE BUGS HERE!!  the middle chars of "word" will be detected as Operator "or" !
                if (rest == null)
                {
                    inx++;
                }
                else
                {
                    Reach firstOptorSmb = rest.At(1, false, operators.array()).Trim();
                    if (firstOptorSmb.At(1, "(").len == 0)
                    {
                        if (operators.Contains((firstOptorSmb + "(").uText))
                        {
                            if (rest.after(firstOptorSmb).startsWith("("))
                            {
                                firstOptorSmb = firstOptorSmb + rest.after(firstOptorSmb).upto(1);                                                                                                                 // both the infix OR and the prefix OR( may be defined as directive
                            }
                        }
                    }
                    String firstOptor = optorForSymbolicOptor(firstOptorSmb.text);
                    if (rest.startsWith(firstOptorSmb))
                    {
                    }
                    else
                    {
                    }

                    if (firstOptorSmb.len == 0)
                    {
                        Reach fieldVal = new Reach((string)this[inx]).Trim();
                        this[inx] = new Reach((string)this[inx]);
                        rest      = "";
                    } // this term has no operand, it is a literal like 3 or a Symbol like a DbField Name or a composite field definition

                    else
                    {
                        if (rest.startsWith(firstOptorSmb))
                        {
                            if (firstOptorSmb.Equals("("))
                            {
                                this[inx] = new Trm(Zone.bracelet.on(rest).text); optor = ""; rest = rest.after(Zone.bracelet.upon(rest)).Trim();
                            }
                            else
                            {
                                string newOptor = firstOptorSmb.Trim().text.Replace("(", "");
                                bool   prefix   = (firstOptorSmb.at(1, "(").len > 0);
                                if (prefix)
                                {
                                    this[inx] = new Trm(Zone.bracelet.on(rest.after(1, optor).Trim()).text); rest = rest.after(Zone.bracelet.upon(rest.after(1, optor))).Trim();
                                }
                                else
                                {
                                    rest = "";
                                    if (optor.Length > 0)
                                    {
                                        this[1] = new Trm(optor, this[1]);
                                        for (int i = 2; i < inx; i++)
                                        {
                                            ((Trm)this[1]).Push(this[i]);
                                        }
                                        for (int i = 2; i <= Len - (inx - 2); i++)
                                        {
                                            this[i] = this[i + (inx - 2)];
                                        }
                                        for (int i = 1; i <= (inx - 2); i++)
                                        {
                                            Del(Len);
                                        }
                                        inx = 2;
                                    }
                                    this[inx] = new Trm(rest.after(1, optor).Trim().text); rest = "";
                                }
                                if ((((Trm)this[inx]).Len == 1 && ((Trm)this[inx]).optor.Length == 0))
                                {
                                    this[inx] = ((Trm)this[inx]).lOpnd;
                                }
                                optor = optorForSymbolicOptor(firstOptorSmb.Trim().text);
                            }
                        }
                        else
                        {
                            if ((Len == 1) && (optor.Length == 0))
                            {
                                optor = optorForSymbolicOptor(firstOptorSmb.Trim().text); this[inx] = rest.before(firstOptorSmb).Trim(); Push(rest.after(firstOptorSmb).Trim().text);
                            }
                            else
                            {
                                this[inx] = new Trm(optorForSymbolicOptor(firstOptorSmb.Trim().text), new object[] { rest.before(firstOptorSmb).Trim(), rest.after(firstOptorSmb).Trim().text });
                            }
                            rest = "";
                        }
                    }
                    if (rest.len > 0)
                    {
                        Push(rest.text);
                    }
                    rest = "";
                    inx++;
                }
            }
        }