Enhanced C#
Language of your choice: library documentation
Nested classes | Properties | Static Public Member Functions | List of all members
Loyc.Syntax.ParsingService Class Reference

Standard extension methods for IParsingService. More...


Source file:

Remarks

Standard extension methods for IParsingService.

Nested classes

struct  PushedCurrent
 Returned by PushCurrent(IParsingService). More...
 

Properties

static IParsingService Current [get, set]
 Gets or sets the active language service on this thread. If no service has been assigned on this thread, returns LesLanguageService.Value. More...
 
static IReadOnlyDictionary< string, IParsingServiceRegisteredLanguages [get]
 Dictionary of registered parsing services, keyed by file extension (without leading dots). The default dictionary contains one pair: ("les", LesLanguageService.Value) More...
 

Static Public Member Functions

static int Register (IParsingService service, IEnumerable< string > fileExtensions=null)
 Registers a parsing service. More...
 
static int Unregister (IParsingService service, IEnumerable< string > fileExtensions=null)
 Unregisters a language service. More...
 
static IParsingService GetServiceForFileName (string filename)
 Finds the language service associated with the longest matching registered file extension. More...
 
static PushedCurrent PushCurrent (IParsingService newValue)
 Sets the current language service, returning a value suitable for use in a C# using statement, which will restore the old service. More...
 
static ILexer< TokenTokenize (this IParsingService parser, UString input, IMessageSink msgs=null)
 Parses a string by invoking IParsingService.Tokenize(ICharSource, string, IMessageSink) using an empty string as the file name. More...
 
static IListSource< LNodeParse (this IParsingService parser, UString input, IMessageSink msgs=null, ParsingMode inputType=null, bool preserveComments=true)
 Parses a string by invoking IParsingService.Parse(ICharSource, string, IMessageSink, ParsingMode, bool) using an empty string as the file name. More...
 
static LNode ParseSingle (this IParsingService parser, UString expr, IMessageSink msgs=null, ParsingMode inputType=null, bool preserveComments=true)
 Parses a string and expects exactly one output. More...
 
static LNode ParseSingle (this IParsingService parser, ICharSource text, string fileName, IMessageSink msgs=null, ParsingMode inputType=null, bool preserveComments=true)
 Parses a string and expects exactly one output. More...
 
static IListSource< LNodeParse (this IParsingService parser, Stream stream, string fileName, ParsingMode inputType=null, IMessageSink msgs=null, bool preserveComments=true)
 Parses a Stream. More...
 
static ILexer< TokenTokenize (this IParsingService parser, Stream stream, string fileName, IMessageSink msgs=null)
 Parses a Stream. More...
 
static IListSource< LNodeParseFile (this IParsingService parser, string fileName, IMessageSink msgs=null, ParsingMode inputType=null, bool preserveComments=true)
 Opens the specified file and parses it. More...
 
static ILexer< TokenTokenizeFile (this IParsingService parser, string fileName, IMessageSink msgs=null)
 Opens the specified file and tokenizes it. More...
 

Member Function Documentation

static IParsingService Loyc.Syntax.ParsingService.GetServiceForFileName ( string  filename)
inlinestatic

Finds the language service associated with the longest matching registered file extension.

Returns null if there is no registered language service for the filename's extension.

Referenced by LeMP.Compiler.AddStdMacros(), LeMP.Compiler.CompleteInputOutputOptions(), and LeMP.Compiler.ProcessArguments().

static IListSource<LNode> Loyc.Syntax.ParsingService.Parse ( this IParsingService  parser,
UString  input,
IMessageSink  msgs = null,
ParsingMode  inputType = null,
bool  preserveComments = true 
)
inlinestatic

Parses a string by invoking IParsingService.Parse(ICharSource, string, IMessageSink, ParsingMode, bool) using an empty string as the file name.

References Loyc.Syntax.IParsingService.Parse().

static IListSource<LNode> Loyc.Syntax.ParsingService.Parse ( this IParsingService  parser,
Stream  stream,
string  fileName,
ParsingMode  inputType = null,
IMessageSink  msgs = null,
bool  preserveComments = true 
)
inlinestatic

Parses a Stream.

References Loyc.Syntax.IParsingService.Parse().

static IListSource<LNode> Loyc.Syntax.ParsingService.ParseFile ( this IParsingService  parser,
string  fileName,
IMessageSink  msgs = null,
ParsingMode  inputType = null,
bool  preserveComments = true 
)
inlinestatic

Opens the specified file and parses it.

References Loyc.Syntax.ParsingMode.File.

static LNode Loyc.Syntax.ParsingService.ParseSingle ( this IParsingService  parser,
UString  expr,
IMessageSink  msgs = null,
ParsingMode  inputType = null,
bool  preserveComments = true 
)
inlinestatic

Parses a string and expects exactly one output.

Exceptions
InvalidOperationExceptionThe output list was empty or contained multiple nodes.

References Loyc.Syntax.IParsingService.Parse().

static LNode Loyc.Syntax.ParsingService.ParseSingle ( this IParsingService  parser,
ICharSource  text,
string  fileName,
IMessageSink  msgs = null,
ParsingMode  inputType = null,
bool  preserveComments = true 
)
inlinestatic

Parses a string and expects exactly one output.

Exceptions
InvalidOperationExceptionThe output list was empty or contained multiple nodes.

References Loyc.Localize.Localized(), Loyc.Syntax.IParsingService.Parse(), and Loyc.Collections.IListSource< out out T >.TryGet().

static PushedCurrent Loyc.Syntax.ParsingService.PushCurrent ( IParsingService  newValue)
inlinestatic

Sets the current language service, returning a value suitable for use in a C# using statement, which will restore the old service.

Parameters
newValuenew value of Current
LNode code;
using (var old = ParsingService.PushCurrent(LesLanguageService.Value))
code = ParsingService.Current.ParseSingle("This `is` LES_code;");

Referenced by Loyc.LLParserGenerator.Program.QuickRun().

static int Loyc.Syntax.ParsingService.Register ( IParsingService  service,
IEnumerable< string >  fileExtensions = null 
)
inlinestatic

Registers a parsing service.

Parameters
serviceService to register.
fileExtensionsFile extensions affected (null to use the service's own list)
Returns
The number of new file extensions registered, or 0 if none.

This method does not replace existing registrations.

References Loyc.Syntax.IParsingService.FileExtensions, and Loyc.Collections.Map< K, V >.With().

static ILexer<Token> Loyc.Syntax.ParsingService.Tokenize ( this IParsingService  parser,
UString  input,
IMessageSink  msgs = null 
)
inlinestatic

Parses a string by invoking IParsingService.Tokenize(ICharSource, string, IMessageSink) using an empty string as the file name.

References Loyc.Syntax.IParsingService.Tokenize().

static ILexer<Token> Loyc.Syntax.ParsingService.Tokenize ( this IParsingService  parser,
Stream  stream,
string  fileName,
IMessageSink  msgs = null 
)
inlinestatic

Parses a Stream.

References Loyc.Syntax.IParsingService.Tokenize().

static ILexer<Token> Loyc.Syntax.ParsingService.TokenizeFile ( this IParsingService  parser,
string  fileName,
IMessageSink  msgs = null 
)
inlinestatic

Opens the specified file and tokenizes it.

static int Loyc.Syntax.ParsingService.Unregister ( IParsingService  service,
IEnumerable< string >  fileExtensions = null 
)
inlinestatic

Unregisters a language service.

Parameters
serviceService to unregister
fileExtensionsFile extensions affected (null to use the service's own list)
Returns
The number of file extensions unregistered, or 0 if none.

The service for a file extension is not removed unless the given service reference is equal to the registered service.

References Loyc.Syntax.IParsingService.FileExtensions, and Loyc.Collections.Map< K, V >.Without().

Property Documentation

IParsingService Loyc.Syntax.ParsingService.Current
staticgetset

Gets or sets the active language service on this thread. If no service has been assigned on this thread, returns LesLanguageService.Value.

Referenced by LeMP.Compiler.AddStdMacros(), LeMP.Compiler.CompleteInputOutputOptions(), and Loyc.LLParserGenerator.Program.QuickRun().

IReadOnlyDictionary<string, IParsingService> Loyc.Syntax.ParsingService.RegisteredLanguages
staticget

Dictionary of registered parsing services, keyed by file extension (without leading dots). The default dictionary contains one pair: ("les", LesLanguageService.Value)