Example #1
0
 public Conditional(string name, ConditionalType type, List <string> parameters)
 {
     Name       = name;
     Type       = type;
     Parameters = parameters;
     Action     = ActionType.Sell;
 }
Example #2
0
 public Conditional(string name, ConditionalType type, ActionType action, List <string> parameters)
 {
     Name       = name;
     Type       = type;
     Action     = action;
     Parameters = parameters;
 }
Example #3
0
        public static IReadOnlyList <IOperationProvider> ConditionalSetup(ConditionalType style, string evaluatorType, bool wholeLine, bool trimWhiteSpace, string id)
        {
            List <IOperationProvider> setup;

            switch (style)
            {
            case ConditionalType.MSBuild:
                setup = MSBuildConditionalSetup(evaluatorType, wholeLine, trimWhiteSpace, id);
                break;

            case ConditionalType.Xml:
                setup = ConditionalBlockCommentConfig.GenerateConditionalSetup("<!--", "-->");
                break;

            case ConditionalType.Razor:
                setup = ConditionalBlockCommentConfig.GenerateConditionalSetup("@*", "*@");
                break;

            case ConditionalType.CLineComments:
                setup = ConditionalLineCommentConfig.GenerateConditionalSetup("//");
                break;

            case ConditionalType.CNoComments:
                setup = CStyleNoCommentsConditionalSetup(evaluatorType, wholeLine, trimWhiteSpace, id);
                break;

            case ConditionalType.CBlockComments:
                setup = ConditionalBlockCommentConfig.GenerateConditionalSetup("/*", "*/");
                break;

            case ConditionalType.HashSignLineComment:
                // Most line comment conditional tags use: <comment symbol><keyword prefix><keyword>
                // But for this one, the '#' comment symbol is all that's needed, so it uses an empty keyword prefix.
                // So we end up with regular conditionals suchs as '#if', '#else'
                // and actionables such as '##if'
                ConditionalKeywords keywords = new ConditionalKeywords()
                {
                    KeywordPrefix = string.Empty
                };
                setup = ConditionalLineCommentConfig.GenerateConditionalSetup("#", keywords, new ConditionalOperationOptions());
                break;

            case ConditionalType.RemLineComment:
                setup = ConditionalLineCommentConfig.GenerateConditionalSetup("rem ");
                break;

            case ConditionalType.HamlLineComment:
                setup = ConditionalLineCommentConfig.GenerateConditionalSetup("-#");
                break;

            case ConditionalType.JsxBlockComment:
                setup = ConditionalBlockCommentConfig.GenerateConditionalSetup("{/*", "*/}");
                break;

            default:
                throw new Exception($"Unrecognized conditional type {style}");
            }

            return(setup);
        }
Example #4
0
 public SpecialOperationConfigParams(string glob, string flagPrefix, string evaluatorName, ConditionalType type)
 {
     EvaluatorName    = evaluatorName;
     Glob             = glob;
     FlagPrefix       = flagPrefix;
     ConditionalStyle = type;
 }
        public static IReadOnlyList <IOperationProvider> ConditionalSetup(ConditionalType style, string evaluatorType, bool wholeLine, bool trimWhiteSpace, string id)
        {
            List <IOperationProvider> setup;

            switch (style)
            {
            case ConditionalType.Xml:
                setup = XmlConditionalSetup(evaluatorType, wholeLine, trimWhiteSpace, id);
                break;

            case ConditionalType.Razor:
                setup = RazorConditionalSetup(evaluatorType, wholeLine, trimWhiteSpace, id);
                break;

            case ConditionalType.CLineComments:
                setup = CStyleLineCommentsConditionalSetup(evaluatorType, wholeLine, trimWhiteSpace, id);
                break;

            case ConditionalType.CNoComments:
                setup = CStyleNoCommentsConditionalSetup(evaluatorType, wholeLine, trimWhiteSpace, id);
                break;

            case ConditionalType.CBlockComments:
                setup = CStyleBlockCommentConditionalSetup(evaluatorType, wholeLine, trimWhiteSpace, id);
                break;

            case ConditionalType.HashSignLineComment:
                setup = HashSignLineCommentConditionalSetup(evaluatorType, wholeLine, trimWhiteSpace, id);
                break;

            case ConditionalType.RemLineComment:
                setup = RemLineCommentConditionalSetup(evaluatorType, wholeLine, trimWhiteSpace, id);
                break;

            default:
                throw new Exception($"Unrecognized conditional type {style}");
            }

            return(setup);
        }
Example #6
0
        public override void ParseParams(JsonData parameters)
        {
            var keys = parameters.Keys;

            if (!keys.Contains(D.STATEMENTS))
            {
                _type = ConditionalType.SinglePair;

                _effectDefinitions    = EffectDefinition.ParseDefinitions(parameters[D.EFFECTS], definition.definitionKey);
                _conditionDefinitions = ConditionDefinition.ParseDefinitions(parameters[D.CONDITIONS], definition.definitionKey);

                if (parameters.Keys.Contains("elseEffects"))
                {
                    _elseEffectDefinitions = EffectDefinition.ParseDefinitions(parameters["elseEffects"], definition.definitionKey);
                }
                else
                {
                    _elseEffectDefinitions = new Definition <Effect> [0];
                }
            }
            else
            {
                _type = ConditionalType.MultiplePairs;

                var conditionEffectData = parameters[D.STATEMENTS];
                var numConditionEffects = conditionEffectData.Count;
                _conditionEffectPairsDefinition =
                    new KeyValuePair <Definition <Condition>[], Definition <Effect>[]> [numConditionEffects];

                for (int i = 0; i < numConditionEffects; i++)
                {
                    _conditionEffectPairsDefinition[i] = new KeyValuePair <Definition <Condition>[], Definition <Effect>[]>(
                        ConditionDefinition.ParseDefinitions(conditionEffectData[i][D.CONDITIONS], definition.definitionKey),
                        EffectDefinition.ParseDefinitions(conditionEffectData[i][D.EFFECTS], definition.definitionKey)
                        );
                }
            }
        }
Example #7
0
        public static UserType ParseType(XElement xmlType, Dictionary <string, IType> scopedTypes)
        {
            var typeName = xmlType.Attribute("name");
            var type     = new UserType(typeName.Value);

            var subTypes   = xmlType.Elements("type");
            var attributes = xmlType.Elements("attr");

            scopedTypes.Add(type.Name, type);
            foreach (var subType in subTypes)
            {
                var parsed = ParseType(subType, new Dictionary <string, IType>(scopedTypes));
                scopedTypes.Add(parsed.Name, parsed);
            }

            foreach (var attr in attributes)
            {
                var attrName = attr.Attribute("name");

                var typeAttr = attr.Attribute("type");
                var typeExpr = attr.Element("type");

                var offsetExpr = attr.Element("offset");
                var sizeExpr   = attr.Element("size");

                var conditionExpr = attr.Element("if");

                var repeatType = attr.Element("repeat");

                IPotential <IType> typePotential;

                if (typeAttr != null || typeExpr != null)
                {
                    IPotential <string> namePotential = typeAttr != null ?
                                                        (IPotential <string>) new TrivialPotential <string>(typeAttr.Value) :
                                                        (IPotential <string>) new Expression <string>(typeExpr.Value);

                    typePotential = new NamedTypePotential(scopedTypes, namePotential);
                }
                else
                {
                    typePotential = new TrivialPotential <IType>(new VoidType(new Expression <long>(sizeExpr.Value)));
                }

                if (offsetExpr != null)
                {
                    var baseType   = typePotential;
                    var offsetType = new OffsetType(baseType, new Expression <long>(offsetExpr.Value));

                    typePotential = new TrivialPotential <IType>(offsetType);
                }

                if (conditionExpr != null)
                {
                    var baseType        = typePotential;
                    var conditionalType = new ConditionalType(baseType, new Expression <bool>(conditionExpr.Value));

                    typePotential = new TrivialPotential <IType>(conditionalType);
                }

                if (repeatType != null)
                {
                    var lengthExpr = attr.Element("repeat-expr");
                    var untilExpr  = attr.Element("repeat-until");

                    var baseType = typePotential;

                    if (repeatType.Value == "expr")
                    {
                        var arrayType = new DefiniteArrayType(baseType, new Expression <int>(lengthExpr.Value));
                        typePotential = new TrivialPotential <IType>(arrayType);
                    }
                    else if (repeatType.Value == "until")
                    {
                        var arrayType = new IndefiniteArrayType(baseType, new Expression <bool>(untilExpr.Value));
                        typePotential = new TrivialPotential <IType>(arrayType);
                    }
                }

                type.Attributes.Add(attrName.Value, typePotential);
            }

            return(type);
        }
 public SpecialOperationConfigParams(string glob, string flagPrefix, ConditionalType type)
 {
     Glob             = glob;
     FlagPrefix       = flagPrefix;
     ConditionalStyle = type;
 }
Example #9
0
 public override string ToString()
 {
     return($"[{GetType ().Name}: {ConditionalType?.ToString () ?? ConditionalTypeName}]");
 }
 public IfNode()
 {
     type = ConditionalType.IF;
 }
Example #11
0
 private static ConditionalModel GetModel(string fieldName, string fieldValue, ConditionalType ct)
 {
     return(new ConditionalModel
     {
         ConditionalType = ct,
         FieldName = fieldName,
         FieldValue = fieldValue
     });
 }
Example #12
0
 public Conditional(ConditionalType type, string contents)
 {
     this.type = type;
     Contents  = contents;
 }
Example #13
0
        /// <summary>
        /// 获取操作符
        /// </summary>
        /// <param name="op">操作符简写</param>
        /// <returns></returns>
        private ConditionalType GetOperator(string op)
        {
            ConditionalType type = ConditionalType.Equal;

            switch (op.ToLower())
            {
            case "eq":
                type = ConditionalType.Equal;
                break;

            case "gt":    //大于
                type = ConditionalType.GreaterThan;
                break;

            case "ge":    //大于或等于
                type = ConditionalType.GreaterThanOrEqual;
                break;

            case "in":    //包括
                type = ConditionalType.In;
                break;

            case "lt":    //小于
                type = ConditionalType.LessThan;
                break;

            case "le":    //小于或等于
                type = ConditionalType.LessThanOrEqual;
                break;

            case "cn":    //包含
                type = ConditionalType.Like;
                break;

            case "sw":    //以...开始
                type = ConditionalType.LikeLeft;
                break;

            case "ew":    //以什么结束
                type = ConditionalType.LikeRight;
                break;

            case "ne":    //不等于
                type = ConditionalType.NoEqual;
                break;

            case "nc":    //不包含
                type = ConditionalType.NoLike;
                break;

            case "ni":    //不包括
                type = ConditionalType.NotIn;
                break;

            case "ie":
                type = ConditionalType.IsNullOrEmpty;
                break;

            case "is":
                type = ConditionalType.IsNot;
                break;
            }
            return(type);
        }