C# Класс 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).
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
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

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
WriteOutput ( InputOutput io ) : void

Приватные методы

Метод Описание
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

Описание методов

AddMacros() публичный Метод

public AddMacros ( Assembly assembly ) : bool
assembly System.Reflection.Assembly
Результат bool

AddStdMacros() публичный Метод

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
Результат void

Compiler() публичный Метод

public Compiler ( IMessageSink sink, Type prelude, IEnumerable sourceFiles ) : System
sink IMessageSink
prelude System.Type
sourceFiles IEnumerable
Результат System

Compiler() публичный Метод

public Compiler ( IMessageSink sink, Type prelude = null, bool registerEcsAndLes = true ) : System
sink IMessageSink
prelude System.Type
registerEcsAndLes bool
Результат System

CompleteInputOutputOptions() публичный Метод

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
Результат void

CompleteInputOutputOptions() публичный Метод

public CompleteInputOutputOptions ( InputOutput file ) : void
file InputOutput
Результат void

MaybeShowHelp() публичный статический Метод

public static MaybeShowHelp ( string>.ICollection options, string>.ICollection knownOptions, TextWriter @out = null ) : bool
options string>.ICollection
knownOptions string>.ICollection
@out System.IO.TextWriter
Результат bool

OpenSourceFiles() публичный статический Метод

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
Результат List

ProcessArguments() публичный Метод

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.
Результат string>.BMultiMap

ProcessArguments() публичный Метод

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
Результат bool

Run() публичный Метод

Runs the MacroProcessor on all input Files.
public Run ( ) : void
Результат void

ShowHelp() публичный статический Метод

public static ShowHelp ( string>.IEnumerable knownOptions, TextWriter @out = null, bool includeUsageLine = true ) : void
knownOptions string>.IEnumerable
@out System.IO.TextWriter
includeUsageLine bool
Результат void

WarnAboutUnknownOptions() публичный статический Метод

public static WarnAboutUnknownOptions ( string>.BMultiMap options, IMessageSink sink, string>.IDictionary knownOptions ) : void
options string>.BMultiMap
sink IMessageSink
knownOptions string>.IDictionary
Результат void

WriteOutput() защищенный Метод

protected WriteOutput ( InputOutput io ) : void
io InputOutput
Результат void

Описание свойств

Files публичное свойство

public List Files
Результат List

ForceInLang публичное свойство

public bool ForceInLang
Результат bool

InLang публичное свойство

public IParsingService InLang
Результат IParsingService

IndentString публичное свойство

public string IndentString
Результат string

KnownOptions публичное статическое свойство

public static MMap> KnownOptions
Результат MMap>

MacroProcessor публичное свойство

public MacroProcessor,LeMP MacroProcessor
Результат MacroProcessor

NewlineString публичное свойство

public string NewlineString
Результат string

OutExt публичное свойство

public string OutExt
Результат string

OutLang публичное свойство

public ILNodePrinter OutLang
Результат ILNodePrinter

OutOptions публичное свойство

public LNodePrinterOptions,Loyc.Syntax OutOptions
Результат Loyc.Syntax.LNodePrinterOptions

Parallel публичное свойство

public bool Parallel
Результат bool

ParsingMode публичное свойство

public ParsingMode,Loyc.Syntax ParsingMode
Результат Loyc.Syntax.ParsingMode

PreserveComments публичное свойство

public bool PreserveComments
Результат bool

ShortOptions публичное статическое свойство

public static Dictionary ShortOptions
Результат string>.Dictionary

TwoArgOptions публичное статическое свойство

public static InvertibleSet TwoArgOptions
Результат InvertibleSet