/// <summary> /// Called by the GetFrom Method /// The purpose of this method is to obtain the Sql WHERE, AND, OR Tokens /// And their comparison operators /// </summary> /// <param name="list"> the List of Tokens </param> /// <param name="i">The index at where the WHERE Statement begins</param> /// <returns>A list of tokens with the SQL property completed with either "whereOrAnd" or "operand" </returns> public static List<Token> gWhere(List<Token> list, int i) { List<Token> where = new List<Token>(); List<string> whereSql = new List<string>() { "TOKEN_AND", "TOKEN_OR", "TOKEN_WHERE" }; List<string> operands = new List<string>() { "<", ">", "=", "!", "|" }; StringBuilder sb = new StringBuilder(); int length = list.Count; for (int l = 0; l < length; l++) { if (whereSql.Contains(list[l].TokenType)) { Token whereOrAndTk = new Token(list[l].Location, list[l].Id, list[l].TokenType, list[l].Value, "notknown", "whereOrAnd"); where.Add(whereOrAndTk); } if (operands.Contains(list[l].TokenType)) { sb.Append(list[l].TokenType); if (operands.Contains(list[l + 1].TokenType)) { } else { Token operandTk = new Token(list[l].Location, list[l].Id, list[l].TokenType, sb.ToString(), "notknown", "operand"); sb.Clear(); where.Add(operandTk); } } } return where; }
/// <summary> /// The purpose of this method is to obtain the parameters that will be passed to the c# methods. /// It will loop through the XML tokens until it reaches the "TOKEN_FROM" token and will extract value from nodes that contain /// an attribute "TOKEN_ID". These values are the parameters to be passed to the C# Methods. /// Once the "TOKEN_FROM" is found, the loop is exited and the Method "getFrom" is called. /// </summary> /// <param name="list"> A full list of all token objects from the XML document are passed to the method</param> /// <returns> A list of Tokens that have their SQL property completed.</returns> public static List<Token> gParams(List<Token> list) { List<Token> param = new List<Token>(); int i = 0; while (list[i].TokenType != "TOKEN_FROM") { if (list[i].TokenType == "TOKEN_ID") { Token tk = new Token(list[i].Location, list[i].Id, list[i].TokenType, list[i].Value, "notknown", "param"); param.Add(tk); } i++; } List<Token> from = getFrom.gFrom(list, i); param.AddRange(from); return param; }
/// <summary> /// Creates a new List of Tokens generated from the parsed Sql XML document. /// An XDocument which can be traversed from node to node is passed to the method /// so that the corresponding node attributes and values can be used to create the Token Objects /// </summary> /// <param name="XmlDoc">The parsed XML is passed to the method as an XDocument</param> /// <returns> A List of Token Objects are returned </returns> public static List<Token> getToken(XDocument XmlDoc) { IEnumerable<XAttribute> location = from t in XmlDoc.Descendants("Token").Attributes("location") select t; List<string> locationList = new List<string>(); foreach (var l in location) { locationList.Add(l.Value); } IEnumerable<XAttribute> id = from i in XmlDoc.Descendants("Token").Attributes("id") select i; List<string> idList = new List<string>(); foreach (var i in id) { idList.Add(i.Value); } IEnumerable<XAttribute> type = from tp in XmlDoc.Descendants("Token").Attributes("type") select tp; List<string> typeList = new List<string>(); foreach (var t in type) { typeList.Add(t.Value); } IEnumerable<XElement> value = from v in XmlDoc.Descendants("Token") select v; List<string> valueList = new List<string>(); foreach (var vl in value) { valueList.Add(vl.Value); } List<Token> list = new List<Token>(); for (int i = 0; i < locationList.Count; i++) { Token tk = new Token(locationList[i], idList[i], typeList[i], valueList[i], "notknown", "sqlnotKnown"); list.Add(tk); } return list; }
/// <summary> /// Called by the GetParams method. /// The purpose of this method is to obtain the tables that are being selected from. /// The method loops through the List of tokens starting at the first "TOKEN_FROM" and /// exiting at the first "TOKEN_WHERE" /// </summary> /// <param name="list">The List of token objects</param> /// <param name="i"> The index of the tokenfrom ie where the loop exited from the previous method </param> /// <returns> a List of tokens with the SQL property completed and the whitespace XML tokens removed </returns> public static List<Token> gFrom(List<Token> list, int i) { List<Token> from = new List<Token>(); while (list[i].TokenType != "TOKEN_WHERE") { if (list[i].TokenType == "TOKEN_ID") { Token tk = new Token(list[i].Location, list[i].Id, list[i].TokenType, list[i].Value, "notknown", "from"); from.Add(tk); } i++; } List<Token> where = getWhere.gWhere(list, i); from.AddRange(where); return from; }
public OxymoronData(Token[] pair, IntClass overlap, bool greedy, bool debug) : this(pair, overlap, greedy) { Debug = debug; }
public OxymoronData(Token[] pair, IntClass overlap, bool greedy) : this(pair, overlap) { Greedy = greedy; }
public OxymoronData(Token[] pair, IntClass overlap) : this(pair) { Overlap = overlap; }
public OxymoronData(Token[] pair) { Pair = pair; _derivedFormsW2 = new Lazy<List<string>>(GetDerivedFormsW2); }