Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Commit

Permalink
Rename Detokenizer to Preprocessor
Browse files Browse the repository at this point in the history
Remove ParserOptions.Detokenize
  • Loading branch information
louistakepillz committed May 5, 2015
1 parent 664d415 commit c014e2d
Show file tree
Hide file tree
Showing 25 changed files with 108 additions and 121 deletions.
18 changes: 9 additions & 9 deletions ArgumentParser/Arguments/Argument`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ protected Argument() { }
/// <param name="description">The description of the argument.</param>
/// <param name="valueOptions">The value parsing behavior of the argument.</param>
/// <param name="typeConverter">The type converter to use for conversion.</param>
/// <param name="detokenizer">The delegate to use for detokenization.</param>
/// <param name="preprocessor">The delegate to use for preprocessing.</param>
/// <param name="defaultValue">The default value of the argument.</param>
protected Argument(Key key, String description = null, ValueOptions valueOptions = ValueOptions.Single, TypeConverter typeConverter = null, Parser.DetokenizerDelegate detokenizer = null, T defaultValue = default (T))
protected Argument(Key key, String description = null, ValueOptions valueOptions = ValueOptions.Single, TypeConverter typeConverter = null, Parser.PreprocessorDelegate preprocessor = null, T defaultValue = default (T))
{
this.Key = key;
this.Description = description;
this.ValueOptions = valueOptions;
this.TypeConverter = typeConverter ?? TypeDescriptor.GetConverter(typeof (T));
this.Detokenizer = detokenizer;
this.Preprocessor = preprocessor;
this.DefaultValue = defaultValue;
}

Expand Down Expand Up @@ -86,9 +86,9 @@ protected Argument() { }
public TypeConverter TypeConverter { get; private set; }

/// <summary>
/// Gets the delegate to use for detokenization.
/// Gets the delegate to use for preprocessing.
/// </summary>
public Parser.DetokenizerDelegate Detokenizer { get; private set; }
public Parser.PreprocessorDelegate Preprocessor { get; private set; }

/// <summary>
/// Gets the default value of the argument.
Expand Down Expand Up @@ -124,11 +124,11 @@ IEnumerable<T> IArgument<T>.GetValues(IEnumerable<String> values, CultureInfo cu
/// Converts a sequence of values to the type of the argument using the specified <see cref="T:System.Globalization.CultureInfo"/>.
/// </summary>
/// <param name="parameters">The source parameters.</param>
/// <param name="detokenizer">The detokenizer to use to transform escaped sequences.</param>
/// <param name="preprocessor">The preprocessor to use to transform raw inputs.</param>
/// <param name="culture">The <see cref="T:System.Globalization.CultureInfo"/> to use for culture-sensitive operations.</param>
/// <param name="trailingValues">The values that are to be interpreted as trailing.</param>
/// <returns>The converted values.</returns>
public virtual ParameterPair GetPair(IEnumerable<RawParameter> parameters, Parser.DetokenizerDelegate detokenizer, CultureInfo culture, out IEnumerable<IEnumerable<String>> trailingValues)
public virtual ParameterPair GetPair(IEnumerable<RawParameter> parameters, Parser.PreprocessorDelegate preprocessor, CultureInfo culture, out IEnumerable<IEnumerable<String>> trailingValues)
{
switch (this.ValueOptions)
{
Expand All @@ -138,10 +138,10 @@ public virtual ParameterPair GetPair(IEnumerable<RawParameter> parameters, Parse
argument: this,
values: this.GetValues(parameters.Select(x => x.Value == null || x.CoupleCount > 1 ? null : x.Value), culture));
case ValueOptions.None:
trailingValues = parameters.Select(x => ValueConverter.GetCompositeValueParts(x, this.Detokenizer ?? detokenizer, culture));
trailingValues = parameters.Select(x => ValueConverter.GetCompositeValueParts(x, this.Preprocessor ?? preprocessor, culture));
return new ParameterPair(this, new Object[0]);
default:
var canonicalValues = parameters.ToDictionary(x => x, x => ValueConverter.GetCompositeValueParts(x, this.Detokenizer ?? detokenizer, culture));
var canonicalValues = parameters.ToDictionary(x => x, x => ValueConverter.GetCompositeValueParts(x, this.Preprocessor ?? preprocessor, culture));
trailingValues = canonicalValues.Select(x => x.Value.Any() ? x.Value.Skip(1) : x.Value);
return new ParameterPair(
argument: this,
Expand Down
6 changes: 3 additions & 3 deletions ArgumentParser/Arguments/FlagArgument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ protected FlagArgument() { }
/// <param name="valueOptions">The value parsing behavior of the argument.</param>
/// <param name="flagOptions">The value conversion behavior.</param>
/// <param name="typeConverter">The type converter to use for conversion.</param>
/// <param name="detokenizer">The delegate to use for detokenization.</param>
/// <param name="preprocessor">The delegate to use for preprocessing.</param>
/// <param name="defaultValue">The default value of the argument.</param>
protected FlagArgument(Key key, String description = null, ValueOptions valueOptions = ValueOptions.Single, FlagOptions flagOptions = FlagOptions.None, TypeConverter typeConverter = null, Parser.DetokenizerDelegate detokenizer = null, Int32 defaultValue = default (Int32))
: base(key, description, valueOptions, flagOptions, typeConverter, detokenizer, defaultValue) { }
protected FlagArgument(Key key, String description = null, ValueOptions valueOptions = ValueOptions.Single, FlagOptions flagOptions = FlagOptions.None, TypeConverter typeConverter = null, Parser.PreprocessorDelegate preprocessor = null, Int32 defaultValue = default (Int32))
: base(key, description, valueOptions, flagOptions, typeConverter, preprocessor, defaultValue) { }
}
}
12 changes: 6 additions & 6 deletions ArgumentParser/Arguments/FlagArgument`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ protected FlagArgument() { }
/// <param name="valueOptions">The value parsing behavior of the argument.</param>
/// <param name="flagOptions">The value conversion behavior.</param>
/// <param name="typeConverter">The type converter to use for conversion.</param>
/// <param name="detokenizer">The delegate to use for detokenization.</param>
/// <param name="preprocessor">The delegate to use for preprocessing.</param>
/// <param name="defaultValue">The default value of the argument.</param>
protected FlagArgument(Key key, String description = null, ValueOptions valueOptions = ValueOptions.Single, FlagOptions flagOptions = FlagOptions.None, TypeConverter typeConverter = null, Parser.DetokenizerDelegate detokenizer = null, T defaultValue = default(T))
: base(key, description, valueOptions, typeConverter, detokenizer, defaultValue)
protected FlagArgument(Key key, String description = null, ValueOptions valueOptions = ValueOptions.Single, FlagOptions flagOptions = FlagOptions.None, TypeConverter typeConverter = null, Parser.PreprocessorDelegate preprocessor = null, T defaultValue = default(T))
: base(key, description, valueOptions, typeConverter, preprocessor, defaultValue)
{
this.FlagOptions = flagOptions;
}
Expand All @@ -61,11 +61,11 @@ protected FlagArgument() { }
/// Converts a sequence of values to the type of the argument using the specified <see cref="T:System.Globalization.CultureInfo"/>.
/// </summary>
/// <param name="parameters">The source parameters.</param>
/// <param name="detokenizer">The detokenizer to use to transform escaped sequences.</param>
/// <param name="preprocessor">The preprocessor to use to transform raw inputs.</param>
/// <param name="culture">The <see cref="T:System.Globalization.CultureInfo"/> to use for culture-sensitive operations.</param>
/// <param name="trailingValues">The values that are to be interpreted as trailing.</param>
/// <returns>The converted values.</returns>
public override ParameterPair GetPair(IEnumerable<RawParameter> parameters, Parser.DetokenizerDelegate detokenizer, CultureInfo culture, out IEnumerable<IEnumerable<String>> trailingValues)
public override ParameterPair GetPair(IEnumerable<RawParameter> parameters, Parser.PreprocessorDelegate preprocessor, CultureInfo culture, out IEnumerable<IEnumerable<String>> trailingValues)
{
var rawParameters = parameters as RawParameter[] ?? parameters.ToArray();

Expand All @@ -79,7 +79,7 @@ public override ParameterPair GetPair(IEnumerable<RawParameter> parameters, Pars
bool invertImplicit = (this.FlagOptions & FlagOptions.InvertBooleanImplicit) != 0;
bool invertExplicit = (this.FlagOptions & FlagOptions.InvertBooleanExplicit) != 0;

var canonicalValues = rawParameters.ToDictionary(x => x, x => ValueConverter.GetCompositeValueParts(x, detokenizer, culture));
var canonicalValues = rawParameters.ToDictionary(x => x, x => ValueConverter.GetCompositeValueParts(x, preprocessor, culture));

var flagValues = canonicalValues.Select(x =>
{
Expand Down
4 changes: 2 additions & 2 deletions ArgumentParser/Arguments/IArgument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public interface IArgument : IPairable
/// Converts a sequence of values to the type of the argument using the specified <see cref="T:System.Globalization.CultureInfo"/>.
/// </summary>
/// <param name="parameters">The source parameters.</param>
/// <param name="detokenizer">The detokenizer to use to transform escaped sequences.</param>
/// <param name="preprocessor">The preprocessor to use to transform raw inputs.</param>
/// <param name="culture">The <see cref="T:System.Globalization.CultureInfo"/> to use for culture-sensitive operations.</param>
/// <param name="trailingValues">The values that are to be interpreted as trailing.</param>
/// <returns>The converted values.</returns>
ParameterPair GetPair(IEnumerable<RawParameter> parameters, Parser.DetokenizerDelegate detokenizer, CultureInfo culture, out IEnumerable<IEnumerable<String>> trailingValues);
ParameterPair GetPair(IEnumerable<RawParameter> parameters, Parser.PreprocessorDelegate preprocessor, CultureInfo culture, out IEnumerable<IEnumerable<String>> trailingValues);
}
}
6 changes: 3 additions & 3 deletions ArgumentParser/Arguments/POSIX/POSIXLongArgument`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public class POSIXLongArgument<T> : Argument<T>
/// <param name="description">The description of the argument.</param>
/// <param name="valueOptions">The value parsing behavior of the argument.</param>
/// <param name="typeConverter">The type converter to use for conversion.</param>
/// <param name="detokenizer">The delegate to use for detokenization.</param>
/// <param name="preprocessor">The delegate to use for preprocessing.</param>
/// <param name="defaultValue">The default value of the argument.</param>
public POSIXLongArgument(String tag, String description = null, ValueOptions valueOptions = ValueOptions.Single, TypeConverter typeConverter = null, Parser.DetokenizerDelegate detokenizer = null, T defaultValue = default (T))
: base(new Key(Prefix, tag), description, valueOptions, typeConverter, detokenizer, defaultValue) { }
public POSIXLongArgument(String tag, String description = null, ValueOptions valueOptions = ValueOptions.Single, TypeConverter typeConverter = null, Parser.PreprocessorDelegate preprocessor = null, T defaultValue = default (T))
: base(new Key(Prefix, tag), description, valueOptions, typeConverter, preprocessor, defaultValue) { }

/// <summary>
/// Gets the prefix used for arguments of the <see cref="T:ArgumentParser.Arguments.POSIX.POSIXLongArgument`1"/> type.
Expand Down
6 changes: 3 additions & 3 deletions ArgumentParser/Arguments/POSIX/POSIXLongFlag`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public class POSIXLongFlag<T> : FlagArgument<T>
/// <param name="valueOptions">The value parsing behavior of the argument.</param>
/// <param name="flagOptions">The value conversion behavior.</param>
/// <param name="typeConverter">The type converter to use for value conversion.</param>
/// <param name="detokenizer">The delegate to use for detokenization.</param>
/// <param name="preprocessor">The delegate to use for preprocessor.</param>
/// <param name="defaultValue">The default value of the argument.</param>
public POSIXLongFlag(String tag, String description = null, ValueOptions valueOptions = ValueOptions.Single, FlagOptions flagOptions = FlagOptions.None, TypeConverter typeConverter = null, Parser.DetokenizerDelegate detokenizer = null, T defaultValue = default (T))
: base(new Key(Prefix, tag), description, valueOptions, flagOptions, typeConverter, detokenizer, defaultValue) { }
public POSIXLongFlag(String tag, String description = null, ValueOptions valueOptions = ValueOptions.Single, FlagOptions flagOptions = FlagOptions.None, TypeConverter typeConverter = null, Parser.PreprocessorDelegate preprocessor = null, T defaultValue = default (T))
: base(new Key(Prefix, tag), description, valueOptions, flagOptions, typeConverter, preprocessor, defaultValue) { }

/// <summary>
/// Gets the prefix used for arguments of the <see cref="T:ArgumentParser.Arguments.POSIX.POSIXLongFlag`1"/> type.
Expand Down
6 changes: 3 additions & 3 deletions ArgumentParser/Arguments/POSIX/POSIXShortArgument`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public class POSIXShortArgument<T> : Argument<T>
/// <param name="description">The description of the argument.</param>
/// <param name="valueOptions">The value parsing behavior of the argument.</param>
/// <param name="typeConverter">The type converter to use for value conversion.</param>
/// <param name="detokenizer">The delegate to use for detokenization.</param>
/// <param name="preprocessor">The delegate to use for preprocessing.</param>
/// <param name="defaultValue">The default value of the argument.</param>
public POSIXShortArgument(Char tag, String description = null, ValueOptions valueOptions = ValueOptions.Single, TypeConverter typeConverter = null, Parser.DetokenizerDelegate detokenizer = null, T defaultValue = default (T))
: base(new Key(Prefix, tag.ToString()), description, valueOptions, typeConverter, detokenizer, defaultValue) { }
public POSIXShortArgument(Char tag, String description = null, ValueOptions valueOptions = ValueOptions.Single, TypeConverter typeConverter = null, Parser.PreprocessorDelegate preprocessor = null, T defaultValue = default (T))
: base(new Key(Prefix, tag.ToString()), description, valueOptions, typeConverter, preprocessor, defaultValue) { }

/// <summary>
/// Gets the prefix used for arguments of the <see cref="T:ArgumentParser.Arguments.POSIX.POSIXShortArgument`1"/> type.
Expand Down
6 changes: 3 additions & 3 deletions ArgumentParser/Arguments/POSIX/POSIXShortFlag`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public class POSIXShortFlag<T> : FlagArgument<T>
/// <param name="valueOptions">The value parsing behavior of the argument.</param>
/// <param name="flagOptions">The value conversion behavior.</param>
/// <param name="typeConverter">The type converter to use for value conversion.</param>
/// <param name="detokenizer">The delegate to use for detokenization.</param>
/// <param name="preprocessor">The delegate to use for preprocessing.</param>
/// <param name="defaultValue">The default value of the argument.</param>
public POSIXShortFlag(Char tag, String description = null, ValueOptions valueOptions = ValueOptions.Single, FlagOptions flagOptions = FlagOptions.None, TypeConverter typeConverter = null, Parser.DetokenizerDelegate detokenizer = null, T defaultValue = default (T))
: base(new Key(Prefix, tag.ToString()), description, valueOptions, flagOptions, typeConverter, detokenizer, defaultValue) { }
public POSIXShortFlag(Char tag, String description = null, ValueOptions valueOptions = ValueOptions.Single, FlagOptions flagOptions = FlagOptions.None, TypeConverter typeConverter = null, Parser.PreprocessorDelegate preprocessor = null, T defaultValue = default (T))
: base(new Key(Prefix, tag.ToString()), description, valueOptions, flagOptions, typeConverter, preprocessor, defaultValue) { }

/// <summary>
/// Gets the prefix used for arguments of the <see cref="T:ArgumentParser.Arguments.POSIX.POSIXShortFlag`1"/> type.
Expand Down
6 changes: 3 additions & 3 deletions ArgumentParser/Arguments/PowerShell/PowerShellArgument`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public class PowerShellArgument<T> : Argument<T>
/// <param name="description">The description of the argument.</param>
/// <param name="valueOptions">The value parsing behavior of the argument.</param>
/// <param name="typeConverter">The type converter to use for value conversion.</param>
/// <param name="detokenizer">The delegate to use for detokenization.</param>
/// <param name="preprocessor">The delegate to use for preprocessing.</param>
/// <param name="defaultValue">The default value of the argument.</param>
public PowerShellArgument(String tag, String description = null, ValueOptions valueOptions = ValueOptions.Single, TypeConverter typeConverter = null, Parser.DetokenizerDelegate detokenizer = null, T defaultValue = default (T))
: base(new Key(Prefix, tag), description, valueOptions, typeConverter, detokenizer, defaultValue) { }
public PowerShellArgument(String tag, String description = null, ValueOptions valueOptions = ValueOptions.Single, TypeConverter typeConverter = null, Parser.PreprocessorDelegate preprocessor = null, T defaultValue = default (T))
: base(new Key(Prefix, tag), description, valueOptions, typeConverter, preprocessor, defaultValue) { }

/// <summary>
/// Gets the prefix used for arguments of the <see cref="T:ArgumentParser.Arguments.PowerShell.PowerShellArgument`1"/> type.
Expand Down
6 changes: 3 additions & 3 deletions ArgumentParser/Arguments/PowerShell/PowerShellFlag`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public class PowerShellFlag<T> : FlagArgument<T>
/// <param name="valueOptions">The value parsing behavior of the argument.</param>
/// <param name="flagOptions">The value conversion behavior.</param>
/// <param name="typeConverter">The type converter to use for value conversion.</param>
/// <param name="detokenizer">The delegate to use for detokenization.</param>
/// <param name="preprocessor">The delegate to use for preprocessing.</param>
/// <param name="defaultValue">The default value of the argument.</param>
public PowerShellFlag(String tag, String description = null, ValueOptions valueOptions = ValueOptions.Single, FlagOptions flagOptions = FlagOptions.None, TypeConverter typeConverter = null, Parser.DetokenizerDelegate detokenizer = null, T defaultValue = default (T))
: base(new Key(Prefix, tag), description, valueOptions, flagOptions, typeConverter, detokenizer, defaultValue) { }
public PowerShellFlag(String tag, String description = null, ValueOptions valueOptions = ValueOptions.Single, FlagOptions flagOptions = FlagOptions.None, TypeConverter typeConverter = null, Parser.PreprocessorDelegate preprocessor = null, T defaultValue = default (T))
: base(new Key(Prefix, tag), description, valueOptions, flagOptions, typeConverter, preprocessor, defaultValue) { }

/// <summary>
/// Gets the prefix used for arguments of the <see cref="T:ArgumentParser.Arguments.PowerShell.PowerShellFlag`1"/> type.
Expand Down
Loading

0 comments on commit c014e2d

Please sign in to comment.