Enhanced C#
Language of your choice: library documentation

Documentation moved to ecsharp.net

GitHub doesn't support HTTP redirects, so you'll be redirected in 3 seconds.

 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Nested classes | Public static fields | Properties | Static Public Member Functions | List of all members
Loyc.Syntax.ParsingService Class Reference

Extension methods for IParsingService. More...


Source file:

Remarks

Extension methods for IParsingService.

Nested classes

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

Public static fields

static readonly Symbol Exprs = GSymbol.Get("Exprs")
 Tells IParsingService.Parse to treat the input as a single expression or expression list (which, in most languages, is comma-separated). More...
 
static readonly Symbol Stmts = GSymbol.Get("Stmts")
 Tells IParsingService.Parse to treat the input as a list of statements. If the language makes a distinction between executable and declaration contexts, this refers to the executable context. More...
 
static readonly Symbol File = GSymbol.Get("File")
 Tells IParsingService.Parse to treat the input as a complete source file (this should be the default, i.e. null will do the same thing). 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, IParsingService
RegisteredLanguages [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 string Print (this IParsingService self, LNode node)
 
static ILexer< TokenTokenize (this IParsingService parser, UString input, IMessageSink msgs=null)
 
static IListSource< LNodeParse (this IParsingService parser, UString input, IMessageSink msgs=null, Symbol inputType=null)
 
static LNode ParseSingle (this IParsingService parser, UString expr, IMessageSink msgs=null, Symbol inputType=null)
 
static LNode ParseSingle (this IParsingService parser, ICharSource file, string fileName, IMessageSink msgs=null, Symbol inputType=null)
 
static IListSource< LNodeParse (this IParsingService parser, Stream stream, string fileName, IMessageSink msgs=null, Symbol inputType=null)
 
static ILexer< TokenTokenize (this IParsingService parser, Stream stream, string fileName, IMessageSink msgs=null)
 
static IListSource< LNodeParseFile (this IParsingService parser, string fileName, IMessageSink msgs=null, Symbol inputType=null)
 
static ILexer< TokenTokenizeFile (this IParsingService parser, string fileName, IMessageSink msgs=null)
 
static string PrintMultiple (this LNodePrinter printer, IEnumerable< LNode > nodes, IMessageSink msgs=null, object mode=null, string indentString="\t", string lineSeparator="\n")
 Converts a sequences of LNodes to strings, adding a newline after each. More...
 
static string Print (this IParsingService service, IEnumerable< LNode > nodes, IMessageSink msgs=null, object mode=null, string indentString="\t", string lineSeparator="\n")
 

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.

static string Loyc.Syntax.ParsingService.PrintMultiple ( this LNodePrinter  printer,
IEnumerable< LNode nodes,
IMessageSink  msgs = null,
object  mode = null,
string  indentString = "\t",
string  lineSeparator = "\n" 
)
inlinestatic

Converts a sequences of LNodes to strings, adding a newline after each.

Parameters
printerPrinter for a single LNode.
modeA language-specific way of modifying printer behavior. The printer ignores the mode object if it does not not understand it.
indentStringA string to print for each level of indentation, such as a tab or four spaces.
lineSeparatorLine separator, typically "\n" or "\r\n".
Returns
A string form of the nodes.
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;");

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.

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.

Member Data Documentation

readonly Symbol Loyc.Syntax.ParsingService.Exprs = GSymbol.Get("Exprs")
static

Tells IParsingService.Parse to treat the input as a single expression or expression list (which, in most languages, is comma-separated).

Referenced by Loyc.Syntax.Les.LesLanguageService.Parse(), and Loyc.Ecs.EcsLanguageService.Parse().

readonly Symbol Loyc.Syntax.ParsingService.File = GSymbol.Get("File")
static

Tells IParsingService.Parse to treat the input as a complete source file (this should be the default, i.e. null will do the same thing).

readonly Symbol Loyc.Syntax.ParsingService.Stmts = GSymbol.Get("Stmts")
static

Tells IParsingService.Parse to treat the input as a list of statements. If the language makes a distinction between executable and declaration contexts, this refers to the executable context.

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.

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)