public Fmla(string text) { while (text.IndexOf(" (") > 0) { text = text.Replace(" (", "("); } this.text = text.Trim(); parts.Push(text); splitparts(); }
/// <summary> sC ("select Columns") is the fields selector clause. (like in SQL Statements)</summary> public DbGrid sC(string allfields) { DbGrid ret = new DbGrid(this); ret.allFields = ret.fields.Clone(); //new Pile<string> (ret.fieldNames); Reach fields = new Reach(allfields + ","); if (!fields.Trim().equals("*,")) { ret.fields = new Pile <DbField>(); Reach tokenMap = fields - bltZone.upon(fields - chrZone.upon(fields)); //AttGeTr: upon is too expensive! while (fields.Trim().len > 0) { Reach token = tokenMap.at(1, ","); ret.fields.Add(new DbField(fields.before(token).Trim().text)); //AttGeTr: no type information is added for each field !!! / ToBeSolved !!! fields = fields.after(token); tokenMap = tokenMap.after(token); } } return(ret); }
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++; } } }