/// <summary> /// rule_conditions : /// key LEFT_PAREN arguments? RIGHT_PAREN /// | NOT rule_conditions /// | rule_conditions AND rule_conditions /// | rule_conditions OR rule_conditions /// | LEFT_PAREN rule_conditions RIGHT_PAREN /// ; /// </summary> /// <param name="context"></param> /// <returns></returns> public override object VisitRule_conditions([NotNull] WorkflowParser.Rule_conditionsContext context) { ExpressionModel result = null; var key = context.key(); if (key != null) { var k = (string)VisitKey(key); var r1 = new RuleExpressionModel() { Key = k, Reference = ResolveRule(k), }; var args = context.arguments(); if (args != null) { var arguments = (List <(string, string)>)VisitArguments(args); foreach (var argument in arguments) { r1.Arguments.Add(argument.Item1, argument.Item2); } } result = r1; } else if (context.NOT() != null) { result = new NotExpressionModel() { Expression = (ExpressionModel)VisitRule_conditions(context.rule_conditions()[0]) } } ; else if (context.AND() != null) { result = new BinaryExpressionModel() { Left = (ExpressionModel)VisitRule_conditions(context.rule_conditions()[0]), Operator = "AND", Right = (ExpressionModel)VisitRule_conditions(context.rule_conditions()[1]) } } ; else if (context.OR() != null) { result = new BinaryExpressionModel() { Left = (ExpressionModel)VisitRule_conditions(context.rule_conditions()[0]), Operator = "OR", Right = (ExpressionModel)VisitRule_conditions(context.rule_conditions()[1]) } } ; else if (context.LEFT_PAREN() != null && context.RIGHT_PAREN() != null) { result = (ExpressionModel)VisitRule_conditions(context.rule_conditions()[0]); } return(result); }