C# Class LeMP.Compiler

A class that helps you invoke MacroProcessor on on a set of source files, given a set of command-line options.
This class helps you process command-line options (see ProcessArguments(IList{string}, bool, bool, IList{string})), complete InputOutput objects based on those options (see CompleteInputOutputOptions), and add macros from Assemblies (AddMacros and AddStdMacros).
Afficher le fichier Open project: qwertie/ecsharp Class Usage Examples

Méthodes publiques

Свойство Type Description
Files List
ForceInLang bool
InLang IParsingService
IndentString string
KnownOptions MMap>
MacroProcessor MacroProcessor
NewlineString string
OutExt string
OutLang ILNodePrinter
OutOptions Loyc.Syntax.LNodePrinterOptions
Parallel bool
ParsingMode Loyc.Syntax.ParsingMode
PreserveComments bool
ShortOptions string>.Dictionary
TwoArgOptions InvertibleSet

Méthodes publiques

Méthode Description
AddMacros ( Assembly assembly ) : bool
AddStdMacros ( ) : void

Adds standard macros from LeMP.StdMacros.dll, and adds the namespaces LeMP and LeMP.Prelude to the pre-opened namespace list.

Note: prelude macros were already added by the constructor.

Compiler ( IMessageSink sink, Type prelude, IEnumerable sourceFiles ) : System
Compiler ( IMessageSink sink, Type prelude = null, bool registerEcsAndLes = true ) : System
CompleteInputOutputOptions ( ) : void

Fills in all fields of Files that are still null, based on the command-line options. Calling this is optional, since Run() calls it anyway.

CompleteInputOutputOptions ( InputOutput file ) : void
MaybeShowHelp ( string>.ICollection options, string>.ICollection knownOptions, TextWriter @out = null ) : bool
OpenSourceFiles ( IMessageSink sink, IEnumerable fileNames ) : List

Opens a set of source files by file name, and creates a text file for each.

ProcessArguments ( IList args, bool warnAboutUnknownOptions, bool autoOpenInputFiles, IList inputFiles = null ) : string>.BMultiMap

Processes command-line arguments to build a BMultiMap and sends those options to the other overload of this method.

Note: If you get your command-line arguments as a single string, use G.SplitCommandLineArguments(string) first to split it into an array. This method doesn't check for --help. To implement --help, call MaybeShowHelp on the return value.

ProcessArguments ( string>.BMultiMap options, bool warnAboutUnknownOptions, IList inputFiles = null ) : bool

Processes all standard command-line arguments from KnownOptions, except --help.

This method calls AddStdMacros() unless options includes "nostdmacros".

Run ( ) : void

Runs the MacroProcessor on all input Files.

ShowHelp ( string>.IEnumerable knownOptions, TextWriter @out = null, bool includeUsageLine = true ) : void
WarnAboutUnknownOptions ( string>.BMultiMap options, IMessageSink sink, string>.IDictionary knownOptions ) : void

Méthodes protégées

Méthode Description
WriteOutput ( InputOutput io ) : void

Private Methods

Méthode Description
ApplyLanguageOption ( IMessageSink sink, string option, string value, IParsingService &lang ) : void
IndexOfExtension ( string fn ) : int
Main ( string args ) : void
ParseBoolOption ( string>.BMultiMap options, string key, IMessageSink sink ) : bool?
ParseNumericOption ( string>.BMultiMap options, string key, IMessageSink sink, double min = null, double max = null ) : double?
SetPropertyHelper ( string exprStr, bool quote ) : bool
TryCatch ( object context, IMessageSink sink, System.Action action ) : bool

Method Details

AddMacros() public méthode

public AddMacros ( Assembly assembly ) : bool
assembly System.Reflection.Assembly
Résultat bool

AddStdMacros() public méthode

Adds standard macros from LeMP.StdMacros.dll, and adds the namespaces LeMP and LeMP.Prelude to the pre-opened namespace list.
Note: prelude macros were already added by the constructor.
public AddStdMacros ( ) : void
Résultat void

Compiler() public méthode

public Compiler ( IMessageSink sink, Type prelude, IEnumerable sourceFiles ) : System
sink IMessageSink
prelude System.Type
sourceFiles IEnumerable
Résultat System

Compiler() public méthode

public Compiler ( IMessageSink sink, Type prelude = null, bool registerEcsAndLes = true ) : System
sink IMessageSink
prelude System.Type
registerEcsAndLes bool
Résultat System

CompleteInputOutputOptions() public méthode

Fills in all fields of Files that are still null, based on the command-line options. Calling this is optional, since Run() calls it anyway.
public CompleteInputOutputOptions ( ) : void
Résultat void

CompleteInputOutputOptions() public méthode

public CompleteInputOutputOptions ( InputOutput file ) : void
file InputOutput
Résultat void

MaybeShowHelp() public static méthode

public static MaybeShowHelp ( string>.ICollection options, string>.ICollection knownOptions, TextWriter @out = null ) : bool
options string>.ICollection
knownOptions string>.ICollection
@out System.IO.TextWriter
Résultat bool

OpenSourceFiles() public static méthode

Opens a set of source files by file name, and creates a text file for each.
public static OpenSourceFiles ( IMessageSink sink, IEnumerable fileNames ) : List
sink IMessageSink
fileNames IEnumerable
Résultat List

ProcessArguments() public méthode

Processes command-line arguments to build a BMultiMap and sends those options to the other overload of this method.
Note: If you get your command-line arguments as a single string, use G.SplitCommandLineArguments(string) first to split it into an array. This method doesn't check for --help. To implement --help, call MaybeShowHelp on the return value.
public ProcessArguments ( IList args, bool warnAboutUnknownOptions, bool autoOpenInputFiles, IList inputFiles = null ) : string>.BMultiMap
args IList Arg list from which to extract options. **NOTE**: /// discovered options are removed from the list. This parameter /// cannot be an array.
warnAboutUnknownOptions bool Whether this method should /// call for you.
autoOpenInputFiles bool Whether to open input files /// for you by calling . ///
inputFiles IList A list of input files to open if /// autoOpenInputFiles is true. If this is null, The input files are /// assumed to be those command-line arguments left over after the options /// are removed.
Résultat string>.BMultiMap

ProcessArguments() public méthode

Processes all standard command-line arguments from KnownOptions, except --help.
This method calls AddStdMacros() unless options includes "nostdmacros".
public ProcessArguments ( string>.BMultiMap options, bool warnAboutUnknownOptions, IList inputFiles = null ) : bool
options string>.BMultiMap A set of options, presumably derived from command- /// line options using
warnAboutUnknownOptions bool Whether to warn (to ) /// about options not listed in .
inputFiles IList Files to open with
Résultat bool

Run() public méthode

Runs the MacroProcessor on all input Files.
public Run ( ) : void
Résultat void

ShowHelp() public static méthode

public static ShowHelp ( string>.IEnumerable knownOptions, TextWriter @out = null, bool includeUsageLine = true ) : void
knownOptions string>.IEnumerable
@out System.IO.TextWriter
includeUsageLine bool
Résultat void

WarnAboutUnknownOptions() public static méthode

public static WarnAboutUnknownOptions ( string>.BMultiMap options, IMessageSink sink, string>.IDictionary knownOptions ) : void
options string>.BMultiMap
sink IMessageSink
knownOptions string>.IDictionary
Résultat void

WriteOutput() protected méthode

protected WriteOutput ( InputOutput io ) : void
io InputOutput
Résultat void

Property Details

Files public_oe property

public List Files
Résultat List

ForceInLang public_oe property

public bool ForceInLang
Résultat bool

InLang public_oe property

public IParsingService InLang
Résultat IParsingService

IndentString public_oe property

public string IndentString
Résultat string

KnownOptions public_oe static_oe property

public static MMap> KnownOptions
Résultat MMap>

MacroProcessor public_oe property

public MacroProcessor,LeMP MacroProcessor
Résultat MacroProcessor

NewlineString public_oe property

public string NewlineString
Résultat string

OutExt public_oe property

public string OutExt
Résultat string

OutLang public_oe property

public ILNodePrinter OutLang
Résultat ILNodePrinter

OutOptions public_oe property

public LNodePrinterOptions,Loyc.Syntax OutOptions
Résultat Loyc.Syntax.LNodePrinterOptions

Parallel public_oe property

public bool Parallel
Résultat bool

ParsingMode public_oe property

public ParsingMode,Loyc.Syntax ParsingMode
Résultat Loyc.Syntax.ParsingMode

PreserveComments public_oe property

public bool PreserveComments
Résultat bool

ShortOptions public_oe static_oe property

public static Dictionary ShortOptions
Résultat string>.Dictionary

TwoArgOptions public_oe static_oe property

public static InvertibleSet TwoArgOptions
Résultat InvertibleSet