public string ToStar(string expression) { var exp = EvaluationFunctions.parseLanguageExpression(expression, 0); if (exp.IsRecordSetExpression) { var rec = exp as LanguageAST.LanguageExpression.RecordSetExpression; if (rec != null) { return($"[[{rec.Item.Name}(*).{rec.Item.Column}]]"); } } if (exp.IsRecordSetNameExpression) { var rec = exp as LanguageAST.LanguageExpression.RecordSetNameExpression; if (rec != null) { return($"[[{rec.Item.Name}(*)]]"); } } if (exp.IsJsonIdentifierExpression) { var replace = expression.Replace(@"()", @"(*)"); return(replace); } return(expression); }
public bool HasRecordSet(string recordsetName) { var x = EvaluationFunctions.parseLanguageExpression(recordsetName, 0, ShouldTypeCast.Yes); if (x.IsRecordSetNameExpression && x is LanguageAST.LanguageExpression.RecordSetNameExpression recsetName) { return(_env.RecordSets.ContainsKey(recsetName.Item.Name)); } return(false); }
public bool HasRecordSet(string recordsetName) { var x = EvaluationFunctions.parseLanguageExpression(recordsetName, 0); if (x.IsRecordSetNameExpression) { var recsetName = x as LanguageAST.LanguageExpression.RecordSetNameExpression; return(_env.RecordSets.ContainsKey(recsetName?.Item.Name)); } return(false); }
public static bool IsRecordSetName(string a) { try { var x = EvaluationFunctions.parseLanguageExpression(a, 0, ShouldTypeCast.Yes); return(x.IsRecordSetNameExpression); } catch (Exception) { return(false); } }
public static bool IsScalar(string assignVar) { try { var x = EvaluationFunctions.parseLanguageExpression(assignVar, 0, ShouldTypeCast.Yes); return(x.IsScalarExpression); } catch (Exception) { return(false); } }
public static bool IsRecordsetIdentifier(string assignVar) { try { var x = EvaluationFunctions.parseLanguageExpression(assignVar, 0); return(x.IsRecordSetExpression); } catch (Exception) { return(false); } }
private static LanguageAST.LanguageExpression ParseExpression(string a) { try { var languageExpression = EvaluationFunctions.parseLanguageExpression(a, 0); return(languageExpression); } catch (Exception) { // } return(LanguageAST.LanguageExpression.NewWarewolfAtomExpression(DataStorage.WarewolfAtom.Nothing)); }
public static string GetPositionColumnExpression(string recordset) { var rec = EvaluationFunctions.parseLanguageExpression(recordset, 0); if (!rec.IsRecordSetExpression && !rec.IsRecordSetNameExpression) { return(recordset); } var recordSetExpression = rec as LanguageAST.LanguageExpression.RecordSetExpression; var recordSetNameExpression = rec as LanguageAST.LanguageExpression.RecordSetNameExpression; var index = recordSetExpression?.Item?.Name ?? recordSetNameExpression?.Item?.Name; return($"[[{index}(*).{EvaluationFunctions.PositionColumn}]]"); }
public void ParseLanguage_RecsetExpression_PassAnUpdate() { //------------Setup for test-------------------------- var data = CreateEnvironmentWithData(); //------------Execute Test--------------------------- var x = EvaluationFunctions.parseLanguageExpression("[[rec(1)]]", 3, ShouldTypeCast.Yes); //------------Assert Results------------------------- Assert.AreEqual(x.IsRecordSetNameExpression, true); var rec = x as LanguageAST.LanguageExpression.RecordSetNameExpression; Assert.IsTrue(rec.Item.Index.IsIntIndex); }
public static string ConvertToIndex(string outputVar, int i) { var output = EvaluationFunctions.parseLanguageExpression(outputVar, 0, ShouldTypeCast.Yes); if (output.IsRecordSetExpression && output is LanguageAST.LanguageExpression.RecordSetExpression recSetExpr) { var outputidentifier = recSetExpr.Item; if (Equals(outputidentifier?.Index, LanguageAST.Index.Star)) { return($"[[{outputidentifier?.Name}({i}).{outputidentifier?.Column}]]"); } } return(outputVar); }
public void ParseLanguage_IndexExpression() { //------------Setup for test-------------------------- var data = CreateEnvironmentWithData(); //------------Execute Test--------------------------- var x = EvaluationFunctions.parseLanguageExpression("[[rec([[a]]).a]]", 1); //------------Assert Results------------------------- Assert.AreEqual(x.IsRecordSetExpression, true); var rec = x as LanguageAST.LanguageExpression.RecordSetExpression; Assert.IsTrue(rec.Item.Index.IsIndexExpression); }
public void ParseLanguage_IndexExpression_PassAnUpdate() { //------------Setup for test-------------------------- var data = CreateEnvironmentWithData(); //------------Execute Test--------------------------- var x = EvaluationFunctions.parseLanguageExpression("[[rec(1).a]]", 3); //------------Assert Results------------------------- Assert.AreEqual(x.IsRecordSetExpression, true); var rec = x as LanguageAST.LanguageExpression.RecordSetExpression; // ReSharper disable once PossibleNullReferenceException Assert.IsTrue(rec.Item.Index.IsIntIndex); }
public static bool IsValidVariableExpression(string expression, out string errorMessage, int update) { errorMessage = string.Empty; try { var x = EvaluationFunctions.parseLanguageExpression(expression, update, ShouldTypeCast.Yes); if (x.IsRecordSetExpression || x.IsScalarExpression || x.IsJsonIdentifierExpression || x.IsRecordSetNameExpression) { return(true); } } catch (Exception e) { errorMessage = e.Message; return(false); } return(false); }
static void MockConstructorExecution(IDSFDataObject dataObject, IServiceTestStep serviceTestStep, ref PluginExecutionDto pluginExecutionDto) { if (!string.IsNullOrEmpty(serviceTestStep.StepOutputs?[0].Variable)) { try { var languageExpression = EvaluationFunctions.parseLanguageExpression(serviceTestStep.StepOutputs?[0].Variable, 0); if (languageExpression.IsJsonIdentifierExpression) { var jToken = JToken.Parse(serviceTestStep.StepOutputs?[0].Value) as JContainer ?? serviceTestStep.StepOutputs?[0].Value.DeserializeToObject(); dataObject.Environment.AddToJsonObjects(serviceTestStep.StepOutputs[0].Variable, jToken); pluginExecutionDto.ObjectString = serviceTestStep.StepOutputs[0].Value; } } catch (Exception e) { dataObject.Environment.Errors.Add(e.Message); } } }
public string ToStar(string expression) { var exp = EvaluationFunctions.parseLanguageExpression(expression, 0, ShouldTypeCast.Yes); if (exp.IsRecordSetExpression && exp is LanguageAST.LanguageExpression.RecordSetExpression rec) { return($"[[{rec.Item.Name}(*).{rec.Item.Column}]]"); } if (exp.IsRecordSetNameExpression && exp is LanguageAST.LanguageExpression.RecordSetNameExpression recNameExp) { return($"[[{recNameExp.Item.Name}(*)]]"); } if (exp.IsJsonIdentifierExpression) { var replace = expression.Replace(@"()", @"(*)"); return(replace); } return(expression); }
public static string GetPositionColumnExpression(string recordset) { var rec = EvaluationFunctions.parseLanguageExpression(recordset, 0, ShouldTypeCast.Yes); if (!rec.IsRecordSetExpression && !rec.IsRecordSetNameExpression) { return(recordset); } if (rec is LanguageAST.LanguageExpression.RecordSetExpression recordSetExpression) { var index = recordSetExpression.Item?.Name; return($"[[{index}(*).{EvaluationFunctions.PositionColumn}]]"); } if (rec is LanguageAST.LanguageExpression.RecordSetNameExpression recordSetNameExpression) { var index = recordSetNameExpression.Item?.Name; return($"[[{index}(*).{EvaluationFunctions.PositionColumn}]]"); } // This is a fail safe throw new Exception("Unhandled Recordset LanguageExpression"); }
public static LanguageAST.LanguageExpression ParseLanguageExpression(string sourceName, int update) { return(EvaluationFunctions.parseLanguageExpression(sourceName, update)); }
public static LanguageAST.LanguageExpression ParseLanguageExpression(string sourceName, int update) => EvaluationFunctions.parseLanguageExpression(sourceName, update, ShouldTypeCast.Yes);