private void BuildPropertyDeclaration(string tcLine) { // the last word in this line is the name of the property tcLine = ReplaceManager.GetSingledSpacedString(tcLine).Trim(); if (tcLine.EndsWith(")")) { int nEnd = tcLine.IndexOf("("); this.PropertyParameterToken = this.ExtractBlock(tcLine, "(", ")"); FieldManager fm = new FieldManager(); this.PropertyParameterToken = "(" + fm.GetConvertedExpression(this.PropertyParameterToken) + ") "; this.PropertyParameterToken = this.PropertyParameterToken.Replace("Dim ", ""); tcLine = tcLine.Substring(0, nEnd).Trim(); } int npos = tcLine.LastIndexOf(" "); this.PropertyNameToken = tcLine.Substring(npos + 1); string cDefinition = tcLine.Substring(0, npos).Trim(); cDefinition = ReplaceManager.HandleModifiers(cDefinition); //A property has to return a value cDefinition = cDefinition.Trim(); npos = cDefinition.LastIndexOf(" "); this.ReturnValueToken = "As " + cDefinition.Substring(npos).Trim(); cDefinition = cDefinition.Substring(0, npos); this.PropertyModifiersToken = cDefinition; }
private void GetCondition(string tcLine) { string lcStr = this.ExtractBlock(tcLine, "(", ")"); lcStr = ReplaceManager.GetSingledSpacedString(lcStr); //We assume that there will not be any spaces in between quotes and parenthesis when GetSingledSpaceString string[] aStr = lcStr.Split(' '); if (aStr.Length > 3) { //The first word in this is a declaration of the second word //foreach( String x in MyArrayList ) FieldManager fm = new FieldManager(); this.DeclarationToken = this.BlankToken + fm.GetConvertedExpression(aStr[0] + " " + aStr[1] + ";") + "\n"; //Build the ConditionToken int npos = lcStr.IndexOf(" "); this.ConditionToken = lcStr.Substring(npos).Trim(); } else { this.ConditionToken = lcStr.Trim(); } this.ConditionToken = this.ConditionToken.Replace(" in ", " In "); }
private void GetCatchToken(string tcCatchToken) { string sCatchToken = this.ExtractBlock(ReplaceManager.GetSingledSpacedString(tcCatchToken).Trim(), "(", ")").Trim(); int npos = sCatchToken.IndexOf(" "); if (npos > 0) { FieldManager fm = new FieldManager(); this.CatchToken = fm.GetConvertedExpression(sCatchToken + ";").Replace("Dim ", "Catch "); } else { this.CatchToken = "Catch"; } }
private void GetCatchToken(string tcCatchToken) { string sCatchToken = ReplaceManager.GetSingledSpacedString(tcCatchToken).Trim(); int npos = sCatchToken.IndexOf(" "); if (npos > 0) { FieldManager fm = new FieldManager(); this.CatchToken = "Catch " + fm.GetConvertedExpression(sCatchToken.Substring(npos) + ";"); } else { this.CatchToken = "Catch"; } }
private string GetParameters(string tcString) { string cParameters; //Remove the paramthesis from the parameters cParameters = this.ExtractBlock(tcString, "(", ")"); string lcRetVal = "()"; if (cParameters.Length > 0) { //split the string on commas string[] aParams = cParameters.Split(','); FieldManager fm = new FieldManager(); StringBuilder sParams = new StringBuilder(); string cParam = ""; string cTypeCast = ""; for (int j = 0; j < aParams.Length; j++) { cParam = aParams[j].Trim(); if ((cParam.IndexOf("ref ") >= 0) || (cParam.IndexOf("out ") >= 0)) { cTypeCast = "ByRef"; cParam = cParam.Replace("ref ", ""); cParam = cParam.Replace("out ", ""); } else { cTypeCast = "ByVal"; } if (j > 0) { sParams.Append(", "); } cParam = fm.GetConvertedExpression(cParam + ";").Trim(); cParam = cTypeCast + cParam.Replace("Dim", ""); sParams.Append(cParam); } lcRetVal = "(" + sParams.ToString() + ")"; } return(lcRetVal); }
private string Build() { //check if the datatype token is an array int npos = this.DataTypeToken.IndexOf('['); if (npos > 0) { this.VariableToken = this.VariableToken + this.DataTypeToken.Substring(npos); this.DataTypeToken = this.DataTypeToken.Substring(0, npos); } //Leave the semi colun purposefully so the property handler does not pick it up string lcRetVal = ""; lcRetVal += this.BlankToken + this.ModifierToken; lcRetVal += this.VariableToken + " As " + this.DataTypeToken + this.AssignmentToken + ";"; foreach (string s in this.CommaSeperatedDeclarations) { FieldManager fm = new FieldManager(); fm.ModifierToken = ","; lcRetVal = lcRetVal + fm.GetConvertedExpression(s).Trim(); } return(lcRetVal); }
public string GetBlock(string tcLine) { // Initialize the properties this.Initialize(); this.GetBlankToken(tcLine); //Check if the operation is ++ or -- int npos; tcLine = ReplaceManager.GetSingledSpacedString(tcLine); // Check for an equal sign in the variable block and if so, then this is the declaration int nEqualsPosition = tcLine.IndexOf("="); if (nEqualsPosition > 0) { // Capture the declaration string lcDeclaration = tcLine.Substring(0, nEqualsPosition); // Fix the declaration by passing it to the appropriate handler FieldManager fm = new FieldManager(); this.DeclarationBlock = fm.GetConvertedExpression(lcDeclaration).Replace(";", "") + " = "; tcLine = tcLine.Substring(nEqualsPosition + 1).Trim(); } // Verify that the expression has atleast a ++ or -- npos = tcLine.IndexOf("++"); if (npos < 0) { npos = tcLine.IndexOf("--"); if (npos < 0) { return(tcLine); } else { this.ExpressionBlock = "- 1"; } } else { this.ExpressionBlock = "+ 1"; } //best case scenario //Determine the expression part and update the variable block if (npos != 0) { //between this and the previous whitespace this.VariableBlock = tcLine.Substring(0, npos); } else { // Begin by removing the semicolon tcLine = tcLine.Replace(";", "").Trim(); // Check if there is extra space at the end left int nBlankPos = tcLine.IndexOf(" "); if (nBlankPos > 0) { // Extract all the padding and store it seperately this.PaddingBlock = tcLine.Substring(nBlankPos); tcLine = tcLine.Substring(0, nBlankPos); } this.VariableBlock = tcLine.Replace("++", "").Replace("--", "").Trim(); } // Update the declaration if (this.DeclarationBlock.Length == 0) { this.DeclarationBlock = this.VariableBlock + " = "; } return(this.Execute()); }