public override void ParseInside(ExpressionParser parser) { var collection = parser.Collection; var le = collection.GotoNextMust(); if (le.LexemType != LexType.Command || le.LexemText.ToLower() != "when") { int idx = collection.IndexLexem; ExpressionParser tonode = new ExpressionParser(collection); tonode.Parse(); if (tonode.Results.Count != 1) { collection.Error("не верное число параметров", collection.Get(idx)); } CaseArg = tonode.Single(); le = collection.CurrentLexem(); } if (le.LexemType != LexType.Command || le.LexemText.ToLower() != "when") { collection.Error("Ожидалось WHEN", collection.CurrentOrLast()); } while (le.LexemType == LexType.Command && le.LexemText.ToLower() == "when") { WhenThen wt = new WhenThen(); collection.GotoNextMust(); int idx = collection.IndexLexem; ExpressionParser tonode = new ExpressionParser(collection); tonode.Parse(); if (tonode.Results.Count != 1) { collection.Error("не верное число параметров", collection.Get(idx)); } wt.When = tonode.Single(); le = collection.CurrentLexem(); if (le == null || le.LexemType != LexType.Command || le.LexemText.ToLower() != "then") { collection.Error("ожидалось THEN", collection.CurrentOrLast()); } le = collection.GotoNextMust(); idx = collection.IndexLexem; tonode = new ExpressionParser(collection); tonode.Parse(); if (tonode.Results.Count != 1) { collection.Error("не верное число параметров", collection.Get(idx)); } wt.Then = tonode.Single(); ListWhenThen.Add(wt); le = collection.CurrentLexem(); if (le == null) { collection.Error("Не найден END", collection.GetLast()); } if (le.LexemText.ToLower() == "end") { break; } if (le.LexemText.ToLower() == "when") { continue; } if (le.LexemText.ToLower() == "else") { le = collection.GotoNextMust(); idx = collection.IndexLexem; tonode = new ExpressionParser(collection); tonode.Parse(); if (tonode.Results.Count != 1) { collection.Error("не верное число параметров", collection.Get(idx)); } Else = tonode.Single(); le = collection.CurrentLexem(); if (le == null || le.LexemText.ToLower() != "end") { collection.Error("Ожидался END", collection.CurrentOrLast()); } break; } collection.Error("Не ожиданный конец", collection.CurrentOrLast()); } base.ParseInside(parser); }
public bool CaseAsBool(WhenThen wt, object data) { return(CaseArg.GetBoolResultOut(data) == wt.When.GetBoolResultOut(data)); }
public bool CaseAsTime(WhenThen wt, object data) { return(CaseArg.GetTimeResultOut(data) == wt.When.GetTimeResultOut(data)); }
public bool CaseAsFloat(WhenThen wt, object data) { return(CaseArg.GetFloatResultOut(data) == wt.When.GetFloatResultOut(data)); }