/// <summary>Parameter that's a single named value that's one of a set of options</summary> internal static Value Single(string name, ValueArray oneOf) { ValueString vName = new ValueString(name); PatternData data = new PatternData(vName); data.OneOf = oneOf; return vName; }
/// <summary>Parameter that's a single named value with a default</summary> internal static Value Single(string name, Value theDefault) { ValueString vName = new ValueString(name); PatternData data = new PatternData(vName); data.Default = theDefault; return vName; }
/// <summary>Parameter that's a single named value of the given type with a default</summary> internal static Value Single(string name, ValueType type, Value theDefault) { ValueString vName = new ValueString(name); PatternData data = new PatternData(vName); data.Type = ValueClasses.ClassOf(type); data.Default = theDefault; return vName; }
/// <summary>Parameter that's a single named value</summary> internal static Value Single(string name) { ValueString vName = new ValueString(name); PatternData data = new PatternData(vName); return vName; }
/// <summary>Parameter that's the remainder of an array of a given type</summary> internal static Value Rest(string name, ValueType type) { ValueString vName = new ValueString(name); PatternData data = new PatternData(vName); data.Type = ValueClasses.ClassOf(type); data.UseRest = true; return vName; }
/// <summary>Parameter that's the remainder of an array or map</summary> internal static Value Rest(string name) { ValueString vName = new ValueString(name); PatternData data = new PatternData(vName); data.UseRest = true; return vName; }
/// <summary>Parameter that indicates that a "body" is required, i.e. an array of strings or parsed lines</summary> internal static Value Body() { ValueString vName = new ValueString("l3.body"); PatternData data = new PatternData(vName); // todo: data.ValueType = ValueType.RawList | ValueType.String; return vName; }
/// <summary> /// Score a parameter based on type annotations, etc. /// </summary> private int CalcPoints(Value value) { ValueString pattern = value as ValueString; if (pattern == null) return 0; PatternData data = new PatternData(pattern); string theType = data.Type; if (theType == ValueClasses.ClassOf(ValueType.Nil)) return 0; else if (theType == ValueClasses.ClassOf(ValueType.Number)) return 1; return 2; }