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).
ファイルを表示 Open project: qwertie/ecsharp Class Usage Examples

Public Properties

Property 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

Public Methods

Method 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

Protected Methods

Method Description
WriteOutput ( InputOutput io ) : void

Private Methods

Method 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 method

public AddMacros ( Assembly assembly ) : bool
assembly System.Reflection.Assembly
return bool

AddStdMacros() public method

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
return void

Compiler() public method

public Compiler ( IMessageSink sink, Type prelude, IEnumerable sourceFiles ) : System
sink IMessageSink
prelude System.Type
sourceFiles IEnumerable
return System

Compiler() public method

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

CompleteInputOutputOptions() public method

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
return void

CompleteInputOutputOptions() public method

public CompleteInputOutputOptions ( InputOutput file ) : void
file InputOutput
return void

MaybeShowHelp() public static method

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

OpenSourceFiles() public static method

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
return List

ProcessArguments() public method

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.
return string>.BMultiMap

ProcessArguments() public method

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
return bool

Run() public method

Runs the MacroProcessor on all input Files.
public Run ( ) : void
return void

ShowHelp() public static method

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

WarnAboutUnknownOptions() public static method

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

WriteOutput() protected method

protected WriteOutput ( InputOutput io ) : void
io InputOutput
return void

Property Details

Files public_oe property

public List Files
return List

ForceInLang public_oe property

public bool ForceInLang
return bool

InLang public_oe property

public IParsingService InLang
return IParsingService

IndentString public_oe property

public string IndentString
return string

KnownOptions public_oe static_oe property

public static MMap> KnownOptions
return MMap>

MacroProcessor public_oe property

public MacroProcessor,LeMP MacroProcessor
return MacroProcessor

NewlineString public_oe property

public string NewlineString
return string

OutExt public_oe property

public string OutExt
return string

OutLang public_oe property

public ILNodePrinter OutLang
return ILNodePrinter

OutOptions public_oe property

public LNodePrinterOptions,Loyc.Syntax OutOptions
return Loyc.Syntax.LNodePrinterOptions

Parallel public_oe property

public bool Parallel
return bool

ParsingMode public_oe property

public ParsingMode,Loyc.Syntax ParsingMode
return Loyc.Syntax.ParsingMode

PreserveComments public_oe property

public bool PreserveComments
return bool

ShortOptions public_oe static_oe property

public static Dictionary ShortOptions
return string>.Dictionary

TwoArgOptions public_oe static_oe property

public static InvertibleSet TwoArgOptions
return InvertibleSet